From d7bcd2a45de727a60bd05eef35b7d96712a34f64 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 4 Apr 2025 16:35:43 +0000 Subject: [PATCH 001/125] build(deps): bump code.gitea.io/sdk/gitea from 0.20.0 to 0.21.0 Bumps code.gitea.io/sdk/gitea from 0.20.0 to 0.21.0. --- updated-dependencies: - dependency-name: code.gitea.io/sdk/gitea dependency-version: 0.21.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 6 +++--- go.sum | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index 6b0fe01b..63fddb25 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/flowline-io/flowbot go 1.24 require ( - code.gitea.io/sdk/gitea v0.20.0 + code.gitea.io/sdk/gitea v0.21.0 github.com/Masterminds/semver/v3 v3.3.1 github.com/PuerkitoBio/goquery v1.10.2 github.com/RealAlexandreAI/json-repair v0.0.14 @@ -84,7 +84,7 @@ require ( require ( aead.dev/minisign v0.2.0 // indirect filippo.io/edwards25519 v1.1.0 // indirect - github.com/42wim/httpsig v1.2.1 // indirect + github.com/42wim/httpsig v1.2.2 // indirect github.com/KyleBanks/depth v1.2.1 // indirect github.com/Microsoft/go-winio v0.6.2 // indirect github.com/Rican7/retry v0.3.1 // indirect @@ -135,7 +135,7 @@ require ( github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect - github.com/hashicorp/go-version v1.6.0 // indirect + github.com/hashicorp/go-version v1.7.0 // indirect github.com/hekmon/cunits/v2 v2.1.0 // indirect github.com/invopop/yaml v0.3.1 // indirect github.com/jinzhu/inflection v1.0.0 // indirect diff --git a/go.sum b/go.sum index 9267dec0..f48d236c 100644 --- a/go.sum +++ b/go.sum @@ -1,11 +1,11 @@ aead.dev/minisign v0.2.0 h1:kAWrq/hBRu4AARY6AlciO83xhNnW9UaC8YipS2uhLPk= aead.dev/minisign v0.2.0/go.mod h1:zdq6LdSd9TbuSxchxwhpA9zEb9YXcVGoE8JakuiGaIQ= -code.gitea.io/sdk/gitea v0.20.0 h1:Zm/QDwwZK1awoM4AxdjeAQbxolzx2rIP8dDfmKu+KoU= -code.gitea.io/sdk/gitea v0.20.0/go.mod h1:faouBHC/zyx5wLgjmRKR62ydyvMzwWf3QnU0bH7Cw6U= +code.gitea.io/sdk/gitea v0.21.0 h1:69n6oz6kEVHRo1+APQQyizkhrZrLsTLXey9142pfkD4= +code.gitea.io/sdk/gitea v0.21.0/go.mod h1:tnBjVhuKJCn8ibdyyhvUyxrR1Ca2KHEoTWoukNhXQPA= filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA= filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4= -github.com/42wim/httpsig v1.2.1 h1:oLBxptMe9U4ZmSGtkosT8Dlfg31P3VQnAGq6psXv82Y= -github.com/42wim/httpsig v1.2.1/go.mod h1:P/UYo7ytNBFwc+dg35IubuAUIs8zj5zzFIgUCEl55WY= +github.com/42wim/httpsig v1.2.2 h1:ofAYoHUNs/MJOLqQ8hIxeyz2QxOz8qdSVvp3PX/oPgA= +github.com/42wim/httpsig v1.2.2/go.mod h1:P/UYo7ytNBFwc+dg35IubuAUIs8zj5zzFIgUCEl55WY= github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 h1:L/gRVlceqvL25UVaW/CKtUDjefjrs0SPonmDGUVOYP0= github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc= @@ -239,8 +239,8 @@ github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9n github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= -github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mOkIeek= -github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= +github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKeRZfjY= +github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/heimdalr/dag v1.5.0 h1:hqVtijvY776P5OKP3QbdVBRt3Xxq6BYopz3XgklsGvo= github.com/heimdalr/dag v1.5.0/go.mod h1:lthekrHl01dddmzqyBQ1YZbi7XcVGGzjFo0jIky5knc= github.com/hekmon/cunits/v2 v2.1.0 h1:k6wIjc4PlacNOHwKEMBgWV2/c8jyD4eRMs5mR1BBhI0= From aac07e66b876fc2bebd1ff9b5ff0fff694f7a7b6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 4 Apr 2025 16:35:52 +0000 Subject: [PATCH 002/125] build(deps): bump github.com/gofiber/contrib/fiberzerolog Bumps [github.com/gofiber/contrib/fiberzerolog](https://github.com/gofiber/contrib) from 1.0.2 to 1.0.3. - [Release notes](https://github.com/gofiber/contrib/releases) - [Commits](https://github.com/gofiber/contrib/compare/jwt/v1.0.2...jwt/v1.0.3) --- updated-dependencies: - dependency-name: github.com/gofiber/contrib/fiberzerolog dependency-version: 1.0.3 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 6b0fe01b..3be8b825 100644 --- a/go.mod +++ b/go.mod @@ -29,7 +29,7 @@ require ( github.com/go-resty/resty/v2 v2.16.5 github.com/go-sql-driver/mysql v1.9.1 github.com/goccy/go-json v0.10.5 - github.com/gofiber/contrib/fiberzerolog v1.0.2 + github.com/gofiber/contrib/fiberzerolog v1.0.3 github.com/gofiber/fiber/v2 v2.52.6 github.com/gofiber/swagger v1.1.1 github.com/golang-migrate/migrate/v4 v4.18.2 diff --git a/go.sum b/go.sum index 9267dec0..e0a150a9 100644 --- a/go.sum +++ b/go.sum @@ -184,8 +184,8 @@ github.com/goccy/go-json v0.10.5/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PU github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk= github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= -github.com/gofiber/contrib/fiberzerolog v1.0.2 h1:LMa/luarQVeINoRwZLHtLQYepLPDIwUNB5OmdZKk+s8= -github.com/gofiber/contrib/fiberzerolog v1.0.2/go.mod h1:aTPsgArSgxRWcUeJ/K6PiICz3mbQENR1QOR426QwOoQ= +github.com/gofiber/contrib/fiberzerolog v1.0.3 h1:Z97hA5bNfThtZjEYG12g9YcT8I/cmCikNgmE4uzFk0U= +github.com/gofiber/contrib/fiberzerolog v1.0.3/go.mod h1:0MD+NNFy0nZwiSo4dSVW7WwWVzOyuATNXwhJwgOP8uM= github.com/gofiber/fiber/v2 v2.52.6 h1:Rfp+ILPiYSvvVuIPvxrBns+HJp8qGLDnLJawAu27XVI= github.com/gofiber/fiber/v2 v2.52.6/go.mod h1:YEcBbO/FB+5M1IZNBP9FO3J9281zgPAreiI1oqg8nDw= github.com/gofiber/swagger v1.1.1 h1:FZVhVQQ9s1ZKLHL/O0loLh49bYB5l1HEAgxDlcTtkRA= From 1f23ccfc8a88e541c8f8d5d0cfba6826bee0c2a4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Apr 2025 17:16:20 +0000 Subject: [PATCH 003/125] build(deps): bump golang.org/x/sys from 0.31.0 to 0.32.0 Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.31.0 to 0.32.0. - [Commits](https://github.com/golang/sys/compare/v0.31.0...v0.32.0) --- updated-dependencies: - dependency-name: golang.org/x/sys dependency-version: 0.32.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index fa440596..87b9f479 100644 --- a/go.mod +++ b/go.mod @@ -68,7 +68,7 @@ require ( go.uber.org/automaxprocs v1.6.0 golang.org/x/crypto v0.36.0 golang.org/x/exp v0.0.0-20250218142911-aa4b98e5adaa - golang.org/x/sys v0.31.0 + golang.org/x/sys v0.32.0 golang.org/x/time v0.11.0 golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 gopkg.in/yaml.v3 v3.0.1 diff --git a/go.sum b/go.sum index 08476465..98c7a4a5 100644 --- a/go.sum +++ b/go.sum @@ -631,8 +631,8 @@ golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik= -golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= +golang.org/x/sys v0.32.0 h1:s77OFDvIQeibCmezSnk/q6iAfkdiQaJi4VzroCFrN20= +golang.org/x/sys v0.32.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= From b9686a9be70e19444848e7da964fe6042623bb6a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Apr 2025 17:22:40 +0000 Subject: [PATCH 004/125] build(deps): bump github.com/cloudwego/eino from 0.3.19 to 0.3.20 Bumps [github.com/cloudwego/eino](https://github.com/cloudwego/eino) from 0.3.19 to 0.3.20. - [Release notes](https://github.com/cloudwego/eino/releases) - [Commits](https://github.com/cloudwego/eino/compare/v0.3.19...v0.3.20) --- updated-dependencies: - dependency-name: github.com/cloudwego/eino dependency-version: 0.3.20 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index fa440596..5e5cc92d 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/bsm/redislock v0.9.4 github.com/bwmarrin/discordgo v0.28.1 github.com/cenkalti/backoff v2.2.1+incompatible - github.com/cloudwego/eino v0.3.19 + github.com/cloudwego/eino v0.3.20 github.com/cloudwego/eino-ext/components/model/openai v0.0.0-20250221090944-e8ef7aabbe10 github.com/creachadair/jrpc2 v1.3.1 github.com/docker/cli v28.0.4+incompatible diff --git a/go.sum b/go.sum index 08476465..b60cd57a 100644 --- a/go.sum +++ b/go.sum @@ -65,8 +65,8 @@ github.com/chengxilo/virtualterm v1.0.4 h1:Z6IpERbRVlfB8WkOmtbHiDbBANU7cimRIof7m github.com/chengxilo/virtualterm v1.0.4/go.mod h1:DyxxBZz/x1iqJjFxTFcr6/x+jSpqN0iwWCOK1q10rlY= github.com/cloudwego/base64x v0.1.5 h1:XPciSp1xaq2VCSt6lF0phncD4koWyULpl5bUxbfCyP4= github.com/cloudwego/base64x v0.1.5/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w= -github.com/cloudwego/eino v0.3.19 h1:PoldC4q5ZWth/aBDUM9WMJISh/t40C0K/OTh1KpA+Kk= -github.com/cloudwego/eino v0.3.19/go.mod h1:wUjz990apdsaOraOXdh6CdhVXq8DJsOvLsVlxNTcNfY= +github.com/cloudwego/eino v0.3.20 h1:SiQH1SgRlu0aTTtUPjmbkZlC3VjCg8L6B9lDIEcNJmo= +github.com/cloudwego/eino v0.3.20/go.mod h1:wUjz990apdsaOraOXdh6CdhVXq8DJsOvLsVlxNTcNfY= github.com/cloudwego/eino-ext/components/model/openai v0.0.0-20250221090944-e8ef7aabbe10 h1:DJAInsXygJKCrkahR42QODKkq91nvQCTe60o3MnjsKs= github.com/cloudwego/eino-ext/components/model/openai v0.0.0-20250221090944-e8ef7aabbe10/go.mod h1:okkkchYXfoEkv5c0GlwhMdVjIshCzmN3DCcnbOWf7DQ= github.com/cloudwego/eino-ext/libs/acl/openai v0.0.0-20250221090944-e8ef7aabbe10 h1:M6Z2PeX+MxW7jgoZ0p6qDfVtMe1/4XqSQSAHUrI2HTM= From 9c4ec46a0a495a12c856021802d27cf6a375722d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Apr 2025 17:27:42 +0000 Subject: [PATCH 005/125] build(deps): bump golang.org/x/crypto from 0.36.0 to 0.37.0 Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.36.0 to 0.37.0. - [Commits](https://github.com/golang/crypto/compare/v0.36.0...v0.37.0) --- updated-dependencies: - dependency-name: golang.org/x/crypto dependency-version: 0.37.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 10 +++++----- go.sum | 20 ++++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/go.mod b/go.mod index fa440596..a961a4c4 100644 --- a/go.mod +++ b/go.mod @@ -66,9 +66,9 @@ require ( github.com/urfave/cli/v2 v2.27.6 github.com/valyala/fasthttp v1.60.0 go.uber.org/automaxprocs v1.6.0 - golang.org/x/crypto v0.36.0 + golang.org/x/crypto v0.37.0 golang.org/x/exp v0.0.0-20250218142911-aa4b98e5adaa - golang.org/x/sys v0.31.0 + golang.org/x/sys v0.32.0 golang.org/x/time v0.11.0 golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 gopkg.in/yaml.v3 v3.0.1 @@ -209,9 +209,9 @@ require ( golang.org/x/arch v0.14.0 // indirect golang.org/x/mod v0.23.0 // indirect golang.org/x/net v0.38.0 // indirect - golang.org/x/sync v0.12.0 // indirect - golang.org/x/term v0.30.0 // indirect - golang.org/x/text v0.23.0 // indirect + golang.org/x/sync v0.13.0 // indirect + golang.org/x/term v0.31.0 // indirect + golang.org/x/text v0.24.0 // indirect golang.org/x/tools v0.30.0 // indirect google.golang.org/appengine v1.6.8 // indirect google.golang.org/protobuf v1.36.5 // indirect diff --git a/go.sum b/go.sum index 08476465..4d011f1c 100644 --- a/go.sum +++ b/go.sum @@ -566,8 +566,8 @@ golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliY golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8= golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk= -golang.org/x/crypto v0.36.0 h1:AnAEvhDddvBdpY+uR+MyHmuZzzNqXSe/GvuDeob5L34= -golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc= +golang.org/x/crypto v0.37.0 h1:kJNSjF/Xp7kU0iB2Z+9viTPMW4EqqsrywMXLJOOsXSE= +golang.org/x/crypto v0.37.0/go.mod h1:vg+k43peMZ0pUMhYmVAWysMK35e6ioLh3wB8ZCAfbVc= golang.org/x/exp v0.0.0-20250218142911-aa4b98e5adaa h1:t2QcU6V556bFjYgu4L6C+6VrCPyJZ+eyRsABUPs1mz4= golang.org/x/exp v0.0.0-20250218142911-aa4b98e5adaa/go.mod h1:BHOTPb3L19zxehTsLoJXVaTktb06DFgmdW6Wb9s8jqk= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= @@ -605,8 +605,8 @@ golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= -golang.org/x/sync v0.12.0 h1:MHc5BpPuC30uJk597Ri8TV3CNZcTLu6B6z4lJy+g6Jw= -golang.org/x/sync v0.12.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= +golang.org/x/sync v0.13.0 h1:AauUjRAJ9OSnvULf/ARrrVywoJDy0YS2AwQ98I37610= +golang.org/x/sync v0.13.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -631,8 +631,8 @@ golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik= -golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= +golang.org/x/sys v0.32.0 h1:s77OFDvIQeibCmezSnk/q6iAfkdiQaJi4VzroCFrN20= +golang.org/x/sys v0.32.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= @@ -643,8 +643,8 @@ golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU= golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY= golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM= -golang.org/x/term v0.30.0 h1:PQ39fJZ+mfadBm0y5WlL4vlM7Sx1Hgf13sMIY2+QS9Y= -golang.org/x/term v0.30.0/go.mod h1:NYYFdzHoI5wRh/h5tDMdMqCqPJZEuNqVR5xJLd/n67g= +golang.org/x/term v0.31.0 h1:erwDkOK1Msy6offm1mOgvspSkslFnIGsFnxOKoufg3o= +golang.org/x/term v0.31.0/go.mod h1:R4BeIy7D95HzImkxGkTW1UQTtP54tio2RyHz7PwK0aw= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= @@ -656,8 +656,8 @@ golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= -golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY= -golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4= +golang.org/x/text v0.24.0 h1:dd5Bzh4yt5KYA8f9CJHCP4FB4D51c2c6JvN37xJJkJ0= +golang.org/x/text v0.24.0/go.mod h1:L8rBsPeo2pSS+xqN0d5u2ikmjtmoJbDBT1b7nHvFCdU= golang.org/x/time v0.11.0 h1:/bpjEDfN9tkoN/ryeYHnv5hcMlc8ncjMcM4XBk5NWV0= golang.org/x/time v0.11.0/go.mod h1:CDIdPxbZBQxdj6cxyCIdrNogrJKMJ7pr37NYpMcMDSg= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= From b728010d8a4a14e1f153501cfed91122bd689d90 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Apr 2025 17:28:29 +0000 Subject: [PATCH 006/125] build(deps): bump github.com/go-sql-driver/mysql from 1.9.1 to 1.9.2 Bumps [github.com/go-sql-driver/mysql](https://github.com/go-sql-driver/mysql) from 1.9.1 to 1.9.2. - [Release notes](https://github.com/go-sql-driver/mysql/releases) - [Changelog](https://github.com/go-sql-driver/mysql/blob/master/CHANGELOG.md) - [Commits](https://github.com/go-sql-driver/mysql/compare/v1.9.1...v1.9.2) --- updated-dependencies: - dependency-name: github.com/go-sql-driver/mysql dependency-version: 1.9.2 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index fa440596..7ff55ce7 100644 --- a/go.mod +++ b/go.mod @@ -27,7 +27,7 @@ require ( github.com/go-echarts/go-echarts/v2 v2.5.2 github.com/go-playground/validator/v10 v10.26.0 github.com/go-resty/resty/v2 v2.16.5 - github.com/go-sql-driver/mysql v1.9.1 + github.com/go-sql-driver/mysql v1.9.2 github.com/goccy/go-json v0.10.5 github.com/gofiber/contrib/fiberzerolog v1.0.3 github.com/gofiber/fiber/v2 v2.52.6 diff --git a/go.sum b/go.sum index 08476465..bd850531 100644 --- a/go.sum +++ b/go.sum @@ -169,8 +169,8 @@ github.com/go-resty/resty/v2 v2.16.5 h1:hBKqmWrr7uRc3euHVqmh1HTHcKn99Smr7o5spptd github.com/go-resty/resty/v2 v2.16.5/go.mod h1:hkJtXbA2iKHzJheXYvQ8snQES5ZLGKMwQ07xAwp/fiA= github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI= github.com/go-sql-driver/mysql v1.8.1/go.mod h1:wEBSXgmK//2ZFJyE+qWnIsVGmvmEKlqwuVSjsCm7DZg= -github.com/go-sql-driver/mysql v1.9.1 h1:FrjNGn/BsJQjVRuSa8CBrM5BWA9BWoXXat3KrtSb/iI= -github.com/go-sql-driver/mysql v1.9.1/go.mod h1:qn46aNg1333BRMNU69Lq93t8du/dwxI64Gl8i5p1WMU= +github.com/go-sql-driver/mysql v1.9.2 h1:4cNKDYQ1I84SXslGddlsrMhc8k4LeDVj6Ad6WRjiHuU= +github.com/go-sql-driver/mysql v1.9.2/go.mod h1:qn46aNg1333BRMNU69Lq93t8du/dwxI64Gl8i5p1WMU= github.com/go-test/deep v1.0.4/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= github.com/go-test/deep v1.0.8/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE= github.com/go-test/deep v1.1.0 h1:WOcxcdHcvdgThNXjw0t76K42FXTU7HpNQWHpA2HHNlg= From 50b118be7dbf107dbfd665a85ecd8db075bd2213 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 9 Apr 2025 17:05:14 +0000 Subject: [PATCH 007/125] build(deps): bump github.com/minio/minio-go/v7 from 7.0.89 to 7.0.90 Bumps [github.com/minio/minio-go/v7](https://github.com/minio/minio-go) from 7.0.89 to 7.0.90. - [Release notes](https://github.com/minio/minio-go/releases) - [Commits](https://github.com/minio/minio-go/compare/v7.0.89...v7.0.90) --- updated-dependencies: - dependency-name: github.com/minio/minio-go/v7 dependency-version: 7.0.90 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 28cf5000..2ab9e3a2 100644 --- a/go.mod +++ b/go.mod @@ -45,7 +45,7 @@ require ( github.com/looplab/fsm v1.0.2 github.com/maxence-charriere/go-app/v10 v10.1.3 github.com/meilisearch/meilisearch-go v0.31.0 - github.com/minio/minio-go/v7 v7.0.89 + github.com/minio/minio-go/v7 v7.0.90 github.com/minio/selfupdate v0.6.0 github.com/mmcdole/gofeed v1.3.0 github.com/montanaflynn/stats v0.7.1 diff --git a/go.sum b/go.sum index 0685030d..9ac524a4 100644 --- a/go.sum +++ b/go.sum @@ -345,8 +345,8 @@ github.com/minio/crc64nvme v1.0.1 h1:DHQPrYPdqK7jQG/Ls5CTBZWeex/2FMS3G5XGkycuFrY github.com/minio/crc64nvme v1.0.1/go.mod h1:eVfm2fAzLlxMdUGc0EEBGSMmPwmXD5XiNRpnu9J3bvg= github.com/minio/md5-simd v1.1.2 h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34= github.com/minio/md5-simd v1.1.2/go.mod h1:MzdKDxYpY2BT9XQFocsiZf/NKVtR7nkE4RoEpN+20RM= -github.com/minio/minio-go/v7 v7.0.89 h1:hx4xV5wwTUfyv8LarhJAwNecnXpoTsj9v3f3q/ZkiJU= -github.com/minio/minio-go/v7 v7.0.89/go.mod h1:2rFnGAp02p7Dddo1Fq4S2wYOfpF0MUTSeLTRC90I204= +github.com/minio/minio-go/v7 v7.0.90 h1:TmSj1083wtAD0kEYTx7a5pFsv3iRYMsOJ6A4crjA1lE= +github.com/minio/minio-go/v7 v7.0.90/go.mod h1:uvMUcGrpgeSAAI6+sD3818508nUyMULw94j2Nxku/Go= github.com/minio/selfupdate v0.6.0 h1:i76PgT0K5xO9+hjzKcacQtO7+MjJ4JKA8Ak8XQ9DDwU= github.com/minio/selfupdate v0.6.0/go.mod h1:bO02GTIPCMQFTEvE5h4DjYB58bCoZ35XLeBf0buTDdM= github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db h1:62I3jR2EmQ4l5rM/4FEfDWcRD+abF5XlKShorW5LRoQ= From 0d8403630befb040603f2fc47eeff186997a5454 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 10 Apr 2025 16:28:41 +0000 Subject: [PATCH 008/125] build(deps): bump github.com/cloudwego/eino from 0.3.20 to 0.3.21 Bumps [github.com/cloudwego/eino](https://github.com/cloudwego/eino) from 0.3.20 to 0.3.21. - [Release notes](https://github.com/cloudwego/eino/releases) - [Commits](https://github.com/cloudwego/eino/compare/v0.3.20...v0.3.21) --- updated-dependencies: - dependency-name: github.com/cloudwego/eino dependency-version: 0.3.21 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 2ab9e3a2..8ee23500 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/bsm/redislock v0.9.4 github.com/bwmarrin/discordgo v0.28.1 github.com/cenkalti/backoff v2.2.1+incompatible - github.com/cloudwego/eino v0.3.20 + github.com/cloudwego/eino v0.3.21 github.com/cloudwego/eino-ext/components/model/openai v0.0.0-20250221090944-e8ef7aabbe10 github.com/creachadair/jrpc2 v1.3.1 github.com/docker/cli v28.0.4+incompatible diff --git a/go.sum b/go.sum index 9ac524a4..95152546 100644 --- a/go.sum +++ b/go.sum @@ -65,8 +65,8 @@ github.com/chengxilo/virtualterm v1.0.4 h1:Z6IpERbRVlfB8WkOmtbHiDbBANU7cimRIof7m github.com/chengxilo/virtualterm v1.0.4/go.mod h1:DyxxBZz/x1iqJjFxTFcr6/x+jSpqN0iwWCOK1q10rlY= github.com/cloudwego/base64x v0.1.5 h1:XPciSp1xaq2VCSt6lF0phncD4koWyULpl5bUxbfCyP4= github.com/cloudwego/base64x v0.1.5/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w= -github.com/cloudwego/eino v0.3.20 h1:SiQH1SgRlu0aTTtUPjmbkZlC3VjCg8L6B9lDIEcNJmo= -github.com/cloudwego/eino v0.3.20/go.mod h1:wUjz990apdsaOraOXdh6CdhVXq8DJsOvLsVlxNTcNfY= +github.com/cloudwego/eino v0.3.21 h1:dbggS3iOKWtsQhiTStepmrXzbauOuXXo/hRf5FKLvbE= +github.com/cloudwego/eino v0.3.21/go.mod h1:wUjz990apdsaOraOXdh6CdhVXq8DJsOvLsVlxNTcNfY= github.com/cloudwego/eino-ext/components/model/openai v0.0.0-20250221090944-e8ef7aabbe10 h1:DJAInsXygJKCrkahR42QODKkq91nvQCTe60o3MnjsKs= github.com/cloudwego/eino-ext/components/model/openai v0.0.0-20250221090944-e8ef7aabbe10/go.mod h1:okkkchYXfoEkv5c0GlwhMdVjIshCzmN3DCcnbOWf7DQ= github.com/cloudwego/eino-ext/libs/acl/openai v0.0.0-20250221090944-e8ef7aabbe10 h1:M6Z2PeX+MxW7jgoZ0p6qDfVtMe1/4XqSQSAHUrI2HTM= From cb7f04303d011c82dc7249ddda580e3d0c8ea4fc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 11 Apr 2025 16:18:45 +0000 Subject: [PATCH 009/125] build(deps): bump github.com/prometheus/client_model from 0.6.1 to 0.6.2 Bumps [github.com/prometheus/client_model](https://github.com/prometheus/client_model) from 0.6.1 to 0.6.2. - [Release notes](https://github.com/prometheus/client_model/releases) - [Commits](https://github.com/prometheus/client_model/compare/v0.6.1...v0.6.2) --- updated-dependencies: - dependency-name: github.com/prometheus/client_model dependency-version: 0.6.2 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 4 ++-- go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 8ee23500..bb2d9263 100644 --- a/go.mod +++ b/go.mod @@ -50,7 +50,7 @@ require ( github.com/mmcdole/gofeed v1.3.0 github.com/montanaflynn/stats v0.7.1 github.com/pkoukk/tiktoken-go v0.1.7 - github.com/prometheus/client_model v0.6.1 + github.com/prometheus/client_model v0.6.2 github.com/prometheus/common v0.63.0 github.com/redis/go-redis/v9 v9.7.3 github.com/robfig/cron/v3 v3.0.1 @@ -214,7 +214,7 @@ require ( golang.org/x/text v0.24.0 // indirect golang.org/x/tools v0.30.0 // indirect google.golang.org/appengine v1.6.8 // indirect - google.golang.org/protobuf v1.36.5 // indirect + google.golang.org/protobuf v1.36.6 // indirect gorm.io/datatypes v1.1.1-0.20230130040222-c43177d3cf8c // indirect gorm.io/hints v1.1.0 // indirect ) diff --git a/go.sum b/go.sum index 95152546..3ed8f819 100644 --- a/go.sum +++ b/go.sum @@ -407,8 +407,8 @@ github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c h1:ncq/mPwQF github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE= github.com/prashantv/gostub v1.1.0 h1:BTyx3RfQjRHnUWaGF9oQos79AlQ5k8WNktv7VGvVH4g= github.com/prashantv/gostub v1.1.0/go.mod h1:A5zLQHz7ieHGG7is6LLXLz7I8+3LZzsrV0P1IAHhP5U= -github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E= -github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY= +github.com/prometheus/client_model v0.6.2 h1:oBsgwpGs7iVziMvrGhE53c/GrLUsZdHnqNwqPLxwZyk= +github.com/prometheus/client_model v0.6.2/go.mod h1:y3m2F6Gdpfy6Ut/GBsUqTWZqCUvMVzSfMLjcu6wAwpE= github.com/prometheus/common v0.63.0 h1:YR/EIY1o3mEFP/kZCD7iDMnLPlGyuU2Gb3HIcXnA98k= github.com/prometheus/common v0.63.0/go.mod h1:VVFF/fBIoToEnWRVkYoXEkq3R3paCoxG9PXP74SnV18= github.com/redis/go-redis/v9 v9.7.3 h1:YpPyAayJV+XErNsatSElgRZZVCwXX9QzkKYNvO7x0wM= @@ -687,8 +687,8 @@ google.golang.org/grpc v1.67.3 h1:OgPcDAFKHnH8X3O4WcO4XUc8GRDeKsKReqbQtiCj7N8= google.golang.org/grpc v1.67.3/go.mod h1:YGaHCc6Oap+FzBJTZLBzkGSYt/cvGPFTPxkn7QfSU8s= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.36.5 h1:tPhr+woSbjfYvY6/GPufUoYizxw1cF/yFoxJ2fmpwlM= -google.golang.org/protobuf v1.36.5/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= +google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY= +google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= From 8d951260713035a386d9065c0c1b2ff2d6b3695b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 14 Apr 2025 16:41:45 +0000 Subject: [PATCH 010/125] build(deps): bump gorm.io/gen from 0.3.26 to 0.3.27 Bumps [gorm.io/gen](https://github.com/go-gorm/gen) from 0.3.26 to 0.3.27. - [Release notes](https://github.com/go-gorm/gen/releases) - [Commits](https://github.com/go-gorm/gen/compare/v0.3.26...v0.3.27) --- updated-dependencies: - dependency-name: gorm.io/gen dependency-version: 0.3.27 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 4 ++-- go.sum | 32 ++++++++++++-------------------- 2 files changed, 14 insertions(+), 22 deletions(-) diff --git a/go.mod b/go.mod index bb2d9263..5604cbe9 100644 --- a/go.mod +++ b/go.mod @@ -73,7 +73,7 @@ require ( golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 gopkg.in/yaml.v3 v3.0.1 gorm.io/driver/mysql v1.5.7 - gorm.io/gen v0.3.26 + gorm.io/gen v0.3.27 gorm.io/gorm v1.25.12 gorm.io/plugin/dbresolver v1.5.3 gotest.tools/v3 v3.5.2 @@ -215,6 +215,6 @@ require ( golang.org/x/tools v0.30.0 // indirect google.golang.org/appengine v1.6.8 // indirect google.golang.org/protobuf v1.36.6 // indirect - gorm.io/datatypes v1.1.1-0.20230130040222-c43177d3cf8c // indirect + gorm.io/datatypes v1.2.4 // indirect gorm.io/hints v1.1.0 // indirect ) diff --git a/go.sum b/go.sum index 3ed8f819..43b2b203 100644 --- a/go.sum +++ b/go.sum @@ -255,22 +255,14 @@ github.com/influxdata/cron v0.0.0-20201006132531-4bb0a200dcbe/go.mod h1:XabtPPW2 github.com/invopop/yaml v0.1.0/go.mod h1:2XuRLgs/ouIrW3XNzuNj7J3Nvu/Dig5MXvbCEdiBN3Q= github.com/invopop/yaml v0.3.1 h1:f0+ZpmhfBSS4MhG+4HYseMdJhoeeopbSKbq5Rpeelso= github.com/invopop/yaml v0.3.1/go.mod h1:PMOp3nn4/12yEZUFfmOuNHJsZToEEOwoWsT+D81KkeA= -github.com/jackc/chunkreader/v2 v2.0.1 h1:i+RDz65UE+mmpjTfyz0MoVTnzeYxroil2G82ki7MGG8= -github.com/jackc/chunkreader/v2 v2.0.1/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk= -github.com/jackc/pgconn v1.14.3 h1:bVoTr12EGANZz66nZPkMInAV/KHD2TxH9npjXXgiB3w= -github.com/jackc/pgconn v1.14.3/go.mod h1:RZbme4uasqzybK2RK5c65VsHxoyaml09lx3tXOcO/VM= -github.com/jackc/pgio v1.0.0 h1:g12B9UwVnzGhueNavwioyEEpAmqMe1E/BN9ES+8ovkE= -github.com/jackc/pgio v1.0.0/go.mod h1:oP+2QK2wFfUWgr+gxjoBH9KGBb31Eio69xUb0w5bYf8= github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM= github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg= -github.com/jackc/pgproto3/v2 v2.3.3 h1:1HLSx5H+tXR9pW3in3zaztoEwQYRC9SQaYUHjTSUOag= -github.com/jackc/pgproto3/v2 v2.3.3/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= -github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a h1:bbPeKD0xmW/Y25WS6cokEszi5g+S0QxI/d45PkRi7Nk= -github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM= -github.com/jackc/pgtype v1.14.0 h1:y+xUdabmyMkJLyApYuPj38mW+aAIqCe5uuBB51rH3Vw= -github.com/jackc/pgtype v1.14.0/go.mod h1:LUMuVrfsFfdKGLw+AFFVv6KtHOFMwRgDDzBt76IqCA4= -github.com/jackc/pgx/v4 v4.18.2 h1:xVpYkNR5pk5bMCZGfClbO962UIqVABcAGt7ha1s/FeU= -github.com/jackc/pgx/v4 v4.18.2/go.mod h1:Ey4Oru5tH5sB6tV7hDmfWFahwF15Eb7DNXlRKx2CkVw= +github.com/jackc/pgservicefile v0.0.0-20231201235250-de7065d80cb9 h1:L0QtFUgDarD7Fpv9jeVMgy/+Ec0mtnmYuImjTz6dtDA= +github.com/jackc/pgservicefile v0.0.0-20231201235250-de7065d80cb9/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM= +github.com/jackc/pgx/v5 v5.5.5 h1:amBjrZVmksIdNjxGW/IiIMzxMKZFelXbUoPNb+8sjQw= +github.com/jackc/pgx/v5 v5.5.5/go.mod h1:ez9gk+OAat140fv9ErkZDYFWmXLfV+++K0uAOiwgm1A= +github.com/jackc/puddle/v2 v2.2.1 h1:RhxXJtFG022u4ibrCSMSiu5aOq1i77R3OHKNJj77OAk= +github.com/jackc/puddle/v2 v2.2.1/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4= github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E= github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= github.com/jinzhu/now v1.1.2/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= @@ -705,19 +697,19 @@ gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C 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= -gorm.io/datatypes v1.1.1-0.20230130040222-c43177d3cf8c h1:jWdr7cHgl8c/ua5vYbR2WhSp+NQmzhsj0xoY3foTzW8= -gorm.io/datatypes v1.1.1-0.20230130040222-c43177d3cf8c/go.mod h1:SH2K9R+2RMjuX1CkCONrPwoe9JzVv2hkQvEu4bXGojE= +gorm.io/datatypes v1.2.4 h1:uZmGAcK/QZ0uyfCuVg0VQY1ZmV9h1fuG0tMwKByO1z4= +gorm.io/datatypes v1.2.4/go.mod h1:f4BsLcFAX67szSv8svwLRjklArSHAvHLeE3pXAS5DZI= gorm.io/driver/mysql v1.5.7 h1:MndhOPYOfEp2rHKgkZIhJ16eVUIRf2HmzgoPmh7FCWo= gorm.io/driver/mysql v1.5.7/go.mod h1:sEtPWMiqiN1N1cMXoXmBbd8C6/l+TESwriotuRRpkDM= -gorm.io/driver/postgres v1.4.5 h1:mTeXTTtHAgnS9PgmhN2YeUbazYpLhUI1doLnw42XUZc= -gorm.io/driver/postgres v1.4.5/go.mod h1:GKNQYSJ14qvWkvPwXljMGehpKrhlDNsqYRr5HnYGncg= +gorm.io/driver/postgres v1.5.0 h1:u2FXTy14l45qc3UeCJ7QaAXZmZfDDv0YrthvmRq1l0U= +gorm.io/driver/postgres v1.5.0/go.mod h1:FUZXzO+5Uqg5zzwzv4KK49R8lvGIyscBOqYrtI1Ce9A= gorm.io/driver/sqlite v1.1.6/go.mod h1:W8LmC/6UvVbHKah0+QOC7Ja66EaZXHwUTjgXY8YNWX8= gorm.io/driver/sqlite v1.4.3 h1:HBBcZSDnWi5BW3B3rwvVTc510KGkBkexlOg0QrmLUuU= gorm.io/driver/sqlite v1.4.3/go.mod h1:0Aq3iPO+v9ZKbcdiz8gLWRw5VOPcBOPUQJFLq5e2ecI= gorm.io/driver/sqlserver v1.4.1 h1:t4r4r6Jam5E6ejqP7N82qAJIJAht27EGT41HyPfXRw0= gorm.io/driver/sqlserver v1.4.1/go.mod h1:DJ4P+MeZbc5rvY58PnmN1Lnyvb5gw5NPzGshHDnJLig= -gorm.io/gen v0.3.26 h1:sFf1j7vNStimPRRAtH4zz5NiHM+1dr6eA9aaRdplyhY= -gorm.io/gen v0.3.26/go.mod h1:a5lq5y3w4g5LMxBcw0wnO6tYUCdNutWODq5LrIt75LE= +gorm.io/gen v0.3.27 h1:ziocAFLpE7e0g4Rum69pGfB9S6DweTxK8gAun7cU8as= +gorm.io/gen v0.3.27/go.mod h1:9zquz2xD1f3Eb/eHq4oLn2z6vDVvQlCY5S3uMBLv4EA= gorm.io/gorm v1.21.15/go.mod h1:F+OptMscr0P2F2qU97WT1WimdH9GaQPoDW7AYd5i2Y0= gorm.io/gorm v1.22.2/go.mod h1:F+OptMscr0P2F2qU97WT1WimdH9GaQPoDW7AYd5i2Y0= gorm.io/gorm v1.25.7/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8= From 4201f23d08e6dc0a2d0d140090540cee4c6ca074 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 14 Apr 2025 16:41:52 +0000 Subject: [PATCH 011/125] build(deps): bump github.com/cloudwego/eino from 0.3.21 to 0.3.22 Bumps [github.com/cloudwego/eino](https://github.com/cloudwego/eino) from 0.3.21 to 0.3.22. - [Release notes](https://github.com/cloudwego/eino/releases) - [Commits](https://github.com/cloudwego/eino/compare/v0.3.21...v0.3.22) --- updated-dependencies: - dependency-name: github.com/cloudwego/eino dependency-version: 0.3.22 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index bb2d9263..96a6e34d 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/bsm/redislock v0.9.4 github.com/bwmarrin/discordgo v0.28.1 github.com/cenkalti/backoff v2.2.1+incompatible - github.com/cloudwego/eino v0.3.21 + github.com/cloudwego/eino v0.3.22 github.com/cloudwego/eino-ext/components/model/openai v0.0.0-20250221090944-e8ef7aabbe10 github.com/creachadair/jrpc2 v1.3.1 github.com/docker/cli v28.0.4+incompatible diff --git a/go.sum b/go.sum index 3ed8f819..bd5a6546 100644 --- a/go.sum +++ b/go.sum @@ -65,8 +65,8 @@ github.com/chengxilo/virtualterm v1.0.4 h1:Z6IpERbRVlfB8WkOmtbHiDbBANU7cimRIof7m github.com/chengxilo/virtualterm v1.0.4/go.mod h1:DyxxBZz/x1iqJjFxTFcr6/x+jSpqN0iwWCOK1q10rlY= github.com/cloudwego/base64x v0.1.5 h1:XPciSp1xaq2VCSt6lF0phncD4koWyULpl5bUxbfCyP4= github.com/cloudwego/base64x v0.1.5/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w= -github.com/cloudwego/eino v0.3.21 h1:dbggS3iOKWtsQhiTStepmrXzbauOuXXo/hRf5FKLvbE= -github.com/cloudwego/eino v0.3.21/go.mod h1:wUjz990apdsaOraOXdh6CdhVXq8DJsOvLsVlxNTcNfY= +github.com/cloudwego/eino v0.3.22 h1:nCz7pQaNk5TkTfbMHi0YGj4zsvSE1Akw7jBYyujIKpw= +github.com/cloudwego/eino v0.3.22/go.mod h1:wUjz990apdsaOraOXdh6CdhVXq8DJsOvLsVlxNTcNfY= github.com/cloudwego/eino-ext/components/model/openai v0.0.0-20250221090944-e8ef7aabbe10 h1:DJAInsXygJKCrkahR42QODKkq91nvQCTe60o3MnjsKs= github.com/cloudwego/eino-ext/components/model/openai v0.0.0-20250221090944-e8ef7aabbe10/go.mod h1:okkkchYXfoEkv5c0GlwhMdVjIshCzmN3DCcnbOWf7DQ= github.com/cloudwego/eino-ext/libs/acl/openai v0.0.0-20250221090944-e8ef7aabbe10 h1:M6Z2PeX+MxW7jgoZ0p6qDfVtMe1/4XqSQSAHUrI2HTM= From 4a17751601cf8b7a750fd0b5445095452d86908f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 14 Apr 2025 16:41:57 +0000 Subject: [PATCH 012/125] build(deps): bump github.com/go-echarts/go-echarts/v2 Bumps [github.com/go-echarts/go-echarts/v2](https://github.com/go-echarts/go-echarts) from 2.5.2 to 2.5.3. - [Release notes](https://github.com/go-echarts/go-echarts/releases) - [Commits](https://github.com/go-echarts/go-echarts/compare/v2.5.2...v2.5.3) --- updated-dependencies: - dependency-name: github.com/go-echarts/go-echarts/v2 dependency-version: 2.5.3 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index bb2d9263..8b285be9 100644 --- a/go.mod +++ b/go.mod @@ -24,7 +24,7 @@ require ( github.com/emicklei/go-restful/v3 v3.12.2 github.com/expr-lang/expr v1.17.2 github.com/gen2brain/beeep v0.0.0-20240516210008-9c006672e7f4 - github.com/go-echarts/go-echarts/v2 v2.5.2 + github.com/go-echarts/go-echarts/v2 v2.5.3 github.com/go-playground/validator/v10 v10.26.0 github.com/go-resty/resty/v2 v2.16.5 github.com/go-sql-driver/mysql v1.9.2 diff --git a/go.sum b/go.sum index 3ed8f819..82eea039 100644 --- a/go.sum +++ b/go.sum @@ -132,8 +132,8 @@ github.com/getkin/kin-openapi v0.118.0/go.mod h1:l5e9PaFUo9fyLJCPGQeXI2ML8c3P8BH github.com/getsentry/raven-go v0.2.0/go.mod h1:KungGk8q33+aIAZUIVWZDr2OfAEBsO49PX4NzFV5kcQ= github.com/go-check/check v0.0.0-20180628173108-788fd7840127 h1:0gkP6mzaMqkmpcJYCFOLkIBwI7xFExG03bbkOkCvUPI= github.com/go-check/check v0.0.0-20180628173108-788fd7840127/go.mod h1:9ES+weclKsC9YodN5RgxqK/VD9HM9JsCSh7rNhMZE98= -github.com/go-echarts/go-echarts/v2 v2.5.2 h1:m0OiI4WZR3TO7OL4IaA0lxqjg5DXtdWjoOCO0CsiIH0= -github.com/go-echarts/go-echarts/v2 v2.5.2/go.mod h1:56YlvzhW/a+du15f3S2qUGNDfKnFOeJSThBIrVFHDtI= +github.com/go-echarts/go-echarts/v2 v2.5.3 h1:5SFAA6bAIWz52VnVGlCM1UZXo8nSdN+H9E8Ysi4m5ec= +github.com/go-echarts/go-echarts/v2 v2.5.3/go.mod h1:56YlvzhW/a+du15f3S2qUGNDfKnFOeJSThBIrVFHDtI= github.com/go-fed/httpsig v1.1.0 h1:9M+hb0jkEICD8/cAiNqEB66R87tTINszBRTjwjQzWcI= github.com/go-fed/httpsig v1.1.0/go.mod h1:RCMrTZvN1bJYtofsG4rd5NaO5obxQ5xBkdiS7xsT7bM= github.com/go-ini/ini v1.67.0 h1:z6ZrTEZqSWOTyH2FlglNbNgARyHG8oLW9gMELqKr06A= From adcf4f989b609648ef593ab9ae71e9f857624a4f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 14 Apr 2025 16:42:03 +0000 Subject: [PATCH 013/125] build(deps): bump github.com/PuerkitoBio/goquery from 1.10.2 to 1.10.3 Bumps [github.com/PuerkitoBio/goquery](https://github.com/PuerkitoBio/goquery) from 1.10.2 to 1.10.3. - [Release notes](https://github.com/PuerkitoBio/goquery/releases) - [Commits](https://github.com/PuerkitoBio/goquery/compare/v1.10.2...v1.10.3) --- updated-dependencies: - dependency-name: github.com/PuerkitoBio/goquery dependency-version: 1.10.3 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 4 ++-- go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index bb2d9263..2405950a 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.24 require ( code.gitea.io/sdk/gitea v0.21.0 github.com/Masterminds/semver/v3 v3.3.1 - github.com/PuerkitoBio/goquery v1.10.2 + github.com/PuerkitoBio/goquery v1.10.3 github.com/RealAlexandreAI/json-repair v0.0.14 github.com/ThreeDotsLabs/watermill v1.4.6 github.com/ThreeDotsLabs/watermill-redisstream v1.4.2 @@ -208,7 +208,7 @@ require ( go.uber.org/multierr v1.9.0 // indirect golang.org/x/arch v0.14.0 // indirect golang.org/x/mod v0.23.0 // indirect - golang.org/x/net v0.38.0 // indirect + golang.org/x/net v0.39.0 // indirect golang.org/x/sync v0.13.0 // indirect golang.org/x/term v0.31.0 // indirect golang.org/x/text v0.24.0 // indirect diff --git a/go.sum b/go.sum index 3ed8f819..f34b9acf 100644 --- a/go.sum +++ b/go.sum @@ -14,8 +14,8 @@ github.com/Masterminds/semver/v3 v3.3.1 h1:QtNSWtVZ3nBfk8mAOu/B6v7FMJ+NHTIgUPi7r github.com/Masterminds/semver/v3 v3.3.1/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM= github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY= github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= -github.com/PuerkitoBio/goquery v1.10.2 h1:7fh2BdHcG6VFZsK7toXBT/Bh1z5Wmy8Q9MV9HqT2AM8= -github.com/PuerkitoBio/goquery v1.10.2/go.mod h1:0guWGjcLu9AYC7C1GHnpysHy056u9aEkUHwhdnePMCU= +github.com/PuerkitoBio/goquery v1.10.3 h1:pFYcNSqHxBD06Fpj/KsbStFRsgRATgnf3LeXiUkhzPo= +github.com/PuerkitoBio/goquery v1.10.3/go.mod h1:tMUX0zDMHXYlAQk6p35XxQMqMweEKB7iK7iLNd4RH4Y= github.com/RealAlexandreAI/json-repair v0.0.14 h1:4kTqotVonDVTio5n2yweRUELVcNe2x518wl0bCsw0t0= github.com/RealAlexandreAI/json-repair v0.0.14/go.mod h1:GKJi5borR78O8c7HCVbgqjhoiVibZ6hJldxbc6dGrAI= github.com/Rican7/retry v0.3.1 h1:scY4IbO8swckzoA/11HgBwaZRJEyY9vaNJshcdhp1Mc= @@ -593,8 +593,8 @@ golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk= golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= -golang.org/x/net v0.38.0 h1:vRMAPTMaeGqVhG5QyLJHqNDwecKTomGeqbnfZyKlBI8= -golang.org/x/net v0.38.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8= +golang.org/x/net v0.39.0 h1:ZCu7HMWDxpXpaiKdhzIfaltL9Lp31x/3fCP11bc6/fY= +golang.org/x/net v0.39.0/go.mod h1:X7NRbYVEA+ewNkCNyJ513WmMdQ3BineSwVtN2zD/d+E= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= From 0216c84dd7361af6433a86f9ca0708ff4e5d2887 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 16 Apr 2025 16:46:51 +0000 Subject: [PATCH 014/125] build(deps): bump github.com/cloudwego/eino from 0.3.22 to 0.3.23 Bumps [github.com/cloudwego/eino](https://github.com/cloudwego/eino) from 0.3.22 to 0.3.23. - [Release notes](https://github.com/cloudwego/eino/releases) - [Commits](https://github.com/cloudwego/eino/compare/v0.3.22...v0.3.23) --- updated-dependencies: - dependency-name: github.com/cloudwego/eino dependency-version: 0.3.23 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 6336274e..66f27bc1 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/bsm/redislock v0.9.4 github.com/bwmarrin/discordgo v0.28.1 github.com/cenkalti/backoff v2.2.1+incompatible - github.com/cloudwego/eino v0.3.22 + github.com/cloudwego/eino v0.3.23 github.com/cloudwego/eino-ext/components/model/openai v0.0.0-20250221090944-e8ef7aabbe10 github.com/creachadair/jrpc2 v1.3.1 github.com/docker/cli v28.0.4+incompatible diff --git a/go.sum b/go.sum index c8553988..22fe9e40 100644 --- a/go.sum +++ b/go.sum @@ -65,8 +65,8 @@ github.com/chengxilo/virtualterm v1.0.4 h1:Z6IpERbRVlfB8WkOmtbHiDbBANU7cimRIof7m github.com/chengxilo/virtualterm v1.0.4/go.mod h1:DyxxBZz/x1iqJjFxTFcr6/x+jSpqN0iwWCOK1q10rlY= github.com/cloudwego/base64x v0.1.5 h1:XPciSp1xaq2VCSt6lF0phncD4koWyULpl5bUxbfCyP4= github.com/cloudwego/base64x v0.1.5/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w= -github.com/cloudwego/eino v0.3.22 h1:nCz7pQaNk5TkTfbMHi0YGj4zsvSE1Akw7jBYyujIKpw= -github.com/cloudwego/eino v0.3.22/go.mod h1:wUjz990apdsaOraOXdh6CdhVXq8DJsOvLsVlxNTcNfY= +github.com/cloudwego/eino v0.3.23 h1:fPjskHM85I4PPa+GZPoh76bMCbdRKWVKd52gdvcGHt8= +github.com/cloudwego/eino v0.3.23/go.mod h1:wUjz990apdsaOraOXdh6CdhVXq8DJsOvLsVlxNTcNfY= github.com/cloudwego/eino-ext/components/model/openai v0.0.0-20250221090944-e8ef7aabbe10 h1:DJAInsXygJKCrkahR42QODKkq91nvQCTe60o3MnjsKs= github.com/cloudwego/eino-ext/components/model/openai v0.0.0-20250221090944-e8ef7aabbe10/go.mod h1:okkkchYXfoEkv5c0GlwhMdVjIshCzmN3DCcnbOWf7DQ= github.com/cloudwego/eino-ext/libs/acl/openai v0.0.0-20250221090944-e8ef7aabbe10 h1:M6Z2PeX+MxW7jgoZ0p6qDfVtMe1/4XqSQSAHUrI2HTM= From ea60fbc63b050a7ae91361d0324bdb3d5d0c123c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 17 Apr 2025 16:53:13 +0000 Subject: [PATCH 015/125] build(deps): bump github.com/cloudwego/eino from 0.3.23 to 0.3.24 Bumps [github.com/cloudwego/eino](https://github.com/cloudwego/eino) from 0.3.23 to 0.3.24. - [Release notes](https://github.com/cloudwego/eino/releases) - [Commits](https://github.com/cloudwego/eino/compare/v0.3.23...v0.3.24) --- updated-dependencies: - dependency-name: github.com/cloudwego/eino dependency-version: 0.3.24 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 66f27bc1..86ff3afe 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/bsm/redislock v0.9.4 github.com/bwmarrin/discordgo v0.28.1 github.com/cenkalti/backoff v2.2.1+incompatible - github.com/cloudwego/eino v0.3.23 + github.com/cloudwego/eino v0.3.24 github.com/cloudwego/eino-ext/components/model/openai v0.0.0-20250221090944-e8ef7aabbe10 github.com/creachadair/jrpc2 v1.3.1 github.com/docker/cli v28.0.4+incompatible diff --git a/go.sum b/go.sum index 22fe9e40..f842fe2d 100644 --- a/go.sum +++ b/go.sum @@ -65,8 +65,8 @@ github.com/chengxilo/virtualterm v1.0.4 h1:Z6IpERbRVlfB8WkOmtbHiDbBANU7cimRIof7m github.com/chengxilo/virtualterm v1.0.4/go.mod h1:DyxxBZz/x1iqJjFxTFcr6/x+jSpqN0iwWCOK1q10rlY= github.com/cloudwego/base64x v0.1.5 h1:XPciSp1xaq2VCSt6lF0phncD4koWyULpl5bUxbfCyP4= github.com/cloudwego/base64x v0.1.5/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w= -github.com/cloudwego/eino v0.3.23 h1:fPjskHM85I4PPa+GZPoh76bMCbdRKWVKd52gdvcGHt8= -github.com/cloudwego/eino v0.3.23/go.mod h1:wUjz990apdsaOraOXdh6CdhVXq8DJsOvLsVlxNTcNfY= +github.com/cloudwego/eino v0.3.24 h1:Z+i9OYj2EFcGbJoTxGz46iP4LSCA42zJLhmRnHRpQI0= +github.com/cloudwego/eino v0.3.24/go.mod h1:wUjz990apdsaOraOXdh6CdhVXq8DJsOvLsVlxNTcNfY= github.com/cloudwego/eino-ext/components/model/openai v0.0.0-20250221090944-e8ef7aabbe10 h1:DJAInsXygJKCrkahR42QODKkq91nvQCTe60o3MnjsKs= github.com/cloudwego/eino-ext/components/model/openai v0.0.0-20250221090944-e8ef7aabbe10/go.mod h1:okkkchYXfoEkv5c0GlwhMdVjIshCzmN3DCcnbOWf7DQ= github.com/cloudwego/eino-ext/libs/acl/openai v0.0.0-20250221090944-e8ef7aabbe10 h1:M6Z2PeX+MxW7jgoZ0p6qDfVtMe1/4XqSQSAHUrI2HTM= From c8ae8da798ea2480b219e5f9ad49246e77af97c3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 17 Apr 2025 16:53:22 +0000 Subject: [PATCH 016/125] build(deps): bump github.com/docker/docker Bumps [github.com/docker/docker](https://github.com/docker/docker) from 28.0.4+incompatible to 28.1.0+incompatible. - [Release notes](https://github.com/docker/docker/releases) - [Commits](https://github.com/docker/docker/compare/v28.0.4...v28.1.0) --- updated-dependencies: - dependency-name: github.com/docker/docker dependency-version: 28.1.0+incompatible dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 3 ++- go.sum | 8 ++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 66f27bc1..dad633ea 100644 --- a/go.mod +++ b/go.mod @@ -18,7 +18,7 @@ require ( github.com/cloudwego/eino-ext/components/model/openai v0.0.0-20250221090944-e8ef7aabbe10 github.com/creachadair/jrpc2 v1.3.1 github.com/docker/cli v28.0.4+incompatible - github.com/docker/docker v28.0.4+incompatible + github.com/docker/docker v28.1.0+incompatible github.com/docker/go-units v0.5.0 github.com/dustin/go-humanize v1.0.1 github.com/emicklei/go-restful/v3 v3.12.2 @@ -155,6 +155,7 @@ require ( github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db // indirect github.com/mmcdole/goxpp v1.1.1-0.20240225020742-a0c311522b23 // indirect github.com/moby/docker-image-spec v1.3.1 // indirect + github.com/moby/sys/atomicwriter v0.1.0 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect diff --git a/go.sum b/go.sum index 22fe9e40..d311bfa0 100644 --- a/go.sum +++ b/go.sum @@ -98,8 +98,8 @@ github.com/dlclark/regexp2 v1.10.0 h1:+/GIL799phkJqYW+3YbOd8LCcbHzT0Pbo8zl70MHsq github.com/dlclark/regexp2 v1.10.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= github.com/docker/cli v28.0.4+incompatible h1:pBJSJeNd9QeIWPjRcV91RVJihd/TXB77q1ef64XEu4A= github.com/docker/cli v28.0.4+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= -github.com/docker/docker v28.0.4+incompatible h1:JNNkBctYKurkw6FrHfKqY0nKIDf5nrbxjVBtS+cdcok= -github.com/docker/docker v28.0.4+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= +github.com/docker/docker v28.1.0+incompatible h1:4iqpcWQCt3Txcz7iWIb1U3SZ/n9ffo4U+ryY5/3eOp0= +github.com/docker/docker v28.1.0+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/go-connections v0.5.0 h1:USnMq7hx7gwdVZq1L49hLXaFtUdTADjXGp+uj1Br63c= github.com/docker/go-connections v0.5.0/go.mod h1:ov60Kzw0kKElRwhNs9UlUHAE/F9Fe6GLaXnqyDdmEXc= github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= @@ -349,6 +349,10 @@ github.com/mmcdole/goxpp v1.1.1-0.20240225020742-a0c311522b23 h1:Zr92CAlFhy2gL+V github.com/mmcdole/goxpp v1.1.1-0.20240225020742-a0c311522b23/go.mod h1:v+25+lT2ViuQ7mVxcncQ8ch1URund48oH+jhjiwEgS8= github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3Nl2EsFP0= github.com/moby/docker-image-spec v1.3.1/go.mod h1:eKmb5VW8vQEh/BAr2yvVNvuiJuY6UIocYsFu/DxxRpo= +github.com/moby/sys/atomicwriter v0.1.0 h1:kw5D/EqkBwsBFi0ss9v1VG3wIkVhzGvLklJ+w3A14Sw= +github.com/moby/sys/atomicwriter v0.1.0/go.mod h1:Ul8oqv2ZMNHOceF643P6FKPXeCmYtlQMvpizfsSoaWs= +github.com/moby/sys/sequential v0.6.0 h1:qrx7XFUd/5DxtqcoH1h438hF5TmOvzC/lspjy7zgvCU= +github.com/moby/sys/sequential v0.6.0/go.mod h1:uyv8EUTrca5PnDsdMGXhZe6CCe8U/UiTWd+lL+7b/Ko= github.com/moby/term v0.5.0 h1:xt8Q1nalod/v7BqbG21f8mQPqH+xAaC9C3N3wfWbVP0= github.com/moby/term v0.5.0/go.mod h1:8FzsFHVUBGZdbDsJw/ot+X+d5HLUbvklYLJ9uGfcI3Y= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= From c2f13b2b1d879eb4e4882db55e9d4721ef94e1a0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 18 Apr 2025 01:51:06 +0000 Subject: [PATCH 017/125] build(deps): bump github.com/docker/cli Bumps [github.com/docker/cli](https://github.com/docker/cli) from 28.0.4+incompatible to 28.1.0+incompatible. - [Commits](https://github.com/docker/cli/compare/v28.0.4...v28.1.0) --- updated-dependencies: - dependency-name: github.com/docker/cli dependency-version: 28.1.0+incompatible dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 1fc6ad6f..c005ed08 100644 --- a/go.mod +++ b/go.mod @@ -17,7 +17,7 @@ require ( github.com/cloudwego/eino v0.3.24 github.com/cloudwego/eino-ext/components/model/openai v0.0.0-20250221090944-e8ef7aabbe10 github.com/creachadair/jrpc2 v1.3.1 - github.com/docker/cli v28.0.4+incompatible + github.com/docker/cli v28.1.0+incompatible github.com/docker/docker v28.1.0+incompatible github.com/docker/go-units v0.5.0 github.com/dustin/go-humanize v1.0.1 diff --git a/go.sum b/go.sum index f3342742..438fb241 100644 --- a/go.sum +++ b/go.sum @@ -96,8 +96,8 @@ github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5Qvfr github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E= github.com/dlclark/regexp2 v1.10.0 h1:+/GIL799phkJqYW+3YbOd8LCcbHzT0Pbo8zl70MHsq0= github.com/dlclark/regexp2 v1.10.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= -github.com/docker/cli v28.0.4+incompatible h1:pBJSJeNd9QeIWPjRcV91RVJihd/TXB77q1ef64XEu4A= -github.com/docker/cli v28.0.4+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= +github.com/docker/cli v28.1.0+incompatible h1:WiJhUBbuIH/BsJtth+C1hPwra4P0nsKJiWy9ie5My5s= +github.com/docker/cli v28.1.0+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= github.com/docker/docker v28.1.0+incompatible h1:4iqpcWQCt3Txcz7iWIb1U3SZ/n9ffo4U+ryY5/3eOp0= github.com/docker/docker v28.1.0+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/go-connections v0.5.0 h1:USnMq7hx7gwdVZq1L49hLXaFtUdTADjXGp+uj1Br63c= From 5d247b6ccb02d64a69715f858ad4430e04ee1dd2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 18 Apr 2025 16:07:10 +0000 Subject: [PATCH 018/125] build(deps): bump github.com/docker/docker Bumps [github.com/docker/docker](https://github.com/docker/docker) from 28.1.0+incompatible to 28.1.1+incompatible. - [Release notes](https://github.com/docker/docker/releases) - [Commits](https://github.com/docker/docker/compare/v28.1.0...v28.1.1) --- updated-dependencies: - dependency-name: github.com/docker/docker dependency-version: 28.1.1+incompatible dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index c005ed08..bd1a3538 100644 --- a/go.mod +++ b/go.mod @@ -18,7 +18,7 @@ require ( github.com/cloudwego/eino-ext/components/model/openai v0.0.0-20250221090944-e8ef7aabbe10 github.com/creachadair/jrpc2 v1.3.1 github.com/docker/cli v28.1.0+incompatible - github.com/docker/docker v28.1.0+incompatible + github.com/docker/docker v28.1.1+incompatible github.com/docker/go-units v0.5.0 github.com/dustin/go-humanize v1.0.1 github.com/emicklei/go-restful/v3 v3.12.2 diff --git a/go.sum b/go.sum index 438fb241..62ac7af7 100644 --- a/go.sum +++ b/go.sum @@ -98,8 +98,8 @@ github.com/dlclark/regexp2 v1.10.0 h1:+/GIL799phkJqYW+3YbOd8LCcbHzT0Pbo8zl70MHsq github.com/dlclark/regexp2 v1.10.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= github.com/docker/cli v28.1.0+incompatible h1:WiJhUBbuIH/BsJtth+C1hPwra4P0nsKJiWy9ie5My5s= github.com/docker/cli v28.1.0+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= -github.com/docker/docker v28.1.0+incompatible h1:4iqpcWQCt3Txcz7iWIb1U3SZ/n9ffo4U+ryY5/3eOp0= -github.com/docker/docker v28.1.0+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= +github.com/docker/docker v28.1.1+incompatible h1:49M11BFLsVO1gxY9UX9p/zwkE/rswggs8AdFmXQw51I= +github.com/docker/docker v28.1.1+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/go-connections v0.5.0 h1:USnMq7hx7gwdVZq1L49hLXaFtUdTADjXGp+uj1Br63c= github.com/docker/go-connections v0.5.0/go.mod h1:ov60Kzw0kKElRwhNs9UlUHAE/F9Fe6GLaXnqyDdmEXc= github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= From 893119b106a10168d74e82b2d4c0a3b0b07ef475 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 18 Apr 2025 16:07:20 +0000 Subject: [PATCH 019/125] build(deps): bump github.com/cloudwego/eino from 0.3.24 to 0.3.25 Bumps [github.com/cloudwego/eino](https://github.com/cloudwego/eino) from 0.3.24 to 0.3.25. - [Release notes](https://github.com/cloudwego/eino/releases) - [Commits](https://github.com/cloudwego/eino/compare/v0.3.24...v0.3.25) --- updated-dependencies: - dependency-name: github.com/cloudwego/eino dependency-version: 0.3.25 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index c005ed08..cf477d46 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/bsm/redislock v0.9.4 github.com/bwmarrin/discordgo v0.28.1 github.com/cenkalti/backoff v2.2.1+incompatible - github.com/cloudwego/eino v0.3.24 + github.com/cloudwego/eino v0.3.25 github.com/cloudwego/eino-ext/components/model/openai v0.0.0-20250221090944-e8ef7aabbe10 github.com/creachadair/jrpc2 v1.3.1 github.com/docker/cli v28.1.0+incompatible diff --git a/go.sum b/go.sum index 438fb241..6caae6c6 100644 --- a/go.sum +++ b/go.sum @@ -65,8 +65,8 @@ github.com/chengxilo/virtualterm v1.0.4 h1:Z6IpERbRVlfB8WkOmtbHiDbBANU7cimRIof7m github.com/chengxilo/virtualterm v1.0.4/go.mod h1:DyxxBZz/x1iqJjFxTFcr6/x+jSpqN0iwWCOK1q10rlY= github.com/cloudwego/base64x v0.1.5 h1:XPciSp1xaq2VCSt6lF0phncD4koWyULpl5bUxbfCyP4= github.com/cloudwego/base64x v0.1.5/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w= -github.com/cloudwego/eino v0.3.24 h1:Z+i9OYj2EFcGbJoTxGz46iP4LSCA42zJLhmRnHRpQI0= -github.com/cloudwego/eino v0.3.24/go.mod h1:wUjz990apdsaOraOXdh6CdhVXq8DJsOvLsVlxNTcNfY= +github.com/cloudwego/eino v0.3.25 h1:/ExJxjxsoGsbSQpa+glLqKsKgc6Njtknl6h0MuwJF0Q= +github.com/cloudwego/eino v0.3.25/go.mod h1:wUjz990apdsaOraOXdh6CdhVXq8DJsOvLsVlxNTcNfY= github.com/cloudwego/eino-ext/components/model/openai v0.0.0-20250221090944-e8ef7aabbe10 h1:DJAInsXygJKCrkahR42QODKkq91nvQCTe60o3MnjsKs= github.com/cloudwego/eino-ext/components/model/openai v0.0.0-20250221090944-e8ef7aabbe10/go.mod h1:okkkchYXfoEkv5c0GlwhMdVjIshCzmN3DCcnbOWf7DQ= github.com/cloudwego/eino-ext/libs/acl/openai v0.0.0-20250221090944-e8ef7aabbe10 h1:M6Z2PeX+MxW7jgoZ0p6qDfVtMe1/4XqSQSAHUrI2HTM= From bfce51d8886e31a50c69e8d95cec69765a2e1dfc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 20 Apr 2025 02:42:39 +0000 Subject: [PATCH 020/125] build(deps): bump github.com/docker/cli Bumps [github.com/docker/cli](https://github.com/docker/cli) from 28.1.0+incompatible to 28.1.1+incompatible. - [Commits](https://github.com/docker/cli/compare/v28.1.0...v28.1.1) --- updated-dependencies: - dependency-name: github.com/docker/cli dependency-version: 28.1.1+incompatible dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 6399723c..a6da23c7 100644 --- a/go.mod +++ b/go.mod @@ -17,7 +17,7 @@ require ( github.com/cloudwego/eino v0.3.25 github.com/cloudwego/eino-ext/components/model/openai v0.0.0-20250221090944-e8ef7aabbe10 github.com/creachadair/jrpc2 v1.3.1 - github.com/docker/cli v28.1.0+incompatible + github.com/docker/cli v28.1.1+incompatible github.com/docker/docker v28.1.1+incompatible github.com/docker/go-units v0.5.0 github.com/dustin/go-humanize v1.0.1 diff --git a/go.sum b/go.sum index 086c09d5..86a999ab 100644 --- a/go.sum +++ b/go.sum @@ -96,8 +96,8 @@ github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5Qvfr github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E= github.com/dlclark/regexp2 v1.10.0 h1:+/GIL799phkJqYW+3YbOd8LCcbHzT0Pbo8zl70MHsq0= github.com/dlclark/regexp2 v1.10.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= -github.com/docker/cli v28.1.0+incompatible h1:WiJhUBbuIH/BsJtth+C1hPwra4P0nsKJiWy9ie5My5s= -github.com/docker/cli v28.1.0+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= +github.com/docker/cli v28.1.1+incompatible h1:eyUemzeI45DY7eDPuwUcmDyDj1pM98oD5MdSpiItp8k= +github.com/docker/cli v28.1.1+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= github.com/docker/docker v28.1.1+incompatible h1:49M11BFLsVO1gxY9UX9p/zwkE/rswggs8AdFmXQw51I= github.com/docker/docker v28.1.1+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/go-connections v0.5.0 h1:USnMq7hx7gwdVZq1L49hLXaFtUdTADjXGp+uj1Br63c= From 0bae6ed7fd350377561e19b1185a886d6aa89ed7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 21 Apr 2025 17:08:20 +0000 Subject: [PATCH 021/125] build(deps): bump github.com/cloudwego/eino from 0.3.25 to 0.3.26 Bumps [github.com/cloudwego/eino](https://github.com/cloudwego/eino) from 0.3.25 to 0.3.26. - [Release notes](https://github.com/cloudwego/eino/releases) - [Commits](https://github.com/cloudwego/eino/compare/v0.3.25...v0.3.26) --- updated-dependencies: - dependency-name: github.com/cloudwego/eino dependency-version: 0.3.26 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index a6da23c7..49d5a09b 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/bsm/redislock v0.9.4 github.com/bwmarrin/discordgo v0.28.1 github.com/cenkalti/backoff v2.2.1+incompatible - github.com/cloudwego/eino v0.3.25 + github.com/cloudwego/eino v0.3.26 github.com/cloudwego/eino-ext/components/model/openai v0.0.0-20250221090944-e8ef7aabbe10 github.com/creachadair/jrpc2 v1.3.1 github.com/docker/cli v28.1.1+incompatible diff --git a/go.sum b/go.sum index 86a999ab..a08538d4 100644 --- a/go.sum +++ b/go.sum @@ -65,8 +65,8 @@ github.com/chengxilo/virtualterm v1.0.4 h1:Z6IpERbRVlfB8WkOmtbHiDbBANU7cimRIof7m github.com/chengxilo/virtualterm v1.0.4/go.mod h1:DyxxBZz/x1iqJjFxTFcr6/x+jSpqN0iwWCOK1q10rlY= github.com/cloudwego/base64x v0.1.5 h1:XPciSp1xaq2VCSt6lF0phncD4koWyULpl5bUxbfCyP4= github.com/cloudwego/base64x v0.1.5/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w= -github.com/cloudwego/eino v0.3.25 h1:/ExJxjxsoGsbSQpa+glLqKsKgc6Njtknl6h0MuwJF0Q= -github.com/cloudwego/eino v0.3.25/go.mod h1:wUjz990apdsaOraOXdh6CdhVXq8DJsOvLsVlxNTcNfY= +github.com/cloudwego/eino v0.3.26 h1:FdJJTCdNrc9xPcYkLZiEyr7AA+WgyCKCbY+VNDXIaCE= +github.com/cloudwego/eino v0.3.26/go.mod h1:wUjz990apdsaOraOXdh6CdhVXq8DJsOvLsVlxNTcNfY= github.com/cloudwego/eino-ext/components/model/openai v0.0.0-20250221090944-e8ef7aabbe10 h1:DJAInsXygJKCrkahR42QODKkq91nvQCTe60o3MnjsKs= github.com/cloudwego/eino-ext/components/model/openai v0.0.0-20250221090944-e8ef7aabbe10/go.mod h1:okkkchYXfoEkv5c0GlwhMdVjIshCzmN3DCcnbOWf7DQ= github.com/cloudwego/eino-ext/libs/acl/openai v0.0.0-20250221090944-e8ef7aabbe10 h1:M6Z2PeX+MxW7jgoZ0p6qDfVtMe1/4XqSQSAHUrI2HTM= From 27e3fe04fcbc70a61b5004f825b88a6ffbfdb1c5 Mon Sep 17 00:00:00 2001 From: sysatom Date: Wed, 23 Apr 2025 00:18:52 +0800 Subject: [PATCH 022/125] =?UTF-8?q?=F0=9F=90=B3=20fix(Dockerfile):=20Updat?= =?UTF-8?q?e=20build=20command=20with=20`--always`=20tag=20inclusion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deployments/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployments/Dockerfile b/deployments/Dockerfile index 9af70da5..23c6c053 100644 --- a/deployments/Dockerfile +++ b/deployments/Dockerfile @@ -5,7 +5,7 @@ WORKDIR /opt/app COPY . . RUN go mod download -RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o flowbot -ldflags "-X github.com/flowline-io/flowbot/version.Buildstamp=`date -u '+%Y-%m-%dT%H:%M:%SZ'` -X github.com/flowline-io/flowbot/version.Buildtags=`git describe --tags`" github.com/flowline-io/flowbot/cmd +RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o flowbot -ldflags "-X github.com/flowline-io/flowbot/version.Buildstamp=`date -u '+%Y-%m-%dT%H:%M:%SZ'` -X github.com/flowline-io/flowbot/version.Buildtags=`git describe --tags --always`" github.com/flowline-io/flowbot/cmd FROM alpine:latest From 889ceffa4bb10aa894ba097c588256f7f9dca035 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 22 Apr 2025 16:30:21 +0000 Subject: [PATCH 023/125] build(deps): bump github.com/valyala/fasthttp from 1.60.0 to 1.61.0 Bumps [github.com/valyala/fasthttp](https://github.com/valyala/fasthttp) from 1.60.0 to 1.61.0. - [Release notes](https://github.com/valyala/fasthttp/releases) - [Commits](https://github.com/valyala/fasthttp/compare/v1.60.0...v1.61.0) --- updated-dependencies: - dependency-name: github.com/valyala/fasthttp dependency-version: 1.61.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 49d5a09b..e6a1fb8e 100644 --- a/go.mod +++ b/go.mod @@ -64,7 +64,7 @@ require ( github.com/swaggo/swag v1.16.4 github.com/tidwall/gjson v1.18.0 github.com/urfave/cli/v2 v2.27.6 - github.com/valyala/fasthttp v1.60.0 + github.com/valyala/fasthttp v1.61.0 go.uber.org/automaxprocs v1.6.0 golang.org/x/crypto v0.37.0 golang.org/x/exp v0.0.0-20250218142911-aa4b98e5adaa diff --git a/go.sum b/go.sum index a08538d4..733e7746 100644 --- a/go.sum +++ b/go.sum @@ -500,8 +500,8 @@ github.com/urfave/cli/v2 v2.27.6 h1:VdRdS98FNhKZ8/Az8B7MTyGQmpIr36O1EHybx/LaZ4g= github.com/urfave/cli/v2 v2.27.6/go.mod h1:3Sevf16NykTbInEnD0yKkjDAeZDS0A6bzhBH5hrMvTQ= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= -github.com/valyala/fasthttp v1.60.0 h1:kBRYS0lOhVJ6V+bYN8PqAHELKHtXqwq9zNMLKx1MBsw= -github.com/valyala/fasthttp v1.60.0/go.mod h1:iY4kDgV3Gc6EqhRZ8icqcmlG6bqhcDXfuHgTO4FXCvc= +github.com/valyala/fasthttp v1.61.0 h1:VV08V0AfoRaFurP1EWKvQQdPTZHiUzaVoulX1aBDgzU= +github.com/valyala/fasthttp v1.61.0/go.mod h1:wRIV/4cMwUPWnRcDno9hGnYZGh78QzODFfo1LTUhBog= github.com/valyala/fastrand v1.1.0 h1:f+5HkLW4rsgzdNoleUOB69hyT9IlD2ZQh9GyDMfb5G8= github.com/valyala/fastrand v1.1.0/go.mod h1:HWqCzkrkg6QXT8V2EXWvXCoow7vLwOFN002oeRzjapQ= github.com/valyala/histogram v1.2.0 h1:wyYGAZZt3CpwUiIb9AU/Zbllg1llXyrtApRS815OLoQ= From e836258bae3d102576e20d2ce93e1026ce1eaf0d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 23 Apr 2025 16:39:51 +0000 Subject: [PATCH 024/125] build(deps): bump miniflux.app/v2 from 2.2.7 to 2.2.8 Bumps [miniflux.app/v2](https://github.com/miniflux/v2) from 2.2.7 to 2.2.8. - [Release notes](https://github.com/miniflux/v2/releases) - [Changelog](https://github.com/miniflux/v2/blob/main/ChangeLog) - [Commits](https://github.com/miniflux/v2/compare/2.2.7...2.2.8) --- updated-dependencies: - dependency-name: miniflux.app/v2 dependency-version: 2.2.8 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index e6a1fb8e..031e3ce4 100644 --- a/go.mod +++ b/go.mod @@ -78,7 +78,7 @@ require ( gorm.io/plugin/dbresolver v1.5.3 gotest.tools/v3 v3.5.2 jaytaylor.com/html2text v0.0.0-20230321000545-74c2419ad056 - miniflux.app/v2 v2.2.7 + miniflux.app/v2 v2.2.8 ) require ( diff --git a/go.sum b/go.sum index 733e7746..7a6407ce 100644 --- a/go.sum +++ b/go.sum @@ -323,8 +323,8 @@ github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6T github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/mattn/go-sqlite3 v1.14.8/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y= -github.com/mattn/go-sqlite3 v1.14.24 h1:tpSp2G2KyMnnQu99ngJ47EIkWVmliIizyZBfPrBWDRM= -github.com/mattn/go-sqlite3 v1.14.24/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y= +github.com/mattn/go-sqlite3 v1.14.28 h1:ThEiQrnbtumT+QMknw63Befp/ce/nUPgBPMlRFEum7A= +github.com/mattn/go-sqlite3 v1.14.28/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y= github.com/maxence-charriere/go-app/v10 v10.1.3 h1:xj4E3Owbi5HLqF8DtAjRLI6IA5g0VREPatGDczcxtk4= github.com/maxence-charriere/go-app/v10 v10.1.3/go.mod h1:FqUW4on4nJewVfBnSkuxQd3fvtK2RdKS/z76OOUDAAY= github.com/meilisearch/meilisearch-go v0.31.0 h1:yZRhY1qJqdH8h6GFZALGtkDLyj8f9v5aJpsNMyrUmnY= @@ -727,6 +727,6 @@ gotest.tools/v3 v3.5.2 h1:7koQfIKdy+I8UTetycgUqXWSDwpgv193Ka+qRsmBY8Q= gotest.tools/v3 v3.5.2/go.mod h1:LtdLGcnqToBH83WByAAi/wiwSFCArdFIUV/xxN4pcjA= jaytaylor.com/html2text v0.0.0-20230321000545-74c2419ad056 h1:6YFJoB+0fUH6X3xU/G2tQqCYg+PkGtnZ5nMR5rpw72g= jaytaylor.com/html2text v0.0.0-20230321000545-74c2419ad056/go.mod h1:OxvTsCwKosqQ1q7B+8FwXqg4rKZ/UG9dUW+g/VL2xH4= -miniflux.app/v2 v2.2.7 h1:hXS54w6d8e4t9KHmRM18zYDksEfNPTC5mZ4EnYgSzlQ= -miniflux.app/v2 v2.2.7/go.mod h1:yryzMfpO1XoJp8AtdmF0vnan6BYE8oEscK/hEkNrq+s= +miniflux.app/v2 v2.2.8 h1:SsWBlyK7hiBJ5fkNeOgK1p872a4/qDJMOyTH2iSWIsA= +miniflux.app/v2 v2.2.8/go.mod h1:30vy970xFSfHePD/W+SKFz1vnzQx9rqo9/xeFP/GDlE= nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50= From e87e7d3147107ebd6773561e25f8adf1579968c1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 23 Apr 2025 16:39:57 +0000 Subject: [PATCH 025/125] build(deps): bump github.com/cloudwego/eino from 0.3.26 to 0.3.27 Bumps [github.com/cloudwego/eino](https://github.com/cloudwego/eino) from 0.3.26 to 0.3.27. - [Release notes](https://github.com/cloudwego/eino/releases) - [Commits](https://github.com/cloudwego/eino/compare/v0.3.26...v0.3.27) --- updated-dependencies: - dependency-name: github.com/cloudwego/eino dependency-version: 0.3.27 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index e6a1fb8e..482637d6 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/bsm/redislock v0.9.4 github.com/bwmarrin/discordgo v0.28.1 github.com/cenkalti/backoff v2.2.1+incompatible - github.com/cloudwego/eino v0.3.26 + github.com/cloudwego/eino v0.3.27 github.com/cloudwego/eino-ext/components/model/openai v0.0.0-20250221090944-e8ef7aabbe10 github.com/creachadair/jrpc2 v1.3.1 github.com/docker/cli v28.1.1+incompatible diff --git a/go.sum b/go.sum index 733e7746..b0547b4b 100644 --- a/go.sum +++ b/go.sum @@ -65,8 +65,8 @@ github.com/chengxilo/virtualterm v1.0.4 h1:Z6IpERbRVlfB8WkOmtbHiDbBANU7cimRIof7m github.com/chengxilo/virtualterm v1.0.4/go.mod h1:DyxxBZz/x1iqJjFxTFcr6/x+jSpqN0iwWCOK1q10rlY= github.com/cloudwego/base64x v0.1.5 h1:XPciSp1xaq2VCSt6lF0phncD4koWyULpl5bUxbfCyP4= github.com/cloudwego/base64x v0.1.5/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w= -github.com/cloudwego/eino v0.3.26 h1:FdJJTCdNrc9xPcYkLZiEyr7AA+WgyCKCbY+VNDXIaCE= -github.com/cloudwego/eino v0.3.26/go.mod h1:wUjz990apdsaOraOXdh6CdhVXq8DJsOvLsVlxNTcNfY= +github.com/cloudwego/eino v0.3.27 h1:Oz4HcuivJyb+zT0W43Gmtb6wqmXZaYel0CS4iF6XsoI= +github.com/cloudwego/eino v0.3.27/go.mod h1:wUjz990apdsaOraOXdh6CdhVXq8DJsOvLsVlxNTcNfY= github.com/cloudwego/eino-ext/components/model/openai v0.0.0-20250221090944-e8ef7aabbe10 h1:DJAInsXygJKCrkahR42QODKkq91nvQCTe60o3MnjsKs= github.com/cloudwego/eino-ext/components/model/openai v0.0.0-20250221090944-e8ef7aabbe10/go.mod h1:okkkchYXfoEkv5c0GlwhMdVjIshCzmN3DCcnbOWf7DQ= github.com/cloudwego/eino-ext/libs/acl/openai v0.0.0-20250221090944-e8ef7aabbe10 h1:M6Z2PeX+MxW7jgoZ0p6qDfVtMe1/4XqSQSAHUrI2HTM= From 451a2eede4a1767009acda573253c7baa9128b15 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 23 Apr 2025 16:40:14 +0000 Subject: [PATCH 026/125] build(deps): bump github.com/minio/minio-go/v7 from 7.0.90 to 7.0.91 Bumps [github.com/minio/minio-go/v7](https://github.com/minio/minio-go) from 7.0.90 to 7.0.91. - [Release notes](https://github.com/minio/minio-go/releases) - [Commits](https://github.com/minio/minio-go/compare/v7.0.90...v7.0.91) --- updated-dependencies: - dependency-name: github.com/minio/minio-go/v7 dependency-version: 7.0.91 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index e6a1fb8e..cb86f253 100644 --- a/go.mod +++ b/go.mod @@ -45,7 +45,7 @@ require ( github.com/looplab/fsm v1.0.2 github.com/maxence-charriere/go-app/v10 v10.1.3 github.com/meilisearch/meilisearch-go v0.31.0 - github.com/minio/minio-go/v7 v7.0.90 + github.com/minio/minio-go/v7 v7.0.91 github.com/minio/selfupdate v0.6.0 github.com/mmcdole/gofeed v1.3.0 github.com/montanaflynn/stats v0.7.1 diff --git a/go.sum b/go.sum index 733e7746..e84220b5 100644 --- a/go.sum +++ b/go.sum @@ -337,8 +337,8 @@ github.com/minio/crc64nvme v1.0.1 h1:DHQPrYPdqK7jQG/Ls5CTBZWeex/2FMS3G5XGkycuFrY github.com/minio/crc64nvme v1.0.1/go.mod h1:eVfm2fAzLlxMdUGc0EEBGSMmPwmXD5XiNRpnu9J3bvg= github.com/minio/md5-simd v1.1.2 h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34= github.com/minio/md5-simd v1.1.2/go.mod h1:MzdKDxYpY2BT9XQFocsiZf/NKVtR7nkE4RoEpN+20RM= -github.com/minio/minio-go/v7 v7.0.90 h1:TmSj1083wtAD0kEYTx7a5pFsv3iRYMsOJ6A4crjA1lE= -github.com/minio/minio-go/v7 v7.0.90/go.mod h1:uvMUcGrpgeSAAI6+sD3818508nUyMULw94j2Nxku/Go= +github.com/minio/minio-go/v7 v7.0.91 h1:tWLZnEfo3OZl5PoXQwcwTAPNNrjyWwOh6cbZitW5JQc= +github.com/minio/minio-go/v7 v7.0.91/go.mod h1:uvMUcGrpgeSAAI6+sD3818508nUyMULw94j2Nxku/Go= github.com/minio/selfupdate v0.6.0 h1:i76PgT0K5xO9+hjzKcacQtO7+MjJ4JKA8Ak8XQ9DDwU= github.com/minio/selfupdate v0.6.0/go.mod h1:bO02GTIPCMQFTEvE5h4DjYB58bCoZ35XLeBf0buTDdM= github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db h1:62I3jR2EmQ4l5rM/4FEfDWcRD+abF5XlKShorW5LRoQ= From 0783ede123785790407f9c2cb477eca4c5619811 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 24 Apr 2025 16:21:28 +0000 Subject: [PATCH 027/125] build(deps): bump github.com/golang-migrate/migrate/v4 Bumps [github.com/golang-migrate/migrate/v4](https://github.com/golang-migrate/migrate) from 4.18.2 to 4.18.3. - [Release notes](https://github.com/golang-migrate/migrate/releases) - [Changelog](https://github.com/golang-migrate/migrate/blob/master/.goreleaser.yml) - [Commits](https://github.com/golang-migrate/migrate/compare/v4.18.2...v4.18.3) --- updated-dependencies: - dependency-name: github.com/golang-migrate/migrate/v4 dependency-version: 4.18.3 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 4 ++-- go.sum | 11 ++++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/go.mod b/go.mod index 8640efe6..9e95a643 100644 --- a/go.mod +++ b/go.mod @@ -32,7 +32,7 @@ require ( github.com/gofiber/contrib/fiberzerolog v1.0.3 github.com/gofiber/fiber/v2 v2.52.6 github.com/gofiber/swagger v1.1.1 - github.com/golang-migrate/migrate/v4 v4.18.2 + github.com/golang-migrate/migrate/v4 v4.18.3 github.com/google/go-github/v66 v66.0.0 github.com/google/uuid v1.6.0 github.com/heimdalr/dag v1.5.0 @@ -126,7 +126,7 @@ require ( github.com/go-viper/mapstructure/v2 v2.2.1 // indirect github.com/godbus/dbus/v5 v5.1.0 // indirect github.com/gogo/protobuf v1.3.2 // indirect - github.com/golang-jwt/jwt/v4 v4.5.1 // indirect + github.com/golang-jwt/jwt/v4 v4.5.2 // indirect github.com/golang/protobuf v1.5.4 // indirect github.com/google/go-cmp v0.7.0 // indirect github.com/google/go-querystring v1.1.0 // indirect diff --git a/go.sum b/go.sum index 339294f8..46ff5426 100644 --- a/go.sum +++ b/go.sum @@ -90,8 +90,8 @@ github.com/davidmz/go-pageant v1.0.2 h1:bPblRCh5jGU+Uptpz6LgMZGD5hJoOt7otgT454Wv github.com/davidmz/go-pageant v1.0.2/go.mod h1:P2EDDnMqIwG5Rrp05dTRITj9z2zpGcD9efWSkTNKLIE= github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78= github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= -github.com/dhui/dktest v0.4.4 h1:+I4s6JRE1yGuqflzwqG+aIaMdgXIorCf5P98JnaAWa8= -github.com/dhui/dktest v0.4.4/go.mod h1:4+22R4lgsdAXrDyaH4Nqx2JEz2hLp49MqQmm9HLCQhM= +github.com/dhui/dktest v0.4.5 h1:uUfYBIVREmj/Rw6MvgmqNAYzTiKOHJak+enB5Di73MM= +github.com/dhui/dktest v0.4.5/go.mod h1:tmcyeHDKagvlDrz7gDKq4UAJOLIfVZYkfD5OnHDwcCo= github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5QvfrDyIgxBk= github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E= github.com/dlclark/regexp2 v1.10.0 h1:+/GIL799phkJqYW+3YbOd8LCcbHzT0Pbo8zl70MHsq0= @@ -193,10 +193,11 @@ github.com/gofiber/swagger v1.1.1/go.mod h1:vtvY/sQAMc/lGTUCg0lqmBL7Ht9O7uzChpbv github.com/gofrs/uuid v3.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/golang-jwt/jwt/v4 v4.5.1 h1:JdqV9zKUdtaa9gdPlywC3aeoEsR681PlKC+4F5gQgeo= github.com/golang-jwt/jwt/v4 v4.5.1/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= -github.com/golang-migrate/migrate/v4 v4.18.2 h1:2VSCMz7x7mjyTXx3m2zPokOY82LTRgxK1yQYKo6wWQ8= -github.com/golang-migrate/migrate/v4 v4.18.2/go.mod h1:2CM6tJvn2kqPXwnXO/d3rAQYiyoIm180VsO8PRX6Rpk= +github.com/golang-jwt/jwt/v4 v4.5.2 h1:YtQM7lnr8iZ+j5q71MGKkNw9Mn7AjHM68uc9g5fXeUI= +github.com/golang-jwt/jwt/v4 v4.5.2/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= +github.com/golang-migrate/migrate/v4 v4.18.3 h1:EYGkoOsvgHHfm5U/naS1RP/6PL/Xv3S4B/swMiAmDLs= +github.com/golang-migrate/migrate/v4 v4.18.3/go.mod h1:99BKpIi6ruaaXRM1A77eqZ+FWPQ3cfRa+ZVy5bmWMaY= github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 h1:au07oEsX2xN0ktxqI+Sida1w446QrXBRJ0nee3SNZlA= github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0= github.com/golang-sql/sqlexp v0.1.0 h1:ZCD6MBpcuOVfGVqsEmY5/4FtYiKz6tSyUv9LPEDei6A= From e4d67a05c5ee3ba72c3a09e0764c3152a9b42b25 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 25 Apr 2025 16:26:52 +0000 Subject: [PATCH 028/125] build(deps): bump gorm.io/plugin/dbresolver from 1.5.3 to 1.6.0 Bumps [gorm.io/plugin/dbresolver](https://github.com/go-gorm/dbresolver) from 1.5.3 to 1.6.0. - [Commits](https://github.com/go-gorm/dbresolver/compare/v1.5.3...v1.6.0) --- updated-dependencies: - dependency-name: gorm.io/plugin/dbresolver dependency-version: 1.6.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 4 ++-- go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 9e95a643..5ccd338d 100644 --- a/go.mod +++ b/go.mod @@ -74,8 +74,8 @@ require ( gopkg.in/yaml.v3 v3.0.1 gorm.io/driver/mysql v1.5.7 gorm.io/gen v0.3.27 - gorm.io/gorm v1.25.12 - gorm.io/plugin/dbresolver v1.5.3 + gorm.io/gorm v1.26.0 + gorm.io/plugin/dbresolver v1.6.0 gotest.tools/v3 v3.5.2 jaytaylor.com/html2text v0.0.0-20230321000545-74c2419ad056 miniflux.app/v2 v2.2.8 diff --git a/go.sum b/go.sum index 46ff5426..38fc2519 100644 --- a/go.sum +++ b/go.sum @@ -718,12 +718,12 @@ gorm.io/gen v0.3.27/go.mod h1:9zquz2xD1f3Eb/eHq4oLn2z6vDVvQlCY5S3uMBLv4EA= gorm.io/gorm v1.21.15/go.mod h1:F+OptMscr0P2F2qU97WT1WimdH9GaQPoDW7AYd5i2Y0= gorm.io/gorm v1.22.2/go.mod h1:F+OptMscr0P2F2qU97WT1WimdH9GaQPoDW7AYd5i2Y0= gorm.io/gorm v1.25.7/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8= -gorm.io/gorm v1.25.12 h1:I0u8i2hWQItBq1WfE0o2+WuL9+8L21K9e2HHSTE/0f8= -gorm.io/gorm v1.25.12/go.mod h1:xh7N7RHfYlNc5EmcI/El95gXusucDrQnHXe0+CgWcLQ= +gorm.io/gorm v1.26.0 h1:9lqQVPG5aNNS6AyHdRiwScAVnXHg/L/Srzx55G5fOgs= +gorm.io/gorm v1.26.0/go.mod h1:8Z33v652h4//uMA76KjeDH8mJXPm1QNCYrMeatR0DOE= gorm.io/hints v1.1.0 h1:Lp4z3rxREufSdxn4qmkK3TLDltrM10FLTHiuqwDPvXw= gorm.io/hints v1.1.0/go.mod h1:lKQ0JjySsPBj3uslFzY3JhYDtqEwzm+G1hv8rWujB6Y= -gorm.io/plugin/dbresolver v1.5.3 h1:wFwINGZZmttuu9h7XpvbDHd8Lf9bb8GNzp/NpAMV2wU= -gorm.io/plugin/dbresolver v1.5.3/go.mod h1:TSrVhaUg2DZAWP3PrHlDlITEJmNOkL0tFTjvTEsQ4XE= +gorm.io/plugin/dbresolver v1.6.0 h1:XvKDeOtTn1EIX6s4SrKpEH82q0gXVemhYjbYZFGFVcw= +gorm.io/plugin/dbresolver v1.6.0/go.mod h1:tctw63jdrOezFR9HmrKnPkmig3m5Edem9fdxk9bQSzM= gotest.tools/v3 v3.5.2 h1:7koQfIKdy+I8UTetycgUqXWSDwpgv193Ka+qRsmBY8Q= gotest.tools/v3 v3.5.2/go.mod h1:LtdLGcnqToBH83WByAAi/wiwSFCArdFIUV/xxN4pcjA= jaytaylor.com/html2text v0.0.0-20230321000545-74c2419ad056 h1:6YFJoB+0fUH6X3xU/G2tQqCYg+PkGtnZ5nMR5rpw72g= From ea34298d0583896310a3415b8920b27eda7465f7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 30 Apr 2025 16:34:46 +0000 Subject: [PATCH 029/125] build(deps): bump github.com/redis/go-redis/v9 from 9.7.3 to 9.8.0 Bumps [github.com/redis/go-redis/v9](https://github.com/redis/go-redis) from 9.7.3 to 9.8.0. - [Release notes](https://github.com/redis/go-redis/releases) - [Changelog](https://github.com/redis/go-redis/blob/master/CHANGELOG.md) - [Commits](https://github.com/redis/go-redis/compare/v9.7.3...v9.8.0) --- updated-dependencies: - dependency-name: github.com/redis/go-redis/v9 dependency-version: 9.8.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 5ccd338d..915a898c 100644 --- a/go.mod +++ b/go.mod @@ -52,7 +52,7 @@ require ( github.com/pkoukk/tiktoken-go v0.1.7 github.com/prometheus/client_model v0.6.2 github.com/prometheus/common v0.63.0 - github.com/redis/go-redis/v9 v9.7.3 + github.com/redis/go-redis/v9 v9.8.0 github.com/robfig/cron/v3 v3.0.1 github.com/rs/zerolog v1.34.0 github.com/schollz/progressbar/v3 v3.18.0 diff --git a/go.sum b/go.sum index 38fc2519..60a06231 100644 --- a/go.sum +++ b/go.sum @@ -408,8 +408,8 @@ github.com/prometheus/client_model v0.6.2 h1:oBsgwpGs7iVziMvrGhE53c/GrLUsZdHnqNw github.com/prometheus/client_model v0.6.2/go.mod h1:y3m2F6Gdpfy6Ut/GBsUqTWZqCUvMVzSfMLjcu6wAwpE= github.com/prometheus/common v0.63.0 h1:YR/EIY1o3mEFP/kZCD7iDMnLPlGyuU2Gb3HIcXnA98k= github.com/prometheus/common v0.63.0/go.mod h1:VVFF/fBIoToEnWRVkYoXEkq3R3paCoxG9PXP74SnV18= -github.com/redis/go-redis/v9 v9.7.3 h1:YpPyAayJV+XErNsatSElgRZZVCwXX9QzkKYNvO7x0wM= -github.com/redis/go-redis/v9 v9.7.3/go.mod h1:bGUrSggJ9X9GUmZpZNEOQKaANxSGgOEBRltRTZHSvrA= +github.com/redis/go-redis/v9 v9.8.0 h1:q3nRvjrlge/6UD7eTu/DSg2uYiU2mCL0G/uzBWqhicI= +github.com/redis/go-redis/v9 v9.8.0/go.mod h1:huWgSWd8mW6+m0VPhJjSSQ+d6Nh1VICQ6Q5lHuCH/Iw= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= From b9ad7f3312bc7acd0237d4f7d9e97ecbf726c49e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 1 May 2025 16:22:06 +0000 Subject: [PATCH 030/125] build(deps): bump github.com/VictoriaMetrics/metrics Bumps [github.com/VictoriaMetrics/metrics](https://github.com/VictoriaMetrics/metrics) from 1.35.2 to 1.35.4. - [Commits](https://github.com/VictoriaMetrics/metrics/compare/v1.35.2...v1.35.4) --- updated-dependencies: - dependency-name: github.com/VictoriaMetrics/metrics dependency-version: 1.35.4 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 5ccd338d..71563453 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/RealAlexandreAI/json-repair v0.0.14 github.com/ThreeDotsLabs/watermill v1.4.6 github.com/ThreeDotsLabs/watermill-redisstream v1.4.2 - github.com/VictoriaMetrics/metrics v1.35.2 + github.com/VictoriaMetrics/metrics v1.35.4 github.com/allegro/bigcache/v3 v3.1.0 github.com/bsm/redislock v0.9.4 github.com/bwmarrin/discordgo v0.28.1 diff --git a/go.sum b/go.sum index 38fc2519..fcd2be32 100644 --- a/go.sum +++ b/go.sum @@ -24,8 +24,8 @@ github.com/ThreeDotsLabs/watermill v1.4.6 h1:rWoXlxdBgUyg/bZ3OO0pON+nESVd9r6tnLT github.com/ThreeDotsLabs/watermill v1.4.6/go.mod h1:lBnrLbxOjeMRgcJbv+UiZr8Ylz8RkJ4m6i/VN/Nk+to= github.com/ThreeDotsLabs/watermill-redisstream v1.4.2 h1:FY6tsBcbhbJpKDOssU4bfybstqY0hQHwiZmVq9qyILQ= github.com/ThreeDotsLabs/watermill-redisstream v1.4.2/go.mod h1:69++855LyB+ckYDe60PiJLBcUrpckfDE2WwyzuVJRCk= -github.com/VictoriaMetrics/metrics v1.35.2 h1:Bj6L6ExfnakZKYPpi7mGUnkJP4NGQz2v5wiChhXNyWQ= -github.com/VictoriaMetrics/metrics v1.35.2/go.mod h1:r7hveu6xMdUACXvB8TYdAj8WEsKzWB0EkpJN+RDtOf8= +github.com/VictoriaMetrics/metrics v1.35.4 h1:GhZ17bHYkujpSzGaH459F7huTLNJ7z90ZXsOXjhHx/8= +github.com/VictoriaMetrics/metrics v1.35.4/go.mod h1:r7hveu6xMdUACXvB8TYdAj8WEsKzWB0EkpJN+RDtOf8= github.com/airbrake/gobrake v3.6.1+incompatible/go.mod h1:wM4gu3Cn0W0K7GUuVWnlXZU11AGBXMILnrdOU8Kn00o= github.com/allegro/bigcache/v3 v3.1.0 h1:H2Vp8VOvxcrB91o86fUSVJFqeuz8kpyyB02eH3bSzwk= github.com/allegro/bigcache/v3 v3.1.0/go.mod h1:aPyh7jEvrog9zAwx5N7+JUQX5dZTSGpxF1LAR4dr35I= From 9f5e494242ed81ece347ab1cc310f39ba69f710e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 1 May 2025 16:22:15 +0000 Subject: [PATCH 031/125] build(deps): bump github.com/shirou/gopsutil/v4 from 4.25.3 to 4.25.4 Bumps [github.com/shirou/gopsutil/v4](https://github.com/shirou/gopsutil) from 4.25.3 to 4.25.4. - [Release notes](https://github.com/shirou/gopsutil/releases) - [Commits](https://github.com/shirou/gopsutil/compare/v4.25.3...v4.25.4) --- updated-dependencies: - dependency-name: github.com/shirou/gopsutil/v4 dependency-version: 4.25.4 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 5ccd338d..2f1ec025 100644 --- a/go.mod +++ b/go.mod @@ -56,7 +56,7 @@ require ( github.com/robfig/cron/v3 v3.0.1 github.com/rs/zerolog v1.34.0 github.com/schollz/progressbar/v3 v3.18.0 - github.com/shirou/gopsutil/v4 v4.25.3 + github.com/shirou/gopsutil/v4 v4.25.4 github.com/slack-go/slack v0.16.0 github.com/spf13/pflag v1.0.6 github.com/spf13/viper v1.20.1 diff --git a/go.sum b/go.sum index 38fc2519..fbf54c83 100644 --- a/go.sum +++ b/go.sum @@ -430,8 +430,8 @@ github.com/sashabaranov/go-openai v1.37.0 h1:hQQowgYm4OXJ1Z/wTrE+XZaO20BYsL0R3uR github.com/sashabaranov/go-openai v1.37.0/go.mod h1:lj5b/K+zjTSFxVLijLSTDZuP7adOgerWeFyZLUhAKRg= github.com/schollz/progressbar/v3 v3.18.0 h1:uXdoHABRFmNIjUfte/Ex7WtuyVslrw2wVPQmCN62HpA= github.com/schollz/progressbar/v3 v3.18.0/go.mod h1:IsO3lpbaGuzh8zIMzgY3+J8l4C8GjO0Y9S69eFvNsec= -github.com/shirou/gopsutil/v4 v4.25.3 h1:SeA68lsu8gLggyMbmCn8cmp97V1TI9ld9sVzAUcKcKE= -github.com/shirou/gopsutil/v4 v4.25.3/go.mod h1:xbuxyoZj+UsgnZrENu3lQivsngRR5BdjbJwf2fv4szA= +github.com/shirou/gopsutil/v4 v4.25.4 h1:cdtFO363VEOOFrUCjZRh4XVJkb548lyF0q0uTeMqYPw= +github.com/shirou/gopsutil/v4 v4.25.4/go.mod h1:xbuxyoZj+UsgnZrENu3lQivsngRR5BdjbJwf2fv4szA= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= From 67aab8bc4690412b8b936bd4593010e1ecebfbd2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 5 May 2025 17:10:51 +0000 Subject: [PATCH 032/125] build(deps): bump golang.org/x/sys from 0.32.0 to 0.33.0 Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.32.0 to 0.33.0. - [Commits](https://github.com/golang/sys/compare/v0.32.0...v0.33.0) --- updated-dependencies: - dependency-name: golang.org/x/sys dependency-version: 0.33.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index cc4f6d26..5f3842d3 100644 --- a/go.mod +++ b/go.mod @@ -68,7 +68,7 @@ require ( go.uber.org/automaxprocs v1.6.0 golang.org/x/crypto v0.37.0 golang.org/x/exp v0.0.0-20250218142911-aa4b98e5adaa - golang.org/x/sys v0.32.0 + golang.org/x/sys v0.33.0 golang.org/x/time v0.11.0 golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 gopkg.in/yaml.v3 v3.0.1 diff --git a/go.sum b/go.sum index 06cd7212..9a35e179 100644 --- a/go.sum +++ b/go.sum @@ -628,8 +628,8 @@ golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.32.0 h1:s77OFDvIQeibCmezSnk/q6iAfkdiQaJi4VzroCFrN20= -golang.org/x/sys v0.32.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= +golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw= +golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= From 76a2a870c554ab91a4ce1f9369a53d9581c9464f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 5 May 2025 17:16:25 +0000 Subject: [PATCH 033/125] build(deps): bump github.com/meilisearch/meilisearch-go Bumps [github.com/meilisearch/meilisearch-go](https://github.com/meilisearch/meilisearch-go) from 0.31.0 to 0.32.0. - [Release notes](https://github.com/meilisearch/meilisearch-go/releases) - [Commits](https://github.com/meilisearch/meilisearch-go/compare/v0.31.0...v0.32.0) --- updated-dependencies: - dependency-name: github.com/meilisearch/meilisearch-go dependency-version: 0.32.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index cc4f6d26..82a30c09 100644 --- a/go.mod +++ b/go.mod @@ -44,7 +44,7 @@ require ( github.com/lithammer/shortuuid/v4 v4.2.0 github.com/looplab/fsm v1.0.2 github.com/maxence-charriere/go-app/v10 v10.1.3 - github.com/meilisearch/meilisearch-go v0.31.0 + github.com/meilisearch/meilisearch-go v0.32.0 github.com/minio/minio-go/v7 v7.0.91 github.com/minio/selfupdate v0.6.0 github.com/mmcdole/gofeed v1.3.0 diff --git a/go.sum b/go.sum index 06cd7212..73142abd 100644 --- a/go.sum +++ b/go.sum @@ -328,8 +328,8 @@ github.com/mattn/go-sqlite3 v1.14.28 h1:ThEiQrnbtumT+QMknw63Befp/ce/nUPgBPMlRFEu github.com/mattn/go-sqlite3 v1.14.28/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y= github.com/maxence-charriere/go-app/v10 v10.1.3 h1:xj4E3Owbi5HLqF8DtAjRLI6IA5g0VREPatGDczcxtk4= github.com/maxence-charriere/go-app/v10 v10.1.3/go.mod h1:FqUW4on4nJewVfBnSkuxQd3fvtK2RdKS/z76OOUDAAY= -github.com/meilisearch/meilisearch-go v0.31.0 h1:yZRhY1qJqdH8h6GFZALGtkDLyj8f9v5aJpsNMyrUmnY= -github.com/meilisearch/meilisearch-go v0.31.0/go.mod h1:aNtyuwurDg/ggxQIcKqWH6G9g2ptc8GyY7PLY4zMn/g= +github.com/meilisearch/meilisearch-go v0.32.0 h1:cWcycpONSH3VLTZ5npUl1O5aXPkNM0vUx6bywnYqGbE= +github.com/meilisearch/meilisearch-go v0.32.0/go.mod h1:aNtyuwurDg/ggxQIcKqWH6G9g2ptc8GyY7PLY4zMn/g= 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/microsoft/go-mssqldb v1.0.0 h1:k2p2uuG8T5T/7Hp7/e3vMGTnnR0sU4h8d1CcC71iLHU= From bbb4d1709c1fd63302b5f81467906a20e040c8d5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 6 May 2025 16:26:23 +0000 Subject: [PATCH 034/125] build(deps): bump golang.org/x/crypto from 0.37.0 to 0.38.0 Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.37.0 to 0.38.0. - [Commits](https://github.com/golang/crypto/compare/v0.37.0...v0.38.0) --- updated-dependencies: - dependency-name: golang.org/x/crypto dependency-version: 0.38.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 8 ++++---- go.sum | 16 ++++++++-------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/go.mod b/go.mod index 39f0a4a2..5d5c8f45 100644 --- a/go.mod +++ b/go.mod @@ -66,7 +66,7 @@ require ( github.com/urfave/cli/v2 v2.27.6 github.com/valyala/fasthttp v1.61.0 go.uber.org/automaxprocs v1.6.0 - golang.org/x/crypto v0.37.0 + golang.org/x/crypto v0.38.0 golang.org/x/exp v0.0.0-20250218142911-aa4b98e5adaa golang.org/x/sys v0.33.0 golang.org/x/time v0.11.0 @@ -210,9 +210,9 @@ require ( golang.org/x/arch v0.14.0 // indirect golang.org/x/mod v0.23.0 // indirect golang.org/x/net v0.39.0 // indirect - golang.org/x/sync v0.13.0 // indirect - golang.org/x/term v0.31.0 // indirect - golang.org/x/text v0.24.0 // indirect + golang.org/x/sync v0.14.0 // indirect + golang.org/x/term v0.32.0 // indirect + golang.org/x/text v0.25.0 // indirect golang.org/x/tools v0.30.0 // indirect google.golang.org/appengine v1.6.8 // indirect google.golang.org/protobuf v1.36.6 // indirect diff --git a/go.sum b/go.sum index 475550b3..4bd524d8 100644 --- a/go.sum +++ b/go.sum @@ -563,8 +563,8 @@ golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliY golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8= golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk= -golang.org/x/crypto v0.37.0 h1:kJNSjF/Xp7kU0iB2Z+9viTPMW4EqqsrywMXLJOOsXSE= -golang.org/x/crypto v0.37.0/go.mod h1:vg+k43peMZ0pUMhYmVAWysMK35e6ioLh3wB8ZCAfbVc= +golang.org/x/crypto v0.38.0 h1:jt+WWG8IZlBnVbomuhg2Mdq0+BBQaHbtqHEFEigjUV8= +golang.org/x/crypto v0.38.0/go.mod h1:MvrbAqul58NNYPKnOra203SB9vpuZW0e+RRZV+Ggqjw= golang.org/x/exp v0.0.0-20250218142911-aa4b98e5adaa h1:t2QcU6V556bFjYgu4L6C+6VrCPyJZ+eyRsABUPs1mz4= golang.org/x/exp v0.0.0-20250218142911-aa4b98e5adaa/go.mod h1:BHOTPb3L19zxehTsLoJXVaTktb06DFgmdW6Wb9s8jqk= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= @@ -602,8 +602,8 @@ golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= -golang.org/x/sync v0.13.0 h1:AauUjRAJ9OSnvULf/ARrrVywoJDy0YS2AwQ98I37610= -golang.org/x/sync v0.13.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= +golang.org/x/sync v0.14.0 h1:woo0S4Yywslg6hp4eUFjTVOyKt0RookbpAHG4c1HmhQ= +golang.org/x/sync v0.14.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -640,8 +640,8 @@ golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU= golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY= golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM= -golang.org/x/term v0.31.0 h1:erwDkOK1Msy6offm1mOgvspSkslFnIGsFnxOKoufg3o= -golang.org/x/term v0.31.0/go.mod h1:R4BeIy7D95HzImkxGkTW1UQTtP54tio2RyHz7PwK0aw= +golang.org/x/term v0.32.0 h1:DR4lr0TjUs3epypdhTOkMmuF5CDFJ/8pOnbzMZPQ7bg= +golang.org/x/term v0.32.0/go.mod h1:uZG1FhGx848Sqfsq4/DlJr3xGGsYMu/L5GW4abiaEPQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= @@ -653,8 +653,8 @@ golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= -golang.org/x/text v0.24.0 h1:dd5Bzh4yt5KYA8f9CJHCP4FB4D51c2c6JvN37xJJkJ0= -golang.org/x/text v0.24.0/go.mod h1:L8rBsPeo2pSS+xqN0d5u2ikmjtmoJbDBT1b7nHvFCdU= +golang.org/x/text v0.25.0 h1:qVyWApTSYLk/drJRO5mDlNYskwQznZmkpV2c8q9zls4= +golang.org/x/text v0.25.0/go.mod h1:WEdwpYrmk1qmdHvhkSTNPm3app7v4rsT8F2UD6+VHIA= golang.org/x/time v0.11.0 h1:/bpjEDfN9tkoN/ryeYHnv5hcMlc8ncjMcM4XBk5NWV0= golang.org/x/time v0.11.0/go.mod h1:CDIdPxbZBQxdj6cxyCIdrNogrJKMJ7pr37NYpMcMDSg= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= From 51fa9a10572d02d4a07c9ca82e87ec6f364618b2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 7 May 2025 16:32:53 +0000 Subject: [PATCH 035/125] build(deps): bump github.com/cloudwego/eino from 0.3.27 to 0.3.28 Bumps [github.com/cloudwego/eino](https://github.com/cloudwego/eino) from 0.3.27 to 0.3.28. - [Release notes](https://github.com/cloudwego/eino/releases) - [Commits](https://github.com/cloudwego/eino/compare/v0.3.27...v0.3.28) --- updated-dependencies: - dependency-name: github.com/cloudwego/eino dependency-version: 0.3.28 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 5d5c8f45..7b1de0fa 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/bsm/redislock v0.9.4 github.com/bwmarrin/discordgo v0.28.1 github.com/cenkalti/backoff v2.2.1+incompatible - github.com/cloudwego/eino v0.3.27 + github.com/cloudwego/eino v0.3.28 github.com/cloudwego/eino-ext/components/model/openai v0.0.0-20250221090944-e8ef7aabbe10 github.com/creachadair/jrpc2 v1.3.1 github.com/docker/cli v28.1.1+incompatible diff --git a/go.sum b/go.sum index 4bd524d8..24969f23 100644 --- a/go.sum +++ b/go.sum @@ -65,8 +65,8 @@ github.com/chengxilo/virtualterm v1.0.4 h1:Z6IpERbRVlfB8WkOmtbHiDbBANU7cimRIof7m github.com/chengxilo/virtualterm v1.0.4/go.mod h1:DyxxBZz/x1iqJjFxTFcr6/x+jSpqN0iwWCOK1q10rlY= github.com/cloudwego/base64x v0.1.5 h1:XPciSp1xaq2VCSt6lF0phncD4koWyULpl5bUxbfCyP4= github.com/cloudwego/base64x v0.1.5/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w= -github.com/cloudwego/eino v0.3.27 h1:Oz4HcuivJyb+zT0W43Gmtb6wqmXZaYel0CS4iF6XsoI= -github.com/cloudwego/eino v0.3.27/go.mod h1:wUjz990apdsaOraOXdh6CdhVXq8DJsOvLsVlxNTcNfY= +github.com/cloudwego/eino v0.3.28 h1:KnL4U9ES4giTYhK84vMWKwqr5IGHJzZf6th9/Li1zyA= +github.com/cloudwego/eino v0.3.28/go.mod h1:wUjz990apdsaOraOXdh6CdhVXq8DJsOvLsVlxNTcNfY= github.com/cloudwego/eino-ext/components/model/openai v0.0.0-20250221090944-e8ef7aabbe10 h1:DJAInsXygJKCrkahR42QODKkq91nvQCTe60o3MnjsKs= github.com/cloudwego/eino-ext/components/model/openai v0.0.0-20250221090944-e8ef7aabbe10/go.mod h1:okkkchYXfoEkv5c0GlwhMdVjIshCzmN3DCcnbOWf7DQ= github.com/cloudwego/eino-ext/libs/acl/openai v0.0.0-20250221090944-e8ef7aabbe10 h1:M6Z2PeX+MxW7jgoZ0p6qDfVtMe1/4XqSQSAHUrI2HTM= From df914a6ad1dd895a872fbb6ea0f16d5d5e241645 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 7 May 2025 16:33:02 +0000 Subject: [PATCH 036/125] build(deps): bump github.com/valyala/fasthttp from 1.61.0 to 1.62.0 Bumps [github.com/valyala/fasthttp](https://github.com/valyala/fasthttp) from 1.61.0 to 1.62.0. - [Release notes](https://github.com/valyala/fasthttp/releases) - [Commits](https://github.com/valyala/fasthttp/compare/v1.61.0...v1.62.0) --- updated-dependencies: - dependency-name: github.com/valyala/fasthttp dependency-version: 1.62.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 4 ++-- go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 5d5c8f45..fdef54ec 100644 --- a/go.mod +++ b/go.mod @@ -64,7 +64,7 @@ require ( github.com/swaggo/swag v1.16.4 github.com/tidwall/gjson v1.18.0 github.com/urfave/cli/v2 v2.27.6 - github.com/valyala/fasthttp v1.61.0 + github.com/valyala/fasthttp v1.62.0 go.uber.org/automaxprocs v1.6.0 golang.org/x/crypto v0.38.0 golang.org/x/exp v0.0.0-20250218142911-aa4b98e5adaa @@ -209,7 +209,7 @@ require ( go.uber.org/multierr v1.9.0 // indirect golang.org/x/arch v0.14.0 // indirect golang.org/x/mod v0.23.0 // indirect - golang.org/x/net v0.39.0 // indirect + golang.org/x/net v0.40.0 // indirect golang.org/x/sync v0.14.0 // indirect golang.org/x/term v0.32.0 // indirect golang.org/x/text v0.25.0 // indirect diff --git a/go.sum b/go.sum index 4bd524d8..eeb8e172 100644 --- a/go.sum +++ b/go.sum @@ -501,8 +501,8 @@ github.com/urfave/cli/v2 v2.27.6 h1:VdRdS98FNhKZ8/Az8B7MTyGQmpIr36O1EHybx/LaZ4g= github.com/urfave/cli/v2 v2.27.6/go.mod h1:3Sevf16NykTbInEnD0yKkjDAeZDS0A6bzhBH5hrMvTQ= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= -github.com/valyala/fasthttp v1.61.0 h1:VV08V0AfoRaFurP1EWKvQQdPTZHiUzaVoulX1aBDgzU= -github.com/valyala/fasthttp v1.61.0/go.mod h1:wRIV/4cMwUPWnRcDno9hGnYZGh78QzODFfo1LTUhBog= +github.com/valyala/fasthttp v1.62.0 h1:8dKRBX/y2rCzyc6903Zu1+3qN0H/d2MsxPPmVNamiH0= +github.com/valyala/fasthttp v1.62.0/go.mod h1:FCINgr4GKdKqV8Q0xv8b+UxPV+H/O5nNFo3D+r54Htg= github.com/valyala/fastrand v1.1.0 h1:f+5HkLW4rsgzdNoleUOB69hyT9IlD2ZQh9GyDMfb5G8= github.com/valyala/fastrand v1.1.0/go.mod h1:HWqCzkrkg6QXT8V2EXWvXCoow7vLwOFN002oeRzjapQ= github.com/valyala/histogram v1.2.0 h1:wyYGAZZt3CpwUiIb9AU/Zbllg1llXyrtApRS815OLoQ= @@ -590,8 +590,8 @@ golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk= golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= -golang.org/x/net v0.39.0 h1:ZCu7HMWDxpXpaiKdhzIfaltL9Lp31x/3fCP11bc6/fY= -golang.org/x/net v0.39.0/go.mod h1:X7NRbYVEA+ewNkCNyJ513WmMdQ3BineSwVtN2zD/d+E= +golang.org/x/net v0.40.0 h1:79Xs7wF06Gbdcg4kdCCIQArK11Z1hr5POQ6+fIYHNuY= +golang.org/x/net v0.40.0/go.mod h1:y0hY0exeL2Pku80/zKK7tpntoX23cqL3Oa6njdgRtds= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= From 8bd684080655e7da341ede508b3c0a9c482ce6c2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 7 May 2025 16:33:10 +0000 Subject: [PATCH 037/125] build(deps): bump gorm.io/gorm from 1.26.0 to 1.26.1 Bumps [gorm.io/gorm](https://github.com/go-gorm/gorm) from 1.26.0 to 1.26.1. - [Release notes](https://github.com/go-gorm/gorm/releases) - [Commits](https://github.com/go-gorm/gorm/compare/v1.26.0...v1.26.1) --- updated-dependencies: - dependency-name: gorm.io/gorm dependency-version: 1.26.1 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 5d5c8f45..f7c4d745 100644 --- a/go.mod +++ b/go.mod @@ -74,7 +74,7 @@ require ( gopkg.in/yaml.v3 v3.0.1 gorm.io/driver/mysql v1.5.7 gorm.io/gen v0.3.27 - gorm.io/gorm v1.26.0 + gorm.io/gorm v1.26.1 gorm.io/plugin/dbresolver v1.6.0 gotest.tools/v3 v3.5.2 jaytaylor.com/html2text v0.0.0-20230321000545-74c2419ad056 diff --git a/go.sum b/go.sum index 4bd524d8..203a9c56 100644 --- a/go.sum +++ b/go.sum @@ -718,8 +718,8 @@ gorm.io/gen v0.3.27/go.mod h1:9zquz2xD1f3Eb/eHq4oLn2z6vDVvQlCY5S3uMBLv4EA= gorm.io/gorm v1.21.15/go.mod h1:F+OptMscr0P2F2qU97WT1WimdH9GaQPoDW7AYd5i2Y0= gorm.io/gorm v1.22.2/go.mod h1:F+OptMscr0P2F2qU97WT1WimdH9GaQPoDW7AYd5i2Y0= gorm.io/gorm v1.25.7/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8= -gorm.io/gorm v1.26.0 h1:9lqQVPG5aNNS6AyHdRiwScAVnXHg/L/Srzx55G5fOgs= -gorm.io/gorm v1.26.0/go.mod h1:8Z33v652h4//uMA76KjeDH8mJXPm1QNCYrMeatR0DOE= +gorm.io/gorm v1.26.1 h1:ghB2gUI9FkS46luZtn6DLZ0f6ooBJ5IbVej2ENFDjRw= +gorm.io/gorm v1.26.1/go.mod h1:8Z33v652h4//uMA76KjeDH8mJXPm1QNCYrMeatR0DOE= gorm.io/hints v1.1.0 h1:Lp4z3rxREufSdxn4qmkK3TLDltrM10FLTHiuqwDPvXw= gorm.io/hints v1.1.0/go.mod h1:lKQ0JjySsPBj3uslFzY3JhYDtqEwzm+G1hv8rWujB6Y= gorm.io/plugin/dbresolver v1.6.0 h1:XvKDeOtTn1EIX6s4SrKpEH82q0gXVemhYjbYZFGFVcw= From 7996a213b6e4be305ff9360127ea9bc8e2331227 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 7 May 2025 16:33:14 +0000 Subject: [PATCH 038/125] build(deps): bump github.com/looplab/fsm from 1.0.2 to 1.0.3 Bumps [github.com/looplab/fsm](https://github.com/looplab/fsm) from 1.0.2 to 1.0.3. - [Release notes](https://github.com/looplab/fsm/releases) - [Commits](https://github.com/looplab/fsm/compare/v1.0.2...v1.0.3) --- updated-dependencies: - dependency-name: github.com/looplab/fsm dependency-version: 1.0.3 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 5d5c8f45..325cf1a4 100644 --- a/go.mod +++ b/go.mod @@ -42,7 +42,7 @@ require ( github.com/jmoiron/sqlx v1.4.0 github.com/json-iterator/go v1.1.12 github.com/lithammer/shortuuid/v4 v4.2.0 - github.com/looplab/fsm v1.0.2 + github.com/looplab/fsm v1.0.3 github.com/maxence-charriere/go-app/v10 v10.1.3 github.com/meilisearch/meilisearch-go v0.32.0 github.com/minio/minio-go/v7 v7.0.91 diff --git a/go.sum b/go.sum index 4bd524d8..2238278e 100644 --- a/go.sum +++ b/go.sum @@ -303,8 +303,8 @@ github.com/lithammer/shortuuid/v3 v3.0.7 h1:trX0KTHy4Pbwo/6ia8fscyHoGA+mf1jWbPJV github.com/lithammer/shortuuid/v3 v3.0.7/go.mod h1:vMk8ke37EmiewwolSO1NLW8vP4ZaKlRuDIi8tWWmAts= github.com/lithammer/shortuuid/v4 v4.2.0 h1:LMFOzVB3996a7b8aBuEXxqOBflbfPQAiVzkIcHO0h8c= github.com/lithammer/shortuuid/v4 v4.2.0/go.mod h1:D5noHZ2oFw/YaKCfGy0YxyE7M0wMbezmMjPdhyEFe6Y= -github.com/looplab/fsm v1.0.2 h1:f0kdMzr4CRpXtaKKRUxwLYJ7PirTdwrtNumeLN+mDx8= -github.com/looplab/fsm v1.0.2/go.mod h1:PmD3fFvQEIsjMEfvZdrCDZ6y8VwKTwWNjlpEr6IKPO4= +github.com/looplab/fsm v1.0.3 h1:qtxBsa2onOs0qFOtkqwf5zE0uP0+Te+wlIvXctPKpcw= +github.com/looplab/fsm v1.0.3/go.mod h1:PmD3fFvQEIsjMEfvZdrCDZ6y8VwKTwWNjlpEr6IKPO4= github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 h1:6E+4a0GO5zZEnZ81pIr0yLvtUWk2if982qA3F3QD6H4= github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I= github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= From e532d45b625dcdb8427e45b28d37870ce025e795 Mon Sep 17 00:00:00 2001 From: sysatom Date: Thu, 8 May 2025 14:19:55 +0800 Subject: [PATCH 039/125] fx --- cmd/main.go | 9 ++++- go.mod | 5 ++- go.sum | 8 ++++ internal/server/http.go | 79 ++++++++++++++++++++++++++++++++++++++ internal/server/modules.go | 24 ++++++++++++ internal/server/server.go | 28 ++++++++++++++ 6 files changed, 151 insertions(+), 2 deletions(-) create mode 100644 internal/server/modules.go diff --git a/cmd/main.go b/cmd/main.go index c934a832..088e9cd4 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -4,6 +4,7 @@ import ( "github.com/flowline-io/flowbot/internal/server" // Importing automaxprocs automatically adjusts GOMAXPROCS. _ "go.uber.org/automaxprocs" + "go.uber.org/fx" ) // @title Flowbot API @@ -19,5 +20,11 @@ import ( // @name X-AccessToken // @description access token func main() { - server.Run() + // server.Run() + fx.New( + server.Modules, + // fx.WithLogger(func(log *zap.Logger) fxevent.Logger { + // return &fxevent.ZapLogger{Logger: log} + // }), + ).Run() } diff --git a/go.mod b/go.mod index 359b12f2..2836b5aa 100644 --- a/go.mod +++ b/go.mod @@ -206,7 +206,10 @@ require ( go.opentelemetry.io/otel/metric v1.29.0 // indirect go.opentelemetry.io/otel/trace v1.29.0 // indirect go.uber.org/atomic v1.9.0 // indirect - go.uber.org/multierr v1.9.0 // indirect + go.uber.org/dig v1.18.0 // indirect + go.uber.org/fx v1.23.0 // indirect + go.uber.org/multierr v1.10.0 // indirect + go.uber.org/zap v1.26.0 // indirect golang.org/x/arch v0.14.0 // indirect golang.org/x/mod v0.23.0 // indirect golang.org/x/net v0.40.0 // indirect diff --git a/go.sum b/go.sum index d4deebe5..8a0b81f2 100644 --- a/go.sum +++ b/go.sum @@ -542,12 +542,20 @@ go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE= go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/automaxprocs v1.6.0 h1:O3y2/QNTOdbF+e/dpXNNW7Rx2hZ4sTIPyybbxyNqTUs= go.uber.org/automaxprocs v1.6.0/go.mod h1:ifeIMSnPZuznNm6jmdzmU3/bfk01Fe2fotchwEFJ8r8= +go.uber.org/dig v1.18.0 h1:imUL1UiY0Mg4bqbFfsRQO5G4CGRBec/ZujWTvSVp3pw= +go.uber.org/dig v1.18.0/go.mod h1:Us0rSJiThwCv2GteUN0Q7OKvU7n5J4dxZ9JKUXozFdE= +go.uber.org/fx v1.23.0 h1:lIr/gYWQGfTwGcSXWXu4vP5Ws6iqnNEIY+F/aFzCKTg= +go.uber.org/fx v1.23.0/go.mod h1:o/D9n+2mLP6v1EG+qsdT1O8wKopYAsqZasju97SDFCU= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.uber.org/mock v0.4.0 h1:VcM4ZOtdbR4f6VXfiOpwpVJDL6lCReaZ6mw31wqh7KU= go.uber.org/mock v0.4.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc= go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI= go.uber.org/multierr v1.9.0/go.mod h1:X2jQV1h+kxSjClGpnseKVIxpmcjrj7MNnI0bnlfKTVQ= +go.uber.org/multierr v1.10.0 h1:S0h4aNzvfcFsC3dRF1jLoaov7oRaKqRGC/pUEJ2yvPQ= +go.uber.org/multierr v1.10.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= +go.uber.org/zap v1.26.0 h1:sI7k6L95XOKS281NhVKOFCUNIvv9e0w4BF8N3u+tCRo= +go.uber.org/zap v1.26.0/go.mod h1:dtElttAiwGvoJ/vj4IwHBS/gXsEu/pZ50mUIRWuG0so= golang.org/x/arch v0.14.0 h1:z9JUEZWr8x4rR0OU6c4/4t6E6jOZ8/QBS2bBYBm4tx4= golang.org/x/arch v0.14.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= diff --git a/internal/server/http.go b/internal/server/http.go index 045d6c4a..a6354577 100644 --- a/internal/server/http.go +++ b/internal/server/http.go @@ -2,11 +2,21 @@ package server import ( "context" + "net/http" "time" "github.com/flowline-io/flowbot/pkg/cache" "github.com/flowline-io/flowbot/pkg/flog" + "github.com/flowline-io/flowbot/pkg/types/protocol" + "github.com/gofiber/contrib/fiberzerolog" "github.com/gofiber/fiber/v2" + "github.com/gofiber/fiber/v2/middleware/compress" + "github.com/gofiber/fiber/v2/middleware/cors" + "github.com/gofiber/fiber/v2/middleware/healthcheck" + "github.com/gofiber/fiber/v2/middleware/limiter" + "github.com/gofiber/fiber/v2/middleware/recover" + "github.com/gofiber/fiber/v2/middleware/requestid" + jsoniter "github.com/json-iterator/go" ) func listenAndServe(app *fiber.App, addr string, stop <-chan bool) error { @@ -54,3 +64,72 @@ Loop: } return nil } + +func NewHTTPServer() *fiber.App { + // Set up HTTP server. + httpApp = fiber.New(fiber.Config{ + DisableStartupMessage: true, + + JSONDecoder: jsoniter.Unmarshal, + JSONEncoder: jsoniter.Marshal, + ReadTimeout: 10 * time.Second, + IdleTimeout: 30 * time.Second, + WriteTimeout: 90 * time.Second, + + ErrorHandler: func(ctx *fiber.Ctx, err error) error { + // Send custom error page + if err != nil { + return ctx.Status(fiber.StatusBadRequest). + JSON(protocol.NewFailedResponseWithError(protocol.ErrBadRequest, err)) + } + + // Return from handler + return nil + }, + }) + httpApp.Use(recover.New(recover.Config{EnableStackTrace: true})) + httpApp.Use(requestid.New()) + httpApp.Use(healthcheck.New()) + httpApp.Use(cors.New(cors.Config{ + AllowOriginsFunc: func(origin string) bool { + return true + }, + })) + httpApp.Use(compress.New(compress.Config{ + Level: compress.LevelBestSpeed, + })) + httpApp.Use(limiter.New(limiter.Config{ + Max: 50, + Expiration: 10 * time.Second, + LimiterMiddleware: limiter.SlidingWindow{}, + })) + logger := flog.GetLogger() + httpApp.Use(fiberzerolog.New(fiberzerolog.Config{ + Logger: &logger, + SkipURIs: []string{ + "/", + "/livez", + "/readyz", + "/service/user/metrics", + }, + })) + + // hook + httpApp.Hooks().OnRoute(func(r fiber.Route) error { + if r.Method == http.MethodHead { + return nil + } + flog.Info("[route] %+7s %s", r.Method, r.Path) + return nil + }) + + // swagger + if swagHandler != nil { + httpApp.Get("/swagger/*", swagHandler) + } + + // Handle extra + setupMux(httpApp) + + return httpApp +} diff --git a/internal/server/modules.go b/internal/server/modules.go new file mode 100644 index 00000000..05eb993c --- /dev/null +++ b/internal/server/modules.go @@ -0,0 +1,24 @@ +package server + +import "go.uber.org/fx" + +var Modules = fx.Options( + // controller.Modules, + // repository.Modules, + fx.Provide( + // config.NewConfig, + // zlog.NewZlog, + // auth.NewEnforcer, + // task.NewServer, + // task.NewClient, + // eventbus.NewManager, + // NewTaskMux, + // NewCronScheduler, + // NewHTTPServer, + // NewEventSubscriber, + NewHTTPServer, + ), + fx.Invoke( + RunServer, + ), +) diff --git a/internal/server/server.go b/internal/server/server.go index db5a7486..e919db24 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -1,8 +1,12 @@ package server import ( + "context" + "github.com/flowline-io/flowbot/pkg/config" "github.com/flowline-io/flowbot/pkg/flog" + "github.com/gofiber/fiber/v2" + "go.uber.org/fx" // bots _ "github.com/flowline-io/flowbot/internal/bots/agent" @@ -52,3 +56,27 @@ func Run() { flog.Fatal("listenAndServe %v", err) } } + +func RunServer(lc fx.Lifecycle, app *fiber.App) { + lc.Append(fx.Hook{ + OnStart: func(ctx context.Context) error { + + // initialize + if err := initialize(); err != nil { + flog.Fatal("initialize %v", err) + } + + go func() { + err := app.Listen(config.App.Listen) + if err != nil { + flog.Error(err) + } + }() + + return nil + }, + OnStop: func(ctx context.Context) error { + return app.Shutdown() + }, + }) +} From f13b2d3b10464cafe853567f96276cc29851572b Mon Sep 17 00:00:00 2001 From: sysatom Date: Thu, 8 May 2025 14:33:28 +0800 Subject: [PATCH 040/125] http fx --- go.mod | 2 +- go.sum | 2 - internal/server/http.go | 48 ----------- internal/server/init.go | 173 -------------------------------------- internal/server/server.go | 122 +++++++++++++++++++++++---- 5 files changed, 108 insertions(+), 239 deletions(-) diff --git a/go.mod b/go.mod index 2836b5aa..805ed99a 100644 --- a/go.mod +++ b/go.mod @@ -66,6 +66,7 @@ require ( github.com/urfave/cli/v2 v2.27.6 github.com/valyala/fasthttp v1.62.0 go.uber.org/automaxprocs v1.6.0 + go.uber.org/fx v1.23.0 golang.org/x/crypto v0.38.0 golang.org/x/exp v0.0.0-20250218142911-aa4b98e5adaa golang.org/x/sys v0.33.0 @@ -207,7 +208,6 @@ require ( go.opentelemetry.io/otel/trace v1.29.0 // indirect go.uber.org/atomic v1.9.0 // indirect go.uber.org/dig v1.18.0 // indirect - go.uber.org/fx v1.23.0 // indirect go.uber.org/multierr v1.10.0 // indirect go.uber.org/zap v1.26.0 // indirect golang.org/x/arch v0.14.0 // indirect diff --git a/go.sum b/go.sum index 8a0b81f2..5be471ee 100644 --- a/go.sum +++ b/go.sum @@ -550,8 +550,6 @@ go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.uber.org/mock v0.4.0 h1:VcM4ZOtdbR4f6VXfiOpwpVJDL6lCReaZ6mw31wqh7KU= go.uber.org/mock v0.4.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc= -go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI= -go.uber.org/multierr v1.9.0/go.mod h1:X2jQV1h+kxSjClGpnseKVIxpmcjrj7MNnI0bnlfKTVQ= go.uber.org/multierr v1.10.0 h1:S0h4aNzvfcFsC3dRF1jLoaov7oRaKqRGC/pUEJ2yvPQ= go.uber.org/multierr v1.10.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= go.uber.org/zap v1.26.0 h1:sI7k6L95XOKS281NhVKOFCUNIvv9e0w4BF8N3u+tCRo= diff --git a/internal/server/http.go b/internal/server/http.go index a6354577..11c3e92d 100644 --- a/internal/server/http.go +++ b/internal/server/http.go @@ -1,11 +1,9 @@ package server import ( - "context" "net/http" "time" - "github.com/flowline-io/flowbot/pkg/cache" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/types/protocol" "github.com/gofiber/contrib/fiberzerolog" @@ -19,52 +17,6 @@ import ( jsoniter "github.com/json-iterator/go" ) -func listenAndServe(app *fiber.App, addr string, stop <-chan bool) error { - globals.shuttingDown = false - - httpdone := make(chan bool) - - go func() { - err := app.Listen(addr) - if err != nil { - flog.Error(err) - } - httpdone <- true - }() - - // Wait for either a termination signal or an error -Loop: - for { - select { - case <-stop: - // Flip the flag that we are terminating and close the Accept-ing socket, so no new connections are possible. - globals.shuttingDown = true - // Give server 2 seconds to shut down. - ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second) - if err := app.ShutdownWithContext(ctx); err != nil { - // failure/timeout shutting down the server gracefully - flog.Error(err) - } - - cancel() - - // Shutdown Extra - globals.taskQueue.Shutdown() - globals.manager.Shutdown() - globals.cronTaskManager.Shutdown() - for _, ruleset := range globals.cronRuleset { - ruleset.Shutdown() - } - cache.Shutdown() - - break Loop - case <-httpdone: - break Loop - } - } - return nil -} - func NewHTTPServer() *fiber.App { // Set up HTTP server. httpApp = fiber.New(fiber.Config{ diff --git a/internal/server/init.go b/internal/server/init.go index 647a337c..587124cc 100644 --- a/internal/server/init.go +++ b/internal/server/init.go @@ -3,7 +3,6 @@ package server import ( "context" "fmt" - "net/http" "os" "runtime" "runtime/pprof" @@ -28,14 +27,7 @@ import ( "github.com/flowline-io/flowbot/pkg/utils" "github.com/flowline-io/flowbot/pkg/utils/sets" "github.com/flowline-io/flowbot/version" - "github.com/gofiber/contrib/fiberzerolog" "github.com/gofiber/fiber/v2" - "github.com/gofiber/fiber/v2/middleware/compress" - "github.com/gofiber/fiber/v2/middleware/cors" - "github.com/gofiber/fiber/v2/middleware/healthcheck" - "github.com/gofiber/fiber/v2/middleware/limiter" - "github.com/gofiber/fiber/v2/middleware/recover" - "github.com/gofiber/fiber/v2/middleware/requestid" jsoniter "github.com/json-iterator/go" "github.com/spf13/pflag" ) @@ -58,102 +50,6 @@ var ( } ) -func initialize() error { - var err error - - // init log - if err = initializeLog(); err != nil { - return err - } - flog.Info("initialize Log ok") - - // init timezone - if err = initializeTimezone(); err != nil { - return err - } - flog.Info("initialize Timezone ok") - - // init flag - if err = initializeFlag(); err != nil { - return err - } - flog.Info("initialize Flag ok") - - // init config - if err = initializeConfig(); err != nil { - return err - } - flog.Info("initialize Config ok") - - // init alarm - if err = initializeAlarm(); err != nil { - return err - } - flog.Info("initialize Alarm ok") - - // init http - if err = initializeHttp(); err != nil { - return err - } - flog.Info("initialize Http ok") - - // init pprof - if err = initializePprof(); err != nil { - return err - } - flog.Info("initialize Pprof ok") - - // init cache - if err = initializeCache(); err != nil { - return err - } - flog.Info("initialize Cache ok") - - // init database - if err = initializeDatabase(); err != nil { - return err - } - flog.Info("initialize Database ok") - - // init media - if err = initializeMedia(); err != nil { - return err - } - flog.Info("initialize Media ok") - - // init signal - if err = initializeSignal(); err != nil { - return err - } - flog.Info("initialize Signal ok") - - // init event - if err = initializeEvent(); err != nil { - return err - } - flog.Info("initialize Event ok") - - // init chatbot - if err = initializeChatbot(stopSignal); err != nil { - return err - } - flog.Info("initialize Chatbot ok") - - // init metrics - if err = initializeMetrics(); err != nil { - return err - } - flog.Info("initialize Metrics ok") - - // init search - if err = initializeSearch(); err != nil { - return err - } - flog.Info("initialize Search ok") - - return nil -} - func initializeLog() error { flog.Init(false) return nil @@ -222,75 +118,6 @@ func initializeConfig() error { return nil } -func initializeHttp() error { - // Set up HTTP server. - httpApp = fiber.New(fiber.Config{ - DisableStartupMessage: true, - - JSONDecoder: jsoniter.Unmarshal, - JSONEncoder: jsoniter.Marshal, - ReadTimeout: 10 * time.Second, - IdleTimeout: 30 * time.Second, - WriteTimeout: 90 * time.Second, - - ErrorHandler: func(ctx *fiber.Ctx, err error) error { - // Send custom error page - if err != nil { - return ctx.Status(fiber.StatusBadRequest). - JSON(protocol.NewFailedResponseWithError(protocol.ErrBadRequest, err)) - } - - // Return from handler - return nil - }, - }) - httpApp.Use(recover.New(recover.Config{EnableStackTrace: true})) - httpApp.Use(requestid.New()) - httpApp.Use(healthcheck.New()) - httpApp.Use(cors.New(cors.Config{ - AllowOriginsFunc: func(origin string) bool { - return true - }, - })) - httpApp.Use(compress.New(compress.Config{ - Level: compress.LevelBestSpeed, - })) - httpApp.Use(limiter.New(limiter.Config{ - Max: 50, - Expiration: 10 * time.Second, - LimiterMiddleware: limiter.SlidingWindow{}, - })) - logger := flog.GetLogger() - httpApp.Use(fiberzerolog.New(fiberzerolog.Config{ - Logger: &logger, - SkipURIs: []string{ - "/", - "/livez", - "/readyz", - "/service/user/metrics", - }, - })) - - // hook - httpApp.Hooks().OnRoute(func(r fiber.Route) error { - if r.Method == http.MethodHead { - return nil - } - flog.Info("[route] %+7s %s", r.Method, r.Path) - return nil - }) - - // swagger - if swagHandler != nil { - httpApp.Get("/swagger/*", swagHandler) - } - - // Handle extra - setupMux(httpApp) - - return nil -} - func initializePprof() error { // Initialize serving debug profiles (optional). pprofs.ServePprof(httpApp, *appFlag.pprofUrl) diff --git a/internal/server/server.go b/internal/server/server.go index e919db24..405e9e11 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -2,7 +2,9 @@ package server import ( "context" + "time" + "github.com/flowline-io/flowbot/pkg/cache" "github.com/flowline-io/flowbot/pkg/config" "github.com/flowline-io/flowbot/pkg/flog" "github.com/gofiber/fiber/v2" @@ -46,26 +48,96 @@ const ( defaultApiPath = "/" ) -func Run() { - // initialize - if err := initialize(); err != nil { - flog.Fatal("initialize %v", err) - } - // serve - if err := listenAndServe(httpApp, config.App.Listen, stopSignal); err != nil { - flog.Fatal("listenAndServe %v", err) - } -} - func RunServer(lc fx.Lifecycle, app *fiber.App) { lc.Append(fx.Hook{ OnStart: func(ctx context.Context) error { + var err error + + // init log + if err = initializeLog(); err != nil { + return err + } + flog.Info("initialize Log ok") + + // init timezone + if err = initializeTimezone(); err != nil { + return err + } + flog.Info("initialize Timezone ok") + + // init flag + if err = initializeFlag(); err != nil { + return err + } + flog.Info("initialize Flag ok") + + // init config + if err = initializeConfig(); err != nil { + return err + } + flog.Info("initialize Config ok") + + // init alarm + if err = initializeAlarm(); err != nil { + return err + } + flog.Info("initialize Alarm ok") + + // init pprof + if err = initializePprof(); err != nil { + return err + } + flog.Info("initialize Pprof ok") + + // init cache + if err = initializeCache(); err != nil { + return err + } + flog.Info("initialize Cache ok") + + // init database + if err = initializeDatabase(); err != nil { + return err + } + flog.Info("initialize Database ok") + + // init media + if err = initializeMedia(); err != nil { + return err + } + flog.Info("initialize Media ok") + + // init signal + if err = initializeSignal(); err != nil { + return err + } + flog.Info("initialize Signal ok") + + // init event + if err = initializeEvent(); err != nil { + return err + } + flog.Info("initialize Event ok") + + // init chatbot + if err = initializeChatbot(stopSignal); err != nil { + return err + } + flog.Info("initialize Chatbot ok") - // initialize - if err := initialize(); err != nil { - flog.Fatal("initialize %v", err) + // init metrics + if err = initializeMetrics(); err != nil { + return err } + flog.Info("initialize Metrics ok") + // init search + if err = initializeSearch(); err != nil { + return err + } + flog.Info("initialize Search ok") + + // http server go func() { err := app.Listen(config.App.Listen) if err != nil { @@ -76,7 +148,27 @@ func RunServer(lc fx.Lifecycle, app *fiber.App) { return nil }, OnStop: func(ctx context.Context) error { - return app.Shutdown() + // Flip the flag that we are terminating and close the Accept-ing socket, so no new connections are possible. + globals.shuttingDown = true + // Give server 2 seconds to shut down. + ctx, cancel := context.WithTimeout(ctx, 2*time.Second) + if err := app.ShutdownWithContext(ctx); err != nil { + // failure/timeout shutting down the server gracefully + flog.Error(err) + } + + cancel() + + // Shutdown Extra + globals.taskQueue.Shutdown() + globals.manager.Shutdown() + globals.cronTaskManager.Shutdown() + for _, ruleset := range globals.cronRuleset { + ruleset.Shutdown() + } + cache.Shutdown() + + return nil }, }) } From 81b56f3c69e46efb97ee4078b47a4496e5c73de1 Mon Sep 17 00:00:00 2001 From: sysatom Date: Thu, 8 May 2025 15:10:59 +0800 Subject: [PATCH 041/125] config fx --- go.mod | 2 +- internal/server/init.go | 121 +------------------------------------ internal/server/modules.go | 8 ++- internal/server/server.go | 33 +--------- pkg/cache/cache.go | 19 ++++-- pkg/config/config.go | 78 +++++++++++++++++++++++- pkg/utils/signal.go | 5 +- pkg/utils/singleton.go | 10 +-- 8 files changed, 109 insertions(+), 167 deletions(-) diff --git a/go.mod b/go.mod index 805ed99a..335067e7 100644 --- a/go.mod +++ b/go.mod @@ -23,6 +23,7 @@ require ( github.com/dustin/go-humanize v1.0.1 github.com/emicklei/go-restful/v3 v3.12.2 github.com/expr-lang/expr v1.17.2 + github.com/fsnotify/fsnotify v1.8.0 github.com/gen2brain/beeep v0.0.0-20240516210008-9c006672e7f4 github.com/go-echarts/go-echarts/v2 v2.5.3 github.com/go-playground/validator/v10 v10.26.0 @@ -109,7 +110,6 @@ require ( github.com/ebitengine/purego v0.8.2 // indirect github.com/emirpasic/gods v1.18.1 // indirect github.com/felixge/httpsnoop v1.0.4 // indirect - github.com/fsnotify/fsnotify v1.8.0 // indirect github.com/gabriel-vasile/mimetype v1.4.8 // indirect github.com/getkin/kin-openapi v0.118.0 // indirect github.com/go-fed/httpsig v1.1.0 // indirect diff --git a/internal/server/init.go b/internal/server/init.go index 587124cc..907fe62f 100644 --- a/internal/server/init.go +++ b/internal/server/init.go @@ -3,10 +3,6 @@ package server import ( "context" "fmt" - "os" - "runtime" - "runtime/pprof" - "strings" "time" "github.com/VictoriaMetrics/metrics" @@ -16,20 +12,16 @@ import ( "github.com/flowline-io/flowbot/internal/store/mysql" "github.com/flowline-io/flowbot/internal/workflow" "github.com/flowline-io/flowbot/pkg/alarm" - "github.com/flowline-io/flowbot/pkg/cache" "github.com/flowline-io/flowbot/pkg/config" "github.com/flowline-io/flowbot/pkg/event" "github.com/flowline-io/flowbot/pkg/flog" - "github.com/flowline-io/flowbot/pkg/pprofs" "github.com/flowline-io/flowbot/pkg/providers/meilisearch" "github.com/flowline-io/flowbot/pkg/types" "github.com/flowline-io/flowbot/pkg/types/protocol" - "github.com/flowline-io/flowbot/pkg/utils" "github.com/flowline-io/flowbot/pkg/utils/sets" "github.com/flowline-io/flowbot/version" "github.com/gofiber/fiber/v2" jsoniter "github.com/json-iterator/go" - "github.com/spf13/pflag" ) var ( @@ -39,19 +31,11 @@ var ( swagHandler fiber.Handler // fiber app httpApp *fiber.App - // flag variables - appFlag struct { - configFile *string - listenOn *string - apiPath *string - tlsEnabled *bool - pprofFile *string - pprofUrl *string - } ) func initializeLog() error { flog.Init(false) + flog.SetLevel(config.App.Log.Level) return nil } @@ -63,104 +47,6 @@ func initializeTimezone() error { return nil } -func initializeFlag() error { - appFlag.configFile = pflag.String("config", "flowbot.yaml", "Path to config file.") - appFlag.listenOn = pflag.String("listen", "", "Override address and port to listen on for HTTP(S) clients.") - appFlag.apiPath = pflag.String("api_path", "", "Override the base URL path where API is served.") - appFlag.tlsEnabled = pflag.Bool("tls_enabled", false, "Override config value for enabling TLS.") - appFlag.pprofFile = pflag.String("pprof", "", "File name to save profiling info to. Disabled if not set.") - appFlag.pprofUrl = pflag.String("pprof_url", "", "Debugging only! URL path for exposing profiling info. Disabled if not set.") - pflag.Parse() - return nil -} - -func initializeConfig() error { - executable, _ := os.Executable() - - curwd, err := os.Getwd() - if err != nil { - flog.Fatal("Couldn't get current working directory: %v", err) - } - - flog.Info("version %s:%s:%s; pid %d; %d process(es)", - version.Buildtags, executable, version.Buildstamp, - os.Getpid(), runtime.GOMAXPROCS(runtime.NumCPU())) - - *appFlag.configFile = utils.ToAbsolutePath(curwd, *appFlag.configFile) - flog.Info("Using config from '%s'", *appFlag.configFile) - - // Load config - config.Load(".", curwd) - - if *appFlag.listenOn != "" { - config.App.Listen = *appFlag.listenOn - } - - // Configure root path for serving API calls. - if *appFlag.apiPath != "" { - config.App.ApiPath = *appFlag.apiPath - } - if config.App.ApiPath == "" { - config.App.ApiPath = defaultApiPath - } else { - if !strings.HasPrefix(config.App.ApiPath, "/") { - config.App.ApiPath = "/" + config.App.ApiPath - } - if !strings.HasSuffix(config.App.ApiPath, "/") { - config.App.ApiPath += "/" - } - } - flog.Info("API served from root URL path '%s'", config.App.ApiPath) - - // log level - flog.SetLevel(config.App.Log.Level) - - return nil -} - -func initializePprof() error { - // Initialize serving debug profiles (optional). - pprofs.ServePprof(httpApp, *appFlag.pprofUrl) - - if *appFlag.pprofFile != "" { - curwd, err := os.Getwd() - if err != nil { - return fmt.Errorf("failed to get current working directory, %w", err) - } - *appFlag.pprofFile = utils.ToAbsolutePath(curwd, *appFlag.pprofFile) - - cpuf, err := os.Create(*appFlag.pprofFile + ".cpu") - if err != nil { - flog.Fatal("Failed to create CPU pprof file: %v", err) - } - defer func() { - _ = cpuf.Close() - }() - - memf, err := os.Create(*appFlag.pprofFile + ".mem") - if err != nil { - flog.Fatal("Failed to create Mem pprof file: %v", err) - } - defer func() { - _ = memf.Close() - }() - - _ = pprof.StartCPUProfile(cpuf) - defer pprof.StopCPUProfile() - defer func() { - _ = pprof.WriteHeapProfile(memf) - }() - - flog.Info("Profiling info saved to '%s.(cpu|mem)'", *appFlag.pprofFile) - } - return nil -} - -func initializeCache() error { - // init cache - return cache.InitCache() -} - func initializeDatabase() error { // init database mysql.Init() @@ -222,11 +108,6 @@ func initializeMedia() error { return nil } -func initializeSignal() error { - stopSignal = utils.SignalHandler() - return nil -} - func initializeChatbot(signal <-chan bool) error { // Initialize bots hookBot(config.App.Bots, config.App.Vendors) diff --git a/internal/server/modules.go b/internal/server/modules.go index 05eb993c..c84af58d 100644 --- a/internal/server/modules.go +++ b/internal/server/modules.go @@ -1,6 +1,10 @@ package server -import "go.uber.org/fx" +import ( + "github.com/flowline-io/flowbot/pkg/cache" + "github.com/flowline-io/flowbot/pkg/config" + "go.uber.org/fx" +) var Modules = fx.Options( // controller.Modules, @@ -16,6 +20,8 @@ var Modules = fx.Options( // NewCronScheduler, // NewHTTPServer, // NewEventSubscriber, + config.NewConfig, + cache.NewCache, NewHTTPServer, ), fx.Invoke( diff --git a/internal/server/server.go b/internal/server/server.go index 405e9e11..2ef820f7 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -8,6 +8,7 @@ import ( "github.com/flowline-io/flowbot/pkg/config" "github.com/flowline-io/flowbot/pkg/flog" "github.com/gofiber/fiber/v2" + "github.com/redis/go-redis/v9" "go.uber.org/fx" // bots @@ -48,7 +49,7 @@ const ( defaultApiPath = "/" ) -func RunServer(lc fx.Lifecycle, app *fiber.App) { +func RunServer(lc fx.Lifecycle, app *fiber.App, _ *redis.Client) { lc.Append(fx.Hook{ OnStart: func(ctx context.Context) error { var err error @@ -65,36 +66,12 @@ func RunServer(lc fx.Lifecycle, app *fiber.App) { } flog.Info("initialize Timezone ok") - // init flag - if err = initializeFlag(); err != nil { - return err - } - flog.Info("initialize Flag ok") - - // init config - if err = initializeConfig(); err != nil { - return err - } - flog.Info("initialize Config ok") - // init alarm if err = initializeAlarm(); err != nil { return err } flog.Info("initialize Alarm ok") - // init pprof - if err = initializePprof(); err != nil { - return err - } - flog.Info("initialize Pprof ok") - - // init cache - if err = initializeCache(); err != nil { - return err - } - flog.Info("initialize Cache ok") - // init database if err = initializeDatabase(); err != nil { return err @@ -107,12 +84,6 @@ func RunServer(lc fx.Lifecycle, app *fiber.App) { } flog.Info("initialize Media ok") - // init signal - if err = initializeSignal(); err != nil { - return err - } - flog.Info("initialize Signal ok") - // init event if err = initializeEvent(); err != nil { return err diff --git a/pkg/cache/cache.go b/pkg/cache/cache.go index 89368ddb..f1fdd1ab 100644 --- a/pkg/cache/cache.go +++ b/pkg/cache/cache.go @@ -8,15 +8,16 @@ import ( "github.com/flowline-io/flowbot/pkg/config" "github.com/flowline-io/flowbot/pkg/flog" "github.com/redis/go-redis/v9" + "go.uber.org/fx" ) var DB *redis.Client -func InitCache() error { +func NewCache(lc fx.Lifecycle, _ config.Type) (*redis.Client, error) { addr := fmt.Sprintf("%s:%d", config.App.Redis.Host, config.App.Redis.Port) password := config.App.Redis.Password if addr == ":" || password == "" { - return fmt.Errorf("redis config error") + return nil, fmt.Errorf("redis config error") } DB = redis.NewClient(&redis.Options{ Addr: addr, @@ -28,9 +29,19 @@ func InitCache() error { s := DB.Ping(context.Background()) _, err := s.Result() if err != nil { - return fmt.Errorf("redis server error %w", err) + return nil, fmt.Errorf("redis server error %w", err) } - return nil + + lc.Append(fx.Hook{ + OnStart: func(ctx context.Context) error { + return nil + }, + OnStop: func(ctx context.Context) error { + return DB.Close() + }, + }) + + return DB, nil } func Shutdown() { diff --git a/pkg/config/config.go b/pkg/config/config.go index 2d027f46..1bd013af 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -1,16 +1,29 @@ package config import ( + "context" "log" + "os" + "runtime" + "strings" + "github.com/flowline-io/flowbot/pkg/utils" + "github.com/flowline-io/flowbot/version" + "github.com/fsnotify/fsnotify" "github.com/spf13/pflag" "github.com/spf13/viper" + "go.uber.org/fx" ) -var App configType +const ( + // Base URL path for serving the streaming API. + defaultApiPath = "/" +) + +var App Type // Contentx of the configuration file -type configType struct { +type Type struct { // HTTP(S) address:port to listen on for websocket and long polling clients. Either a // numeric or a canonical name, e.g. ":80" or ":https". Could include a host name, e.g. // "localhost:80". @@ -262,3 +275,64 @@ func Load(path ...string) { log.Fatalf("[config] Failed to unmarshal config: %v", err) } } + +func NewConfig(lc fx.Lifecycle) Type { + executable, _ := os.Executable() + + curwd, err := os.Getwd() + if err != nil { + log.Fatalf("Couldn't get current working directory: %v", err) + } + + log.Printf("version %s:%s:%s; pid %d; %d process(es)\n", + version.Buildtags, executable, version.Buildstamp, + os.Getpid(), runtime.GOMAXPROCS(runtime.NumCPU())) + + configFile := utils.ToAbsolutePath(curwd, "flowbot.yaml") + log.Printf("Using config from '%s'\n", configFile) + + // Load config + Load(".", curwd) + + // Configure root path for serving API calls. + if App.ApiPath == "" { + App.ApiPath = defaultApiPath + } else { + if !strings.HasPrefix(App.ApiPath, "/") { + App.ApiPath = "/" + App.ApiPath + } + if !strings.HasSuffix(App.ApiPath, "/") { + App.ApiPath += "/" + } + } + log.Printf("API served from root URL path '%s'\n", App.ApiPath) + + // // Debug + // if App.IsDevelopmentMode() { + // viper.Debug() + // } + + // fx hooks + lc.Append(fx.Hook{ + OnStart: func(ctx context.Context) error { + // Watch config + viper.OnConfigChange(func(e fsnotify.Event) { + log.Printf("Config file changed: %s\n", e.Name) + + // Reload + err := viper.Unmarshal(&App) + if err != nil { + log.Fatalf("[config] Failed to unmarshal config: %v", err) + } + }) + viper.WatchConfig() + + return nil + }, + OnStop: func(ctx context.Context) error { + return nil + }, + }) + + return App +} diff --git a/pkg/utils/signal.go b/pkg/utils/signal.go index e7a6a06b..8d26b5f9 100644 --- a/pkg/utils/signal.go +++ b/pkg/utils/signal.go @@ -1,11 +1,10 @@ package utils import ( + "log" "os" "os/signal" "syscall" - - "github.com/flowline-io/flowbot/pkg/flog" ) func SignalHandler() <-chan bool { @@ -17,7 +16,7 @@ func SignalHandler() <-chan bool { go func() { // Wait for a signal. Don't care which signal it is sig := <-signchan - flog.Info("Signal received: '%s', shutting down", sig) + log.Printf("Signal received: '%s', shutting down", sig) stop <- true }() diff --git a/pkg/utils/singleton.go b/pkg/utils/singleton.go index 42665065..b54164e5 100644 --- a/pkg/utils/singleton.go +++ b/pkg/utils/singleton.go @@ -2,10 +2,10 @@ package utils import ( "fmt" + "log" "net" "time" - "github.com/flowline-io/flowbot/pkg/flog" "github.com/go-resty/resty/v2" "github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2/middleware/cors" @@ -20,18 +20,18 @@ func CheckSingleton() { resp, err := resty.New().SetTimeout(500 * time.Millisecond).R(). Get(fmt.Sprintf("http://127.0.0.1:%s/health", EmbedServerPort)) if err != nil { - flog.Error(err) + log.Print(err) return } if resp.String() == "ok" { - flog.Fatal("app exists") + log.Fatal("app exists") } } } func EmbedServer() { go func() { - flog.Info("embed server http://127.0.0.1:%v", EmbedServerPort) + log.Printf("embed server http://127.0.0.1:%v", EmbedServerPort) app := fiber.New(fiber.Config{DisableStartupMessage: true}) app.Use(cors.New()) @@ -43,7 +43,7 @@ func EmbedServer() { err := app.Listen(net.JoinHostPort("127.0.0.1", EmbedServerPort)) if err != nil { - flog.Fatal("embed server error") + log.Fatal("embed server error") } }() } From f1c01162bf9a1b3ee05fbe02a649bc796aef29e3 Mon Sep 17 00:00:00 2001 From: sysatom Date: Thu, 8 May 2025 15:25:07 +0800 Subject: [PATCH 042/125] rdb fx --- internal/bots/anki/cron.go | 6 +++--- internal/bots/bookmark/cron.go | 6 +++--- internal/bots/gitea/cron.go | 4 ++-- internal/bots/kanban/cron.go | 4 ++-- internal/bots/reader/cron.go | 4 ++-- internal/bots/server/command.go | 6 +++--- internal/bots/server/cron.go | 14 +++++++------- internal/bots/torrent/cron.go | 4 ++-- internal/bots/user/webservice.go | 20 ++++++++++---------- internal/bots/workflow/workflow.go | 6 ++---- internal/server/func.go | 14 +++++++------- internal/server/hook.go | 6 ++++-- internal/server/modules.go | 4 ++-- internal/server/server.go | 2 -- internal/workflow/job.go | 8 ++++---- pkg/crawler/crawler.go | 18 +++++++++--------- pkg/event/pubsub.go | 6 +++--- pkg/locker/locker.go | 4 ++-- pkg/providers/pocket/pocket.go | 11 +++++------ pkg/{cache/cache.go => rdb/rdb.go} | 24 ++++++++++++------------ pkg/{cache => rdb}/unique.go | 6 +++--- pkg/types/ruleset/cron/cron.go | 6 +++--- 22 files changed, 90 insertions(+), 93 deletions(-) rename pkg/{cache/cache.go => rdb/rdb.go} (73%) rename pkg/{cache => rdb}/unique.go (91%) diff --git a/internal/bots/anki/cron.go b/internal/bots/anki/cron.go index bbb59f52..20239419 100644 --- a/internal/bots/anki/cron.go +++ b/internal/bots/anki/cron.go @@ -8,7 +8,7 @@ import ( "time" "github.com/flowline-io/flowbot/internal/store" - "github.com/flowline-io/flowbot/pkg/cache" + "github.com/flowline-io/flowbot/pkg/rdb" "github.com/flowline-io/flowbot/pkg/types" "github.com/flowline-io/flowbot/pkg/types/ruleset/cron" "github.com/redis/go-redis/v9" @@ -35,7 +35,7 @@ var cronRules = []cron.Rule{ } key := fmt.Sprintf("anki:review_remind:%s", ctx.AsUser) - sendString, err := cache.DB.Get(ctx.Context(), key).Result() + sendString, err := rdb.Client.Get(ctx.Context(), key).Result() if err != nil && !errors.Is(err, redis.Nil) { return nil } @@ -46,7 +46,7 @@ var cronRules = []cron.Rule{ now := time.Now().Unix() if now-oldSend > 24*60*60 { - _ = cache.DB.Set(context.Background(), key, strconv.FormatInt(now, 10), redis.KeepTTL) + _ = rdb.Client.Set(context.Background(), key, strconv.FormatInt(now, 10), redis.KeepTTL) return []types.MsgPayload{ types.TextMsg{Text: fmt.Sprintf("Anki review %d (%d)", num, now)}, diff --git a/internal/bots/bookmark/cron.go b/internal/bots/bookmark/cron.go index 51f4c3f9..65b3ce4b 100644 --- a/internal/bots/bookmark/cron.go +++ b/internal/bots/bookmark/cron.go @@ -4,13 +4,13 @@ import ( "fmt" "time" - "github.com/flowline-io/flowbot/pkg/cache" "github.com/flowline-io/flowbot/pkg/config" "github.com/flowline-io/flowbot/pkg/event" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/providers/hoarder" "github.com/flowline-io/flowbot/pkg/providers/kanboard" "github.com/flowline-io/flowbot/pkg/providers/meilisearch" + "github.com/flowline-io/flowbot/pkg/rdb" "github.com/flowline-io/flowbot/pkg/stats" "github.com/flowline-io/flowbot/pkg/types" "github.com/flowline-io/flowbot/pkg/types/ruleset/cron" @@ -72,7 +72,7 @@ var cronRules = []cron.Rule{ bookmarkTotal++ } stats.BookmarkTotalCounter().Set(uint64(bookmarkTotal)) - cache.SetInt64(stats.BookmarkTotalStatsName, int64(bookmarkTotal)) + rdb.SetInt64(stats.BookmarkTotalStatsName, int64(bookmarkTotal)) return nil }, @@ -131,7 +131,7 @@ var cronRules = []cron.Rule{ } // filter - ok, err := cache.UniqueString(ctx.Context(), "bookmarks:task:filter", bookmark.Id) + ok, err := rdb.UniqueString(ctx.Context(), "bookmarks:task:filter", bookmark.Id) if err != nil { flog.Error(fmt.Errorf("cron bookmarks_task unique error %w", err)) continue diff --git a/internal/bots/gitea/cron.go b/internal/bots/gitea/cron.go index d853cd7b..a418f65f 100644 --- a/internal/bots/gitea/cron.go +++ b/internal/bots/gitea/cron.go @@ -2,9 +2,9 @@ package gitea import ( "fmt" - "github.com/flowline-io/flowbot/pkg/cache" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/providers/gitea" + "github.com/flowline-io/flowbot/pkg/rdb" "github.com/flowline-io/flowbot/pkg/stats" "github.com/flowline-io/flowbot/pkg/types" "github.com/flowline-io/flowbot/pkg/types/ruleset/cron" @@ -34,7 +34,7 @@ var cronRules = []cron.Rule{ return nil } stats.GiteaIssueTotalCounter("open").Set(uint64(len(issues))) - cache.SetInt64(stats.GiteaIssueTotalStatsName, int64(len(issues))) + rdb.SetInt64(stats.GiteaIssueTotalStatsName, int64(len(issues))) return nil }, diff --git a/internal/bots/kanban/cron.go b/internal/bots/kanban/cron.go index 86257ed1..f35b6cd9 100755 --- a/internal/bots/kanban/cron.go +++ b/internal/bots/kanban/cron.go @@ -1,9 +1,9 @@ package kanban import ( - "github.com/flowline-io/flowbot/pkg/cache" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/providers/kanboard" + "github.com/flowline-io/flowbot/pkg/rdb" "github.com/flowline-io/flowbot/pkg/stats" "github.com/flowline-io/flowbot/pkg/types" "github.com/flowline-io/flowbot/pkg/types/ruleset/cron" @@ -25,7 +25,7 @@ var cronRules = []cron.Rule{ taskTotal := len(list) stats.KanbanTaskTotalCounter().Set(uint64(taskTotal)) - cache.SetInt64(stats.KanbanTaskTotalStatsName, int64(taskTotal)) + rdb.SetInt64(stats.KanbanTaskTotalStatsName, int64(taskTotal)) return nil }, diff --git a/internal/bots/reader/cron.go b/internal/bots/reader/cron.go index 09fce20e..9a92a087 100644 --- a/internal/bots/reader/cron.go +++ b/internal/bots/reader/cron.go @@ -5,10 +5,10 @@ import ( "strings" "time" - "github.com/flowline-io/flowbot/pkg/cache" "github.com/flowline-io/flowbot/pkg/event" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/providers/miniflux" + "github.com/flowline-io/flowbot/pkg/rdb" "github.com/flowline-io/flowbot/pkg/stats" "github.com/flowline-io/flowbot/pkg/types" "github.com/flowline-io/flowbot/pkg/types/ruleset/cron" @@ -38,7 +38,7 @@ var cronRules = []cron.Rule{ return nil } stats.ReaderUnreadTotalCounter().Set(uint64(result.Total)) - cache.SetInt64(stats.ReaderUnreadTotalStatsName, int64(result.Total)) + rdb.SetInt64(stats.ReaderUnreadTotalStatsName, int64(result.Total)) return nil }, diff --git a/internal/bots/server/command.go b/internal/bots/server/command.go index 8f2ac9a6..bb1c78a8 100644 --- a/internal/bots/server/command.go +++ b/internal/bots/server/command.go @@ -13,11 +13,11 @@ import ( "github.com/flowline-io/flowbot/internal/bots" "github.com/flowline-io/flowbot/internal/store" "github.com/flowline-io/flowbot/internal/workflow" - "github.com/flowline-io/flowbot/pkg/cache" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/notify" "github.com/flowline-io/flowbot/pkg/parser" "github.com/flowline-io/flowbot/pkg/providers/adguard" + "github.com/flowline-io/flowbot/pkg/rdb" "github.com/flowline-io/flowbot/pkg/types" "github.com/flowline-io/flowbot/pkg/types/ruleset/command" "github.com/flowline-io/flowbot/version" @@ -79,7 +79,7 @@ var commandRules = []command.Rule{ Help: `Online stats`, Handler: func(ctx types.Context, tokens []*parser.Token) types.MsgPayload { ctx_ := context.Background() - keys, err := cache.DB.Keys(ctx_, "online:*").Result() + keys, err := rdb.Client.Keys(ctx_, "online:*").Result() if err != nil { if !errors.Is(err, redis.Nil) { flog.Error(err) @@ -90,7 +90,7 @@ var commandRules = []command.Rule{ var texts []string texts = append(texts, fmt.Sprintf("online %d", len(keys))) for _, key := range keys { - t, err := cache.DB.Get(ctx_, key).Result() + t, err := rdb.Client.Get(ctx_, key).Result() if err != nil { continue } diff --git a/internal/bots/server/cron.go b/internal/bots/server/cron.go index 3f1e8881..2c736939 100644 --- a/internal/bots/server/cron.go +++ b/internal/bots/server/cron.go @@ -6,9 +6,9 @@ import ( "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/filters" "github.com/docker/docker/client" - "github.com/flowline-io/flowbot/pkg/cache" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/providers/uptimekuma" + "github.com/flowline-io/flowbot/pkg/rdb" "github.com/flowline-io/flowbot/pkg/stats" "github.com/flowline-io/flowbot/pkg/types" "github.com/flowline-io/flowbot/pkg/types/ruleset/cron" @@ -21,13 +21,13 @@ var cronRules = []cron.Rule{ Scope: cron.CronScopeUser, When: "* * * * *", Action: func(ctx types.Context) []types.MsgPayload { - keys, _ := cache.DB.Keys(ctx.Context(), "online:*").Result() + keys, _ := rdb.Client.Keys(ctx.Context(), "online:*").Result() currentCount := int64(len(keys)) lastKey := fmt.Sprintf("server:cron:online_count_last:%s", ctx.AsUser.String()) - lastCount, _ := cache.DB.Get(ctx.Context(), lastKey).Int64() - cache.DB.Set(ctx.Context(), lastKey, currentCount, redis.KeepTTL) + lastCount, _ := rdb.Client.Get(ctx.Context(), lastKey).Int64() + rdb.Client.Set(ctx.Context(), lastKey, currentCount, redis.KeepTTL) if lastCount != currentCount { return nil @@ -79,7 +79,7 @@ var cronRules = []cron.Rule{ total++ } - cache.SetInt64(stats.DockerContainerTotalStatsName, total) + rdb.SetInt64(stats.DockerContainerTotalStatsName, total) stats.DockerContainerTotalCounter().Set(uint64(total)) return nil @@ -110,8 +110,8 @@ var cronRules = []cron.Rule{ } } } - cache.SetInt64(stats.MonitorUpTotalStatsName, up) - cache.SetInt64(stats.MonitorDownTotalStatsName, down) + rdb.SetInt64(stats.MonitorUpTotalStatsName, up) + rdb.SetInt64(stats.MonitorDownTotalStatsName, down) return nil }, diff --git a/internal/bots/torrent/cron.go b/internal/bots/torrent/cron.go index 97814b1f..6579af88 100644 --- a/internal/bots/torrent/cron.go +++ b/internal/bots/torrent/cron.go @@ -4,9 +4,9 @@ import ( "context" "fmt" - "github.com/flowline-io/flowbot/pkg/cache" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/providers/transmission" + "github.com/flowline-io/flowbot/pkg/rdb" "github.com/flowline-io/flowbot/pkg/stats" "github.com/flowline-io/flowbot/pkg/types" "github.com/flowline-io/flowbot/pkg/types/ruleset/cron" @@ -53,7 +53,7 @@ var cronRules = []cron.Rule{ stats.TorrentStatusTotalCounter(status).Set(amount) } stats.TorrentDownloadTotalCounter().Set(uint64(len(list))) - cache.SetInt64(stats.TorrentDownloadTotalStatsName, int64(len(list))) + rdb.SetInt64(stats.TorrentDownloadTotalStatsName, int64(len(list))) return nil }, diff --git a/internal/bots/user/webservice.go b/internal/bots/user/webservice.go index a28fb804..5720526c 100644 --- a/internal/bots/user/webservice.go +++ b/internal/bots/user/webservice.go @@ -3,9 +3,9 @@ package user import ( "fmt" - "github.com/flowline-io/flowbot/pkg/cache" "github.com/flowline-io/flowbot/pkg/providers/hoarder" "github.com/flowline-io/flowbot/pkg/providers/kanboard" + "github.com/flowline-io/flowbot/pkg/rdb" "github.com/flowline-io/flowbot/pkg/stats" "github.com/flowline-io/flowbot/pkg/types" "github.com/flowline-io/flowbot/pkg/types/protocol" @@ -46,15 +46,15 @@ func dashboard(ctx *fiber.Ctx) error { // @Router /user/metrics [get] func metrics(ctx *fiber.Ctx) error { return ctx.JSON(protocol.NewSuccessResponse(types.KV{ - stats.BotTotalStatsName: cache.GetInt64(stats.BotTotalStatsName), - stats.BookmarkTotalStatsName: cache.GetInt64(stats.BookmarkTotalStatsName), - stats.TorrentDownloadTotalStatsName: cache.GetInt64(stats.TorrentDownloadTotalStatsName), - stats.GiteaIssueTotalStatsName: cache.GetInt64(stats.GiteaIssueTotalStatsName), - stats.ReaderUnreadTotalStatsName: cache.GetInt64(stats.ReaderUnreadTotalStatsName), - stats.KanbanTaskTotalStatsName: cache.GetInt64(stats.KanbanTaskTotalStatsName), - stats.MonitorUpTotalStatsName: cache.GetInt64(stats.MonitorUpTotalStatsName), - stats.MonitorDownTotalStatsName: cache.GetInt64(stats.MonitorDownTotalStatsName), - stats.DockerContainerTotalStatsName: cache.GetInt64(stats.DockerContainerTotalStatsName), + stats.BotTotalStatsName: rdb.GetInt64(stats.BotTotalStatsName), + stats.BookmarkTotalStatsName: rdb.GetInt64(stats.BookmarkTotalStatsName), + stats.TorrentDownloadTotalStatsName: rdb.GetInt64(stats.TorrentDownloadTotalStatsName), + stats.GiteaIssueTotalStatsName: rdb.GetInt64(stats.GiteaIssueTotalStatsName), + stats.ReaderUnreadTotalStatsName: rdb.GetInt64(stats.ReaderUnreadTotalStatsName), + stats.KanbanTaskTotalStatsName: rdb.GetInt64(stats.KanbanTaskTotalStatsName), + stats.MonitorUpTotalStatsName: rdb.GetInt64(stats.MonitorUpTotalStatsName), + stats.MonitorDownTotalStatsName: rdb.GetInt64(stats.MonitorDownTotalStatsName), + stats.DockerContainerTotalStatsName: rdb.GetInt64(stats.DockerContainerTotalStatsName), })) } diff --git a/internal/bots/workflow/workflow.go b/internal/bots/workflow/workflow.go index 14a2315c..4d0bf89d 100644 --- a/internal/bots/workflow/workflow.go +++ b/internal/bots/workflow/workflow.go @@ -7,9 +7,6 @@ import ( "github.com/cloudwego/eino/components/prompt" "github.com/cloudwego/eino/schema" "github.com/flowline-io/flowbot/internal/agents" - - "github.com/flowline-io/flowbot/pkg/cache" - "github.com/flowline-io/flowbot/pkg/crawler" "github.com/flowline-io/flowbot/pkg/event" "github.com/flowline-io/flowbot/pkg/executer" @@ -18,6 +15,7 @@ import ( "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/providers/lobehub" "github.com/flowline-io/flowbot/pkg/providers/transmission" + "github.com/flowline-io/flowbot/pkg/rdb" "github.com/flowline-io/flowbot/pkg/types" "github.com/flowline-io/flowbot/pkg/types/ruleset/workflow" "github.com/flowline-io/flowbot/pkg/utils" @@ -168,7 +166,7 @@ var workflowRules = []workflow.Rule{ return nil, fmt.Errorf("%s step, empty data", uniqueWorkflowActionID) } if v, ok := list.([]any); ok { - result, err := cache.Unique(ctx.Context(), id, v) + result, err := rdb.Unique(ctx.Context(), id, v) if err != nil { return nil, fmt.Errorf("%s step, unique failed, %w", uniqueWorkflowActionID, err) } diff --git a/internal/server/func.go b/internal/server/func.go index 9d5e7be5..b7a64e6c 100644 --- a/internal/server/func.go +++ b/internal/server/func.go @@ -13,13 +13,13 @@ import ( "github.com/flowline-io/flowbot/internal/platforms" "github.com/flowline-io/flowbot/internal/store" "github.com/flowline-io/flowbot/internal/store/model" - "github.com/flowline-io/flowbot/pkg/cache" "github.com/flowline-io/flowbot/pkg/event" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/providers" "github.com/flowline-io/flowbot/pkg/providers/dropbox" "github.com/flowline-io/flowbot/pkg/providers/github" "github.com/flowline-io/flowbot/pkg/providers/pocket" + "github.com/flowline-io/flowbot/pkg/rdb" "github.com/flowline-io/flowbot/pkg/stats" "github.com/flowline-io/flowbot/pkg/types" "github.com/flowline-io/flowbot/pkg/types/protocol" @@ -129,7 +129,7 @@ func directIncomingMessage(caller *platforms.Caller, e protocol.Event) { // get chat key chatKey := fmt.Sprintf("chat:%s", uid) - session, err := cache.DB.Get(ctx.Context(), chatKey).Result() + session, err := rdb.Client.Get(ctx.Context(), chatKey).Result() if err != nil { if !errors.Is(err, redis.Nil) { flog.Error(err) @@ -141,7 +141,7 @@ func directIncomingMessage(caller *platforms.Caller, e protocol.Event) { if strings.ToLower(msg.AltMessage) == "chat" { if session == "" { payload = types.TextMsg{Text: "Chat started"} - err = cache.DB.Set(ctx.Context(), chatKey, types.Id(), 24*time.Hour).Err() + err = rdb.Client.Set(ctx.Context(), chatKey, types.Id(), 24*time.Hour).Err() if err != nil { flog.Error(fmt.Errorf("failed to set chat key: %w", err)) } @@ -153,7 +153,7 @@ func directIncomingMessage(caller *platforms.Caller, e protocol.Event) { // chat end command // end Multi-turn conversation if strings.ToLower(msg.AltMessage) == "end" { - err = cache.DB.Del(ctx.Context(), chatKey).Err() + err = rdb.Client.Del(ctx.Context(), chatKey).Err() if err != nil { flog.Error(fmt.Errorf("failed to delete chat key: %w", err)) } @@ -430,13 +430,13 @@ func onlineStatus(msg protocol.Event) { ctx := context.Background() key := fmt.Sprintf("online:%s", med.UserId) - _, err := cache.DB.Get(ctx, key).Result() + _, err := rdb.Client.Get(ctx, key).Result() if errors.Is(err, redis.Nil) { - cache.DB.Set(ctx, key, time.Now().Unix(), 30*time.Minute) + rdb.Client.Set(ctx, key, time.Now().Unix(), 30*time.Minute) } else if err != nil { return } else { - cache.DB.Expire(ctx, key, 30*time.Minute) + rdb.Client.Expire(ctx, key, 30*time.Minute) } } diff --git a/internal/server/hook.go b/internal/server/hook.go index 4372196f..93b4fc31 100644 --- a/internal/server/hook.go +++ b/internal/server/hook.go @@ -4,9 +4,9 @@ import ( "fmt" "github.com/flowline-io/flowbot/internal/bots" "github.com/flowline-io/flowbot/internal/platforms" - "github.com/flowline-io/flowbot/pkg/cache" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/providers" + "github.com/flowline-io/flowbot/pkg/rdb" "github.com/flowline-io/flowbot/pkg/stats" "github.com/flowline-io/flowbot/pkg/types/protocol" "github.com/flowline-io/flowbot/version" @@ -57,9 +57,11 @@ func hookBot(botsConfig interface{}, vendorsConfig interface{}) { } stats.BotTotalCounter().Set(uint64(len(bots.List()))) - cache.SetInt64(stats.BotTotalStatsName, int64(len(bots.List()))) + rdb.SetInt64(stats.BotTotalStatsName, int64(len(bots.List()))) } +/************* ✨ Windsurf Command ⭐ *************/ +/******* d1f3b9b1-a06b-4ef6-b535-3391cf4e6fbe *******/ func hookIncomingMessage(caller *platforms.Caller, msg protocol.Event) { // update online status onlineStatus(msg) diff --git a/internal/server/modules.go b/internal/server/modules.go index c84af58d..256534d1 100644 --- a/internal/server/modules.go +++ b/internal/server/modules.go @@ -1,8 +1,8 @@ package server import ( - "github.com/flowline-io/flowbot/pkg/cache" "github.com/flowline-io/flowbot/pkg/config" + "github.com/flowline-io/flowbot/pkg/rdb" "go.uber.org/fx" ) @@ -21,7 +21,7 @@ var Modules = fx.Options( // NewHTTPServer, // NewEventSubscriber, config.NewConfig, - cache.NewCache, + rdb.NewClient, NewHTTPServer, ), fx.Invoke( diff --git a/internal/server/server.go b/internal/server/server.go index 2ef820f7..61e3f911 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -4,7 +4,6 @@ import ( "context" "time" - "github.com/flowline-io/flowbot/pkg/cache" "github.com/flowline-io/flowbot/pkg/config" "github.com/flowline-io/flowbot/pkg/flog" "github.com/gofiber/fiber/v2" @@ -137,7 +136,6 @@ func RunServer(lc fx.Lifecycle, app *fiber.App, _ *redis.Client) { for _, ruleset := range globals.cronRuleset { ruleset.Shutdown() } - cache.Shutdown() return nil }, diff --git a/internal/workflow/job.go b/internal/workflow/job.go index b4d3601e..7775f393 100644 --- a/internal/workflow/job.go +++ b/internal/workflow/job.go @@ -6,7 +6,7 @@ import ( "strconv" "github.com/flowline-io/flowbot/internal/store/model" - "github.com/flowline-io/flowbot/pkg/cache" + "github.com/flowline-io/flowbot/pkg/rdb" "github.com/flowline-io/flowbot/pkg/utils" jsoniter "github.com/json-iterator/go" ) @@ -16,15 +16,15 @@ const ( ) func SyncJob(ctx context.Context, job *model.Job) error { - return cache.DB.HSet(ctx, jobListKey, strconv.FormatInt(job.ID, 10), job).Err() + return rdb.Client.HSet(ctx, jobListKey, strconv.FormatInt(job.ID, 10), job).Err() } func DeleteJob(ctx context.Context, job *model.Job) error { - return cache.DB.HDel(ctx, jobListKey, strconv.FormatInt(job.ID, 10)).Err() + return rdb.Client.HDel(ctx, jobListKey, strconv.FormatInt(job.ID, 10)).Err() } func GetJobsByState(ctx context.Context, state model.JobState) ([]*model.Job, error) { - res, err := cache.DB.HGetAll(ctx, jobListKey).Result() + res, err := rdb.Client.HGetAll(ctx, jobListKey).Result() if err != nil { return nil, fmt.Errorf("failed to get jobs from cache key %s, %w", jobListKey, err) } diff --git a/pkg/crawler/crawler.go b/pkg/crawler/crawler.go index d297e79e..4b90b2c0 100644 --- a/pkg/crawler/crawler.go +++ b/pkg/crawler/crawler.go @@ -12,8 +12,8 @@ import ( "strconv" "time" - "github.com/flowline-io/flowbot/pkg/cache" "github.com/flowline-io/flowbot/pkg/flog" + "github.com/flowline-io/flowbot/pkg/rdb" "github.com/flowline-io/flowbot/pkg/utils" "github.com/influxdata/cron" jsoniter "github.com/json-iterator/go" @@ -147,7 +147,7 @@ func (s *Crawler) filter(name, mode string, latest []map[string]string) []map[st sendTimeKey := fmt.Sprintf("crawler:%s:sendtime", name) // sent - oldArr, err := cache.DB.SMembers(ctx, sentKey).Result() + oldArr, err := rdb.Client.SMembers(ctx, sentKey).Result() if err != nil { return nil } @@ -161,7 +161,7 @@ func (s *Crawler) filter(name, mode string, latest []map[string]string) []map[st } // to do - todoArr, err := cache.DB.SMembers(ctx, todoKey).Result() + todoArr, err := rdb.Client.SMembers(ctx, todoKey).Result() if err != nil { return nil } @@ -182,9 +182,9 @@ func (s *Crawler) filter(name, mode string, latest []map[string]string) []map[st switch mode { case "instant": - _ = cache.DB.Set(ctx, sendTimeKey, strconv.FormatInt(time.Now().Unix(), 10), redis.KeepTTL) + _ = rdb.Client.Set(ctx, sendTimeKey, strconv.FormatInt(time.Now().Unix(), 10), redis.KeepTTL) case "daily": - sendString, err := cache.DB.Get(ctx, sendTimeKey).Result() + sendString, err := rdb.Client.Get(ctx, sendTimeKey).Result() if err != nil && !errors.Is(err, redis.Nil) { flog.Error(err) } @@ -196,7 +196,7 @@ func (s *Crawler) filter(name, mode string, latest []map[string]string) []map[st if time.Now().Unix()-oldSend < 24*60*60 { for _, item := range diff { d, _ := jsoniter.Marshal(item) - _ = cache.DB.SAdd(ctx, todoKey, d) + _ = rdb.Client.SAdd(ctx, todoKey, d) } return nil @@ -204,7 +204,7 @@ func (s *Crawler) filter(name, mode string, latest []map[string]string) []map[st diff = append(diff, todo...) - _ = cache.DB.Set(ctx, sendTimeKey, strconv.FormatInt(time.Now().Unix(), 10), redis.KeepTTL) + _ = rdb.Client.Set(ctx, sendTimeKey, strconv.FormatInt(time.Now().Unix(), 10), redis.KeepTTL) default: return nil } @@ -212,11 +212,11 @@ func (s *Crawler) filter(name, mode string, latest []map[string]string) []map[st // add data for _, item := range diff { d, _ := jsoniter.Marshal(item) - _ = cache.DB.SAdd(ctx, sentKey, d) + _ = rdb.Client.SAdd(ctx, sentKey, d) } // clear to do - _ = cache.DB.Del(ctx, todoKey) + _ = rdb.Client.Del(ctx, todoKey) return diff } diff --git a/pkg/event/pubsub.go b/pkg/event/pubsub.go index e8306eae..2c677421 100644 --- a/pkg/event/pubsub.go +++ b/pkg/event/pubsub.go @@ -10,8 +10,8 @@ import ( "github.com/ThreeDotsLabs/watermill/message" "github.com/ThreeDotsLabs/watermill/message/router/middleware" "github.com/ThreeDotsLabs/watermill/message/router/plugin" - "github.com/flowline-io/flowbot/pkg/cache" "github.com/flowline-io/flowbot/pkg/flog" + "github.com/flowline-io/flowbot/pkg/rdb" "github.com/flowline-io/flowbot/pkg/stats" jsoniter "github.com/json-iterator/go" ) @@ -21,7 +21,7 @@ var logger = flog.WatermillLogger func NewSubscriber() (message.Subscriber, error) { return redisstream.NewSubscriber( redisstream.SubscriberConfig{ - Client: cache.DB, + Client: rdb.Client, Unmarshaller: redisstream.DefaultMarshallerUnmarshaller{}, }, logger, @@ -31,7 +31,7 @@ func NewSubscriber() (message.Subscriber, error) { func NewPublisher() (message.Publisher, error) { return redisstream.NewPublisher( redisstream.PublisherConfig{ - Client: cache.DB, + Client: rdb.Client, Marshaller: redisstream.DefaultMarshallerUnmarshaller{}, }, logger, diff --git a/pkg/locker/locker.go b/pkg/locker/locker.go index c46fd2a9..7665c145 100644 --- a/pkg/locker/locker.go +++ b/pkg/locker/locker.go @@ -5,7 +5,7 @@ import ( "time" "github.com/bsm/redislock" - "github.com/flowline-io/flowbot/pkg/cache" + "github.com/flowline-io/flowbot/pkg/rdb" ) type Locker struct { @@ -13,7 +13,7 @@ type Locker struct { } func NewLocker() *Locker { - return &Locker{lock: redislock.New(cache.DB)} + return &Locker{lock: redislock.New(rdb.Client)} } func (l *Locker) Acquire(ctx context.Context, key string, ttl time.Duration) (*redislock.Lock, error) { diff --git a/pkg/providers/pocket/pocket.go b/pkg/providers/pocket/pocket.go index cecf212b..90c25a29 100644 --- a/pkg/providers/pocket/pocket.go +++ b/pkg/providers/pocket/pocket.go @@ -7,12 +7,11 @@ import ( "net/http" "time" - "github.com/flowline-io/flowbot/pkg/cache" + "github.com/flowline-io/flowbot/pkg/rdb" "github.com/flowline-io/flowbot/pkg/types" + "github.com/go-resty/resty/v2" "github.com/gofiber/fiber/v2" jsoniter "github.com/json-iterator/go" - - "github.com/go-resty/resty/v2" "github.com/redis/go-redis/v9" ) @@ -55,7 +54,7 @@ func (v *Pocket) GetCode(state string) (*CodeResponse, error) { v.code = result.Code ctx := context.Background() - _ = cache.DB.Set(ctx, "pocket:code", v.code, redis.KeepTTL) // todo code param + _ = rdb.Client.Set(ctx, "pocket:code", v.code, redis.KeepTTL) // todo code param return result, nil } else { @@ -88,7 +87,7 @@ func (v *Pocket) completeAuth(code string) (interface{}, error) { func (v *Pocket) Redirect(_ *http.Request) (string, error) { ctx := context.Background() - _ = cache.DB.Set(ctx, "pocket:code", v.code, redis.KeepTTL).Err() // fixme uid key + _ = rdb.Client.Set(ctx, "pocket:code", v.code, redis.KeepTTL).Err() // fixme uid key appRedirectURI := v.GetAuthorizeURL() return appRedirectURI, nil @@ -96,7 +95,7 @@ func (v *Pocket) Redirect(_ *http.Request) (string, error) { func (v *Pocket) GetAccessToken(_ *fiber.Ctx) (types.KV, error) { ctx := context.Background() - code, err := cache.DB.Get(ctx, "pocket:code").Result() // fixme uid key + code, err := rdb.Client.Get(ctx, "pocket:code").Result() // fixme uid key if err != nil && !errors.Is(err, redis.Nil) { return nil, err } diff --git a/pkg/cache/cache.go b/pkg/rdb/rdb.go similarity index 73% rename from pkg/cache/cache.go rename to pkg/rdb/rdb.go index f1fdd1ab..887ebe61 100644 --- a/pkg/cache/cache.go +++ b/pkg/rdb/rdb.go @@ -1,4 +1,4 @@ -package cache +package rdb import ( "context" @@ -11,22 +11,22 @@ import ( "go.uber.org/fx" ) -var DB *redis.Client +var Client *redis.Client -func NewCache(lc fx.Lifecycle, _ config.Type) (*redis.Client, error) { +func NewClient(lc fx.Lifecycle, _ config.Type) (*redis.Client, error) { addr := fmt.Sprintf("%s:%d", config.App.Redis.Host, config.App.Redis.Port) password := config.App.Redis.Password if addr == ":" || password == "" { return nil, fmt.Errorf("redis config error") } - DB = redis.NewClient(&redis.Options{ + Client = redis.NewClient(&redis.Options{ Addr: addr, Password: password, DB: config.App.Redis.DB, ReadTimeout: 60 * time.Second, WriteTimeout: 60 * time.Second, }) - s := DB.Ping(context.Background()) + s := Client.Ping(context.Background()) _, err := s.Result() if err != nil { return nil, fmt.Errorf("redis server error %w", err) @@ -37,22 +37,22 @@ func NewCache(lc fx.Lifecycle, _ config.Type) (*redis.Client, error) { return nil }, OnStop: func(ctx context.Context) error { - return DB.Close() + return Client.Close() }, }) - return DB, nil + return Client, nil } func Shutdown() { - if DB == nil { + if Client == nil { flog.Warn("redis not initialized") return } - _, err := DB.Ping(context.Background()).Result() + _, err := Client.Ping(context.Background()).Result() if err == nil { - err = DB.Close() + err = Client.Close() if err != nil { flog.Error(fmt.Errorf("failed to close redis connection: %w", err)) return @@ -64,11 +64,11 @@ func Shutdown() { } func SetInt64(key string, value int64) { - DB.Set(context.Background(), key, value, 0) + Client.Set(context.Background(), key, value, 0) } func GetInt64(key string) int64 { - r, err := DB.Get(context.Background(), key).Int64() + r, err := Client.Get(context.Background(), key).Int64() if err != nil { flog.Error(err) } diff --git a/pkg/cache/unique.go b/pkg/rdb/unique.go similarity index 91% rename from pkg/cache/unique.go rename to pkg/rdb/unique.go index 91d4ddcc..f20dca67 100644 --- a/pkg/cache/unique.go +++ b/pkg/rdb/unique.go @@ -1,4 +1,4 @@ -package cache +package rdb import ( "context" @@ -21,7 +21,7 @@ func Unique(ctx context.Context, id string, latest []any) ([]types.KV, error) { if len(val) == 0 { continue } - b, err := DB.SAdd(ctx, uniqueKey, val).Result() + b, err := Client.SAdd(ctx, uniqueKey, val).Result() if err != nil { return nil, fmt.Errorf("failed to set unique key: %w", err) } @@ -48,7 +48,7 @@ func kvHash(item any) (string, error) { func UniqueString(ctx context.Context, id string, latest string) (bool, error) { uniqueKey := fmt.Sprintf("unique:%s", id) - b, err := DB.SAdd(ctx, uniqueKey, latest).Result() + b, err := Client.SAdd(ctx, uniqueKey, latest).Result() if err != nil { return false, fmt.Errorf("failed to set unique key: %w", err) } diff --git a/pkg/types/ruleset/cron/cron.go b/pkg/types/ruleset/cron/cron.go index aa9b776b..4051a2d7 100644 --- a/pkg/types/ruleset/cron/cron.go +++ b/pkg/types/ruleset/cron/cron.go @@ -9,9 +9,9 @@ import ( "time" "github.com/flowline-io/flowbot/internal/store" - "github.com/flowline-io/flowbot/pkg/cache" "github.com/flowline-io/flowbot/pkg/event" "github.com/flowline-io/flowbot/pkg/flog" + "github.com/flowline-io/flowbot/pkg/rdb" "github.com/flowline-io/flowbot/pkg/types" "github.com/influxdata/cron" ) @@ -196,12 +196,12 @@ func (r *Ruleset) filter(res result) result { hash := s.Sum(nil) ctx := context.Background() - state := cache.DB.SIsMember(ctx, filterKey, hash).Val() + state := rdb.Client.SIsMember(ctx, filterKey, hash).Val() if state { return result{} } - _ = cache.DB.SAdd(ctx, filterKey, hash) + _ = rdb.Client.SAdd(ctx, filterKey, hash) return res } From e230310c475100b2db83b7d541a6ebeee54e6b79 Mon Sep 17 00:00:00 2001 From: sysatom Date: Thu, 8 May 2025 15:28:08 +0800 Subject: [PATCH 043/125] update globals --- internal/server/globals.go | 3 --- internal/server/server.go | 7 ------- 2 files changed, 10 deletions(-) diff --git a/internal/server/globals.go b/internal/server/globals.go index 792db92a..568ccc67 100644 --- a/internal/server/globals.go +++ b/internal/server/globals.go @@ -8,9 +8,6 @@ import ( ) var globals struct { - // Indicator that shutdown is in progress - shuttingDown bool - // Add Strict-Transport-Security to headers, the value signifies age. // Empty string "" turns it off tlsStrictMaxAge string diff --git a/internal/server/server.go b/internal/server/server.go index 61e3f911..ad495b8a 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -43,11 +43,6 @@ import ( _ "github.com/flowline-io/flowbot/pkg/notify/slack" ) -const ( - // Base URL path for serving the streaming API. - defaultApiPath = "/" -) - func RunServer(lc fx.Lifecycle, app *fiber.App, _ *redis.Client) { lc.Append(fx.Hook{ OnStart: func(ctx context.Context) error { @@ -118,8 +113,6 @@ func RunServer(lc fx.Lifecycle, app *fiber.App, _ *redis.Client) { return nil }, OnStop: func(ctx context.Context) error { - // Flip the flag that we are terminating and close the Accept-ing socket, so no new connections are possible. - globals.shuttingDown = true // Give server 2 seconds to shut down. ctx, cancel := context.WithTimeout(ctx, 2*time.Second) if err := app.ShutdownWithContext(ctx); err != nil { From 756e75823d655dccd5656b38bf23fd3823413386 Mon Sep 17 00:00:00 2001 From: sysatom Date: Thu, 8 May 2025 15:33:27 +0800 Subject: [PATCH 044/125] bindRoutes --- internal/server/http.go | 3 --- internal/server/modules.go | 11 +---------- internal/server/router.go | 2 +- 3 files changed, 2 insertions(+), 14 deletions(-) diff --git a/internal/server/http.go b/internal/server/http.go index 11c3e92d..71fdae93 100644 --- a/internal/server/http.go +++ b/internal/server/http.go @@ -80,8 +80,5 @@ func NewHTTPServer() *fiber.App { httpApp.Get("/swagger/*", swagHandler) } - // Handle extra - setupMux(httpApp) - return httpApp } diff --git a/internal/server/modules.go b/internal/server/modules.go index 256534d1..4da432c0 100644 --- a/internal/server/modules.go +++ b/internal/server/modules.go @@ -10,21 +10,12 @@ var Modules = fx.Options( // controller.Modules, // repository.Modules, fx.Provide( - // config.NewConfig, - // zlog.NewZlog, - // auth.NewEnforcer, - // task.NewServer, - // task.NewClient, - // eventbus.NewManager, - // NewTaskMux, - // NewCronScheduler, - // NewHTTPServer, - // NewEventSubscriber, config.NewConfig, rdb.NewClient, NewHTTPServer, ), fx.Invoke( + bindRoutes, RunServer, ), ) diff --git a/internal/server/router.go b/internal/server/router.go index a07f1da8..735e685f 100644 --- a/internal/server/router.go +++ b/internal/server/router.go @@ -32,7 +32,7 @@ import ( "gorm.io/gorm" ) -func setupMux(a *fiber.App) { +func bindRoutes(a *fiber.App) { // Webservice for _, bot := range bots.List() { bot.Webservice(a) From 38bad596f5a322d7e37732033c5b0fa8bbdcb169 Mon Sep 17 00:00:00 2001 From: sysatom Date: Thu, 8 May 2025 15:38:47 +0800 Subject: [PATCH 045/125] controller fx --- internal/server/http.go | 2 +- internal/server/modules.go | 3 ++- internal/server/router.go | 36 +++++++++++++++++++++--------------- 3 files changed, 24 insertions(+), 17 deletions(-) diff --git a/internal/server/http.go b/internal/server/http.go index 71fdae93..8ea707c6 100644 --- a/internal/server/http.go +++ b/internal/server/http.go @@ -17,7 +17,7 @@ import ( jsoniter "github.com/json-iterator/go" ) -func NewHTTPServer() *fiber.App { +func newHTTPServer() *fiber.App { // Set up HTTP server. httpApp = fiber.New(fiber.Config{ DisableStartupMessage: true, diff --git a/internal/server/modules.go b/internal/server/modules.go index 4da432c0..09afe9f6 100644 --- a/internal/server/modules.go +++ b/internal/server/modules.go @@ -12,7 +12,8 @@ var Modules = fx.Options( fx.Provide( config.NewConfig, rdb.NewClient, - NewHTTPServer, + newController, + newHTTPServer, ), fx.Invoke( bindRoutes, diff --git a/internal/server/router.go b/internal/server/router.go index 735e685f..6fa29a6a 100644 --- a/internal/server/router.go +++ b/internal/server/router.go @@ -32,7 +32,7 @@ import ( "gorm.io/gorm" ) -func bindRoutes(a *fiber.App) { +func bindRoutes(a *fiber.App, ctl *Controller) { // Webservice for _, bot := range bots.List() { bot.Webservice(a) @@ -40,23 +40,29 @@ func bindRoutes(a *fiber.App) { // common a.Get("/", func(c *fiber.Ctx) error { return nil }) - a.All("/oauth/:provider/:flag", storeOAuth) - a.Get("/p/:id", getPage) + a.All("/oauth/:provider/:flag", ctl.storeOAuth) + a.Get("/p/:id", ctl.getPage) // form - a.Post("/form", postForm) + a.Post("/form", ctl.postForm) // page - a.Get("/page/:id/:flag", renderPage) + a.Get("/page/:id/:flag", ctl.renderPage) // agent - a.Post("/agent", agentData) + a.Post("/agent", ctl.agentData) // webhook - a.All("/webhook/:flag", doWebhook) + a.All("/webhook/:flag", ctl.doWebhook) // platform - a.All("/chatbot/:platform", platformCallback) + a.All("/chatbot/:platform", ctl.platformCallback) } // handler -func storeOAuth(ctx *fiber.Ctx) error { +type Controller struct {} + +func newController() *Controller { + return &Controller{} +} + +func (c *Controller) storeOAuth(ctx *fiber.Ctx) error { name := ctx.Params("provider") flag := ctx.Params("flag") @@ -99,7 +105,7 @@ func storeOAuth(ctx *fiber.Ctx) error { return ctx.SendString("ok") } -func getPage(ctx *fiber.Ctx) error { +func (c *Controller) getPage(ctx *fiber.Ctx) error { id := ctx.Params("id") p, err := store.Database.PageGet(id) @@ -155,7 +161,7 @@ func getPage(ctx *fiber.Ctx) error { return ctx.SendString(page.RenderComponent(title, comp)) } -func renderPage(ctx *fiber.Ctx) error { +func (c *Controller) renderPage(ctx *fiber.Ctx) error { pageRuleId := ctx.Params("id") flag := ctx.Params("flag") @@ -205,7 +211,7 @@ func renderPage(ctx *fiber.Ctx) error { return ctx.SendString(html) } -func postForm(ctx *fiber.Ctx) error { +func (c *Controller) postForm(ctx *fiber.Ctx) error { formId := ctx.FormValue("x-form_id") uid := ctx.FormValue("x-uid") topic := ctx.FormValue("x-topic") @@ -323,7 +329,7 @@ func postForm(ctx *fiber.Ctx) error { return ctx.JSON(protocol.NewSuccessResponse("ok")) } -func agentData(ctx *fiber.Ctx) error { +func (c *Controller) agentData(ctx *fiber.Ctx) error { var r http.Request if err := fasthttpadaptor.ConvertRequest(ctx.Context(), &r, true); err != nil { return ctx.Status(http.StatusInternalServerError).JSON(protocol.NewFailedResponseWithError(protocol.ErrInternalServerError, err)) @@ -349,7 +355,7 @@ func agentData(ctx *fiber.Ctx) error { return ctx.JSON(protocol.NewSuccessResponse(result)) } -func platformCallback(ctx *fiber.Ctx) error { +func (c *Controller) platformCallback(ctx *fiber.Ctx) error { platform := ctx.Params("platform") var err error @@ -370,7 +376,7 @@ func platformCallback(ctx *fiber.Ctx) error { return ctx.JSON(protocol.NewSuccessResponse(nil)) } -func doWebhook(ctx *fiber.Ctx) error { +func (c *Controller) doWebhook(ctx *fiber.Ctx) error { flag := ctx.Params("flag") method := ctx.Method() From f54df270c1ec0255bd9502cb2cc76d0583f56fb3 Mon Sep 17 00:00:00 2001 From: sysatom Date: Thu, 8 May 2025 16:14:12 +0800 Subject: [PATCH 046/125] cache fx --- go.mod | 1 + go.sum | 4 ++++ internal/server/hook.go | 2 -- internal/server/init.go | 5 ---- internal/server/modules.go | 2 ++ internal/server/router.go | 2 +- internal/server/server.go | 9 ++----- pkg/alarm/alarm.go | 30 +++++------------------ pkg/cache/cache.go | 49 ++++++++++++++++++++++++++++++++++++++ 9 files changed, 65 insertions(+), 39 deletions(-) create mode 100644 pkg/cache/cache.go diff --git a/go.mod b/go.mod index 335067e7..1f5542b1 100644 --- a/go.mod +++ b/go.mod @@ -17,6 +17,7 @@ require ( github.com/cloudwego/eino v0.3.28 github.com/cloudwego/eino-ext/components/model/openai v0.0.0-20250221090944-e8ef7aabbe10 github.com/creachadair/jrpc2 v1.3.1 + github.com/dgraph-io/ristretto/v2 v2.2.0 github.com/docker/cli v28.1.1+incompatible github.com/docker/docker v28.1.1+incompatible github.com/docker/go-units v0.5.0 diff --git a/go.sum b/go.sum index 5be471ee..63b15d1a 100644 --- a/go.sum +++ b/go.sum @@ -88,6 +88,10 @@ github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1 github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davidmz/go-pageant v1.0.2 h1:bPblRCh5jGU+Uptpz6LgMZGD5hJoOt7otgT454WvHn0= github.com/davidmz/go-pageant v1.0.2/go.mod h1:P2EDDnMqIwG5Rrp05dTRITj9z2zpGcD9efWSkTNKLIE= +github.com/dgraph-io/ristretto/v2 v2.2.0 h1:bkY3XzJcXoMuELV8F+vS8kzNgicwQFAaGINAEJdWGOM= +github.com/dgraph-io/ristretto/v2 v2.2.0/go.mod h1:RZrm63UmcBAaYWC1DotLYBmTvgkrs0+XhBd7Npn7/zI= +github.com/dgryski/go-farm v0.0.0-20240924180020-3414d57e47da h1:aIftn67I1fkbMa512G+w+Pxci9hJPB8oMnkcP3iZF38= +github.com/dgryski/go-farm v0.0.0-20240924180020-3414d57e47da/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78= github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= github.com/dhui/dktest v0.4.5 h1:uUfYBIVREmj/Rw6MvgmqNAYzTiKOHJak+enB5Di73MM= diff --git a/internal/server/hook.go b/internal/server/hook.go index 93b4fc31..2366abf9 100644 --- a/internal/server/hook.go +++ b/internal/server/hook.go @@ -60,8 +60,6 @@ func hookBot(botsConfig interface{}, vendorsConfig interface{}) { rdb.SetInt64(stats.BotTotalStatsName, int64(len(bots.List()))) } -/************* ✨ Windsurf Command ⭐ *************/ -/******* d1f3b9b1-a06b-4ef6-b535-3391cf4e6fbe *******/ func hookIncomingMessage(caller *platforms.Caller, msg protocol.Event) { // update online status onlineStatus(msg) diff --git a/internal/server/init.go b/internal/server/init.go index 907fe62f..3d14184f 100644 --- a/internal/server/init.go +++ b/internal/server/init.go @@ -11,7 +11,6 @@ import ( "github.com/flowline-io/flowbot/internal/store/model" "github.com/flowline-io/flowbot/internal/store/mysql" "github.com/flowline-io/flowbot/internal/workflow" - "github.com/flowline-io/flowbot/pkg/alarm" "github.com/flowline-io/flowbot/pkg/config" "github.com/flowline-io/flowbot/pkg/event" "github.com/flowline-io/flowbot/pkg/flog" @@ -251,7 +250,3 @@ func initializeSearch() error { } return nil } - -func initializeAlarm() error { - return alarm.InitAlarm() -} diff --git a/internal/server/modules.go b/internal/server/modules.go index 09afe9f6..792d4a75 100644 --- a/internal/server/modules.go +++ b/internal/server/modules.go @@ -1,6 +1,7 @@ package server import ( + "github.com/flowline-io/flowbot/pkg/cache" "github.com/flowline-io/flowbot/pkg/config" "github.com/flowline-io/flowbot/pkg/rdb" "go.uber.org/fx" @@ -11,6 +12,7 @@ var Modules = fx.Options( // repository.Modules, fx.Provide( config.NewConfig, + cache.NewCache, rdb.NewClient, newController, newHTTPServer, diff --git a/internal/server/router.go b/internal/server/router.go index 6fa29a6a..3c6bdc1d 100644 --- a/internal/server/router.go +++ b/internal/server/router.go @@ -56,7 +56,7 @@ func bindRoutes(a *fiber.App, ctl *Controller) { // handler -type Controller struct {} +type Controller struct{} func newController() *Controller { return &Controller{} diff --git a/internal/server/server.go b/internal/server/server.go index ad495b8a..e05d3438 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -4,6 +4,7 @@ import ( "context" "time" + "github.com/flowline-io/flowbot/pkg/cache" "github.com/flowline-io/flowbot/pkg/config" "github.com/flowline-io/flowbot/pkg/flog" "github.com/gofiber/fiber/v2" @@ -43,7 +44,7 @@ import ( _ "github.com/flowline-io/flowbot/pkg/notify/slack" ) -func RunServer(lc fx.Lifecycle, app *fiber.App, _ *redis.Client) { +func RunServer(lc fx.Lifecycle, app *fiber.App, _ *cache.Cache, _ *redis.Client) { lc.Append(fx.Hook{ OnStart: func(ctx context.Context) error { var err error @@ -60,12 +61,6 @@ func RunServer(lc fx.Lifecycle, app *fiber.App, _ *redis.Client) { } flog.Info("initialize Timezone ok") - // init alarm - if err = initializeAlarm(); err != nil { - return err - } - flog.Info("initialize Alarm ok") - // init database if err = initializeDatabase(); err != nil { return err diff --git a/pkg/alarm/alarm.go b/pkg/alarm/alarm.go index 67cfc273..b4cc15e8 100644 --- a/pkg/alarm/alarm.go +++ b/pkg/alarm/alarm.go @@ -2,10 +2,8 @@ package alarm import ( "bytes" - "context" "crypto/sha1" "encoding/hex" - "errors" "fmt" "io" "net/http" @@ -14,29 +12,11 @@ import ( "text/template" "time" + "github.com/flowline-io/flowbot/pkg/cache" "github.com/flowline-io/flowbot/pkg/config" - "github.com/redis/go-redis/v9" "github.com/rs/zerolog" ) -var db *redis.Client - -func InitAlarm() error { - addr := fmt.Sprintf("%s:%d", config.App.Redis.Host, config.App.Redis.Port) - password := config.App.Redis.Password - if addr == ":" || password == "" { - return errors.New("redis config error") - } - db = redis.NewClient(&redis.Options{ - Addr: addr, - Password: password, - DB: config.App.Redis.DB, - ReadTimeout: 60 * time.Second, - WriteTimeout: 60 * time.Second, - }) - return nil -} - func Alarm(err error, skip int) { if err == nil { return @@ -93,10 +73,12 @@ func nx(text string) (bool, error) { hash := hex.EncodeToString(h.Sum(nil)) key := fmt.Sprintf("alarm:%s", hash) - ok, err := db.SetNX(context.Background(), key, "1", 24*time.Hour).Result() - if err != nil { - return false, fmt.Errorf("failed to set alarm key: %w", err) + _, ok := cache.Instance.Get(key) + if ok { + return false, nil } + + ok = cache.Instance.SetWithTTL(key, "1", 0, 24*time.Hour) if !ok { return false, nil } diff --git a/pkg/cache/cache.go b/pkg/cache/cache.go new file mode 100644 index 00000000..74701d38 --- /dev/null +++ b/pkg/cache/cache.go @@ -0,0 +1,49 @@ +package cache + +import ( + "time" + + "github.com/dgraph-io/ristretto/v2" + "github.com/flowline-io/flowbot/pkg/config" +) + +var Instance *Cache + +type Cache struct { + i *ristretto.Cache[string, any] +} + +func NewCache(_ config.Type) (*Cache, error) { + cache, err := ristretto.NewCache(&ristretto.Config[string, any]{ + NumCounters: 1e7, // number of keys to track frequency of (10M). + MaxCost: 1 << 30, // maximum cost of cache (1GB). + BufferItems: 64, // number of keys per Get buffer. + }) + if err != nil { + return nil, err + } + + Instance = &Cache{i: cache} + + return Instance, nil +} + +func (c *Cache) Set(key string, value any, cost int64) bool { + return c.i.Set(key, value, cost) +} + +func (c *Cache) SetWithTTL(key string, value any, cost int64, ttl time.Duration) bool { + return c.i.SetWithTTL(key, value, cost, ttl) +} + +func (c *Cache) Get(key string) (any, bool) { + return c.i.Get(key) +} + +func (c *Cache) Del(key string) { + c.i.Del(key) +} + +func (c *Cache) Wait() { + c.i.Wait() +} From 4a3c76f81f454c002ae8deaac4b8001f10344b43 Mon Sep 17 00:00:00 2001 From: sysatom Date: Thu, 8 May 2025 16:28:54 +0800 Subject: [PATCH 047/125] search fx --- internal/bots/bookmark/cron.go | 4 +-- internal/bots/dev/command.go | 6 ++-- internal/bots/search/page.go | 7 ++-- internal/bots/search/webservice.go | 6 ++-- internal/server/init.go | 9 ----- internal/server/modules.go | 2 ++ internal/server/server.go | 9 ++--- .../meilisearch.go => search/search.go} | 33 +++++++++++++++---- 8 files changed, 42 insertions(+), 34 deletions(-) rename pkg/{providers/meilisearch/meilisearch.go => search/search.go} (78%) diff --git a/internal/bots/bookmark/cron.go b/internal/bots/bookmark/cron.go index 65b3ce4b..538f5456 100644 --- a/internal/bots/bookmark/cron.go +++ b/internal/bots/bookmark/cron.go @@ -9,8 +9,8 @@ import ( "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/providers/hoarder" "github.com/flowline-io/flowbot/pkg/providers/kanboard" - "github.com/flowline-io/flowbot/pkg/providers/meilisearch" "github.com/flowline-io/flowbot/pkg/rdb" + "github.com/flowline-io/flowbot/pkg/search" "github.com/flowline-io/flowbot/pkg/stats" "github.com/flowline-io/flowbot/pkg/types" "github.com/flowline-io/flowbot/pkg/types/ruleset/cron" @@ -92,7 +92,7 @@ var cronRules = []cron.Rule{ for _, bookmark := range resp.Bookmarks { title := bookmark.GetTitle() summary := bookmark.GetSummary() - err := meilisearch.NewMeiliSearch().AddDocument(types.Document{ + err := search.Instance.AddDocument(types.Document{ SourceId: bookmark.Id, Source: hoarder.ID, Title: title, diff --git a/internal/bots/dev/command.go b/internal/bots/dev/command.go index f81f7c4b..9878af7f 100644 --- a/internal/bots/dev/command.go +++ b/internal/bots/dev/command.go @@ -17,9 +17,9 @@ import ( "github.com/flowline-io/flowbot/pkg/parser" "github.com/flowline-io/flowbot/pkg/providers/gitea" "github.com/flowline-io/flowbot/pkg/providers/hoarder" - "github.com/flowline-io/flowbot/pkg/providers/meilisearch" "github.com/flowline-io/flowbot/pkg/providers/safeline" "github.com/flowline-io/flowbot/pkg/providers/transmission" + "github.com/flowline-io/flowbot/pkg/search" "github.com/flowline-io/flowbot/pkg/types" "github.com/flowline-io/flowbot/pkg/types/ruleset/command" "github.com/flowline-io/flowbot/pkg/utils" @@ -235,7 +235,7 @@ var commandRules = []command.Rule{ Handler: func(ctx types.Context, tokens []*parser.Token) types.MsgPayload { flog.Info("dev bot environment config: %s", config.Environment) - err := meilisearch.NewMeiliSearch().AddDocument(types.Document{ + err := search.Instance.AddDocument(types.Document{ SourceId: types.Id(), Source: hoarder.ID, Title: "the title....", @@ -247,7 +247,7 @@ var commandRules = []command.Rule{ return types.TextMsg{Text: err.Error()} } - list, total, err := meilisearch.NewMeiliSearch().Search(gitea.ID, "title", 1, 10) + list, total, err := search.Instance.Search(gitea.ID, "title", 1, 10) if err != nil { return types.TextMsg{Text: err.Error()} } diff --git a/internal/bots/search/page.go b/internal/bots/search/page.go index de7e42f8..be877519 100644 --- a/internal/bots/search/page.go +++ b/internal/bots/search/page.go @@ -2,12 +2,13 @@ package search import ( "fmt" + "net/http" + "github.com/flowline-io/flowbot/pkg/page/uikit" - "github.com/flowline-io/flowbot/pkg/providers/meilisearch" + "github.com/flowline-io/flowbot/pkg/search" "github.com/flowline-io/flowbot/pkg/types" "github.com/flowline-io/flowbot/pkg/types/ruleset/page" "github.com/maxence-charriere/go-app/v10/pkg/app" - "net/http" ) const ( @@ -26,7 +27,7 @@ var pageRules = []page.Rule{ return nil, fmt.Errorf("empty keyword") } - list, _, err := meilisearch.NewMeiliSearch().Search(source, keyword, 1, 10) + list, _, err := search.Instance.Search(source, keyword, 1, 10) if err != nil { return nil, fmt.Errorf("search error: %s", err) } diff --git a/internal/bots/search/webservice.go b/internal/bots/search/webservice.go index 7ec13b36..930d1332 100644 --- a/internal/bots/search/webservice.go +++ b/internal/bots/search/webservice.go @@ -2,7 +2,7 @@ package search import ( "github.com/flowline-io/flowbot/pkg/flog" - "github.com/flowline-io/flowbot/pkg/providers/meilisearch" + "github.com/flowline-io/flowbot/pkg/search" "github.com/flowline-io/flowbot/pkg/types/protocol" "github.com/flowline-io/flowbot/pkg/types/ruleset/webservice" "github.com/gofiber/fiber/v2" @@ -29,7 +29,7 @@ func query(ctx *fiber.Ctx) error { return ctx.JSON(protocol.NewSuccessResponse(nil)) } - list, _, err := meilisearch.NewMeiliSearch().Search(source, q, 1, 10) + list, _, err := search.Instance.Search(source, q, 1, 10) if err != nil { flog.Error(err) return ctx.JSON(protocol.NewSuccessResponse(nil)) @@ -54,7 +54,7 @@ func autocomplete(ctx *fiber.Ctx) error { return ctx.JSON(protocol.NewSuccessResponse(nil)) } - list, _, err := meilisearch.NewMeiliSearch().Search(source, "title", 1, 10) + list, _, err := search.Instance.Search(source, "title", 1, 10) if err != nil { flog.Error(err) return ctx.JSON(protocol.NewSuccessResponse(nil)) diff --git a/internal/server/init.go b/internal/server/init.go index 3d14184f..ae06d75e 100644 --- a/internal/server/init.go +++ b/internal/server/init.go @@ -14,7 +14,6 @@ import ( "github.com/flowline-io/flowbot/pkg/config" "github.com/flowline-io/flowbot/pkg/event" "github.com/flowline-io/flowbot/pkg/flog" - "github.com/flowline-io/flowbot/pkg/providers/meilisearch" "github.com/flowline-io/flowbot/pkg/types" "github.com/flowline-io/flowbot/pkg/types/protocol" "github.com/flowline-io/flowbot/pkg/utils/sets" @@ -242,11 +241,3 @@ func initializeMetrics() error { }, ) } - -func initializeSearch() error { - err := meilisearch.NewMeiliSearch().DefaultIndexSettings() - if err != nil { - flog.Error(err) - } - return nil -} diff --git a/internal/server/modules.go b/internal/server/modules.go index 792d4a75..a67046f4 100644 --- a/internal/server/modules.go +++ b/internal/server/modules.go @@ -4,6 +4,7 @@ import ( "github.com/flowline-io/flowbot/pkg/cache" "github.com/flowline-io/flowbot/pkg/config" "github.com/flowline-io/flowbot/pkg/rdb" + "github.com/flowline-io/flowbot/pkg/search" "go.uber.org/fx" ) @@ -14,6 +15,7 @@ var Modules = fx.Options( config.NewConfig, cache.NewCache, rdb.NewClient, + search.NewClient, newController, newHTTPServer, ), diff --git a/internal/server/server.go b/internal/server/server.go index e05d3438..a2d54f9b 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -7,6 +7,7 @@ import ( "github.com/flowline-io/flowbot/pkg/cache" "github.com/flowline-io/flowbot/pkg/config" "github.com/flowline-io/flowbot/pkg/flog" + "github.com/flowline-io/flowbot/pkg/search" "github.com/gofiber/fiber/v2" "github.com/redis/go-redis/v9" "go.uber.org/fx" @@ -44,7 +45,7 @@ import ( _ "github.com/flowline-io/flowbot/pkg/notify/slack" ) -func RunServer(lc fx.Lifecycle, app *fiber.App, _ *cache.Cache, _ *redis.Client) { +func RunServer(lc fx.Lifecycle, app *fiber.App, _ *cache.Cache, _ *redis.Client, _ *search.Client) { lc.Append(fx.Hook{ OnStart: func(ctx context.Context) error { var err error @@ -91,12 +92,6 @@ func RunServer(lc fx.Lifecycle, app *fiber.App, _ *cache.Cache, _ *redis.Client) } flog.Info("initialize Metrics ok") - // init search - if err = initializeSearch(); err != nil { - return err - } - flog.Info("initialize Search ok") - // http server go func() { err := app.Listen(config.App.Listen) diff --git a/pkg/providers/meilisearch/meilisearch.go b/pkg/search/search.go similarity index 78% rename from pkg/providers/meilisearch/meilisearch.go rename to pkg/search/search.go index 93ad1ec4..29e0aec5 100644 --- a/pkg/providers/meilisearch/meilisearch.go +++ b/pkg/search/search.go @@ -1,6 +1,7 @@ -package meilisearch +package search import ( + "context" "fmt" "github.com/flowline-io/flowbot/pkg/config" @@ -11,19 +12,37 @@ import ( "github.com/goccy/go-json" jsoniter "github.com/json-iterator/go" "github.com/meilisearch/meilisearch-go" + "go.uber.org/fx" ) -type MeiliSearch struct { +var Instance *Client + +type Client struct { manager meilisearch.ServiceManager } -func NewMeiliSearch() MeiliSearch { - return MeiliSearch{ +func NewClient(lc fx.Lifecycle, _ config.Type) *Client { + Instance = &Client{ manager: meilisearch.New(config.App.Search.Endpoint, meilisearch.WithAPIKey(config.App.Search.MasterKey)), } + + lc.Append(fx.Hook{ + OnStart: func(ctx context.Context) error { + err := Instance.DefaultIndexSettings() + if err != nil { + flog.Error(err) + } + return nil + }, + OnStop: func(ctx context.Context) error { + return nil + }, + }) + + return Instance } -func (c MeiliSearch) AddDocument(data types.Document) error { +func (c *Client) AddDocument(data types.Document) error { // metrics stats.SearchProcessedDocumentTotalCounter(config.App.Search.DataIndex).Inc() @@ -45,7 +64,7 @@ func (c MeiliSearch) AddDocument(data types.Document) error { return nil } -func (c MeiliSearch) Search(source, query string, page, pageSize int32) (types.DocumentList, int64, error) { +func (c *Client) Search(source, query string, page, pageSize int32) (types.DocumentList, int64, error) { // metrics stats.SearchTotalCounter(config.App.Search.DataIndex).Inc() @@ -80,7 +99,7 @@ func (c MeiliSearch) Search(source, query string, page, pageSize int32) (types.D return list, resp.EstimatedTotalHits, nil } -func (c MeiliSearch) DefaultIndexSettings() error { +func (c *Client) DefaultIndexSettings() error { taskInfo, err := c.manager.Index(config.App.Search.DataIndex).UpdateSettings(&meilisearch.Settings{ SortableAttributes: []string{"created_at"}, FilterableAttributes: []string{"source"}, From ad5b042bcc34675b23a951a356375321aaaa75c2 Mon Sep 17 00:00:00 2001 From: sysatom Date: Thu, 8 May 2025 16:50:04 +0800 Subject: [PATCH 048/125] event fx --- internal/server/event.go | 53 ++++++++++++++++++++++++++++++++++++ internal/server/init.go | 55 -------------------------------------- internal/server/modules.go | 5 ++++ internal/server/server.go | 9 ++----- pkg/event/pubsub.go | 18 ++++++------- 5 files changed, 69 insertions(+), 71 deletions(-) diff --git a/internal/server/event.go b/internal/server/event.go index c1ad068d..0da0bd77 100644 --- a/internal/server/event.go +++ b/internal/server/event.go @@ -1,6 +1,7 @@ package server import ( + "context" "fmt" "time" @@ -11,8 +12,60 @@ import ( "github.com/flowline-io/flowbot/pkg/types" "github.com/flowline-io/flowbot/pkg/types/protocol" jsoniter "github.com/json-iterator/go" + "go.uber.org/fx" ) +// init event +func handleEvents(lc fx.Lifecycle, router *message.Router, subscriber message.Subscriber) error { + router.AddNoPublisherHandler( + "onMessageChannelEvent", + protocol.MessageChannelEvent, + subscriber, + onPlatformMessageEventHandler, + ) + router.AddNoPublisherHandler( + "onMessageDirectEvent", + protocol.MessageDirectEvent, + subscriber, + onPlatformMessageEventHandler, + ) + router.AddNoPublisherHandler( + "onMessageSendEventHandler", + types.MessageSendEvent, + subscriber, + onMessageSendEventHandler, + ) + router.AddNoPublisherHandler( + "onInstructPushEventHandler", + types.InstructPushEvent, + subscriber, + onInstructPushEventHandler, + ) + router.AddNoPublisherHandler( + "onBotRunEventHandler", + types.BotRunEvent, + subscriber, + onBotRunEventHandler, + ) + + lc.Append(fx.Hook{ + OnStart: func(ctx context.Context) error { + go func() { + if err := router.Run(context.Background()); err != nil { + flog.Error(err) + } + }() + + return nil + }, + OnStop: func(ctx context.Context) error { + return nil + }, + }) + + return nil +} + // send message func onMessageSendEventHandler(msg *message.Message) error { flog.Debug("[event] on event %+v %+v", msg.UUID, msg.Metadata) diff --git a/internal/server/init.go b/internal/server/init.go index ae06d75e..fcca8646 100644 --- a/internal/server/init.go +++ b/internal/server/init.go @@ -12,10 +12,7 @@ import ( "github.com/flowline-io/flowbot/internal/store/mysql" "github.com/flowline-io/flowbot/internal/workflow" "github.com/flowline-io/flowbot/pkg/config" - "github.com/flowline-io/flowbot/pkg/event" "github.com/flowline-io/flowbot/pkg/flog" - "github.com/flowline-io/flowbot/pkg/types" - "github.com/flowline-io/flowbot/pkg/types/protocol" "github.com/flowline-io/flowbot/pkg/utils/sets" "github.com/flowline-io/flowbot/version" "github.com/gofiber/fiber/v2" @@ -178,58 +175,6 @@ func initializeBot() { } } -// init event -func initializeEvent() error { - router, err := event.NewRouter() - if err != nil { - return err - } - - subscriber, err := event.NewSubscriber() - if err != nil { - return err - } - - router.AddNoPublisherHandler( - "onMessageChannelEvent", - protocol.MessageChannelEvent, - subscriber, - onPlatformMessageEventHandler, - ) - router.AddNoPublisherHandler( - "onMessageDirectEvent", - protocol.MessageDirectEvent, - subscriber, - onPlatformMessageEventHandler, - ) - router.AddNoPublisherHandler( - "onMessageSendEventHandler", - types.MessageSendEvent, - subscriber, - onMessageSendEventHandler, - ) - router.AddNoPublisherHandler( - "onInstructPushEventHandler", - types.InstructPushEvent, - subscriber, - onInstructPushEventHandler, - ) - router.AddNoPublisherHandler( - "onBotRunEventHandler", - types.BotRunEvent, - subscriber, - onBotRunEventHandler, - ) - - go func() { - if err = router.Run(context.Background()); err != nil { - flog.Error(err) - } - }() - - return nil -} - func initializeMetrics() error { return metrics.InitPushWithOptions( context.Background(), diff --git a/internal/server/modules.go b/internal/server/modules.go index a67046f4..6864e147 100644 --- a/internal/server/modules.go +++ b/internal/server/modules.go @@ -3,6 +3,7 @@ package server import ( "github.com/flowline-io/flowbot/pkg/cache" "github.com/flowline-io/flowbot/pkg/config" + "github.com/flowline-io/flowbot/pkg/event" "github.com/flowline-io/flowbot/pkg/rdb" "github.com/flowline-io/flowbot/pkg/search" "go.uber.org/fx" @@ -16,11 +17,15 @@ var Modules = fx.Options( cache.NewCache, rdb.NewClient, search.NewClient, + event.NewRouter, + event.NewSubscriber, + event.NewPublisher, newController, newHTTPServer, ), fx.Invoke( bindRoutes, + handleEvents, RunServer, ), ) diff --git a/internal/server/server.go b/internal/server/server.go index a2d54f9b..9d65ff64 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -4,6 +4,7 @@ import ( "context" "time" + "github.com/ThreeDotsLabs/watermill/message" "github.com/flowline-io/flowbot/pkg/cache" "github.com/flowline-io/flowbot/pkg/config" "github.com/flowline-io/flowbot/pkg/flog" @@ -45,7 +46,7 @@ import ( _ "github.com/flowline-io/flowbot/pkg/notify/slack" ) -func RunServer(lc fx.Lifecycle, app *fiber.App, _ *cache.Cache, _ *redis.Client, _ *search.Client) { +func RunServer(lc fx.Lifecycle, app *fiber.App, _ *cache.Cache, _ *redis.Client, _ *search.Client, _ message.Publisher) { lc.Append(fx.Hook{ OnStart: func(ctx context.Context) error { var err error @@ -74,12 +75,6 @@ func RunServer(lc fx.Lifecycle, app *fiber.App, _ *cache.Cache, _ *redis.Client, } flog.Info("initialize Media ok") - // init event - if err = initializeEvent(); err != nil { - return err - } - flog.Info("initialize Event ok") - // init chatbot if err = initializeChatbot(stopSignal); err != nil { return err diff --git a/pkg/event/pubsub.go b/pkg/event/pubsub.go index 2c677421..95e166fc 100644 --- a/pkg/event/pubsub.go +++ b/pkg/event/pubsub.go @@ -14,11 +14,12 @@ import ( "github.com/flowline-io/flowbot/pkg/rdb" "github.com/flowline-io/flowbot/pkg/stats" jsoniter "github.com/json-iterator/go" + "github.com/redis/go-redis/v9" ) var logger = flog.WatermillLogger -func NewSubscriber() (message.Subscriber, error) { +func NewSubscriber(_ *redis.Client) (message.Subscriber, error) { return redisstream.NewSubscriber( redisstream.SubscriberConfig{ Client: rdb.Client, @@ -28,14 +29,18 @@ func NewSubscriber() (message.Subscriber, error) { ) } -func NewPublisher() (message.Publisher, error) { - return redisstream.NewPublisher( +var Publisher message.Publisher + +func NewPublisher(_ *redis.Client) (message.Publisher, error) { + var err error + Publisher, err = redisstream.NewPublisher( redisstream.PublisherConfig{ Client: rdb.Client, Marshaller: redisstream.DefaultMarshallerUnmarshaller{}, }, logger, ) + return Publisher, err } func NewRouter() (*message.Router, error) { @@ -95,10 +100,5 @@ func PublishMessage(ctx context.Context, topic string, payload any) error { return fmt.Errorf("failed to new message: %w", err) } - publisher, err := NewPublisher() - if err != nil { - return fmt.Errorf("failed to new publisher: %w", err) - } - - return publisher.Publish(topic, msg) + return Publisher.Publish(topic, msg) } From d0095b2cbde7e3335ac416b0c118219e0c067e54 Mon Sep 17 00:00:00 2001 From: sysatom Date: Thu, 8 May 2025 17:15:07 +0800 Subject: [PATCH 049/125] workflow, database fx --- internal/server/database.go | 39 ++++++++++++++++++++++++++++++++ internal/server/globals.go | 6 ----- internal/server/hook.go | 6 ----- internal/server/init.go | 44 ------------------------------------ internal/server/modules.go | 5 ++++ internal/server/server.go | 14 ++++-------- internal/workflow/cron.go | 20 ++++++++++++++-- internal/workflow/manager.go | 18 +++++++++++++-- internal/workflow/queue.go | 21 ++++++++++++++--- 9 files changed, 100 insertions(+), 73 deletions(-) create mode 100644 internal/server/database.go diff --git a/internal/server/database.go b/internal/server/database.go new file mode 100644 index 00000000..1b9c55ab --- /dev/null +++ b/internal/server/database.go @@ -0,0 +1,39 @@ +package server + +import ( + "context" + "fmt" + + "github.com/flowline-io/flowbot/internal/store" + "github.com/flowline-io/flowbot/internal/store/mysql" + "github.com/flowline-io/flowbot/pkg/config" + "go.uber.org/fx" +) + +func newDatabaseAdapter(lc fx.Lifecycle, _ config.Type) (store.Adapter, error) { + // init database + mysql.Init() + store.Init() + + lc.Append(fx.Hook{ + OnStart: func(ctx context.Context) error { + // Open database + err := store.Store.Open(config.App.Store) + if err != nil { + return fmt.Errorf("failed to open DB, %w", err) + } + + // migrate + if err := store.Migrate(); err != nil { + return fmt.Errorf("failed to migrate DB, %w", err) + } + + return nil + }, + OnStop: func(ctx context.Context) error { + return store.Store.Close() + }, + }) + + return store.Database, nil +} diff --git a/internal/server/globals.go b/internal/server/globals.go index 568ccc67..7037b83f 100644 --- a/internal/server/globals.go +++ b/internal/server/globals.go @@ -3,7 +3,6 @@ package server import ( "time" - "github.com/flowline-io/flowbot/internal/workflow" "github.com/flowline-io/flowbot/pkg/types/ruleset/cron" ) @@ -21,9 +20,4 @@ var globals struct { // Cron cronRuleset []*cron.Ruleset - - // Workflow - taskQueue *workflow.Queue - manager *workflow.Manager - cronTaskManager *workflow.CronTaskManager } diff --git a/internal/server/hook.go b/internal/server/hook.go index 2366abf9..4aa46cef 100644 --- a/internal/server/hook.go +++ b/internal/server/hook.go @@ -50,12 +50,6 @@ func hookBot(botsConfig interface{}, vendorsConfig interface{}) { flog.Fatal("Failed to bot cron: %v", err) } - // bot workflow - err = initializeWorkflow() - if err != nil { - flog.Fatal("Failed to initialize workflow: %v", err) - } - stats.BotTotalCounter().Set(uint64(len(bots.List()))) rdb.SetInt64(stats.BotTotalStatsName, int64(len(bots.List()))) } diff --git a/internal/server/init.go b/internal/server/init.go index fcca8646..784377a7 100644 --- a/internal/server/init.go +++ b/internal/server/init.go @@ -9,8 +9,6 @@ import ( "github.com/flowline-io/flowbot/internal/bots" "github.com/flowline-io/flowbot/internal/store" "github.com/flowline-io/flowbot/internal/store/model" - "github.com/flowline-io/flowbot/internal/store/mysql" - "github.com/flowline-io/flowbot/internal/workflow" "github.com/flowline-io/flowbot/pkg/config" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/utils/sets" @@ -42,33 +40,6 @@ func initializeTimezone() error { return nil } -func initializeDatabase() error { - // init database - mysql.Init() - store.Init() - - // Open database - err := store.Store.Open(config.App.Store) - if err != nil { - return fmt.Errorf("failed to open DB, %w", err) - } - go func() { - <-stopSignal - err = store.Store.Close() - if err != nil { - flog.Error(err) - } - flog.Debug("Closed database connection(s)") - }() - - // migrate - if err := store.Migrate(); err != nil { - return fmt.Errorf("failed to migrate DB, %w", err) - } - - return nil -} - func initializeMedia() error { // Media if config.App.Media != nil { @@ -116,21 +87,6 @@ func initializeChatbot(signal <-chan bool) error { return nil } -// init workflow -func initializeWorkflow() error { - // Task queue - globals.taskQueue = workflow.NewQueue() - go globals.taskQueue.Run() - // manager - globals.manager = workflow.NewManager() - go globals.manager.Run() - // cron task manager - globals.cronTaskManager = workflow.NewCronTaskManager() - go globals.cronTaskManager.Run() - - return nil -} - // init bots func initializeBot() { // register bots diff --git a/internal/server/modules.go b/internal/server/modules.go index 6864e147..e0d5b9b8 100644 --- a/internal/server/modules.go +++ b/internal/server/modules.go @@ -1,6 +1,7 @@ package server import ( + "github.com/flowline-io/flowbot/internal/workflow" "github.com/flowline-io/flowbot/pkg/cache" "github.com/flowline-io/flowbot/pkg/config" "github.com/flowline-io/flowbot/pkg/event" @@ -20,7 +21,11 @@ var Modules = fx.Options( event.NewRouter, event.NewSubscriber, event.NewPublisher, + workflow.NewQueue, + workflow.NewManager, + workflow.NewCronTaskManager, newController, + newDatabaseAdapter, newHTTPServer, ), fx.Invoke( diff --git a/internal/server/server.go b/internal/server/server.go index 9d65ff64..1d17dce6 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -34,6 +34,8 @@ import ( _ "github.com/flowline-io/flowbot/internal/bots/user" _ "github.com/flowline-io/flowbot/internal/bots/webhook" _ "github.com/flowline-io/flowbot/internal/bots/workflow" + "github.com/flowline-io/flowbot/internal/store" + "github.com/flowline-io/flowbot/internal/workflow" // File upload handlers _ "github.com/flowline-io/flowbot/pkg/media/fs" @@ -46,7 +48,8 @@ import ( _ "github.com/flowline-io/flowbot/pkg/notify/slack" ) -func RunServer(lc fx.Lifecycle, app *fiber.App, _ *cache.Cache, _ *redis.Client, _ *search.Client, _ message.Publisher) { +func RunServer(lc fx.Lifecycle, app *fiber.App, _ store.Adapter, _ *cache.Cache, _ *redis.Client, _ *search.Client, _ message.Publisher, + _ *workflow.Queue, _ *workflow.Manager, _ *workflow.CronTaskManager) { lc.Append(fx.Hook{ OnStart: func(ctx context.Context) error { var err error @@ -63,12 +66,6 @@ func RunServer(lc fx.Lifecycle, app *fiber.App, _ *cache.Cache, _ *redis.Client, } flog.Info("initialize Timezone ok") - // init database - if err = initializeDatabase(); err != nil { - return err - } - flog.Info("initialize Database ok") - // init media if err = initializeMedia(); err != nil { return err @@ -108,9 +105,6 @@ func RunServer(lc fx.Lifecycle, app *fiber.App, _ *cache.Cache, _ *redis.Client, cancel() // Shutdown Extra - globals.taskQueue.Shutdown() - globals.manager.Shutdown() - globals.cronTaskManager.Shutdown() for _, ruleset := range globals.cronRuleset { ruleset.Shutdown() } diff --git a/internal/workflow/cron.go b/internal/workflow/cron.go index a5ad4d93..d9de407b 100644 --- a/internal/workflow/cron.go +++ b/internal/workflow/cron.go @@ -1,6 +1,7 @@ package workflow import ( + "context" "time" "github.com/flowline-io/flowbot/internal/store" @@ -10,13 +11,15 @@ import ( "github.com/flowline-io/flowbot/pkg/types" "github.com/hibiken/asynq" jsoniter "github.com/json-iterator/go" + "github.com/redis/go-redis/v9" + "go.uber.org/fx" ) type CronTaskManager struct { mgr *asynq.PeriodicTaskManager } -func NewCronTaskManager() *CronTaskManager { +func NewCronTaskManager(lc fx.Lifecycle, _ *redis.Client, _ store.Adapter) *CronTaskManager { provider := &DatabaseProvider{} mgr, err := asynq.NewPeriodicTaskManager(asynq.PeriodicTaskManagerOpts{ RedisConnOpt: defaultRedisClientOpt(), @@ -41,7 +44,20 @@ func NewCronTaskManager() *CronTaskManager { if err != nil { flog.Fatal("error %v", err) } - return &CronTaskManager{mgr: mgr} + i := &CronTaskManager{mgr: mgr} + + lc.Append(fx.Hook{ + OnStart: func(ctx context.Context) error { + go i.Run() + return nil + }, + OnStop: func(ctx context.Context) error { + i.Shutdown() + return nil + }, + }) + + return i } func (c *CronTaskManager) Run() { diff --git a/internal/workflow/manager.go b/internal/workflow/manager.go index 06703f86..033c9de4 100644 --- a/internal/workflow/manager.go +++ b/internal/workflow/manager.go @@ -11,16 +11,30 @@ import ( "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/utils/parallelizer" "github.com/hibiken/asynq" + "go.uber.org/fx" ) type Manager struct { stop chan struct{} } -func NewManager() *Manager { - return &Manager{ +func NewManager(lc fx.Lifecycle, _ store.Adapter) *Manager { + i := &Manager{ stop: make(chan struct{}), } + + lc.Append(fx.Hook{ + OnStart: func(ctx context.Context) error { + i.Run() + return nil + }, + OnStop: func(ctx context.Context) error { + i.Shutdown() + return nil + }, + }) + + return i } func (m *Manager) Run() { diff --git a/internal/workflow/queue.go b/internal/workflow/queue.go index dbe9bc43..a2cbdf21 100644 --- a/internal/workflow/queue.go +++ b/internal/workflow/queue.go @@ -3,13 +3,15 @@ package workflow import ( "context" "fmt" - "github.com/flowline-io/flowbot/pkg/stats" "runtime" "time" "github.com/flowline-io/flowbot/pkg/config" "github.com/flowline-io/flowbot/pkg/flog" + "github.com/flowline-io/flowbot/pkg/stats" "github.com/hibiken/asynq" + "github.com/redis/go-redis/v9" + "go.uber.org/fx" ) const ( @@ -58,7 +60,7 @@ type Queue struct { srv *asynq.Server } -func NewQueue() *Queue { +func NewQueue(lc fx.Lifecycle, _ config.Type, _ *redis.Client) *Queue { srv := asynq.NewServer(defaultRedisClientOpt(), asynq.Config{ Logger: flog.AsynqLogger, LogLevel: flog.AsynqLogLevel(config.App.Log.Level), @@ -68,7 +70,20 @@ func NewQueue() *Queue { cronQueueName: 10, }, }) - return &Queue{srv: srv} + i := &Queue{srv: srv} + + lc.Append(fx.Hook{ + OnStart: func(ctx context.Context) error { + go i.Run() + return nil + }, + OnStop: func(ctx context.Context) error { + i.Shutdown() + return nil + }, + }) + + return i } func (q *Queue) Run() { From 8bd7b3b05c4c75a07a6c7c913fe6bbf61757af14 Mon Sep 17 00:00:00 2001 From: sysatom Date: Thu, 8 May 2025 18:08:11 +0800 Subject: [PATCH 050/125] bot modules --- internal/bots/agent/bot.go | 2 +- internal/bots/anki/bot.go | 2 +- internal/bots/bookmark/bot.go | 2 +- internal/bots/clipboard/bot.go | 2 +- internal/bots/cloudflare/bot.go | 2 +- internal/bots/dev/bot.go | 2 +- internal/bots/finance/bot.go | 2 +- internal/bots/gitea/bot.go | 2 +- internal/bots/github/bot.go | 2 +- internal/bots/kanban/bot.go | 2 +- internal/bots/notify/bot.go | 2 +- internal/bots/obsidian/bot.go | 2 +- internal/bots/okr/bot.go | 2 +- internal/bots/reader/bot.go | 2 +- internal/bots/search/bot.go | 2 +- internal/bots/server/bot.go | 2 +- internal/bots/torrent/bot.go | 2 +- internal/bots/user/bot.go | 2 +- internal/bots/webhook/bot.go | 2 +- internal/bots/workflow/bot.go | 2 +- internal/server/bots.go | 50 +++++++++++++++++++++++++++++++++ internal/server/modules.go | 3 +- internal/server/server.go | 26 ++--------------- 23 files changed, 73 insertions(+), 46 deletions(-) create mode 100644 internal/server/bots.go diff --git a/internal/bots/agent/bot.go b/internal/bots/agent/bot.go index 54bf561f..9905071c 100644 --- a/internal/bots/agent/bot.go +++ b/internal/bots/agent/bot.go @@ -14,7 +14,7 @@ const Name = "agent" var handler bot -func init() { +func Register() { bots.Register(Name, &handler) } diff --git a/internal/bots/anki/bot.go b/internal/bots/anki/bot.go index 8f6235fc..8d810123 100644 --- a/internal/bots/anki/bot.go +++ b/internal/bots/anki/bot.go @@ -15,7 +15,7 @@ const Name = "anki" var handler bot -func init() { +func Register() { bots.Register(Name, &handler) } diff --git a/internal/bots/bookmark/bot.go b/internal/bots/bookmark/bot.go index c6daea0f..d0f56575 100644 --- a/internal/bots/bookmark/bot.go +++ b/internal/bots/bookmark/bot.go @@ -16,7 +16,7 @@ const Name = "bookmark" var handler bot var Config configType -func init() { +func Register() { bots.Register(Name, &handler) } diff --git a/internal/bots/clipboard/bot.go b/internal/bots/clipboard/bot.go index 1a062403..6f4f64a8 100644 --- a/internal/bots/clipboard/bot.go +++ b/internal/bots/clipboard/bot.go @@ -15,7 +15,7 @@ const Name = "clipboard" var handler bot -func init() { +func Register() { bots.Register(Name, &handler) } diff --git a/internal/bots/cloudflare/bot.go b/internal/bots/cloudflare/bot.go index 7d62493a..2e25978a 100644 --- a/internal/bots/cloudflare/bot.go +++ b/internal/bots/cloudflare/bot.go @@ -14,7 +14,7 @@ const Name = "cloudflare" var handler bot -func init() { +func Register() { bots.Register(Name, &handler) } diff --git a/internal/bots/dev/bot.go b/internal/bots/dev/bot.go index e182d0a8..7ca103c9 100644 --- a/internal/bots/dev/bot.go +++ b/internal/bots/dev/bot.go @@ -17,7 +17,7 @@ const Name = "dev" var handler bot var config configType -func init() { +func Register() { bots.Register(Name, &handler) } diff --git a/internal/bots/finance/bot.go b/internal/bots/finance/bot.go index a205f47e..f6d99760 100644 --- a/internal/bots/finance/bot.go +++ b/internal/bots/finance/bot.go @@ -15,7 +15,7 @@ const Name = "finance" var handler bot -func init() { +func Register() { bots.Register(Name, &handler) } diff --git a/internal/bots/gitea/bot.go b/internal/bots/gitea/bot.go index b8606903..befbfeed 100644 --- a/internal/bots/gitea/bot.go +++ b/internal/bots/gitea/bot.go @@ -15,7 +15,7 @@ const Name = "gitea" var handler bot -func init() { +func Register() { bots.Register(Name, &handler) } diff --git a/internal/bots/github/bot.go b/internal/bots/github/bot.go index f5febc77..f7765d6d 100644 --- a/internal/bots/github/bot.go +++ b/internal/bots/github/bot.go @@ -16,7 +16,7 @@ const Name = "github" var handler bot var Config configType -func init() { +func Register() { bots.Register(Name, &handler) } diff --git a/internal/bots/kanban/bot.go b/internal/bots/kanban/bot.go index 5b4874c6..5de90817 100755 --- a/internal/bots/kanban/bot.go +++ b/internal/bots/kanban/bot.go @@ -15,7 +15,7 @@ const Name = "kanban" var handler bot -func init() { +func Register() { bots.Register(Name, &handler) } diff --git a/internal/bots/notify/bot.go b/internal/bots/notify/bot.go index b150fdb7..10815b69 100644 --- a/internal/bots/notify/bot.go +++ b/internal/bots/notify/bot.go @@ -14,7 +14,7 @@ const Name = "notify" var handler bot -func init() { +func Register() { bots.Register(Name, &handler) } diff --git a/internal/bots/obsidian/bot.go b/internal/bots/obsidian/bot.go index ec6febb6..c566f153 100644 --- a/internal/bots/obsidian/bot.go +++ b/internal/bots/obsidian/bot.go @@ -14,7 +14,7 @@ const Name = "obsidian" var handler bot -func init() { +func Register() { bots.Register(Name, &handler) } diff --git a/internal/bots/okr/bot.go b/internal/bots/okr/bot.go index 5d38b928..3cc98d3a 100644 --- a/internal/bots/okr/bot.go +++ b/internal/bots/okr/bot.go @@ -15,7 +15,7 @@ const Name = "okr" var handler bot -func init() { +func Register() { bots.Register(Name, &handler) } diff --git a/internal/bots/reader/bot.go b/internal/bots/reader/bot.go index 375aefe9..a84e392c 100644 --- a/internal/bots/reader/bot.go +++ b/internal/bots/reader/bot.go @@ -14,7 +14,7 @@ const Name = "reader" var handler bot -func init() { +func Register() { bots.Register(Name, &handler) } diff --git a/internal/bots/search/bot.go b/internal/bots/search/bot.go index 185b2384..1bb3011c 100755 --- a/internal/bots/search/bot.go +++ b/internal/bots/search/bot.go @@ -16,7 +16,7 @@ const Name = "search" var handler bot -func init() { +func Register() { bots.Register(Name, &handler) } diff --git a/internal/bots/server/bot.go b/internal/bots/server/bot.go index e2abb46a..841b22e1 100644 --- a/internal/bots/server/bot.go +++ b/internal/bots/server/bot.go @@ -16,7 +16,7 @@ const Name = "server" var handler bot -func init() { +func Register() { bots.Register(Name, &handler) } diff --git a/internal/bots/torrent/bot.go b/internal/bots/torrent/bot.go index 7e42197d..84399514 100644 --- a/internal/bots/torrent/bot.go +++ b/internal/bots/torrent/bot.go @@ -14,7 +14,7 @@ const Name = "torrent" var handler bot -func init() { +func Register() { bots.Register(Name, &handler) } diff --git a/internal/bots/user/bot.go b/internal/bots/user/bot.go index d2a4f924..76c26660 100644 --- a/internal/bots/user/bot.go +++ b/internal/bots/user/bot.go @@ -15,7 +15,7 @@ const Name = "user" var handler bot -func init() { +func Register() { bots.Register(Name, &handler) } diff --git a/internal/bots/webhook/bot.go b/internal/bots/webhook/bot.go index 252ab2ed..ee57ec36 100644 --- a/internal/bots/webhook/bot.go +++ b/internal/bots/webhook/bot.go @@ -14,7 +14,7 @@ const Name = "webhook" var handler bot -func init() { +func Register() { bots.Register(Name, &handler) } diff --git a/internal/bots/workflow/bot.go b/internal/bots/workflow/bot.go index f8481754..9c779192 100644 --- a/internal/bots/workflow/bot.go +++ b/internal/bots/workflow/bot.go @@ -16,7 +16,7 @@ const Name = "workflow" var handler bot -func init() { +func Register() { bots.Register(Name, &handler) } diff --git a/internal/server/bots.go b/internal/server/bots.go new file mode 100644 index 00000000..05009a52 --- /dev/null +++ b/internal/server/bots.go @@ -0,0 +1,50 @@ +package server + +import ( + "github.com/flowline-io/flowbot/internal/bots/agent" + "github.com/flowline-io/flowbot/internal/bots/anki" + "github.com/flowline-io/flowbot/internal/bots/bookmark" + "github.com/flowline-io/flowbot/internal/bots/clipboard" + "github.com/flowline-io/flowbot/internal/bots/cloudflare" + "github.com/flowline-io/flowbot/internal/bots/dev" + "github.com/flowline-io/flowbot/internal/bots/finance" + "github.com/flowline-io/flowbot/internal/bots/gitea" + "github.com/flowline-io/flowbot/internal/bots/github" + "github.com/flowline-io/flowbot/internal/bots/kanban" + "github.com/flowline-io/flowbot/internal/bots/notify" + "github.com/flowline-io/flowbot/internal/bots/obsidian" + "github.com/flowline-io/flowbot/internal/bots/okr" + "github.com/flowline-io/flowbot/internal/bots/reader" + "github.com/flowline-io/flowbot/internal/bots/search" + "github.com/flowline-io/flowbot/internal/bots/server" + "github.com/flowline-io/flowbot/internal/bots/torrent" + "github.com/flowline-io/flowbot/internal/bots/user" + "github.com/flowline-io/flowbot/internal/bots/webhook" + "github.com/flowline-io/flowbot/internal/bots/workflow" + "go.uber.org/fx" +) + +var BotsModules = fx.Options( + fx.Invoke( + agent.Register, + anki.Register, + bookmark.Register, + clipboard.Register, + cloudflare.Register, + dev.Register, + finance.Register, + gitea.Register, + github.Register, + kanban.Register, + notify.Register, + obsidian.Register, + okr.Register, + reader.Register, + search.Register, + server.Register, + torrent.Register, + user.Register, + webhook.Register, + workflow.Register, + ), +) diff --git a/internal/server/modules.go b/internal/server/modules.go index e0d5b9b8..617d9fcb 100644 --- a/internal/server/modules.go +++ b/internal/server/modules.go @@ -11,8 +11,7 @@ import ( ) var Modules = fx.Options( - // controller.Modules, - // repository.Modules, + BotsModules, fx.Provide( config.NewConfig, cache.NewCache, diff --git a/internal/server/server.go b/internal/server/server.go index 1d17dce6..e8203f00 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -5,6 +5,8 @@ import ( "time" "github.com/ThreeDotsLabs/watermill/message" + "github.com/flowline-io/flowbot/internal/store" + "github.com/flowline-io/flowbot/internal/workflow" "github.com/flowline-io/flowbot/pkg/cache" "github.com/flowline-io/flowbot/pkg/config" "github.com/flowline-io/flowbot/pkg/flog" @@ -13,30 +15,6 @@ import ( "github.com/redis/go-redis/v9" "go.uber.org/fx" - // bots - _ "github.com/flowline-io/flowbot/internal/bots/agent" - _ "github.com/flowline-io/flowbot/internal/bots/anki" - _ "github.com/flowline-io/flowbot/internal/bots/bookmark" - _ "github.com/flowline-io/flowbot/internal/bots/clipboard" - _ "github.com/flowline-io/flowbot/internal/bots/cloudflare" - _ "github.com/flowline-io/flowbot/internal/bots/dev" - _ "github.com/flowline-io/flowbot/internal/bots/finance" - _ "github.com/flowline-io/flowbot/internal/bots/gitea" - _ "github.com/flowline-io/flowbot/internal/bots/github" - _ "github.com/flowline-io/flowbot/internal/bots/kanban" - _ "github.com/flowline-io/flowbot/internal/bots/notify" - _ "github.com/flowline-io/flowbot/internal/bots/obsidian" - _ "github.com/flowline-io/flowbot/internal/bots/okr" - _ "github.com/flowline-io/flowbot/internal/bots/reader" - _ "github.com/flowline-io/flowbot/internal/bots/search" - _ "github.com/flowline-io/flowbot/internal/bots/server" - _ "github.com/flowline-io/flowbot/internal/bots/torrent" - _ "github.com/flowline-io/flowbot/internal/bots/user" - _ "github.com/flowline-io/flowbot/internal/bots/webhook" - _ "github.com/flowline-io/flowbot/internal/bots/workflow" - "github.com/flowline-io/flowbot/internal/store" - "github.com/flowline-io/flowbot/internal/workflow" - // File upload handlers _ "github.com/flowline-io/flowbot/pkg/media/fs" _ "github.com/flowline-io/flowbot/pkg/media/minio" From 85bc94250a0e5f158e73a45b1eeaed07ec16a71c Mon Sep 17 00:00:00 2001 From: sysatom Date: Thu, 8 May 2025 18:17:21 +0800 Subject: [PATCH 051/125] media, notify modules --- internal/server/media.go | 14 ++++++++++++++ internal/server/modules.go | 2 ++ internal/server/notify.go | 19 +++++++++++++++++++ internal/server/server.go | 10 ---------- pkg/media/fs/filesys.go | 2 +- pkg/media/minio/minio.go | 2 +- pkg/notify/message-pusher/message_pusher.go | 2 +- pkg/notify/ntfy/notify.go | 2 +- pkg/notify/pushover/notify.go | 2 +- pkg/notify/slack/slack.go | 2 +- 10 files changed, 41 insertions(+), 16 deletions(-) create mode 100644 internal/server/media.go create mode 100644 internal/server/notify.go diff --git a/internal/server/media.go b/internal/server/media.go new file mode 100644 index 00000000..91f6df78 --- /dev/null +++ b/internal/server/media.go @@ -0,0 +1,14 @@ +package server + +import ( + "github.com/flowline-io/flowbot/pkg/media/fs" + "github.com/flowline-io/flowbot/pkg/media/minio" + "go.uber.org/fx" +) + +var MediaModules = fx.Options( + fx.Invoke( + fs.Register, + minio.Register, + ), +) diff --git a/internal/server/modules.go b/internal/server/modules.go index 617d9fcb..00fbc898 100644 --- a/internal/server/modules.go +++ b/internal/server/modules.go @@ -12,6 +12,8 @@ import ( var Modules = fx.Options( BotsModules, + NotifyModules, + MediaModules, fx.Provide( config.NewConfig, cache.NewCache, diff --git a/internal/server/notify.go b/internal/server/notify.go new file mode 100644 index 00000000..f46754b8 --- /dev/null +++ b/internal/server/notify.go @@ -0,0 +1,19 @@ +package server + +import ( + message_pusher "github.com/flowline-io/flowbot/pkg/notify/message-pusher" + "github.com/flowline-io/flowbot/pkg/notify/ntfy" + "github.com/flowline-io/flowbot/pkg/notify/pushover" + "github.com/flowline-io/flowbot/pkg/notify/slack" + "go.uber.org/fx" +) + + +var NotifyModules = fx.Options( + fx.Invoke( + message_pusher.Register, + ntfy.Register, + pushover.Register, + slack.Register, + ), +) diff --git a/internal/server/server.go b/internal/server/server.go index e8203f00..78e6333f 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -14,16 +14,6 @@ import ( "github.com/gofiber/fiber/v2" "github.com/redis/go-redis/v9" "go.uber.org/fx" - - // File upload handlers - _ "github.com/flowline-io/flowbot/pkg/media/fs" - _ "github.com/flowline-io/flowbot/pkg/media/minio" - - // Notify - _ "github.com/flowline-io/flowbot/pkg/notify/message-pusher" - _ "github.com/flowline-io/flowbot/pkg/notify/ntfy" - _ "github.com/flowline-io/flowbot/pkg/notify/pushover" - _ "github.com/flowline-io/flowbot/pkg/notify/slack" ) func RunServer(lc fx.Lifecycle, app *fiber.App, _ store.Adapter, _ *cache.Cache, _ *redis.Client, _ *search.Client, _ message.Publisher, diff --git a/pkg/media/fs/filesys.go b/pkg/media/fs/filesys.go index dbbb5a9e..57f31b22 100644 --- a/pkg/media/fs/filesys.go +++ b/pkg/media/fs/filesys.go @@ -166,6 +166,6 @@ func (fh *fshandler) getFileRecord(fid types.Uid) (*types.FileDef, error) { return fd, nil } -func init() { +func Register() { store.RegisterMediaHandler(handlerName, &fshandler{}) } diff --git a/pkg/media/minio/minio.go b/pkg/media/minio/minio.go index d506476a..8cf1a285 100644 --- a/pkg/media/minio/minio.go +++ b/pkg/media/minio/minio.go @@ -202,6 +202,6 @@ func (ah *handler) presignedURL(fdef *types.FileDef) (string, error) { return presignedURL.String(), nil } -func init() { +func Register() { store.RegisterMediaHandler(handlerName, &handler{}) } diff --git a/pkg/notify/message-pusher/message_pusher.go b/pkg/notify/message-pusher/message_pusher.go index f3e778f9..559d3ec5 100644 --- a/pkg/notify/message-pusher/message_pusher.go +++ b/pkg/notify/message-pusher/message_pusher.go @@ -15,7 +15,7 @@ var handler plugin type plugin struct{} -func init() { +func Register() { notify.Register(ID, &handler) } diff --git a/pkg/notify/ntfy/notify.go b/pkg/notify/ntfy/notify.go index a9dc9bba..7f85d5ca 100644 --- a/pkg/notify/ntfy/notify.go +++ b/pkg/notify/ntfy/notify.go @@ -16,7 +16,7 @@ var handler plugin type plugin struct{} -func init() { +func Register() { notify.Register(ID, &handler) } diff --git a/pkg/notify/pushover/notify.go b/pkg/notify/pushover/notify.go index f67ddd4e..2fae2659 100644 --- a/pkg/notify/pushover/notify.go +++ b/pkg/notify/pushover/notify.go @@ -11,7 +11,7 @@ var handler plugin type plugin struct{} -func init() { +func Register() { notify.Register(ID, &handler) } diff --git a/pkg/notify/slack/slack.go b/pkg/notify/slack/slack.go index b1c50492..81958879 100644 --- a/pkg/notify/slack/slack.go +++ b/pkg/notify/slack/slack.go @@ -17,7 +17,7 @@ var handler plugin type plugin struct{} -func init() { +func Register() { notify.Register(ID, &handler) } From 7159c537c2720734f1ece6b52751f57c76abe691 Mon Sep 17 00:00:00 2001 From: sysatom Date: Thu, 8 May 2025 18:50:55 +0800 Subject: [PATCH 052/125] chatbot fx --- internal/server/bots.go | 50 ----------- internal/server/chatbot.go | 169 ++++++++++++++++++++++++++++++++++++ internal/server/database.go | 22 ++--- internal/server/event.go | 11 ++- internal/server/hook.go | 72 --------------- internal/server/http.go | 2 +- internal/server/init.go | 62 ------------- internal/server/modules.go | 1 + internal/server/server.go | 6 -- 9 files changed, 192 insertions(+), 203 deletions(-) delete mode 100644 internal/server/bots.go create mode 100644 internal/server/chatbot.go delete mode 100644 internal/server/hook.go diff --git a/internal/server/bots.go b/internal/server/bots.go deleted file mode 100644 index 05009a52..00000000 --- a/internal/server/bots.go +++ /dev/null @@ -1,50 +0,0 @@ -package server - -import ( - "github.com/flowline-io/flowbot/internal/bots/agent" - "github.com/flowline-io/flowbot/internal/bots/anki" - "github.com/flowline-io/flowbot/internal/bots/bookmark" - "github.com/flowline-io/flowbot/internal/bots/clipboard" - "github.com/flowline-io/flowbot/internal/bots/cloudflare" - "github.com/flowline-io/flowbot/internal/bots/dev" - "github.com/flowline-io/flowbot/internal/bots/finance" - "github.com/flowline-io/flowbot/internal/bots/gitea" - "github.com/flowline-io/flowbot/internal/bots/github" - "github.com/flowline-io/flowbot/internal/bots/kanban" - "github.com/flowline-io/flowbot/internal/bots/notify" - "github.com/flowline-io/flowbot/internal/bots/obsidian" - "github.com/flowline-io/flowbot/internal/bots/okr" - "github.com/flowline-io/flowbot/internal/bots/reader" - "github.com/flowline-io/flowbot/internal/bots/search" - "github.com/flowline-io/flowbot/internal/bots/server" - "github.com/flowline-io/flowbot/internal/bots/torrent" - "github.com/flowline-io/flowbot/internal/bots/user" - "github.com/flowline-io/flowbot/internal/bots/webhook" - "github.com/flowline-io/flowbot/internal/bots/workflow" - "go.uber.org/fx" -) - -var BotsModules = fx.Options( - fx.Invoke( - agent.Register, - anki.Register, - bookmark.Register, - clipboard.Register, - cloudflare.Register, - dev.Register, - finance.Register, - gitea.Register, - github.Register, - kanban.Register, - notify.Register, - obsidian.Register, - okr.Register, - reader.Register, - search.Register, - server.Register, - torrent.Register, - user.Register, - webhook.Register, - workflow.Register, - ), -) diff --git a/internal/server/chatbot.go b/internal/server/chatbot.go new file mode 100644 index 00000000..d2bf0e49 --- /dev/null +++ b/internal/server/chatbot.go @@ -0,0 +1,169 @@ +package server + +import ( + "context" + "fmt" + + "github.com/flowline-io/flowbot/internal/bots" + "github.com/flowline-io/flowbot/internal/bots/agent" + "github.com/flowline-io/flowbot/internal/bots/anki" + "github.com/flowline-io/flowbot/internal/bots/bookmark" + "github.com/flowline-io/flowbot/internal/bots/clipboard" + "github.com/flowline-io/flowbot/internal/bots/cloudflare" + "github.com/flowline-io/flowbot/internal/bots/dev" + "github.com/flowline-io/flowbot/internal/bots/finance" + "github.com/flowline-io/flowbot/internal/bots/gitea" + "github.com/flowline-io/flowbot/internal/bots/github" + "github.com/flowline-io/flowbot/internal/bots/kanban" + "github.com/flowline-io/flowbot/internal/bots/notify" + "github.com/flowline-io/flowbot/internal/bots/obsidian" + "github.com/flowline-io/flowbot/internal/bots/okr" + "github.com/flowline-io/flowbot/internal/bots/reader" + "github.com/flowline-io/flowbot/internal/bots/search" + "github.com/flowline-io/flowbot/internal/bots/server" + "github.com/flowline-io/flowbot/internal/bots/torrent" + "github.com/flowline-io/flowbot/internal/bots/user" + "github.com/flowline-io/flowbot/internal/bots/webhook" + "github.com/flowline-io/flowbot/internal/bots/workflow" + "github.com/flowline-io/flowbot/internal/store" + "github.com/flowline-io/flowbot/internal/store/model" + "github.com/flowline-io/flowbot/pkg/config" + "github.com/flowline-io/flowbot/pkg/flog" + "github.com/flowline-io/flowbot/pkg/providers" + "github.com/flowline-io/flowbot/pkg/rdb" + "github.com/flowline-io/flowbot/pkg/stats" + "github.com/flowline-io/flowbot/pkg/utils/sets" + "github.com/flowline-io/flowbot/version" + jsoniter "github.com/json-iterator/go" + "github.com/redis/go-redis/v9" + "go.uber.org/fx" +) + +var BotsModules = fx.Options( + fx.Invoke( + agent.Register, + anki.Register, + bookmark.Register, + clipboard.Register, + cloudflare.Register, + dev.Register, + finance.Register, + gitea.Register, + github.Register, + kanban.Register, + notify.Register, + obsidian.Register, + okr.Register, + reader.Register, + search.Register, + server.Register, + torrent.Register, + user.Register, + webhook.Register, + workflow.Register, + ), +) + +func handleChatbot(lc fx.Lifecycle, _ config.Type, _ store.Adapter, _ *redis.Client) error { + // Initialize bots + initializeBot(config.App.Bots, config.App.Vendors) + + lc.Append(fx.Hook{ + OnStart: func(ctx context.Context) error { + // notify after online + go notifyAll(fmt.Sprintf("flowbot (%s) online", version.Buildtags)) + + // Platform + hookPlatform(make(<-chan bool)) + + return nil + }, + OnStop: func(ctx context.Context) error { + return nil + }, + }) + + return nil +} + +// register bots +func registerBot() { + // register bots + registerBots := sets.NewString() + for name, handler := range bots.List() { + registerBots.Insert(name) + + state := model.BotInactive + if handler.IsReady() { + state = model.BotActive + } + bot, _ := store.Database.GetBotByName(name) + if bot == nil { + bot = &model.Bot{ + Name: name, + State: state, + } + if _, err := store.Database.CreateBot(bot); err != nil { + flog.Error(err) + } + } else { + bot.State = state + err := store.Database.UpdateBot(bot) + if err != nil { + flog.Error(err) + } + } + } + + // inactive bot + list, err := store.Database.GetBots() + if err != nil { + flog.Error(err) + } + for _, bot := range list { + if !registerBots.Has(bot.Name) { + bot.State = model.BotInactive + if err := store.Database.UpdateBot(bot); err != nil { + flog.Error(err) + } + } + } +} + +func initializeBot(botsConfig interface{}, vendorsConfig interface{}) { + b, err := jsoniter.Marshal(botsConfig) + if err != nil { + flog.Fatal("Failed to marshal bots: %v", err) + } + v, err := jsoniter.Marshal(vendorsConfig) + if err != nil { + flog.Fatal("Failed to marshal vendors: %v", err) + } + + // set vendors configs + providers.Configs = v + + // init bots + err = bots.Init(b) + if err != nil { + flog.Fatal("Failed to initialize bot: %v", err) + } + + // register bots + registerBot() + + // bootstrap bots + err = bots.Bootstrap() + if err != nil { + flog.Fatal("Failed to bootstrap bot: %v", err) + } + + // bot cron + globals.cronRuleset, err = bots.Cron() + if err != nil { + flog.Fatal("Failed to bot cron: %v", err) + } + + stats.BotTotalCounter().Set(uint64(len(bots.List()))) + rdb.SetInt64(stats.BotTotalStatsName, int64(len(bots.List()))) +} diff --git a/internal/server/database.go b/internal/server/database.go index 1b9c55ab..3bbbbb7f 100644 --- a/internal/server/database.go +++ b/internal/server/database.go @@ -15,19 +15,19 @@ func newDatabaseAdapter(lc fx.Lifecycle, _ config.Type) (store.Adapter, error) { mysql.Init() store.Init() - lc.Append(fx.Hook{ - OnStart: func(ctx context.Context) error { - // Open database - err := store.Store.Open(config.App.Store) - if err != nil { - return fmt.Errorf("failed to open DB, %w", err) - } + // Open database + err := store.Store.Open(config.App.Store) + if err != nil { + return nil, fmt.Errorf("failed to open DB, %w", err) + } - // migrate - if err := store.Migrate(); err != nil { - return fmt.Errorf("failed to migrate DB, %w", err) - } + // migrate + if err := store.Migrate(); err != nil { + return nil, fmt.Errorf("failed to migrate DB, %w", err) + } + lc.Append(fx.Hook{ + OnStart: func(ctx context.Context) error { return nil }, OnStop: func(ctx context.Context) error { diff --git a/internal/server/event.go b/internal/server/event.go index 0da0bd77..1345bb99 100644 --- a/internal/server/event.go +++ b/internal/server/event.go @@ -3,6 +3,7 @@ package server import ( "context" "fmt" + "strings" "time" "github.com/ThreeDotsLabs/watermill/message" @@ -162,7 +163,15 @@ func onPlatformMessageEventHandler(msg *message.Message) error { return fmt.Errorf("failed to get caller: %w", err) } - hookIncomingMessage(caller, pe) + // update online status + onlineStatus(pe) + // check grp or p2p + if strings.HasSuffix(pe.DetailType, ".direct") { + directIncomingMessage(caller, pe) + } + if strings.HasSuffix(pe.DetailType, ".group") { + groupIncomingMessage(caller, pe) + } return nil } diff --git a/internal/server/hook.go b/internal/server/hook.go deleted file mode 100644 index 4aa46cef..00000000 --- a/internal/server/hook.go +++ /dev/null @@ -1,72 +0,0 @@ -package server - -import ( - "fmt" - "github.com/flowline-io/flowbot/internal/bots" - "github.com/flowline-io/flowbot/internal/platforms" - "github.com/flowline-io/flowbot/pkg/flog" - "github.com/flowline-io/flowbot/pkg/providers" - "github.com/flowline-io/flowbot/pkg/rdb" - "github.com/flowline-io/flowbot/pkg/stats" - "github.com/flowline-io/flowbot/pkg/types/protocol" - "github.com/flowline-io/flowbot/version" - jsoniter "github.com/json-iterator/go" - "strings" -) - -// hook - -func hookBot(botsConfig interface{}, vendorsConfig interface{}) { - b, err := jsoniter.Marshal(botsConfig) - if err != nil { - flog.Fatal("Failed to marshal bots: %v", err) - } - v, err := jsoniter.Marshal(vendorsConfig) - if err != nil { - flog.Fatal("Failed to marshal vendors: %v", err) - } - - // set vendors configs - providers.Configs = v - - // init bots - err = bots.Init(b) - if err != nil { - flog.Fatal("Failed to initialize bot: %v", err) - } - - // register bots - initializeBot() - - // bootstrap bots - err = bots.Bootstrap() - if err != nil { - flog.Fatal("Failed to bootstrap bot: %v", err) - } - - // bot cron - globals.cronRuleset, err = bots.Cron() - if err != nil { - flog.Fatal("Failed to bot cron: %v", err) - } - - stats.BotTotalCounter().Set(uint64(len(bots.List()))) - rdb.SetInt64(stats.BotTotalStatsName, int64(len(bots.List()))) -} - -func hookIncomingMessage(caller *platforms.Caller, msg protocol.Event) { - // update online status - onlineStatus(msg) - // check grp or p2p - if strings.HasSuffix(msg.DetailType, ".direct") { - directIncomingMessage(caller, msg) - } - if strings.HasSuffix(msg.DetailType, ".group") { - groupIncomingMessage(caller, msg) - } -} - -func hookStarted() { - // notify after online - go notifyAll(fmt.Sprintf("flowbot (%s) online", version.Buildtags)) -} diff --git a/internal/server/http.go b/internal/server/http.go index 8ea707c6..8e9f5132 100644 --- a/internal/server/http.go +++ b/internal/server/http.go @@ -19,7 +19,7 @@ import ( func newHTTPServer() *fiber.App { // Set up HTTP server. - httpApp = fiber.New(fiber.Config{ + httpApp := fiber.New(fiber.Config{ DisableStartupMessage: true, JSONDecoder: jsoniter.Unmarshal, diff --git a/internal/server/init.go b/internal/server/init.go index 784377a7..35cd7814 100644 --- a/internal/server/init.go +++ b/internal/server/init.go @@ -6,12 +6,9 @@ import ( "time" "github.com/VictoriaMetrics/metrics" - "github.com/flowline-io/flowbot/internal/bots" "github.com/flowline-io/flowbot/internal/store" - "github.com/flowline-io/flowbot/internal/store/model" "github.com/flowline-io/flowbot/pkg/config" "github.com/flowline-io/flowbot/pkg/flog" - "github.com/flowline-io/flowbot/pkg/utils/sets" "github.com/flowline-io/flowbot/version" "github.com/gofiber/fiber/v2" jsoniter "github.com/json-iterator/go" @@ -22,8 +19,6 @@ var ( stopSignal <-chan bool // swagger swagHandler fiber.Handler - // fiber app - httpApp *fiber.App ) func initializeLog() error { @@ -74,63 +69,6 @@ func initializeMedia() error { return nil } -func initializeChatbot(signal <-chan bool) error { - // Initialize bots - hookBot(config.App.Bots, config.App.Vendors) - - // hook - hookStarted() - - // Platform - hookPlatform(signal) - - return nil -} - -// init bots -func initializeBot() { - // register bots - registerBots := sets.NewString() - for name, handler := range bots.List() { - registerBots.Insert(name) - - state := model.BotInactive - if handler.IsReady() { - state = model.BotActive - } - bot, _ := store.Database.GetBotByName(name) - if bot == nil { - bot = &model.Bot{ - Name: name, - State: state, - } - if _, err := store.Database.CreateBot(bot); err != nil { - flog.Error(err) - } - } else { - bot.State = state - err := store.Database.UpdateBot(bot) - if err != nil { - flog.Error(err) - } - } - } - - // inactive bot - list, err := store.Database.GetBots() - if err != nil { - flog.Error(err) - } - for _, bot := range list { - if !registerBots.Has(bot.Name) { - bot.State = model.BotInactive - if err := store.Database.UpdateBot(bot); err != nil { - flog.Error(err) - } - } - } -} - func initializeMetrics() error { return metrics.InitPushWithOptions( context.Background(), diff --git a/internal/server/modules.go b/internal/server/modules.go index 00fbc898..67c4f708 100644 --- a/internal/server/modules.go +++ b/internal/server/modules.go @@ -32,6 +32,7 @@ var Modules = fx.Options( fx.Invoke( bindRoutes, handleEvents, + handleChatbot, RunServer, ), ) diff --git a/internal/server/server.go b/internal/server/server.go index 78e6333f..2699fcfc 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -40,12 +40,6 @@ func RunServer(lc fx.Lifecycle, app *fiber.App, _ store.Adapter, _ *cache.Cache, } flog.Info("initialize Media ok") - // init chatbot - if err = initializeChatbot(stopSignal); err != nil { - return err - } - flog.Info("initialize Chatbot ok") - // init metrics if err = initializeMetrics(); err != nil { return err From 2eeea1a02a2423a504c077b708d8522b7504b130 Mon Sep 17 00:00:00 2001 From: sysatom Date: Thu, 8 May 2025 22:19:29 +0800 Subject: [PATCH 053/125] =?UTF-8?q?=F0=9F=90=9B=20fix(server/notify.go):?= =?UTF-8?q?=20Fix=20typo=20in=20NotifyModules=20declaration?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/server/notify.go | 1 - 1 file changed, 1 deletion(-) diff --git a/internal/server/notify.go b/internal/server/notify.go index f46754b8..4f7d8f4e 100644 --- a/internal/server/notify.go +++ b/internal/server/notify.go @@ -8,7 +8,6 @@ import ( "go.uber.org/fx" ) - var NotifyModules = fx.Options( fx.Invoke( message_pusher.Register, From 29d47967f413a44ee8715cfc428718bd1bbc47eb Mon Sep 17 00:00:00 2001 From: sysatom Date: Thu, 8 May 2025 22:24:18 +0800 Subject: [PATCH 054/125] =?UTF-8?q?=F0=9F=94=A7=20refactor(server):=20Opti?= =?UTF-8?q?mize=20server=20shutdown=20timeout=20and=20update=20HTTP=20serv?= =?UTF-8?q?er=20setup.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/server/chatbot.go | 77 +++++++++++++++++++------------------- internal/server/http.go | 22 +++++------ internal/server/server.go | 4 +- 3 files changed, 52 insertions(+), 51 deletions(-) diff --git a/internal/server/chatbot.go b/internal/server/chatbot.go index d2bf0e49..a6e6a14f 100644 --- a/internal/server/chatbot.go +++ b/internal/server/chatbot.go @@ -86,6 +86,45 @@ func handleChatbot(lc fx.Lifecycle, _ config.Type, _ store.Adapter, _ *redis.Cli return nil } +// initialize bots +func initializeBot(botsConfig interface{}, vendorsConfig interface{}) { + b, err := jsoniter.Marshal(botsConfig) + if err != nil { + flog.Fatal("Failed to marshal bots: %v", err) + } + v, err := jsoniter.Marshal(vendorsConfig) + if err != nil { + flog.Fatal("Failed to marshal vendors: %v", err) + } + + // set vendors configs + providers.Configs = v + + // init bots + err = bots.Init(b) + if err != nil { + flog.Fatal("Failed to initialize bot: %v", err) + } + + // register bots + registerBot() + + // bootstrap bots + err = bots.Bootstrap() + if err != nil { + flog.Fatal("Failed to bootstrap bot: %v", err) + } + + // bot cron + globals.cronRuleset, err = bots.Cron() + if err != nil { + flog.Fatal("Failed to bot cron: %v", err) + } + + stats.BotTotalCounter().Set(uint64(len(bots.List()))) + rdb.SetInt64(stats.BotTotalStatsName, int64(len(bots.List()))) +} + // register bots func registerBot() { // register bots @@ -129,41 +168,3 @@ func registerBot() { } } } - -func initializeBot(botsConfig interface{}, vendorsConfig interface{}) { - b, err := jsoniter.Marshal(botsConfig) - if err != nil { - flog.Fatal("Failed to marshal bots: %v", err) - } - v, err := jsoniter.Marshal(vendorsConfig) - if err != nil { - flog.Fatal("Failed to marshal vendors: %v", err) - } - - // set vendors configs - providers.Configs = v - - // init bots - err = bots.Init(b) - if err != nil { - flog.Fatal("Failed to initialize bot: %v", err) - } - - // register bots - registerBot() - - // bootstrap bots - err = bots.Bootstrap() - if err != nil { - flog.Fatal("Failed to bootstrap bot: %v", err) - } - - // bot cron - globals.cronRuleset, err = bots.Cron() - if err != nil { - flog.Fatal("Failed to bot cron: %v", err) - } - - stats.BotTotalCounter().Set(uint64(len(bots.List()))) - rdb.SetInt64(stats.BotTotalStatsName, int64(len(bots.List()))) -} diff --git a/internal/server/http.go b/internal/server/http.go index 8e9f5132..131e3f41 100644 --- a/internal/server/http.go +++ b/internal/server/http.go @@ -19,7 +19,7 @@ import ( func newHTTPServer() *fiber.App { // Set up HTTP server. - httpApp := fiber.New(fiber.Config{ + app := fiber.New(fiber.Config{ DisableStartupMessage: true, JSONDecoder: jsoniter.Unmarshal, @@ -39,24 +39,24 @@ func newHTTPServer() *fiber.App { return nil }, }) - httpApp.Use(recover.New(recover.Config{EnableStackTrace: true})) - httpApp.Use(requestid.New()) - httpApp.Use(healthcheck.New()) - httpApp.Use(cors.New(cors.Config{ + app.Use(recover.New(recover.Config{EnableStackTrace: true})) + app.Use(requestid.New()) + app.Use(healthcheck.New()) + app.Use(cors.New(cors.Config{ AllowOriginsFunc: func(origin string) bool { return true }, })) - httpApp.Use(compress.New(compress.Config{ + app.Use(compress.New(compress.Config{ Level: compress.LevelBestSpeed, })) - httpApp.Use(limiter.New(limiter.Config{ + app.Use(limiter.New(limiter.Config{ Max: 50, Expiration: 10 * time.Second, LimiterMiddleware: limiter.SlidingWindow{}, })) logger := flog.GetLogger() - httpApp.Use(fiberzerolog.New(fiberzerolog.Config{ + app.Use(fiberzerolog.New(fiberzerolog.Config{ Logger: &logger, SkipURIs: []string{ "/", @@ -67,7 +67,7 @@ func newHTTPServer() *fiber.App { })) // hook - httpApp.Hooks().OnRoute(func(r fiber.Route) error { + app.Hooks().OnRoute(func(r fiber.Route) error { if r.Method == http.MethodHead { return nil } @@ -77,8 +77,8 @@ func newHTTPServer() *fiber.App { // swagger if swagHandler != nil { - httpApp.Get("/swagger/*", swagHandler) + app.Get("/swagger/*", swagHandler) } - return httpApp + return app } diff --git a/internal/server/server.go b/internal/server/server.go index 2699fcfc..d8e443cf 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -57,8 +57,8 @@ func RunServer(lc fx.Lifecycle, app *fiber.App, _ store.Adapter, _ *cache.Cache, return nil }, OnStop: func(ctx context.Context) error { - // Give server 2 seconds to shut down. - ctx, cancel := context.WithTimeout(ctx, 2*time.Second) + // Give server 10 seconds to shut down. + ctx, cancel := context.WithTimeout(ctx, 10*time.Second) if err := app.ShutdownWithContext(ctx); err != nil { // failure/timeout shutting down the server gracefully flog.Error(err) From 739e846ecc6ce0aab74612da2de96553e7b7fe1a Mon Sep 17 00:00:00 2001 From: sysatom Date: Fri, 9 May 2025 00:19:17 +0800 Subject: [PATCH 055/125] =?UTF-8?q?=F0=9F=90=9B=20fix:=20Update=20pubsub?= =?UTF-8?q?=20subscriber=20and=20publisher=20to=20use=20fx.Lifecycle=20for?= =?UTF-8?q?=20graceful=20shutdown=20=F0=9F=9B=A0=20=F0=9F=9A=80=20feat:=20?= =?UTF-8?q?Introduce=20new=20platform=20driver=20interface=20and=20Slack?= =?UTF-8?q?=20driver=20=F0=9F=9B=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/platforms/slack/driver.go | 19 ++++++++++----- internal/server/chatbot.go | 3 --- internal/server/event.go | 2 +- internal/server/modules.go | 5 +++- internal/server/platform.go | 20 +++++++++------ internal/server/router.go | 14 +++++++---- internal/server/server.go | 2 +- internal/workflow/manager.go | 6 ++--- pkg/event/pubsub.go | 39 +++++++++++++++++++++++------- pkg/rdb/rdb.go | 3 ++- pkg/types/protocol/platform.go | 6 +++-- 11 files changed, 80 insertions(+), 39 deletions(-) diff --git a/internal/platforms/slack/driver.go b/internal/platforms/slack/driver.go index 1677709d..cdf8bac8 100644 --- a/internal/platforms/slack/driver.go +++ b/internal/platforms/slack/driver.go @@ -3,9 +3,8 @@ package slack import ( "context" "fmt" - "time" - "github.com/flowline-io/flowbot/internal/platforms" + "github.com/flowline-io/flowbot/internal/store" "github.com/flowline-io/flowbot/pkg/config" "github.com/flowline-io/flowbot/pkg/event" "github.com/flowline-io/flowbot/pkg/flog" @@ -13,15 +12,17 @@ import ( "github.com/gofiber/fiber/v2" "github.com/slack-go/slack" "github.com/slack-go/slack/socketmode" + "time" ) type Driver struct { adapter *Adapter action *Action api *slack.Client + stop chan bool } -func NewDriver() *Driver { +func NewDriver(_ config.Type, _ store.Adapter) protocol.Driver { api := slack.New( config.App.Platform.Slack.BotToken, slack.OptionDebug(config.App.Log.Level == flog.DebugLevel), @@ -42,6 +43,7 @@ func NewDriver() *Driver { adapter: &Adapter{}, action: &Action{api: api}, api: api, + stop: make(chan bool), } } @@ -53,7 +55,7 @@ func (d *Driver) HttpWebhookClient(_ protocol.Message) error { return nil } -func (d *Driver) WebSocketClient(stop <-chan bool) { +func (d *Driver) WebSocketClient() { if !config.App.Platform.Slack.Enabled { flog.Info("Slack is disabled") return @@ -69,7 +71,7 @@ func (d *Driver) WebSocketClient(stop <-chan bool) { go func() { for { select { - case <-stop: + case <-d.stop: flog.Info("Slack is shutting down.") return case evt := <-client.Events: @@ -104,9 +106,14 @@ func (d *Driver) WebSocketClient(stop <-chan bool) { }() } -func (d *Driver) WebSocketServer(_ <-chan bool) { +func (d *Driver) WebSocketServer() { if !config.App.Platform.Slack.Enabled { flog.Info("Slack is disabled") return } } + +func (d *Driver) Shoutdown() error { + d.stop <- true + return nil +} diff --git a/internal/server/chatbot.go b/internal/server/chatbot.go index a6e6a14f..309934f3 100644 --- a/internal/server/chatbot.go +++ b/internal/server/chatbot.go @@ -73,9 +73,6 @@ func handleChatbot(lc fx.Lifecycle, _ config.Type, _ store.Adapter, _ *redis.Cli // notify after online go notifyAll(fmt.Sprintf("flowbot (%s) online", version.Buildtags)) - // Platform - hookPlatform(make(<-chan bool)) - return nil }, OnStop: func(ctx context.Context) error { diff --git a/internal/server/event.go b/internal/server/event.go index 1345bb99..06b32b33 100644 --- a/internal/server/event.go +++ b/internal/server/event.go @@ -60,7 +60,7 @@ func handleEvents(lc fx.Lifecycle, router *message.Router, subscriber message.Su return nil }, OnStop: func(ctx context.Context) error { - return nil + return router.Close() }, }) diff --git a/internal/server/modules.go b/internal/server/modules.go index 67c4f708..aceccc01 100644 --- a/internal/server/modules.go +++ b/internal/server/modules.go @@ -1,6 +1,7 @@ package server import ( + "github.com/flowline-io/flowbot/internal/platforms/slack" "github.com/flowline-io/flowbot/internal/workflow" "github.com/flowline-io/flowbot/pkg/cache" "github.com/flowline-io/flowbot/pkg/config" @@ -25,14 +26,16 @@ var Modules = fx.Options( workflow.NewQueue, workflow.NewManager, workflow.NewCronTaskManager, + slack.NewDriver, newController, newDatabaseAdapter, newHTTPServer, ), fx.Invoke( - bindRoutes, + handleRoutes, handleEvents, handleChatbot, + handlePlatform, RunServer, ), ) diff --git a/internal/server/platform.go b/internal/server/platform.go index d233bab6..23e12191 100644 --- a/internal/server/platform.go +++ b/internal/server/platform.go @@ -1,13 +1,19 @@ package server import ( - "github.com/flowline-io/flowbot/internal/platforms/discord" - "github.com/flowline-io/flowbot/internal/platforms/slack" + "context" + "github.com/flowline-io/flowbot/pkg/types/protocol" + "go.uber.org/fx" ) -func hookPlatform(stop <-chan bool) { - // slack - go slack.NewDriver().WebSocketClient(stop) - // discord - go discord.HandleWebsocket(stop) +func handlePlatform(lc fx.Lifecycle, driver protocol.Driver) { + lc.Append(fx.Hook{ + OnStart: func(ctx context.Context) error { + go driver.WebSocketClient() + return nil + }, + OnStop: func(ctx context.Context) error { + return driver.Shoutdown() + }, + }) } diff --git a/internal/server/router.go b/internal/server/router.go index 3c6bdc1d..96a3ac74 100644 --- a/internal/server/router.go +++ b/internal/server/router.go @@ -32,7 +32,7 @@ import ( "gorm.io/gorm" ) -func bindRoutes(a *fiber.App, ctl *Controller) { +func handleRoutes(a *fiber.App, ctl *Controller) { // Webservice for _, bot := range bots.List() { bot.Webservice(a) @@ -56,10 +56,14 @@ func bindRoutes(a *fiber.App, ctl *Controller) { // handler -type Controller struct{} +type Controller struct { + driver protocol.Driver +} -func newController() *Controller { - return &Controller{} +func newController(driver protocol.Driver) *Controller { + return &Controller{ + driver: driver, + } } func (c *Controller) storeOAuth(ctx *fiber.Ctx) error { @@ -363,7 +367,7 @@ func (c *Controller) platformCallback(ctx *fiber.Ctx) error { case tailchat.ID: err = tailchat.HandleHttp(ctx) case slack.ID: - err = slack.NewDriver().HttpServer(ctx) + err = c.driver.HttpServer(ctx) } if err != nil { var protocolError *protocol.Error diff --git a/internal/server/server.go b/internal/server/server.go index d8e443cf..de8c802c 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -58,7 +58,7 @@ func RunServer(lc fx.Lifecycle, app *fiber.App, _ store.Adapter, _ *cache.Cache, }, OnStop: func(ctx context.Context) error { // Give server 10 seconds to shut down. - ctx, cancel := context.WithTimeout(ctx, 10*time.Second) + ctx, cancel := context.WithTimeout(ctx, 2*time.Second) if err := app.ShutdownWithContext(ctx); err != nil { // failure/timeout shutting down the server gracefully flog.Error(err) diff --git a/internal/workflow/manager.go b/internal/workflow/manager.go index 033c9de4..626d81c7 100644 --- a/internal/workflow/manager.go +++ b/internal/workflow/manager.go @@ -4,21 +4,21 @@ import ( "context" "errors" "fmt" - "time" - "github.com/flowline-io/flowbot/internal/store" "github.com/flowline-io/flowbot/internal/store/model" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/utils/parallelizer" "github.com/hibiken/asynq" + "github.com/redis/go-redis/v9" "go.uber.org/fx" + "time" ) type Manager struct { stop chan struct{} } -func NewManager(lc fx.Lifecycle, _ store.Adapter) *Manager { +func NewManager(lc fx.Lifecycle, _ store.Adapter, _ *redis.Client) *Manager { i := &Manager{ stop: make(chan struct{}), } diff --git a/pkg/event/pubsub.go b/pkg/event/pubsub.go index 95e166fc..0939702c 100644 --- a/pkg/event/pubsub.go +++ b/pkg/event/pubsub.go @@ -3,35 +3,48 @@ package event import ( "context" "fmt" - "time" - "github.com/ThreeDotsLabs/watermill" "github.com/ThreeDotsLabs/watermill-redisstream/pkg/redisstream" "github.com/ThreeDotsLabs/watermill/message" "github.com/ThreeDotsLabs/watermill/message/router/middleware" - "github.com/ThreeDotsLabs/watermill/message/router/plugin" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/rdb" "github.com/flowline-io/flowbot/pkg/stats" jsoniter "github.com/json-iterator/go" "github.com/redis/go-redis/v9" + "go.uber.org/fx" + "time" ) var logger = flog.WatermillLogger -func NewSubscriber(_ *redis.Client) (message.Subscriber, error) { - return redisstream.NewSubscriber( +func NewSubscriber(lc fx.Lifecycle, _ *redis.Client) (message.Subscriber, error) { + subscriber, err := redisstream.NewSubscriber( redisstream.SubscriberConfig{ Client: rdb.Client, Unmarshaller: redisstream.DefaultMarshallerUnmarshaller{}, }, logger, ) + if err != nil { + return nil, fmt.Errorf("failed to create redis subscriber: %w", err) + } + + lc.Append(fx.Hook{ + OnStart: func(ctx context.Context) error { + return nil + }, + OnStop: func(ctx context.Context) error { + return subscriber.Close() + }, + }) + + return subscriber, err } var Publisher message.Publisher -func NewPublisher(_ *redis.Client) (message.Publisher, error) { +func NewPublisher(lc fx.Lifecycle, _ *redis.Client) (message.Publisher, error) { var err error Publisher, err = redisstream.NewPublisher( redisstream.PublisherConfig{ @@ -40,17 +53,25 @@ func NewPublisher(_ *redis.Client) (message.Publisher, error) { }, logger, ) + + lc.Append(fx.Hook{ + OnStart: func(ctx context.Context) error { + return nil + }, + OnStop: func(ctx context.Context) error { + return Publisher.Close() + }, + }) + return Publisher, err } -func NewRouter() (*message.Router, error) { +func NewRouter(_ *redis.Client) (*message.Router, error) { router, err := message.NewRouter(message.RouterConfig{}, logger) if err != nil { return nil, err } - router.AddPlugin(plugin.SignalsHandler) - router.AddMiddleware( middleware.CorrelationID, middleware.Timeout(10*time.Minute), diff --git a/pkg/rdb/rdb.go b/pkg/rdb/rdb.go index 887ebe61..881ff75e 100644 --- a/pkg/rdb/rdb.go +++ b/pkg/rdb/rdb.go @@ -37,7 +37,8 @@ func NewClient(lc fx.Lifecycle, _ config.Type) (*redis.Client, error) { return nil }, OnStop: func(ctx context.Context) error { - return Client.Close() + Shutdown() + return nil }, }) diff --git a/pkg/types/protocol/platform.go b/pkg/types/protocol/platform.go index 7fb36b4b..06d63997 100644 --- a/pkg/types/protocol/platform.go +++ b/pkg/types/protocol/platform.go @@ -12,9 +12,11 @@ type Driver interface { // HttpWebhookClient Chatbot implements active access to applications HttpWebhookClient(message Message) error // WebSocketClient The application can actively access the Chatbot implementation. - WebSocketClient(stop <-chan bool) + WebSocketClient() // WebSocketServer Chatbot implements active access to applications - WebSocketServer(stop <-chan bool) + WebSocketServer() + // Shoutdown Shut down the driver + Shoutdown() error } // Adapter Responsible for converting platform messages to chatbot event/message formats. From 6d891d777a681805b6f756fde23d388c68c627cb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 8 May 2025 16:34:03 +0000 Subject: [PATCH 056/125] build(deps): bump github.com/VictoriaMetrics/metrics Bumps [github.com/VictoriaMetrics/metrics](https://github.com/VictoriaMetrics/metrics) from 1.35.4 to 1.36.0. - [Commits](https://github.com/VictoriaMetrics/metrics/compare/v1.35.4...v1.36.0) --- updated-dependencies: - dependency-name: github.com/VictoriaMetrics/metrics dependency-version: 1.36.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 359b12f2..4d06b1f1 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/RealAlexandreAI/json-repair v0.0.14 github.com/ThreeDotsLabs/watermill v1.4.6 github.com/ThreeDotsLabs/watermill-redisstream v1.4.2 - github.com/VictoriaMetrics/metrics v1.35.4 + github.com/VictoriaMetrics/metrics v1.36.0 github.com/allegro/bigcache/v3 v3.1.0 github.com/bsm/redislock v0.9.4 github.com/bwmarrin/discordgo v0.28.1 diff --git a/go.sum b/go.sum index d4deebe5..9b9fbee1 100644 --- a/go.sum +++ b/go.sum @@ -24,8 +24,8 @@ github.com/ThreeDotsLabs/watermill v1.4.6 h1:rWoXlxdBgUyg/bZ3OO0pON+nESVd9r6tnLT github.com/ThreeDotsLabs/watermill v1.4.6/go.mod h1:lBnrLbxOjeMRgcJbv+UiZr8Ylz8RkJ4m6i/VN/Nk+to= github.com/ThreeDotsLabs/watermill-redisstream v1.4.2 h1:FY6tsBcbhbJpKDOssU4bfybstqY0hQHwiZmVq9qyILQ= github.com/ThreeDotsLabs/watermill-redisstream v1.4.2/go.mod h1:69++855LyB+ckYDe60PiJLBcUrpckfDE2WwyzuVJRCk= -github.com/VictoriaMetrics/metrics v1.35.4 h1:GhZ17bHYkujpSzGaH459F7huTLNJ7z90ZXsOXjhHx/8= -github.com/VictoriaMetrics/metrics v1.35.4/go.mod h1:r7hveu6xMdUACXvB8TYdAj8WEsKzWB0EkpJN+RDtOf8= +github.com/VictoriaMetrics/metrics v1.36.0 h1:f3SZMpLgIG4hJm2zfDs6wicxQ/QNWBZekY5rEGgbHKs= +github.com/VictoriaMetrics/metrics v1.36.0/go.mod h1:r7hveu6xMdUACXvB8TYdAj8WEsKzWB0EkpJN+RDtOf8= github.com/airbrake/gobrake v3.6.1+incompatible/go.mod h1:wM4gu3Cn0W0K7GUuVWnlXZU11AGBXMILnrdOU8Kn00o= github.com/allegro/bigcache/v3 v3.1.0 h1:H2Vp8VOvxcrB91o86fUSVJFqeuz8kpyyB02eH3bSzwk= github.com/allegro/bigcache/v3 v3.1.0/go.mod h1:aPyh7jEvrog9zAwx5N7+JUQX5dZTSGpxF1LAR4dr35I= From 6e1a550ed2642762fa4cdfd64c1fdb6cfc9f2c39 Mon Sep 17 00:00:00 2001 From: sysatom Date: Fri, 9 May 2025 00:34:13 +0800 Subject: [PATCH 057/125] =?UTF-8?q?=F0=9F=97=91=EF=B8=8F=20fix(server/file?= =?UTF-8?q?s.go):=20Remove=20largeFileRunGarbageCollection=20function=20an?= =?UTF-8?q?d=20related=20code.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/server/files.go | 37 ------------------------------------- internal/server/init.go | 11 ----------- internal/workflow/cron.go | 3 ++- 3 files changed, 2 insertions(+), 49 deletions(-) delete mode 100644 internal/server/files.go diff --git a/internal/server/files.go b/internal/server/files.go deleted file mode 100644 index 1c797546..00000000 --- a/internal/server/files.go +++ /dev/null @@ -1,37 +0,0 @@ -package server - -import ( - "crypto/rand" - "math/big" - "time" - - "github.com/flowline-io/flowbot/internal/store" - "github.com/flowline-io/flowbot/pkg/flog" -) - -// largeFileRunGarbageCollection runs every 'period' and deletes up to 'blockSize' unused files. -// Returns channel which can be used to stop the process. -func largeFileRunGarbageCollection(period time.Duration, blockSize int) chan<- bool { - // Unbuffered stop channel. Whoever stops the gc must wait for the process to finish. - stop := make(chan bool) - go func() { - // Add some randomness to the tick period to desynchronize runs on cluster nodes: - // 0.75 * period + rand(0, 0.5) * period. - n, _ := rand.Int(rand.Reader, big.NewInt(int64(period>>1))) - period = (period >> 1) + (period >> 2) + time.Duration(n.Int64()) - gcTicker := time.NewTicker(period) - for { - select { - case <-gcTicker.C: - if _, err := store.Database.FileDeleteUnused(time.Now().Add(-time.Hour), blockSize); err != nil { - flog.Warn("media gc: %v", err) - } - // todo delete unused - case <-stop: - return - } - } - }() - - return stop -} diff --git a/internal/server/init.go b/internal/server/init.go index 35cd7814..4421a795 100644 --- a/internal/server/init.go +++ b/internal/server/init.go @@ -15,8 +15,6 @@ import ( ) var ( - // stop signal - stopSignal <-chan bool // swagger swagHandler fiber.Handler ) @@ -55,15 +53,6 @@ func initializeMedia() error { return fmt.Errorf("failed to init media handler, %w", err) } } - if config.App.Media.GcPeriod > 0 && config.App.Media.GcBlockSize > 0 { - globals.mediaGcPeriod = time.Second * time.Duration(config.App.Media.GcPeriod) - stopFilesGc := largeFileRunGarbageCollection(globals.mediaGcPeriod, config.App.Media.GcBlockSize) - go func() { - <-stopSignal - stopFilesGc <- true - flog.Info("Stopped files garbage collector") - }() - } } } return nil diff --git a/internal/workflow/cron.go b/internal/workflow/cron.go index d9de407b..4dbe5805 100644 --- a/internal/workflow/cron.go +++ b/internal/workflow/cron.go @@ -61,12 +61,13 @@ func NewCronTaskManager(lc fx.Lifecycle, _ *redis.Client, _ store.Adapter) *Cron } func (c *CronTaskManager) Run() { - if err := c.mgr.Run(); err != nil { + if err := c.mgr.Start(); err != nil { flog.Error(err) } } func (c *CronTaskManager) Shutdown() { + c.mgr.Shutdown() flog.Info("cron task shutdown") } From 258bdb20508608e3bdce1275136ba848f509d74a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 8 May 2025 16:38:43 +0000 Subject: [PATCH 058/125] build(deps): bump github.com/cloudwego/eino from 0.3.28 to 0.3.29 Bumps [github.com/cloudwego/eino](https://github.com/cloudwego/eino) from 0.3.28 to 0.3.29. - [Release notes](https://github.com/cloudwego/eino/releases) - [Commits](https://github.com/cloudwego/eino/compare/v0.3.28...v0.3.29) --- updated-dependencies: - dependency-name: github.com/cloudwego/eino dependency-version: 0.3.29 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 1f5542b1..1aa69c02 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/bsm/redislock v0.9.4 github.com/bwmarrin/discordgo v0.28.1 github.com/cenkalti/backoff v2.2.1+incompatible - github.com/cloudwego/eino v0.3.28 + github.com/cloudwego/eino v0.3.29 github.com/cloudwego/eino-ext/components/model/openai v0.0.0-20250221090944-e8ef7aabbe10 github.com/creachadair/jrpc2 v1.3.1 github.com/dgraph-io/ristretto/v2 v2.2.0 diff --git a/go.sum b/go.sum index 63b15d1a..f7ffe0cd 100644 --- a/go.sum +++ b/go.sum @@ -65,8 +65,8 @@ github.com/chengxilo/virtualterm v1.0.4 h1:Z6IpERbRVlfB8WkOmtbHiDbBANU7cimRIof7m github.com/chengxilo/virtualterm v1.0.4/go.mod h1:DyxxBZz/x1iqJjFxTFcr6/x+jSpqN0iwWCOK1q10rlY= github.com/cloudwego/base64x v0.1.5 h1:XPciSp1xaq2VCSt6lF0phncD4koWyULpl5bUxbfCyP4= github.com/cloudwego/base64x v0.1.5/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w= -github.com/cloudwego/eino v0.3.28 h1:KnL4U9ES4giTYhK84vMWKwqr5IGHJzZf6th9/Li1zyA= -github.com/cloudwego/eino v0.3.28/go.mod h1:wUjz990apdsaOraOXdh6CdhVXq8DJsOvLsVlxNTcNfY= +github.com/cloudwego/eino v0.3.29 h1:yPiV/bMjxvQzBZlmDFF71Sly59y3HSNpdfOPQWayrYM= +github.com/cloudwego/eino v0.3.29/go.mod h1:wUjz990apdsaOraOXdh6CdhVXq8DJsOvLsVlxNTcNfY= github.com/cloudwego/eino-ext/components/model/openai v0.0.0-20250221090944-e8ef7aabbe10 h1:DJAInsXygJKCrkahR42QODKkq91nvQCTe60o3MnjsKs= github.com/cloudwego/eino-ext/components/model/openai v0.0.0-20250221090944-e8ef7aabbe10/go.mod h1:okkkchYXfoEkv5c0GlwhMdVjIshCzmN3DCcnbOWf7DQ= github.com/cloudwego/eino-ext/libs/acl/openai v0.0.0-20250221090944-e8ef7aabbe10 h1:M6Z2PeX+MxW7jgoZ0p6qDfVtMe1/4XqSQSAHUrI2HTM= From 9b6985d9ef64743bc34c0440df798d4454fba4e2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 8 May 2025 16:52:10 +0000 Subject: [PATCH 059/125] build(deps): bump github.com/fsnotify/fsnotify from 1.8.0 to 1.9.0 Bumps [github.com/fsnotify/fsnotify](https://github.com/fsnotify/fsnotify) from 1.8.0 to 1.9.0. - [Release notes](https://github.com/fsnotify/fsnotify/releases) - [Changelog](https://github.com/fsnotify/fsnotify/blob/main/CHANGELOG.md) - [Commits](https://github.com/fsnotify/fsnotify/compare/v1.8.0...v1.9.0) --- updated-dependencies: - dependency-name: github.com/fsnotify/fsnotify dependency-version: 1.9.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 1f5542b1..e3a3c8dd 100644 --- a/go.mod +++ b/go.mod @@ -24,7 +24,7 @@ require ( github.com/dustin/go-humanize v1.0.1 github.com/emicklei/go-restful/v3 v3.12.2 github.com/expr-lang/expr v1.17.2 - github.com/fsnotify/fsnotify v1.8.0 + github.com/fsnotify/fsnotify v1.9.0 github.com/gen2brain/beeep v0.0.0-20240516210008-9c006672e7f4 github.com/go-echarts/go-echarts/v2 v2.5.3 github.com/go-playground/validator/v10 v10.26.0 diff --git a/go.sum b/go.sum index 63b15d1a..5f5ee829 100644 --- a/go.sum +++ b/go.sum @@ -125,8 +125,8 @@ github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHqu 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/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= -github.com/fsnotify/fsnotify v1.8.0 h1:dAwr6QBTBZIkG8roQaJjGof0pp0EeF+tNV7YBP3F/8M= -github.com/fsnotify/fsnotify v1.8.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0= +github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k= +github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0= github.com/gabriel-vasile/mimetype v1.4.8 h1:FfZ3gj38NjllZIeJAmMhr+qKL8Wu+nOoI3GqacKw1NM= github.com/gabriel-vasile/mimetype v1.4.8/go.mod h1:ByKUIKGjh1ODkGM1asKUbQZOLGrPjydw3hYPU2YU9t8= github.com/gen2brain/beeep v0.0.0-20240516210008-9c006672e7f4 h1:ygs9POGDQpQGLJPlq4+0LBUmMBNox1N4JSpw+OETcvI= From c82141ccb81bfd25a9a2434bb42020533de624da Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 8 May 2025 16:52:19 +0000 Subject: [PATCH 060/125] build(deps): bump github.com/go-echarts/go-echarts/v2 Bumps [github.com/go-echarts/go-echarts/v2](https://github.com/go-echarts/go-echarts) from 2.5.3 to 2.5.4. - [Release notes](https://github.com/go-echarts/go-echarts/releases) - [Commits](https://github.com/go-echarts/go-echarts/compare/v2.5.3...v2.5.4) --- updated-dependencies: - dependency-name: github.com/go-echarts/go-echarts/v2 dependency-version: 2.5.4 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 1f5542b1..0c247c56 100644 --- a/go.mod +++ b/go.mod @@ -26,7 +26,7 @@ require ( github.com/expr-lang/expr v1.17.2 github.com/fsnotify/fsnotify v1.8.0 github.com/gen2brain/beeep v0.0.0-20240516210008-9c006672e7f4 - github.com/go-echarts/go-echarts/v2 v2.5.3 + github.com/go-echarts/go-echarts/v2 v2.5.4 github.com/go-playground/validator/v10 v10.26.0 github.com/go-resty/resty/v2 v2.16.5 github.com/go-sql-driver/mysql v1.9.2 diff --git a/go.sum b/go.sum index 63b15d1a..1fa2580b 100644 --- a/go.sum +++ b/go.sum @@ -136,8 +136,8 @@ github.com/getkin/kin-openapi v0.118.0/go.mod h1:l5e9PaFUo9fyLJCPGQeXI2ML8c3P8BH github.com/getsentry/raven-go v0.2.0/go.mod h1:KungGk8q33+aIAZUIVWZDr2OfAEBsO49PX4NzFV5kcQ= github.com/go-check/check v0.0.0-20180628173108-788fd7840127 h1:0gkP6mzaMqkmpcJYCFOLkIBwI7xFExG03bbkOkCvUPI= github.com/go-check/check v0.0.0-20180628173108-788fd7840127/go.mod h1:9ES+weclKsC9YodN5RgxqK/VD9HM9JsCSh7rNhMZE98= -github.com/go-echarts/go-echarts/v2 v2.5.3 h1:5SFAA6bAIWz52VnVGlCM1UZXo8nSdN+H9E8Ysi4m5ec= -github.com/go-echarts/go-echarts/v2 v2.5.3/go.mod h1:56YlvzhW/a+du15f3S2qUGNDfKnFOeJSThBIrVFHDtI= +github.com/go-echarts/go-echarts/v2 v2.5.4 h1:bw0REczgtgI/o7GPqae4AzsiJwwyJvyWwJ7vuM0G6tQ= +github.com/go-echarts/go-echarts/v2 v2.5.4/go.mod h1:56YlvzhW/a+du15f3S2qUGNDfKnFOeJSThBIrVFHDtI= github.com/go-fed/httpsig v1.1.0 h1:9M+hb0jkEICD8/cAiNqEB66R87tTINszBRTjwjQzWcI= github.com/go-fed/httpsig v1.1.0/go.mod h1:RCMrTZvN1bJYtofsG4rd5NaO5obxQ5xBkdiS7xsT7bM= github.com/go-ini/ini v1.67.0 h1:z6ZrTEZqSWOTyH2FlglNbNgARyHG8oLW9gMELqKr06A= From e79877c67b5e1d5c56bd4786f0d7857a8807d61f Mon Sep 17 00:00:00 2001 From: sysatom Date: Fri, 9 May 2025 01:09:24 +0800 Subject: [PATCH 061/125] =?UTF-8?q?=F0=9F=90=9B=20fix(search):=20Asynchron?= =?UTF-8?q?ously=20set=20default=20index=20settings=20to=20avoid=20blockin?= =?UTF-8?q?g?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/search/search.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/pkg/search/search.go b/pkg/search/search.go index 29e0aec5..62d63eab 100644 --- a/pkg/search/search.go +++ b/pkg/search/search.go @@ -28,10 +28,12 @@ func NewClient(lc fx.Lifecycle, _ config.Type) *Client { lc.Append(fx.Hook{ OnStart: func(ctx context.Context) error { - err := Instance.DefaultIndexSettings() - if err != nil { - flog.Error(err) - } + go func() { + err := Instance.DefaultIndexSettings() + if err != nil { + flog.Error(err) + } + }() return nil }, OnStop: func(ctx context.Context) error { From d484f94a5321510d10eb42da961e415aa40fba13 Mon Sep 17 00:00:00 2001 From: sysatom Date: Fri, 9 May 2025 01:14:39 +0800 Subject: [PATCH 062/125] =?UTF-8?q?=F0=9F=94=84=20Refactor:=20Remove=20unu?= =?UTF-8?q?sed=20redis=20client=20dependency=20from=20pubsub=20(pkg/event/?= =?UTF-8?q?pubsub.go)=20&=20add=20new=20redis=20client=20creation=20functi?= =?UTF-8?q?on=20(pkg/event/redis.go)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/event/pubsub.go | 17 ++++++++++++----- pkg/event/redis.go | 31 +++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 5 deletions(-) create mode 100644 pkg/event/redis.go diff --git a/pkg/event/pubsub.go b/pkg/event/pubsub.go index 0939702c..c09c118e 100644 --- a/pkg/event/pubsub.go +++ b/pkg/event/pubsub.go @@ -8,7 +8,6 @@ import ( "github.com/ThreeDotsLabs/watermill/message" "github.com/ThreeDotsLabs/watermill/message/router/middleware" "github.com/flowline-io/flowbot/pkg/flog" - "github.com/flowline-io/flowbot/pkg/rdb" "github.com/flowline-io/flowbot/pkg/stats" jsoniter "github.com/json-iterator/go" "github.com/redis/go-redis/v9" @@ -18,10 +17,14 @@ import ( var logger = flog.WatermillLogger -func NewSubscriber(lc fx.Lifecycle, _ *redis.Client) (message.Subscriber, error) { +func NewSubscriber(lc fx.Lifecycle) (message.Subscriber, error) { + client, err := newRedisClient() + if err != nil { + return nil, err + } subscriber, err := redisstream.NewSubscriber( redisstream.SubscriberConfig{ - Client: rdb.Client, + Client: client, Unmarshaller: redisstream.DefaultMarshallerUnmarshaller{}, }, logger, @@ -44,11 +47,15 @@ func NewSubscriber(lc fx.Lifecycle, _ *redis.Client) (message.Subscriber, error) var Publisher message.Publisher -func NewPublisher(lc fx.Lifecycle, _ *redis.Client) (message.Publisher, error) { +func NewPublisher(lc fx.Lifecycle) (message.Publisher, error) { var err error + client, err := newRedisClient() + if err != nil { + return nil, err + } Publisher, err = redisstream.NewPublisher( redisstream.PublisherConfig{ - Client: rdb.Client, + Client: client, Marshaller: redisstream.DefaultMarshallerUnmarshaller{}, }, logger, diff --git a/pkg/event/redis.go b/pkg/event/redis.go new file mode 100644 index 00000000..c4621832 --- /dev/null +++ b/pkg/event/redis.go @@ -0,0 +1,31 @@ +package event + +import ( + "context" + "fmt" + "github.com/flowline-io/flowbot/pkg/config" + "github.com/redis/go-redis/v9" + "time" +) + +func newRedisClient() (*redis.Client, error) { + addr := fmt.Sprintf("%s:%d", config.App.Redis.Host, config.App.Redis.Port) + password := config.App.Redis.Password + if addr == ":" || password == "" { + return nil, fmt.Errorf("redis config error") + } + client := redis.NewClient(&redis.Options{ + Addr: addr, + Password: password, + DB: config.App.Redis.DB, + ReadTimeout: 60 * time.Second, + WriteTimeout: 60 * time.Second, + }) + s := client.Ping(context.Background()) + _, err := s.Result() + if err != nil { + return nil, fmt.Errorf("redis server error %w", err) + } + + return client, nil +} From 26fda79d44b99f31c8d9aadb1d387c172b66d383 Mon Sep 17 00:00:00 2001 From: sysatom Date: Fri, 9 May 2025 10:36:20 +0800 Subject: [PATCH 063/125] upgrade ToolCallingChatModel --- go.mod | 6 +++--- go.sum | 12 ++++++------ internal/agents/agent.go | 2 +- internal/agents/llm.go | 4 ++-- internal/agents/model.go | 2 +- internal/agents/token.go | 2 +- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/go.mod b/go.mod index 076949b3..80eb06c0 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,7 @@ require ( github.com/bwmarrin/discordgo v0.28.1 github.com/cenkalti/backoff v2.2.1+incompatible github.com/cloudwego/eino v0.3.29 - github.com/cloudwego/eino-ext/components/model/openai v0.0.0-20250221090944-e8ef7aabbe10 + github.com/cloudwego/eino-ext/components/model/openai v0.0.0-20250507115047-b20720df8528 github.com/creachadair/jrpc2 v1.3.1 github.com/dgraph-io/ristretto/v2 v2.2.0 github.com/docker/cli v28.1.1+incompatible @@ -98,7 +98,7 @@ require ( github.com/cenkalti/backoff/v3 v3.2.2 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/cloudwego/base64x v0.1.5 // indirect - github.com/cloudwego/eino-ext/libs/acl/openai v0.0.0-20250221090944-e8ef7aabbe10 // indirect + github.com/cloudwego/eino-ext/libs/acl/openai v0.0.0-20250422092704-54e372e1fa3d // indirect github.com/containerd/log v0.1.0 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.5 // indirect github.com/creachadair/mds v0.23.0 // indirect @@ -152,6 +152,7 @@ require ( 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.16 // indirect + github.com/meguminnnnnnnnn/go-openai v0.0.0-20250408071642-761325becfd6 // indirect github.com/minio/crc64nvme v1.0.1 // indirect github.com/minio/md5-simd v1.1.2 // indirect github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db // indirect @@ -178,7 +179,6 @@ require ( github.com/rs/xid v1.6.0 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/sagikazarmark/locafero v0.7.0 // indirect - github.com/sashabaranov/go-openai v1.37.0 // indirect github.com/sirupsen/logrus v1.9.3 // indirect github.com/slongfield/pyfmt v0.0.0-20220222012616-ea85ff4c361f // indirect github.com/sony/gobreaker v1.0.0 // indirect diff --git a/go.sum b/go.sum index 2b1da7ff..a6845550 100644 --- a/go.sum +++ b/go.sum @@ -67,10 +67,10 @@ github.com/cloudwego/base64x v0.1.5 h1:XPciSp1xaq2VCSt6lF0phncD4koWyULpl5bUxbfCy github.com/cloudwego/base64x v0.1.5/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w= github.com/cloudwego/eino v0.3.29 h1:yPiV/bMjxvQzBZlmDFF71Sly59y3HSNpdfOPQWayrYM= github.com/cloudwego/eino v0.3.29/go.mod h1:wUjz990apdsaOraOXdh6CdhVXq8DJsOvLsVlxNTcNfY= -github.com/cloudwego/eino-ext/components/model/openai v0.0.0-20250221090944-e8ef7aabbe10 h1:DJAInsXygJKCrkahR42QODKkq91nvQCTe60o3MnjsKs= -github.com/cloudwego/eino-ext/components/model/openai v0.0.0-20250221090944-e8ef7aabbe10/go.mod h1:okkkchYXfoEkv5c0GlwhMdVjIshCzmN3DCcnbOWf7DQ= -github.com/cloudwego/eino-ext/libs/acl/openai v0.0.0-20250221090944-e8ef7aabbe10 h1:M6Z2PeX+MxW7jgoZ0p6qDfVtMe1/4XqSQSAHUrI2HTM= -github.com/cloudwego/eino-ext/libs/acl/openai v0.0.0-20250221090944-e8ef7aabbe10/go.mod h1:6CThw1XQx/ASXNt31yuvp0X4Yp4GprknQuIvP9VKDpw= +github.com/cloudwego/eino-ext/components/model/openai v0.0.0-20250507115047-b20720df8528 h1:LWlv4+NUNKVG2ojRtEbMDhExS45DH1t+kXakBCB3+Cw= +github.com/cloudwego/eino-ext/components/model/openai v0.0.0-20250507115047-b20720df8528/go.mod h1:uXIWTFbaAbZ1128EIXjFc4S+tDqmz1idMZd5qt5kkwU= +github.com/cloudwego/eino-ext/libs/acl/openai v0.0.0-20250422092704-54e372e1fa3d h1:unNqPz9vuJmJCZAw5YKFcszRX9e3CdVEjh0lR6QArxk= +github.com/cloudwego/eino-ext/libs/acl/openai v0.0.0-20250422092704-54e372e1fa3d/go.mod h1:Ye0YAqpESCxMlnALNrjeNJjhS9q2PIdxVdJbtFeni8o= github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY= github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I= github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo= @@ -332,6 +332,8 @@ github.com/mattn/go-sqlite3 v1.14.28 h1:ThEiQrnbtumT+QMknw63Befp/ce/nUPgBPMlRFEu github.com/mattn/go-sqlite3 v1.14.28/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y= github.com/maxence-charriere/go-app/v10 v10.1.3 h1:xj4E3Owbi5HLqF8DtAjRLI6IA5g0VREPatGDczcxtk4= github.com/maxence-charriere/go-app/v10 v10.1.3/go.mod h1:FqUW4on4nJewVfBnSkuxQd3fvtK2RdKS/z76OOUDAAY= +github.com/meguminnnnnnnnn/go-openai v0.0.0-20250408071642-761325becfd6 h1:nmdXxiUX48DZ2ELC/jSYzyGUVgxVEF2QJRGhLJ933zA= +github.com/meguminnnnnnnnn/go-openai v0.0.0-20250408071642-761325becfd6/go.mod h1:kyz7fcXqXtccmRAIARn1Q+cKLNXJHC3AoqqJGeCqNI0= github.com/meilisearch/meilisearch-go v0.32.0 h1:cWcycpONSH3VLTZ5npUl1O5aXPkNM0vUx6bywnYqGbE= github.com/meilisearch/meilisearch-go v0.32.0/go.mod h1:aNtyuwurDg/ggxQIcKqWH6G9g2ptc8GyY7PLY4zMn/g= github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b h1:j7+1HpAFS1zy5+Q4qx1fWh90gTKwiN4QCGoY9TWyyO4= @@ -430,8 +432,6 @@ github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/sagikazarmark/locafero v0.7.0 h1:5MqpDsTGNDhY8sGp0Aowyf0qKsPrhewaLSsFaodPcyo= github.com/sagikazarmark/locafero v0.7.0/go.mod h1:2za3Cg5rMaTMoG/2Ulr9AwtFaIppKXTRYnozin4aB5k= -github.com/sashabaranov/go-openai v1.37.0 h1:hQQowgYm4OXJ1Z/wTrE+XZaO20BYsL0R3uRPSpfNZkY= -github.com/sashabaranov/go-openai v1.37.0/go.mod h1:lj5b/K+zjTSFxVLijLSTDZuP7adOgerWeFyZLUhAKRg= github.com/schollz/progressbar/v3 v3.18.0 h1:uXdoHABRFmNIjUfte/Ex7WtuyVslrw2wVPQmCN62HpA= github.com/schollz/progressbar/v3 v3.18.0/go.mod h1:IsO3lpbaGuzh8zIMzgY3+J8l4C8GjO0Y9S69eFvNsec= github.com/shirou/gopsutil/v4 v4.25.4 h1:cdtFO363VEOOFrUCjZRh4XVJkb548lyF0q0uTeMqYPw= diff --git a/internal/agents/agent.go b/internal/agents/agent.go index 226f255e..83edcdd2 100644 --- a/internal/agents/agent.go +++ b/internal/agents/agent.go @@ -15,7 +15,7 @@ func ReactAgent(ctx context.Context, tools []tool.BaseTool) (*react.Agent, error return nil, fmt.Errorf("chat model failed, %w", err) } agent, err := react.NewAgent(ctx, &react.AgentConfig{ - Model: llm, + ToolCallingModel: llm, ToolsConfig: compose.ToolsNodeConfig{ Tools: tools, }, diff --git a/internal/agents/llm.go b/internal/agents/llm.go index 70e92d88..dcac35f7 100644 --- a/internal/agents/llm.go +++ b/internal/agents/llm.go @@ -8,7 +8,7 @@ import ( "github.com/cloudwego/eino/schema" ) -func Generate(ctx context.Context, llm model.ChatModel, in []*schema.Message) (*schema.Message, error) { +func Generate(ctx context.Context, llm model.ToolCallingChatModel, in []*schema.Message) (*schema.Message, error) { _, err := CountMessageTokens(in) if err != nil { return nil, fmt.Errorf("count token failed: %w", err) @@ -21,7 +21,7 @@ func Generate(ctx context.Context, llm model.ChatModel, in []*schema.Message) (* return result, nil } -func Stream(ctx context.Context, llm model.ChatModel, in []*schema.Message) (*schema.StreamReader[*schema.Message], error) { +func Stream(ctx context.Context, llm model.ToolCallingChatModel, in []*schema.Message) (*schema.StreamReader[*schema.Message], error) { _, err := CountMessageTokens(in) if err != nil { return nil, fmt.Errorf("count token failed: %w", err) diff --git a/internal/agents/model.go b/internal/agents/model.go index ce5b88d9..e6a1f1c2 100644 --- a/internal/agents/model.go +++ b/internal/agents/model.go @@ -9,7 +9,7 @@ import ( "github.com/flowline-io/flowbot/pkg/config" ) -func ChatModel(ctx context.Context, modelName string) (model.ChatModel, error) { +func ChatModel(ctx context.Context, modelName string) (model.ToolCallingChatModel, error) { return openai.NewChatModel(ctx, &openai.ChatModelConfig{ BaseURL: config.App.Agent.BaseUrl, APIKey: config.App.Agent.Token, diff --git a/internal/agents/token.go b/internal/agents/token.go index 42d1b708..3666c854 100644 --- a/internal/agents/token.go +++ b/internal/agents/token.go @@ -15,7 +15,7 @@ func CountToken(text string) int { // tiktoken.SetBpeLoader(tiktoken_loader.NewOfflineLoader()) tke, err := tiktoken.GetEncoding(encoding) if err != nil { - flog.Warn("get encoding failed: %w", err) + flog.Warn("get encoding failed: %v", err) return 0 } From 36153066f3defc36cd286dce3b9e58bfbd63ac71 Mon Sep 17 00:00:00 2001 From: sysatom Date: Fri, 9 May 2025 11:26:13 +0800 Subject: [PATCH 064/125] sonic json --- cmd/agent/client/client.go | 6 +++--- cmd/composer/action/generator/tmpl/main.tmpl | 4 ++-- go.mod | 2 +- internal/bots/agent/bot.go | 4 ++-- internal/bots/anki/bot.go | 4 ++-- internal/bots/bookmark/bot.go | 4 ++-- internal/bots/bot.go | 18 +++++++----------- internal/bots/clipboard/bot.go | 4 ++-- internal/bots/cloudflare/bot.go | 4 ++-- internal/bots/dev/bot.go | 5 +++-- internal/bots/finance/bot.go | 5 +++-- internal/bots/gitea/bot.go | 4 ++-- internal/bots/gitea/webhook.go | 6 +++--- internal/bots/github/bot.go | 4 ++-- internal/bots/kanban/bot.go | 4 ++-- internal/bots/notify/bot.go | 5 +++-- internal/bots/obsidian/bot.go | 4 ++-- internal/bots/okr/bot.go | 4 ++-- internal/bots/reader/bot.go | 5 +++-- internal/bots/search/bot.go | 4 ++-- internal/bots/server/bot.go | 5 +++-- internal/bots/torrent/bot.go | 5 +++-- internal/bots/user/bot.go | 4 ++-- internal/bots/webhook/bot.go | 4 ++-- internal/bots/workflow/bot.go | 4 ++-- internal/bots/workflow/form.go | 4 ++-- internal/server/chatbot.go | 6 +++--- internal/server/event.go | 12 ++++++------ internal/server/http.go | 6 +++--- internal/server/init.go | 4 ++-- internal/server/router.go | 12 ++++++------ internal/store/model/json.go | 10 +++++----- internal/store/model/model.go | 4 ++-- internal/store/mysql/adapter.go | 6 +++--- internal/workflow/cron.go | 4 ++-- internal/workflow/handler.go | 8 ++++---- internal/workflow/job.go | 4 ++-- pkg/crawler/crawler.go | 10 +++++----- pkg/event/action.go | 4 ++-- pkg/event/pubsub.go | 7 ++++--- pkg/executer/runtime/docker/auth.go | 8 ++++---- pkg/executer/runtime/docker/docker.go | 4 ++-- pkg/flog/flog.go | 5 ++--- pkg/media/fs/filesys.go | 4 ++-- pkg/media/minio/minio.go | 4 ++-- pkg/page/layout.go | 8 ++++---- pkg/providers/dropbox/dropbox.go | 8 ++++---- pkg/providers/github/github.go | 4 ++-- pkg/providers/pocket/pocket.go | 4 ++-- pkg/search/search.go | 4 ++-- pkg/types/kv.go | 6 +++--- pkg/types/msg.go | 15 ++++++++------- pkg/utils/string.go | 7 ++++--- 53 files changed, 154 insertions(+), 150 deletions(-) diff --git a/cmd/agent/client/client.go b/cmd/agent/client/client.go index 4a152d39..cb412a17 100644 --- a/cmd/agent/client/client.go +++ b/cmd/agent/client/client.go @@ -5,11 +5,11 @@ import ( "net/http" "time" + "github.com/bytedance/sonic" "github.com/flowline-io/flowbot/cmd/agent/config" "github.com/flowline-io/flowbot/pkg/types" "github.com/flowline-io/flowbot/pkg/types/protocol" "github.com/go-resty/resty/v2" - jsoniter "github.com/json-iterator/go" ) type flowbot struct { @@ -43,7 +43,7 @@ func (v *flowbot) fetcher(action types.Action, content types.KV) ([]byte, error) if resp.StatusCode() == http.StatusOK { r := resp.Result().(*protocol.Response) - return jsoniter.Marshal(r.Data) + return sonic.Marshal(r.Data) } else { return nil, fmt.Errorf("%d", resp.StatusCode()) } @@ -59,7 +59,7 @@ func Pull() (*InstructResult, error) { return nil, nil } var r InstructResult - err = jsoniter.Unmarshal(data, &r.Instruct) + err = sonic.Unmarshal(data, &r.Instruct) if err != nil { return nil, err } diff --git a/cmd/composer/action/generator/tmpl/main.tmpl b/cmd/composer/action/generator/tmpl/main.tmpl index 4b11b6c5..e8e3f613 100644 --- a/cmd/composer/action/generator/tmpl/main.tmpl +++ b/cmd/composer/action/generator/tmpl/main.tmpl @@ -7,7 +7,7 @@ import ( "github.com/flowline-io/flowbot/pkg/types" "github.com/flowline-io/flowbot/pkg/flog" {{if .HasCron}}"github.com/flowline-io/flowbot/pkg/types/ruleset/cron"{{end}} - jsoniter "github.com/json-iterator/go" + "github.com/bytedance/sonic" ) const Name = "{{ .BotName }}" @@ -34,7 +34,7 @@ func (bot) Init(jsonconf json.RawMessage) error { } var config configType - if err := jsoniter.Unmarshal(jsonconf, &config); err != nil { + if err := sonic.Unmarshal(jsonconf, &config); err != nil { return errors.New("failed to parse config: " + err.Error()) } diff --git a/go.mod b/go.mod index 80eb06c0..529e3570 100644 --- a/go.mod +++ b/go.mod @@ -13,6 +13,7 @@ require ( github.com/allegro/bigcache/v3 v3.1.0 github.com/bsm/redislock v0.9.4 github.com/bwmarrin/discordgo v0.28.1 + github.com/bytedance/sonic v1.13.2 github.com/cenkalti/backoff v2.2.1+incompatible github.com/cloudwego/eino v0.3.29 github.com/cloudwego/eino-ext/components/model/openai v0.0.0-20250507115047-b20720df8528 @@ -93,7 +94,6 @@ require ( github.com/Rican7/retry v0.3.1 // indirect github.com/andybalholm/brotli v1.1.1 // indirect github.com/andybalholm/cascadia v1.3.3 // indirect - github.com/bytedance/sonic v1.13.2 // indirect github.com/bytedance/sonic/loader v0.2.4 // indirect github.com/cenkalti/backoff/v3 v3.2.2 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect diff --git a/internal/bots/agent/bot.go b/internal/bots/agent/bot.go index 9905071c..8d7cda2e 100644 --- a/internal/bots/agent/bot.go +++ b/internal/bots/agent/bot.go @@ -4,10 +4,10 @@ import ( "encoding/json" "errors" + "github.com/bytedance/sonic" "github.com/flowline-io/flowbot/internal/bots" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/types" - jsoniter "github.com/json-iterator/go" ) const Name = "agent" @@ -34,7 +34,7 @@ func (bot) Init(jsonconf json.RawMessage) error { } var config configType - if err := jsoniter.Unmarshal(jsonconf, &config); err != nil { + if err := sonic.Unmarshal(jsonconf, &config); err != nil { return errors.New("failed to parse config: " + err.Error()) } diff --git a/internal/bots/anki/bot.go b/internal/bots/anki/bot.go index 8d810123..7594e21b 100644 --- a/internal/bots/anki/bot.go +++ b/internal/bots/anki/bot.go @@ -4,11 +4,11 @@ import ( "encoding/json" "errors" + "github.com/bytedance/sonic" "github.com/flowline-io/flowbot/internal/bots" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/types" "github.com/flowline-io/flowbot/pkg/types/ruleset/cron" - jsoniter "github.com/json-iterator/go" ) const Name = "anki" @@ -35,7 +35,7 @@ func (bot) Init(jsonconf json.RawMessage) error { } var config configType - if err := jsoniter.Unmarshal(jsonconf, &config); err != nil { + if err := sonic.Unmarshal(jsonconf, &config); err != nil { return errors.New("failed to parse config: " + err.Error()) } diff --git a/internal/bots/bookmark/bot.go b/internal/bots/bookmark/bot.go index d0f56575..2287be29 100644 --- a/internal/bots/bookmark/bot.go +++ b/internal/bots/bookmark/bot.go @@ -4,11 +4,11 @@ import ( "encoding/json" "errors" + "github.com/bytedance/sonic" "github.com/flowline-io/flowbot/internal/bots" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/types" "github.com/flowline-io/flowbot/pkg/types/ruleset/cron" - jsoniter "github.com/json-iterator/go" ) const Name = "bookmark" @@ -35,7 +35,7 @@ func (bot) Init(jsonconf json.RawMessage) error { return errors.New("already initialized") } - if err := jsoniter.Unmarshal(jsonconf, &Config); err != nil { + if err := sonic.Unmarshal(jsonconf, &Config); err != nil { return errors.New("failed to parse config: " + err.Error()) } diff --git a/internal/bots/bot.go b/internal/bots/bot.go index 018a2c1f..9312ae00 100644 --- a/internal/bots/bot.go +++ b/internal/bots/bot.go @@ -6,11 +6,8 @@ import ( "fmt" "time" + "github.com/bytedance/sonic" llmTool "github.com/cloudwego/eino/components/tool" - "github.com/flowline-io/flowbot/pkg/types/ruleset/tool" - - "github.com/flowline-io/flowbot/pkg/types/ruleset/event" - "github.com/flowline-io/flowbot/internal/store" "github.com/flowline-io/flowbot/internal/store/model" "github.com/flowline-io/flowbot/pkg/flog" @@ -21,16 +18,17 @@ import ( "github.com/flowline-io/flowbot/pkg/types/ruleset/collect" "github.com/flowline-io/flowbot/pkg/types/ruleset/command" "github.com/flowline-io/flowbot/pkg/types/ruleset/cron" + "github.com/flowline-io/flowbot/pkg/types/ruleset/event" "github.com/flowline-io/flowbot/pkg/types/ruleset/form" "github.com/flowline-io/flowbot/pkg/types/ruleset/instruct" "github.com/flowline-io/flowbot/pkg/types/ruleset/page" "github.com/flowline-io/flowbot/pkg/types/ruleset/setting" + "github.com/flowline-io/flowbot/pkg/types/ruleset/tool" "github.com/flowline-io/flowbot/pkg/types/ruleset/webhook" "github.com/flowline-io/flowbot/pkg/types/ruleset/webservice" "github.com/flowline-io/flowbot/pkg/types/ruleset/workflow" "github.com/flowline-io/flowbot/pkg/utils" "github.com/gofiber/fiber/v2" - jsoniter "github.com/json-iterator/go" "gorm.io/gorm" ) @@ -273,8 +271,7 @@ func StoreForm(ctx types.Context, payload types.MsgPayload) types.MsgPayload { } formId := types.Id() - var j = jsoniter.ConfigCompatibleWithStandardLibrary - d, err := j.Marshal(payload) + d, err := sonic.Marshal(payload) if err != nil { flog.Error(err) return types.TextMsg{Text: "store form error"} @@ -338,8 +335,7 @@ func StoreParameter(params types.KV, expiredAt time.Time) (string, error) { func StorePage(ctx types.Context, category model.PageType, title string, payload types.MsgPayload) types.MsgPayload { pageId := types.Id() - var j = jsoniter.ConfigCompatibleWithStandardLibrary - d, err := j.Marshal(payload) + d, err := sonic.Marshal(payload) if err != nil { flog.Error(err) return types.TextMsg{Text: "store form error"} @@ -578,14 +574,14 @@ type configType struct { func Init(jsonconf json.RawMessage) error { var config []json.RawMessage - if err := jsoniter.Unmarshal(jsonconf, &config); err != nil { + if err := sonic.Unmarshal(jsonconf, &config); err != nil { return errors.New("failed to parse config: " + err.Error()) } configMap := make(map[string]json.RawMessage) for _, cc := range config { var item configType - if err := jsoniter.Unmarshal(cc, &item); err != nil { + if err := sonic.Unmarshal(cc, &item); err != nil { return errors.New("failed to parse config: " + err.Error()) } diff --git a/internal/bots/clipboard/bot.go b/internal/bots/clipboard/bot.go index 6f4f64a8..660755d3 100644 --- a/internal/bots/clipboard/bot.go +++ b/internal/bots/clipboard/bot.go @@ -4,11 +4,11 @@ import ( "encoding/json" "errors" + "github.com/bytedance/sonic" "github.com/flowline-io/flowbot/internal/bots" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/types" "github.com/flowline-io/flowbot/pkg/types/ruleset/instruct" - jsoniter "github.com/json-iterator/go" ) const Name = "clipboard" @@ -35,7 +35,7 @@ func (bot) Init(jsonconf json.RawMessage) error { } var config configType - if err := jsoniter.Unmarshal(jsonconf, &config); err != nil { + if err := sonic.Unmarshal(jsonconf, &config); err != nil { return errors.New("failed to parse config: " + err.Error()) } diff --git a/internal/bots/cloudflare/bot.go b/internal/bots/cloudflare/bot.go index 2e25978a..c6a56e3f 100644 --- a/internal/bots/cloudflare/bot.go +++ b/internal/bots/cloudflare/bot.go @@ -4,10 +4,10 @@ import ( "encoding/json" "errors" + "github.com/bytedance/sonic" "github.com/flowline-io/flowbot/internal/bots" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/types" - jsoniter "github.com/json-iterator/go" ) const Name = "cloudflare" @@ -34,7 +34,7 @@ func (bot) Init(jsonconf json.RawMessage) error { } var config configType - if err := jsoniter.Unmarshal(jsonconf, &config); err != nil { + if err := sonic.Unmarshal(jsonconf, &config); err != nil { return errors.New("failed to parse config: " + err.Error()) } diff --git a/internal/bots/dev/bot.go b/internal/bots/dev/bot.go index 7ca103c9..0694c200 100644 --- a/internal/bots/dev/bot.go +++ b/internal/bots/dev/bot.go @@ -3,13 +3,14 @@ package dev import ( "encoding/json" "errors" + + "github.com/bytedance/sonic" "github.com/flowline-io/flowbot/internal/bots" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/types" "github.com/flowline-io/flowbot/pkg/types/ruleset/cron" "github.com/flowline-io/flowbot/pkg/types/ruleset/instruct" "github.com/gofiber/fiber/v2" - jsoniter "github.com/json-iterator/go" ) const Name = "dev" @@ -37,7 +38,7 @@ func (bot) Init(jsonconf json.RawMessage) error { return errors.New("already initialized") } - if err := jsoniter.Unmarshal(jsonconf, &config); err != nil { + if err := sonic.Unmarshal(jsonconf, &config); err != nil { return errors.New("failed to parse config: " + err.Error()) } diff --git a/internal/bots/finance/bot.go b/internal/bots/finance/bot.go index f6d99760..ab2a2464 100644 --- a/internal/bots/finance/bot.go +++ b/internal/bots/finance/bot.go @@ -3,12 +3,13 @@ package finance import ( "encoding/json" "errors" + "github.com/flowline-io/flowbot/pkg/types/ruleset/cron" + "github.com/bytedance/sonic" "github.com/flowline-io/flowbot/internal/bots" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/types" - jsoniter "github.com/json-iterator/go" ) const Name = "finance" @@ -35,7 +36,7 @@ func (bot) Init(jsonconf json.RawMessage) error { } var config configType - if err := jsoniter.Unmarshal(jsonconf, &config); err != nil { + if err := sonic.Unmarshal(jsonconf, &config); err != nil { return errors.New("failed to parse config: " + err.Error()) } diff --git a/internal/bots/gitea/bot.go b/internal/bots/gitea/bot.go index befbfeed..ff9e3d53 100644 --- a/internal/bots/gitea/bot.go +++ b/internal/bots/gitea/bot.go @@ -4,11 +4,11 @@ import ( "encoding/json" "errors" + "github.com/bytedance/sonic" "github.com/flowline-io/flowbot/internal/bots" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/types" "github.com/flowline-io/flowbot/pkg/types/ruleset/cron" - jsoniter "github.com/json-iterator/go" ) const Name = "gitea" @@ -35,7 +35,7 @@ func (bot) Init(jsonconf json.RawMessage) error { } var config configType - if err := jsoniter.Unmarshal(jsonconf, &config); err != nil { + if err := sonic.Unmarshal(jsonconf, &config); err != nil { return errors.New("failed to parse config: " + err.Error()) } diff --git a/internal/bots/gitea/webhook.go b/internal/bots/gitea/webhook.go index 95987be3..6e913f24 100644 --- a/internal/bots/gitea/webhook.go +++ b/internal/bots/gitea/webhook.go @@ -3,12 +3,12 @@ package gitea import ( "net/http" + "github.com/bytedance/sonic" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/providers/gitea" "github.com/flowline-io/flowbot/pkg/types" "github.com/flowline-io/flowbot/pkg/types/ruleset/webhook" "github.com/flowline-io/flowbot/pkg/utils" - jsoniter "github.com/json-iterator/go" ) const ( @@ -26,7 +26,7 @@ var webhookRules = []webhook.Rule{ } var issue *gitea.IssuePayload - err := jsoniter.Unmarshal(data, &issue) + err := sonic.Unmarshal(data, &issue) if err != nil { flog.Error(err) return types.TextMsg{Text: "error"} @@ -79,7 +79,7 @@ var webhookRules = []webhook.Rule{ switch eventType { case "push": var repoPayload *gitea.RepoPayload - err := jsoniter.Unmarshal(data, &repoPayload) + err := sonic.Unmarshal(data, &repoPayload) if err != nil { flog.Error(err) return types.TextMsg{Text: "error"} diff --git a/internal/bots/github/bot.go b/internal/bots/github/bot.go index f7765d6d..341adf8f 100644 --- a/internal/bots/github/bot.go +++ b/internal/bots/github/bot.go @@ -4,11 +4,11 @@ import ( "encoding/json" "errors" + "github.com/bytedance/sonic" "github.com/flowline-io/flowbot/internal/bots" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/types" "github.com/flowline-io/flowbot/pkg/types/ruleset/cron" - jsoniter "github.com/json-iterator/go" ) const Name = "github" @@ -35,7 +35,7 @@ func (bot) Init(jsonconf json.RawMessage) error { return errors.New("already initialized") } - if err := jsoniter.Unmarshal(jsonconf, &Config); err != nil { + if err := sonic.Unmarshal(jsonconf, &Config); err != nil { return errors.New("failed to parse config: " + err.Error()) } diff --git a/internal/bots/kanban/bot.go b/internal/bots/kanban/bot.go index 5de90817..bae12816 100755 --- a/internal/bots/kanban/bot.go +++ b/internal/bots/kanban/bot.go @@ -4,11 +4,11 @@ import ( "encoding/json" "errors" + "github.com/bytedance/sonic" "github.com/flowline-io/flowbot/internal/bots" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/types" "github.com/flowline-io/flowbot/pkg/types/ruleset/cron" - jsoniter "github.com/json-iterator/go" ) const Name = "kanban" @@ -35,7 +35,7 @@ func (bot) Init(jsonconf json.RawMessage) error { } var config configType - if err := jsoniter.Unmarshal(jsonconf, &config); err != nil { + if err := sonic.Unmarshal(jsonconf, &config); err != nil { return errors.New("failed to parse config: " + err.Error()) } diff --git a/internal/bots/notify/bot.go b/internal/bots/notify/bot.go index 10815b69..298057a5 100644 --- a/internal/bots/notify/bot.go +++ b/internal/bots/notify/bot.go @@ -3,11 +3,12 @@ package notify import ( "encoding/json" "errors" + + "github.com/bytedance/sonic" "github.com/flowline-io/flowbot/internal/bots" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/types" "github.com/flowline-io/flowbot/pkg/types/ruleset/cron" - jsoniter "github.com/json-iterator/go" ) const Name = "notify" @@ -34,7 +35,7 @@ func (bot) Init(jsonconf json.RawMessage) error { } var config configType - if err := jsoniter.Unmarshal(jsonconf, &config); err != nil { + if err := sonic.Unmarshal(jsonconf, &config); err != nil { return errors.New("failed to parse config: " + err.Error()) } diff --git a/internal/bots/obsidian/bot.go b/internal/bots/obsidian/bot.go index c566f153..bbe1ee5d 100644 --- a/internal/bots/obsidian/bot.go +++ b/internal/bots/obsidian/bot.go @@ -4,10 +4,10 @@ import ( "encoding/json" "errors" + "github.com/bytedance/sonic" "github.com/flowline-io/flowbot/internal/bots" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/types" - jsoniter "github.com/json-iterator/go" ) const Name = "obsidian" @@ -34,7 +34,7 @@ func (bot) Init(jsonconf json.RawMessage) error { } var config configType - if err := jsoniter.Unmarshal(jsonconf, &config); err != nil { + if err := sonic.Unmarshal(jsonconf, &config); err != nil { return errors.New("failed to parse config: " + err.Error()) } diff --git a/internal/bots/okr/bot.go b/internal/bots/okr/bot.go index 3cc98d3a..dc688abc 100644 --- a/internal/bots/okr/bot.go +++ b/internal/bots/okr/bot.go @@ -4,11 +4,11 @@ import ( "encoding/json" "errors" + "github.com/bytedance/sonic" "github.com/flowline-io/flowbot/internal/bots" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/types" "github.com/gofiber/fiber/v2" - jsoniter "github.com/json-iterator/go" ) const Name = "okr" @@ -35,7 +35,7 @@ func (bot) Init(jsonconf json.RawMessage) error { } var config configType - if err := jsoniter.Unmarshal(jsonconf, &config); err != nil { + if err := sonic.Unmarshal(jsonconf, &config); err != nil { return errors.New("failed to parse config: " + err.Error()) } diff --git a/internal/bots/reader/bot.go b/internal/bots/reader/bot.go index a84e392c..905c9408 100644 --- a/internal/bots/reader/bot.go +++ b/internal/bots/reader/bot.go @@ -3,11 +3,12 @@ package reader import ( "encoding/json" "errors" + + "github.com/bytedance/sonic" "github.com/flowline-io/flowbot/internal/bots" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/types" "github.com/flowline-io/flowbot/pkg/types/ruleset/cron" - jsoniter "github.com/json-iterator/go" ) const Name = "reader" @@ -34,7 +35,7 @@ func (bot) Init(jsonconf json.RawMessage) error { } var config configType - if err := jsoniter.Unmarshal(jsonconf, &config); err != nil { + if err := sonic.Unmarshal(jsonconf, &config); err != nil { return errors.New("failed to parse config: " + err.Error()) } diff --git a/internal/bots/search/bot.go b/internal/bots/search/bot.go index 1bb3011c..8d4a9e1f 100755 --- a/internal/bots/search/bot.go +++ b/internal/bots/search/bot.go @@ -4,12 +4,12 @@ import ( "encoding/json" "errors" + "github.com/bytedance/sonic" "github.com/flowline-io/flowbot/internal/bots" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/types" "github.com/flowline-io/flowbot/pkg/types/ruleset/cron" "github.com/gofiber/fiber/v2" - jsoniter "github.com/json-iterator/go" ) const Name = "search" @@ -36,7 +36,7 @@ func (bot) Init(jsonconf json.RawMessage) error { } var config configType - if err := jsoniter.Unmarshal(jsonconf, &config); err != nil { + if err := sonic.Unmarshal(jsonconf, &config); err != nil { return errors.New("failed to parse config: " + err.Error()) } diff --git a/internal/bots/server/bot.go b/internal/bots/server/bot.go index 841b22e1..0ab0e350 100644 --- a/internal/bots/server/bot.go +++ b/internal/bots/server/bot.go @@ -3,13 +3,14 @@ package server import ( "encoding/json" "errors" + "github.com/gofiber/fiber/v2" + "github.com/bytedance/sonic" "github.com/flowline-io/flowbot/internal/bots" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/types" "github.com/flowline-io/flowbot/pkg/types/ruleset/cron" - jsoniter "github.com/json-iterator/go" ) const Name = "server" @@ -36,7 +37,7 @@ func (bot) Init(jsonconf json.RawMessage) error { } var config configType - if err := jsoniter.Unmarshal(jsonconf, &config); err != nil { + if err := sonic.Unmarshal(jsonconf, &config); err != nil { return errors.New("failed to parse config: " + err.Error()) } diff --git a/internal/bots/torrent/bot.go b/internal/bots/torrent/bot.go index 84399514..bd374df7 100644 --- a/internal/bots/torrent/bot.go +++ b/internal/bots/torrent/bot.go @@ -3,11 +3,12 @@ package torrent import ( "encoding/json" "errors" + + "github.com/bytedance/sonic" "github.com/flowline-io/flowbot/internal/bots" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/types" "github.com/flowline-io/flowbot/pkg/types/ruleset/cron" - jsoniter "github.com/json-iterator/go" ) const Name = "torrent" @@ -34,7 +35,7 @@ func (bot) Init(jsonconf json.RawMessage) error { } var config configType - if err := jsoniter.Unmarshal(jsonconf, &config); err != nil { + if err := sonic.Unmarshal(jsonconf, &config); err != nil { return errors.New("failed to parse config: " + err.Error()) } diff --git a/internal/bots/user/bot.go b/internal/bots/user/bot.go index 76c26660..9e2e0c20 100644 --- a/internal/bots/user/bot.go +++ b/internal/bots/user/bot.go @@ -4,11 +4,11 @@ import ( "encoding/json" "errors" + "github.com/bytedance/sonic" "github.com/flowline-io/flowbot/internal/bots" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/types" "github.com/gofiber/fiber/v2" - jsoniter "github.com/json-iterator/go" ) const Name = "user" @@ -35,7 +35,7 @@ func (bot) Init(jsonconf json.RawMessage) error { } var config configType - if err := jsoniter.Unmarshal(jsonconf, &config); err != nil { + if err := sonic.Unmarshal(jsonconf, &config); err != nil { return errors.New("failed to parse config: " + err.Error()) } diff --git a/internal/bots/webhook/bot.go b/internal/bots/webhook/bot.go index ee57ec36..ac951ebe 100644 --- a/internal/bots/webhook/bot.go +++ b/internal/bots/webhook/bot.go @@ -4,10 +4,10 @@ import ( "encoding/json" "errors" + "github.com/bytedance/sonic" "github.com/flowline-io/flowbot/internal/bots" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/types" - jsoniter "github.com/json-iterator/go" ) const Name = "webhook" @@ -34,7 +34,7 @@ func (bot) Init(jsonconf json.RawMessage) error { } var config configType - if err := jsoniter.Unmarshal(jsonconf, &config); err != nil { + if err := sonic.Unmarshal(jsonconf, &config); err != nil { return errors.New("failed to parse config: " + err.Error()) } diff --git a/internal/bots/workflow/bot.go b/internal/bots/workflow/bot.go index 9c779192..6474a3a8 100644 --- a/internal/bots/workflow/bot.go +++ b/internal/bots/workflow/bot.go @@ -4,12 +4,12 @@ import ( "encoding/json" "errors" + "github.com/bytedance/sonic" "github.com/flowline-io/flowbot/internal/bots" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/types" "github.com/flowline-io/flowbot/pkg/types/ruleset/cron" "github.com/gofiber/fiber/v2" - jsoniter "github.com/json-iterator/go" ) const Name = "workflow" @@ -36,7 +36,7 @@ func (bot) Init(jsonconf json.RawMessage) error { } var config configType - if err := jsoniter.Unmarshal(jsonconf, &config); err != nil { + if err := sonic.Unmarshal(jsonconf, &config); err != nil { return errors.New("failed to parse config: " + err.Error()) } diff --git a/internal/bots/workflow/form.go b/internal/bots/workflow/form.go index a8a01484..5867acc1 100644 --- a/internal/bots/workflow/form.go +++ b/internal/bots/workflow/form.go @@ -4,13 +4,13 @@ import ( "fmt" "strings" + "github.com/bytedance/sonic" "github.com/flowline-io/flowbot/internal/bots" "github.com/flowline-io/flowbot/internal/store" "github.com/flowline-io/flowbot/internal/store/model" "github.com/flowline-io/flowbot/pkg/types" "github.com/flowline-io/flowbot/pkg/types/ruleset/form" "github.com/flowline-io/flowbot/pkg/types/ruleset/workflow" - jsoniter "github.com/json-iterator/go" "gopkg.in/yaml.v3" ) @@ -94,7 +94,7 @@ var formRules = []form.Rule{ return types.TextMsg{Text: fmt.Sprintf("error: %s", err)} } - result, err := jsoniter.Marshal(output) + result, err := sonic.Marshal(output) if err != nil { return types.TextMsg{Text: fmt.Sprintf("error: %s", err)} } diff --git a/internal/server/chatbot.go b/internal/server/chatbot.go index 309934f3..2bd4e820 100644 --- a/internal/server/chatbot.go +++ b/internal/server/chatbot.go @@ -4,6 +4,7 @@ import ( "context" "fmt" + "github.com/bytedance/sonic" "github.com/flowline-io/flowbot/internal/bots" "github.com/flowline-io/flowbot/internal/bots/agent" "github.com/flowline-io/flowbot/internal/bots/anki" @@ -34,7 +35,6 @@ import ( "github.com/flowline-io/flowbot/pkg/stats" "github.com/flowline-io/flowbot/pkg/utils/sets" "github.com/flowline-io/flowbot/version" - jsoniter "github.com/json-iterator/go" "github.com/redis/go-redis/v9" "go.uber.org/fx" ) @@ -85,11 +85,11 @@ func handleChatbot(lc fx.Lifecycle, _ config.Type, _ store.Adapter, _ *redis.Cli // initialize bots func initializeBot(botsConfig interface{}, vendorsConfig interface{}) { - b, err := jsoniter.Marshal(botsConfig) + b, err := sonic.Marshal(botsConfig) if err != nil { flog.Fatal("Failed to marshal bots: %v", err) } - v, err := jsoniter.Marshal(vendorsConfig) + v, err := sonic.Marshal(vendorsConfig) if err != nil { flog.Fatal("Failed to marshal vendors: %v", err) } diff --git a/internal/server/event.go b/internal/server/event.go index 06b32b33..5c573f26 100644 --- a/internal/server/event.go +++ b/internal/server/event.go @@ -7,12 +7,12 @@ import ( "time" "github.com/ThreeDotsLabs/watermill/message" + "github.com/bytedance/sonic" "github.com/flowline-io/flowbot/internal/bots" "github.com/flowline-io/flowbot/internal/platforms" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/types" "github.com/flowline-io/flowbot/pkg/types/protocol" - jsoniter "github.com/json-iterator/go" "go.uber.org/fx" ) @@ -72,7 +72,7 @@ func onMessageSendEventHandler(msg *message.Message) error { flog.Debug("[event] on event %+v %+v", msg.UUID, msg.Metadata) var pe types.Message - err := jsoniter.Unmarshal(msg.Payload, &pe) + err := sonic.Unmarshal(msg.Payload, &pe) if err != nil { return fmt.Errorf("failed to unmarshal message: %w", err) } @@ -116,7 +116,7 @@ func onBotRunEventHandler(msg *message.Message) error { flog.Debug("[event] on event %+v %+v", msg.UUID, msg.Metadata) var be types.BotEvent - err := jsoniter.Unmarshal(msg.Payload, &be) + err := sonic.Unmarshal(msg.Payload, &be) if err != nil { return fmt.Errorf("failed to unmarshal bot event: %w", err) } @@ -142,17 +142,17 @@ func onPlatformMessageEventHandler(msg *message.Message) error { flog.Debug("[event] on event %+v %+v", msg.UUID, msg.Metadata) var pe protocol.Event - err := jsoniter.Unmarshal(msg.Payload, &pe) + err := sonic.Unmarshal(msg.Payload, &pe) if err != nil { return fmt.Errorf("failed to unmarshal platform message event: %w", err) } - data, err := jsoniter.Marshal(pe.Data) + data, err := sonic.Marshal(pe.Data) if err != nil { return fmt.Errorf("failed to marshal platform message event: %w", err) } var v protocol.MessageEventData - err = jsoniter.Unmarshal(data, &v) + err = sonic.Unmarshal(data, &v) if err != nil { return fmt.Errorf("failed to unmarshal platform message event: %w", err) } diff --git a/internal/server/http.go b/internal/server/http.go index 131e3f41..804a9753 100644 --- a/internal/server/http.go +++ b/internal/server/http.go @@ -4,6 +4,7 @@ import ( "net/http" "time" + "github.com/bytedance/sonic" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/types/protocol" "github.com/gofiber/contrib/fiberzerolog" @@ -14,7 +15,6 @@ import ( "github.com/gofiber/fiber/v2/middleware/limiter" "github.com/gofiber/fiber/v2/middleware/recover" "github.com/gofiber/fiber/v2/middleware/requestid" - jsoniter "github.com/json-iterator/go" ) func newHTTPServer() *fiber.App { @@ -22,8 +22,8 @@ func newHTTPServer() *fiber.App { app := fiber.New(fiber.Config{ DisableStartupMessage: true, - JSONDecoder: jsoniter.Unmarshal, - JSONEncoder: jsoniter.Marshal, + JSONDecoder: sonic.Unmarshal, + JSONEncoder: sonic.Marshal, ReadTimeout: 10 * time.Second, IdleTimeout: 30 * time.Second, WriteTimeout: 90 * time.Second, diff --git a/internal/server/init.go b/internal/server/init.go index 4421a795..c5fb09a3 100644 --- a/internal/server/init.go +++ b/internal/server/init.go @@ -6,12 +6,12 @@ import ( "time" "github.com/VictoriaMetrics/metrics" + "github.com/bytedance/sonic" "github.com/flowline-io/flowbot/internal/store" "github.com/flowline-io/flowbot/pkg/config" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/version" "github.com/gofiber/fiber/v2" - jsoniter "github.com/json-iterator/go" ) var ( @@ -43,7 +43,7 @@ func initializeMedia() error { if config.App.Media.Handlers != nil { var conf string if params := config.App.Media.Handlers[config.App.Media.UseHandler]; params != nil { - data, err := jsoniter.Marshal(params) + data, err := sonic.Marshal(params) if err != nil { return fmt.Errorf("failed to marshal media handler, %w", err) } diff --git a/internal/server/router.go b/internal/server/router.go index 96a3ac74..320478b3 100644 --- a/internal/server/router.go +++ b/internal/server/router.go @@ -8,6 +8,7 @@ import ( "strconv" "strings" + "github.com/bytedance/sonic" "github.com/flowline-io/flowbot/internal/bots" "github.com/flowline-io/flowbot/internal/platforms/slack" "github.com/flowline-io/flowbot/internal/platforms/tailchat" @@ -26,7 +27,6 @@ import ( "github.com/go-echarts/go-echarts/v2/charts" "github.com/go-echarts/go-echarts/v2/opts" "github.com/gofiber/fiber/v2" - jsoniter "github.com/json-iterator/go" "github.com/maxence-charriere/go-app/v10/pkg/app" "github.com/valyala/fasthttp/fasthttpadaptor" "gorm.io/gorm" @@ -132,12 +132,12 @@ func (c *Controller) getPage(ctx *fiber.Ctx) error { case model.PageHtml: comp = page.RenderHtml(p) case model.PageChart: - d, err := jsoniter.Marshal(p.Schema) + d, err := sonic.Marshal(p.Schema) if err != nil { return ctx.JSON(protocol.NewFailedResponseWithError(protocol.ErrBadRequest, err)) } var msg types.ChartMsg - err = jsoniter.Unmarshal(d, &msg) + err = sonic.Unmarshal(d, &msg) if err != nil { return ctx.JSON(protocol.NewFailedResponseWithError(protocol.ErrBadRequest, err)) } @@ -229,12 +229,12 @@ func (c *Controller) postForm(ctx *fiber.Ctx) error { } values := make(types.KV) - d, err := jsoniter.Marshal(formData.Schema) + d, err := sonic.Marshal(formData.Schema) if err != nil { return ctx.JSON(protocol.NewFailedResponseWithError(protocol.ErrBadRequest, err)) } var formMsg types.FormMsg - err = jsoniter.Unmarshal(d, &formMsg) + err = sonic.Unmarshal(d, &formMsg) if err != nil { return ctx.JSON(protocol.NewFailedResponseWithError(protocol.ErrBadRequest, err)) } @@ -345,7 +345,7 @@ func (c *Controller) agentData(ctx *fiber.Ctx) error { } var data types.AgentData - err := jsoniter.Unmarshal(ctx.Body(), &data) + err := sonic.Unmarshal(ctx.Body(), &data) if err != nil { return ctx.JSON(protocol.NewFailedResponseWithError(protocol.ErrBadRequest, err)) } diff --git a/internal/store/model/json.go b/internal/store/model/json.go index c993a4c4..74b50e36 100644 --- a/internal/store/model/json.go +++ b/internal/store/model/json.go @@ -5,7 +5,7 @@ import ( "errors" "fmt" - jsoniter "github.com/json-iterator/go" + "github.com/bytedance/sonic" ) type JSON map[string]interface{} @@ -17,7 +17,7 @@ func (j JSON) GormDataType() string { func (j *JSON) Scan(value interface{}) error { if bytes, ok := value.([]byte); ok { result := make(map[string]interface{}) - err := jsoniter.Unmarshal(bytes, &result) + err := sonic.Unmarshal(bytes, &result) if err != nil { return err } @@ -35,7 +35,7 @@ func (j JSON) Value() (driver.Value, error) { if len(j) == 0 { return nil, nil } - return jsoniter.Marshal(j) + return sonic.Marshal(j) } type IDList []int64 @@ -47,7 +47,7 @@ func (j IDList) GormDataType() string { func (j *IDList) Scan(value interface{}) error { if bytes, ok := value.([]byte); ok { result := make([]int64, 0) - err := jsoniter.Unmarshal(bytes, &result) + err := sonic.Unmarshal(bytes, &result) if err != nil { return err } @@ -65,5 +65,5 @@ func (j IDList) Value() (driver.Value, error) { if len(j) == 0 { return nil, nil } - return jsoniter.Marshal(j) + return sonic.Marshal(j) } diff --git a/internal/store/model/model.go b/internal/store/model/model.go index a195456d..57e4e8e2 100644 --- a/internal/store/model/model.go +++ b/internal/store/model/model.go @@ -3,7 +3,7 @@ package model import ( "time" - jsoniter "github.com/json-iterator/go" + "github.com/bytedance/sonic" ) // IsExpired check expired @@ -12,5 +12,5 @@ func (p *Parameter) IsExpired() bool { } func (j *Job) MarshalBinary() (data []byte, err error) { - return jsoniter.Marshal(j) + return sonic.Marshal(j) } diff --git a/internal/store/mysql/adapter.go b/internal/store/mysql/adapter.go index d795d32d..695b2241 100644 --- a/internal/store/mysql/adapter.go +++ b/internal/store/mysql/adapter.go @@ -8,6 +8,7 @@ import ( "time" "github.com/bsm/redislock" + "github.com/bytedance/sonic" "github.com/flowline-io/flowbot/internal/store" "github.com/flowline-io/flowbot/internal/store/dao" "github.com/flowline-io/flowbot/internal/store/model" @@ -16,7 +17,6 @@ import ( "github.com/flowline-io/flowbot/pkg/locker" "github.com/flowline-io/flowbot/pkg/types" ms "github.com/go-sql-driver/mysql" - jsoniter "github.com/json-iterator/go" mysqlDriver "gorm.io/driver/mysql" "gorm.io/gen/field" "gorm.io/gorm" @@ -221,11 +221,11 @@ func (a *adapter) Open(adaptersConfig config.StoreType) error { defaultCfg := ms.NewConfig() conf := configType{Config: *defaultCfg} - data, err := jsoniter.Marshal(adaptersConfig.Adapters["mysql"]) + data, err := sonic.Marshal(adaptersConfig.Adapters["mysql"]) if err != nil { return errors.New("mysql adapter failed to parse config: " + err.Error()) } - if err = jsoniter.Unmarshal(data, &conf); err != nil { + if err = sonic.Unmarshal(data, &conf); err != nil { return errors.New("mysql adapter failed to parse config: " + err.Error()) } diff --git a/internal/workflow/cron.go b/internal/workflow/cron.go index 4dbe5805..eabbac89 100644 --- a/internal/workflow/cron.go +++ b/internal/workflow/cron.go @@ -4,13 +4,13 @@ import ( "context" "time" + "github.com/bytedance/sonic" "github.com/flowline-io/flowbot/internal/store" "github.com/flowline-io/flowbot/internal/store/model" "github.com/flowline-io/flowbot/pkg/config" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/types" "github.com/hibiken/asynq" - jsoniter "github.com/json-iterator/go" "github.com/redis/go-redis/v9" "go.uber.org/fx" ) @@ -89,7 +89,7 @@ func (d *DatabaseProvider) GetConfigs() ([]*asynq.PeriodicTaskConfig, error) { flog.Warn("error %v", err) continue } - payload, err := jsoniter.Marshal(trigger) + payload, err := sonic.Marshal(trigger) if err != nil { flog.Error(err) continue diff --git a/internal/workflow/handler.go b/internal/workflow/handler.go index 23e68216..34582427 100644 --- a/internal/workflow/handler.go +++ b/internal/workflow/handler.go @@ -6,16 +6,16 @@ import ( "strconv" "time" + "github.com/bytedance/sonic" "github.com/flowline-io/flowbot/internal/store" "github.com/flowline-io/flowbot/internal/store/model" "github.com/flowline-io/flowbot/pkg/flog" "github.com/hibiken/asynq" - jsoniter "github.com/json-iterator/go" ) func HandleCronTask(ctx context.Context, t *asynq.Task) error { var trigger model.WorkflowTrigger - if err := jsoniter.Unmarshal(t.Payload(), &trigger); err != nil { + if err := sonic.Unmarshal(t.Payload(), &trigger); err != nil { return fmt.Errorf("failed to unmarshal trigger: %w: %w", err, asynq.SkipRetry) } flog.Debug("trigger %+v, %s task has been received", trigger, t.Type()) @@ -70,7 +70,7 @@ func HandleCronTask(ctx context.Context, t *asynq.Task) error { } func NewJobTask(job *model.Job) (*Task, error) { - payload, err := jsoniter.Marshal(job) + payload, err := sonic.Marshal(job) if err != nil { return nil, fmt.Errorf("failed to marshal job %d, %w", job.ID, err) } @@ -86,7 +86,7 @@ func NewJobTask(job *model.Job) (*Task, error) { func HandleJobTask(ctx context.Context, t *asynq.Task) error { var job *model.Job - if err := jsoniter.Unmarshal(t.Payload(), &job); err != nil { + if err := sonic.Unmarshal(t.Payload(), &job); err != nil { return fmt.Errorf("failed to unmarshal job: %w: %w", err, asynq.SkipRetry) } flog.Debug("job: %+v", job) diff --git a/internal/workflow/job.go b/internal/workflow/job.go index 7775f393..0574d270 100644 --- a/internal/workflow/job.go +++ b/internal/workflow/job.go @@ -5,10 +5,10 @@ import ( "fmt" "strconv" + "github.com/bytedance/sonic" "github.com/flowline-io/flowbot/internal/store/model" "github.com/flowline-io/flowbot/pkg/rdb" "github.com/flowline-io/flowbot/pkg/utils" - jsoniter "github.com/json-iterator/go" ) const ( @@ -31,7 +31,7 @@ func GetJobsByState(ctx context.Context, state model.JobState) ([]*model.Job, er var jobs []*model.Job for _, v := range res { job := &model.Job{} - err = jsoniter.Unmarshal(utils.StringToBytes(v), job) + err = sonic.Unmarshal(utils.StringToBytes(v), job) if err != nil { return nil, fmt.Errorf("failed to unmarshal job %s, %w", v, err) } diff --git a/pkg/crawler/crawler.go b/pkg/crawler/crawler.go index 4b90b2c0..e0f8a5c5 100644 --- a/pkg/crawler/crawler.go +++ b/pkg/crawler/crawler.go @@ -12,11 +12,11 @@ import ( "strconv" "time" + "github.com/bytedance/sonic" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/rdb" "github.com/flowline-io/flowbot/pkg/utils" "github.com/influxdata/cron" - jsoniter "github.com/json-iterator/go" "github.com/redis/go-redis/v9" ) @@ -154,7 +154,7 @@ func (s *Crawler) filter(name, mode string, latest []map[string]string) []map[st var old []map[string]string for _, item := range oldArr { var tmp map[string]string - _ = jsoniter.Unmarshal([]byte(item), &tmp) + _ = sonic.Unmarshal([]byte(item), &tmp) if tmp != nil { old = append(old, tmp) } @@ -168,7 +168,7 @@ func (s *Crawler) filter(name, mode string, latest []map[string]string) []map[st var todo []map[string]string for _, item := range todoArr { var tmp map[string]string - _ = jsoniter.Unmarshal([]byte(item), &tmp) + _ = sonic.Unmarshal([]byte(item), &tmp) if tmp != nil { todo = append(todo, tmp) } @@ -195,7 +195,7 @@ func (s *Crawler) filter(name, mode string, latest []map[string]string) []map[st if time.Now().Unix()-oldSend < 24*60*60 { for _, item := range diff { - d, _ := jsoniter.Marshal(item) + d, _ := sonic.Marshal(item) _ = rdb.Client.SAdd(ctx, todoKey, d) } @@ -211,7 +211,7 @@ func (s *Crawler) filter(name, mode string, latest []map[string]string) []map[st // add data for _, item := range diff { - d, _ := jsoniter.Marshal(item) + d, _ := sonic.Marshal(item) _ = rdb.Client.SAdd(ctx, sentKey, d) } diff --git a/pkg/event/action.go b/pkg/event/action.go index 8a97bbc6..eed2e1a4 100644 --- a/pkg/event/action.go +++ b/pkg/event/action.go @@ -3,16 +3,16 @@ package event import ( "fmt" + "github.com/bytedance/sonic" "github.com/flowline-io/flowbot/internal/store" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/types" "github.com/flowline-io/flowbot/pkg/utils/sets" - jsoniter "github.com/json-iterator/go" ) func SendMessage(ctx types.Context, msg types.MsgPayload) error { // payload - src, err := jsoniter.Marshal(msg) + src, err := sonic.Marshal(msg) if err != nil { return fmt.Errorf("failed to marshal payload: %w", err) } diff --git a/pkg/event/pubsub.go b/pkg/event/pubsub.go index c09c118e..58f74a7e 100644 --- a/pkg/event/pubsub.go +++ b/pkg/event/pubsub.go @@ -3,16 +3,17 @@ package event import ( "context" "fmt" + "time" + "github.com/ThreeDotsLabs/watermill" "github.com/ThreeDotsLabs/watermill-redisstream/pkg/redisstream" "github.com/ThreeDotsLabs/watermill/message" "github.com/ThreeDotsLabs/watermill/message/router/middleware" + "github.com/bytedance/sonic" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/stats" - jsoniter "github.com/json-iterator/go" "github.com/redis/go-redis/v9" "go.uber.org/fx" - "time" ) var logger = flog.WatermillLogger @@ -111,7 +112,7 @@ func NewRouter(_ *redis.Client) (*message.Router, error) { } func NewMessage(payload any) (*message.Message, error) { - data, err := jsoniter.Marshal(payload) + data, err := sonic.Marshal(payload) if err != nil { return nil, fmt.Errorf("failed to marshal payload: %w", err) } diff --git a/pkg/executer/runtime/docker/auth.go b/pkg/executer/runtime/docker/auth.go index cd5031c7..a0847baf 100644 --- a/pkg/executer/runtime/docker/auth.go +++ b/pkg/executer/runtime/docker/auth.go @@ -10,8 +10,8 @@ import ( "runtime" "strings" + "github.com/bytedance/sonic" "github.com/flowline-io/flowbot/pkg/flog" - jsoniter "github.com/json-iterator/go" ) // Errors from credential helpers @@ -145,7 +145,7 @@ func getCredentialsFromHelper(helper, hostname string) (string, string, error) { Secret string } - if err := jsoniter.Unmarshal(b, &creds); err != nil { + if err := sonic.Unmarshal(b, &creds); err != nil { return "", "", err } @@ -187,7 +187,7 @@ func userHomeConfigPath() (string, error) { // ConfigPath returns the path to the docker cli config. // // It will either use the DOCKER_CONFIG env var if set, or the value from `UserHomeConfigPath` -// DOCKER_CONFIG would be the dir path where `config.json` is stored, this returns the path to config.jsoniter. +// DOCKER_CONFIG would be the dir path where `config.json` is stored, this returns the path to config.sonic. func configPath(configFile string) (string, error) { if configFile != "" { return configFile, nil @@ -212,7 +212,7 @@ func fromFile(configPath string, cfg *config) error { if err != nil { return err } - if err := jsoniter.NewDecoder(f).Decode(&cfg); err != nil { + if err := sonic.ConfigDefault.NewDecoder(f).Decode(&cfg); err != nil { return fmt.Errorf("error decoding docker config, %w", err) } if err := f.Close(); err != nil { diff --git a/pkg/executer/runtime/docker/docker.go b/pkg/executer/runtime/docker/docker.go index 01116626..9b74015c 100644 --- a/pkg/executer/runtime/docker/docker.go +++ b/pkg/executer/runtime/docker/docker.go @@ -14,6 +14,7 @@ import ( "time" "unicode" + "github.com/bytedance/sonic" cliopts "github.com/docker/cli/opts" "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/image" @@ -27,7 +28,6 @@ import ( "github.com/flowline-io/flowbot/pkg/types" "github.com/flowline-io/flowbot/pkg/utils" "github.com/flowline-io/flowbot/pkg/utils/syncx" - jsoniter "github.com/json-iterator/go" ) type Runtime struct { @@ -602,7 +602,7 @@ func (d *Runtime) puller(ctx context.Context) { } } - encodedJSON, err := jsoniter.Marshal(authConfig) + encodedJSON, err := sonic.Marshal(authConfig) if err != nil { pr.done <- err continue diff --git a/pkg/flog/flog.go b/pkg/flog/flog.go index 86d2ba81..516595c8 100644 --- a/pkg/flog/flog.go +++ b/pkg/flog/flog.go @@ -6,8 +6,8 @@ import ( "os" "time" + "github.com/bytedance/sonic" "github.com/flowline-io/flowbot/pkg/alarm" - jsoniter "github.com/json-iterator/go" "github.com/rs/zerolog" "github.com/rs/zerolog/pkgerrors" ) @@ -18,8 +18,7 @@ func Init(fileLogEnabled bool) { // error stack zerolog.ErrorStackMarshaler = pkgerrors.MarshalStack // json marshaling - json := jsoniter.ConfigCompatibleWithStandardLibrary - zerolog.InterfaceMarshalFunc = json.Marshal + zerolog.InterfaceMarshalFunc = sonic.Marshal var writer []io.Writer // console diff --git a/pkg/media/fs/filesys.go b/pkg/media/fs/filesys.go index 57f31b22..7693c1b9 100644 --- a/pkg/media/fs/filesys.go +++ b/pkg/media/fs/filesys.go @@ -12,13 +12,13 @@ import ( "os" "path/filepath" + "github.com/bytedance/sonic" "github.com/flowline-io/flowbot/internal/store" appConfig "github.com/flowline-io/flowbot/pkg/config" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/media" "github.com/flowline-io/flowbot/pkg/types" "github.com/flowline-io/flowbot/pkg/types/protocol" - jsoniter "github.com/json-iterator/go" ) const ( @@ -43,7 +43,7 @@ func (fh *fshandler) Init(jsconf string) error { var err error var config configType - if err = jsoniter.Unmarshal([]byte(jsconf), &config); err != nil { + if err = sonic.Unmarshal([]byte(jsconf), &config); err != nil { return fmt.Errorf("error parsing config: %s, %w", jsconf, err) } diff --git a/pkg/media/minio/minio.go b/pkg/media/minio/minio.go index 8cf1a285..13ee7db4 100644 --- a/pkg/media/minio/minio.go +++ b/pkg/media/minio/minio.go @@ -14,12 +14,12 @@ import ( "github.com/flowline-io/flowbot/pkg/flog" + "github.com/bytedance/sonic" "github.com/flowline-io/flowbot/internal/store" appConfig "github.com/flowline-io/flowbot/pkg/config" "github.com/flowline-io/flowbot/pkg/media" "github.com/flowline-io/flowbot/pkg/types" "github.com/flowline-io/flowbot/pkg/types/protocol" - jsoniter "github.com/json-iterator/go" "github.com/minio/minio-go/v7" "github.com/minio/minio-go/v7/pkg/credentials" ) @@ -49,7 +49,7 @@ type handler struct { // Init initializes the media handler. func (ah *handler) Init(jsconf string) error { var err error - if err = jsoniter.Unmarshal([]byte(jsconf), &ah.conf); err != nil { + if err = sonic.Unmarshal([]byte(jsconf), &ah.conf); err != nil { return fmt.Errorf("error parsing config: %s", jsconf) } diff --git a/pkg/page/layout.go b/pkg/page/layout.go index 01cfa09e..fd0a9525 100644 --- a/pkg/page/layout.go +++ b/pkg/page/layout.go @@ -6,13 +6,13 @@ import ( "html" "strings" + "github.com/bytedance/sonic" "github.com/flowline-io/flowbot/internal/store/model" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/page/component" "github.com/flowline-io/flowbot/pkg/page/library" "github.com/flowline-io/flowbot/pkg/page/uikit" "github.com/flowline-io/flowbot/pkg/types" - jsoniter "github.com/json-iterator/go" "github.com/maxence-charriere/go-app/v10/pkg/app" ) @@ -33,13 +33,13 @@ const htmlLayout = ` // unmarshalPageSchema parses specific types of messages from Page.Schema func unmarshalPageSchema(page model.Page, target interface{}) error { - data, err := jsoniter.Marshal(page.Schema) + data, err := sonic.Marshal(page.Schema) if err != nil { flog.Error(fmt.Errorf("failed to marshal page schema: %w", err)) return err } - err = jsoniter.Unmarshal(data, target) + err = sonic.Unmarshal(data, target) if err != nil { flog.Error(fmt.Errorf("failed to unmarshal page schema: %w", err)) return err @@ -108,7 +108,7 @@ func scripts(comp *types.UI) string { case float32, float64: _, _ = fmt.Fprintf(&scriptsStr, "Global.%s = %f;\n", key, v) case map[string]interface{}: - j, err := jsoniter.Marshal(v) + j, err := sonic.Marshal(v) if err != nil { flog.Error(fmt.Errorf("failed to marshal global variable %s: %w", key, err)) continue diff --git a/pkg/providers/dropbox/dropbox.go b/pkg/providers/dropbox/dropbox.go index 9e3c7cca..eddaf907 100644 --- a/pkg/providers/dropbox/dropbox.go +++ b/pkg/providers/dropbox/dropbox.go @@ -6,11 +6,11 @@ import ( "net/http" "time" + "github.com/bytedance/sonic" "github.com/flowline-io/flowbot/pkg/providers" "github.com/flowline-io/flowbot/pkg/types" "github.com/go-resty/resty/v2" "github.com/gofiber/fiber/v2" - jsoniter "github.com/json-iterator/go" ) const ( @@ -56,7 +56,7 @@ func (v *Dropbox) completeAuth(code string) (interface{}, error) { if resp.StatusCode() == http.StatusOK { var result TokenResponse - err = jsoniter.Unmarshal(resp.Body(), &result) + err = sonic.Unmarshal(resp.Body(), &result) if err != nil { return nil, err } @@ -84,7 +84,7 @@ func (v *Dropbox) GetAccessToken(ctx *fiber.Ctx) (types.KV, error) { return nil, err } - extra, err := jsoniter.Marshal(&tokenResp) + extra, err := sonic.Marshal(&tokenResp) if err != nil { return nil, err } @@ -97,7 +97,7 @@ func (v *Dropbox) GetAccessToken(ctx *fiber.Ctx) (types.KV, error) { } func (v *Dropbox) Upload(path string, content io.Reader) error { - apiArg, err := jsoniter.Marshal(map[string]interface{}{ + apiArg, err := sonic.Marshal(map[string]interface{}{ "path": path, "mode": "add", "autorename": true, diff --git a/pkg/providers/github/github.go b/pkg/providers/github/github.go index 7efd8693..70b604d5 100644 --- a/pkg/providers/github/github.go +++ b/pkg/providers/github/github.go @@ -5,10 +5,10 @@ import ( "net/http" "time" + "github.com/bytedance/sonic" "github.com/flowline-io/flowbot/pkg/types" "github.com/go-resty/resty/v2" "github.com/gofiber/fiber/v2" - jsoniter "github.com/json-iterator/go" ) const ( @@ -74,7 +74,7 @@ func (v *Github) GetAccessToken(ctx *fiber.Ctx) (types.KV, error) { return nil, err } - extra, err := jsoniter.Marshal(&tokenResp) + extra, err := sonic.Marshal(&tokenResp) if err != nil { return nil, err } diff --git a/pkg/providers/pocket/pocket.go b/pkg/providers/pocket/pocket.go index 90c25a29..3696431c 100644 --- a/pkg/providers/pocket/pocket.go +++ b/pkg/providers/pocket/pocket.go @@ -7,11 +7,11 @@ import ( "net/http" "time" + "github.com/bytedance/sonic" "github.com/flowline-io/flowbot/pkg/rdb" "github.com/flowline-io/flowbot/pkg/types" "github.com/go-resty/resty/v2" "github.com/gofiber/fiber/v2" - jsoniter "github.com/json-iterator/go" "github.com/redis/go-redis/v9" ) @@ -106,7 +106,7 @@ func (v *Pocket) GetAccessToken(_ *fiber.Ctx) (types.KV, error) { return nil, err } - extra, err := jsoniter.Marshal(&tokenResp) + extra, err := sonic.Marshal(&tokenResp) if err != nil { return nil, err } diff --git a/pkg/search/search.go b/pkg/search/search.go index 62d63eab..f663212e 100644 --- a/pkg/search/search.go +++ b/pkg/search/search.go @@ -4,13 +4,13 @@ import ( "context" "fmt" + "github.com/bytedance/sonic" "github.com/flowline-io/flowbot/pkg/config" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/stats" "github.com/flowline-io/flowbot/pkg/types" "github.com/flowline-io/flowbot/pkg/utils" "github.com/goccy/go-json" - jsoniter "github.com/json-iterator/go" "github.com/meilisearch/meilisearch-go" "go.uber.org/fx" ) @@ -86,7 +86,7 @@ func (c *Client) Search(source, query string, page, pageSize int32) (types.Docum } utils.PrettyPrintJsonStyle(resp) - data, err := jsoniter.Marshal(resp.Hits) + data, err := sonic.Marshal(resp.Hits) if err != nil { return nil, 0, err } diff --git a/pkg/types/kv.go b/pkg/types/kv.go index ce195f9a..bd249544 100644 --- a/pkg/types/kv.go +++ b/pkg/types/kv.go @@ -6,7 +6,7 @@ import ( "fmt" "reflect" - jsoniter "github.com/json-iterator/go" + "github.com/bytedance/sonic" ) type KV map[string]interface{} @@ -14,7 +14,7 @@ type KV map[string]interface{} func (j *KV) Scan(value interface{}) error { if bytes, ok := value.([]byte); ok { result := make(map[string]interface{}) - err := jsoniter.Unmarshal(bytes, &result) + err := sonic.Unmarshal(bytes, &result) if err != nil { return err } @@ -32,7 +32,7 @@ func (j KV) Value() (driver.Value, error) { if len(j) == 0 { return nil, nil } - return jsoniter.Marshal(j) + return sonic.Marshal(j) } func (j KV) String(key string) (string, bool) { diff --git a/pkg/types/msg.go b/pkg/types/msg.go index 9678f478..de58eec9 100644 --- a/pkg/types/msg.go +++ b/pkg/types/msg.go @@ -1,10 +1,11 @@ package types import ( - jsoniter "github.com/json-iterator/go" "reflect" "time" + "github.com/bytedance/sonic" + "github.com/flowline-io/flowbot/internal/store/model" ) @@ -167,27 +168,27 @@ func ToPayload(typ string, src []byte) MsgPayload { switch typ { case "TextMsg": var r TextMsg - _ = jsoniter.Unmarshal(src, &r) + _ = sonic.Unmarshal(src, &r) return r case "LinkMsg": var r LinkMsg - _ = jsoniter.Unmarshal(src, &r) + _ = sonic.Unmarshal(src, &r) return r case "TableMsg": var r TableMsg - _ = jsoniter.Unmarshal(src, &r) + _ = sonic.Unmarshal(src, &r) return r case "InfoMsg": var r InfoMsg - _ = jsoniter.Unmarshal(src, &r) + _ = sonic.Unmarshal(src, &r) return r case "ChartMsg": var r ChartMsg - _ = jsoniter.Unmarshal(src, &r) + _ = sonic.Unmarshal(src, &r) return r case "KVMsg": var r KVMsg - _ = jsoniter.Unmarshal(src, &r) + _ = sonic.Unmarshal(src, &r) return r } return nil diff --git a/pkg/utils/string.go b/pkg/utils/string.go index f7f7f3ff..fe442abc 100644 --- a/pkg/utils/string.go +++ b/pkg/utils/string.go @@ -6,14 +6,15 @@ import ( "crypto/sha1" "encoding/hex" "fmt" - jsoniter "github.com/json-iterator/go" - "gopkg.in/yaml.v3" "math/big" "regexp" "runtime" "strings" "unicode" + "github.com/bytedance/sonic" + "gopkg.in/yaml.v3" + "github.com/google/uuid" ) @@ -126,7 +127,7 @@ func FileAndLine() string { } func PrettyPrintJsonStyle(data any) { - d, err := jsoniter.MarshalIndent(data, "", " ") + d, err := sonic.MarshalIndent(data, "", " ") if err != nil { _, _ = fmt.Println(fmt.Sprintf("error: %s, data: %+v", err, data)) return From aca5f46ac8c6c332db6304d50247ec3492f7ab46 Mon Sep 17 00:00:00 2001 From: sysatom Date: Sat, 10 May 2025 00:25:52 +0800 Subject: [PATCH 065/125] error code --- docs/docs.go | 2 +- docs/swagger.json | 2 +- docs/swagger.yaml | 2 +- go.mod | 3 ++ go.sum | 7 +++ internal/bots/okr/webservice.go | 44 ++++++++--------- internal/bots/workflow/webservice.go | 30 ++++++------ internal/platforms/platforms.go | 4 +- internal/platforms/slack/action.go | 24 +++++----- internal/server/http.go | 2 +- internal/server/router.go | 72 ++++++++++++++-------------- pkg/media/fs/filesys.go | 6 +-- pkg/media/minio/minio.go | 2 +- pkg/route/route.go | 9 ++-- pkg/types/protocol/action.go | 61 ++++++++++++----------- 15 files changed, 139 insertions(+), 131 deletions(-) diff --git a/docs/docs.go b/docs/docs.go index a9ec514c..c48b1d0b 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -2141,7 +2141,7 @@ const docTemplate = `{ }, "retcode": { "description": "The return code, which must conform to the return code rules defined later on this page", - "type": "integer" + "type": "string" }, "status": { "description": "Execution status (success or failure), must be one of ok and failed,\nindicating successful and unsuccessful execution, respectively.", diff --git a/docs/swagger.json b/docs/swagger.json index 2aef3a59..a5b01b75 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -2138,7 +2138,7 @@ }, "retcode": { "description": "The return code, which must conform to the return code rules defined later on this page", - "type": "integer" + "type": "string" }, "status": { "description": "Execution status (success or failure), must be one of ok and failed,\nindicating successful and unsuccessful execution, respectively.", diff --git a/docs/swagger.yaml b/docs/swagger.yaml index c10cd4a7..09f05df1 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -571,7 +571,7 @@ definitions: retcode: description: The return code, which must conform to the return code rules defined later on this page - type: integer + type: string status: allOf: - $ref: '#/definitions/protocol.ResponseStatus' diff --git a/go.mod b/go.mod index 529e3570..3b7b32d9 100644 --- a/go.mod +++ b/go.mod @@ -58,6 +58,7 @@ require ( github.com/redis/go-redis/v9 v9.8.0 github.com/robfig/cron/v3 v3.0.1 github.com/rs/zerolog v1.34.0 + github.com/samber/oops v1.17.0 github.com/schollz/progressbar/v3 v3.18.0 github.com/shirou/gopsutil/v4 v4.25.4 github.com/slack-go/slack v0.16.0 @@ -166,6 +167,7 @@ require ( github.com/nikolalohinski/gonja v1.5.3 // indirect github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d // indirect github.com/oklog/ulid v1.3.1 // indirect + github.com/oklog/ulid/v2 v2.1.0 // indirect github.com/olekukonko/tablewriter v0.0.5 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect github.com/opencontainers/image-spec v1.1.0 // indirect @@ -179,6 +181,7 @@ require ( github.com/rs/xid v1.6.0 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/sagikazarmark/locafero v0.7.0 // indirect + github.com/samber/lo v1.49.1 // indirect github.com/sirupsen/logrus v1.9.3 // indirect github.com/slongfield/pyfmt v0.0.0-20220222012616-ea85ff4c361f // indirect github.com/sony/gobreaker v1.0.0 // indirect diff --git a/go.sum b/go.sum index a6845550..8f829025 100644 --- a/go.sum +++ b/go.sum @@ -382,6 +382,8 @@ github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d h1:VhgPp6v9qf9Agr/ github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d/go.mod h1:YUTz3bUH2ZwIWBy3CJBeOBEugqcmXREj14T+iG/4k4U= github.com/oklog/ulid v1.3.1 h1:EGfNDEx6MqHz8B3uNV6QAib1UR2Lm97sHi3ocA6ESJ4= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= +github.com/oklog/ulid/v2 v2.1.0 h1:+9lhoxAP56we25tyYETBBY1YLA2SaoLvUFgrP2miPJU= +github.com/oklog/ulid/v2 v2.1.0/go.mod h1:rcEKHmBBKfef9DhnvX7y1HZBYxjXb0cP5ExxNsTT1QQ= github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= @@ -391,6 +393,7 @@ github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8 github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= github.com/opencontainers/image-spec v1.1.0 h1:8SG7/vwALn54lVB/0yZ/MMwhFrPYtpEHQb2IpWsCzug= github.com/opencontainers/image-spec v1.1.0/go.mod h1:W4s4sFTMaBeK1BQLXbG4AdM2szdn85PY75RI83NrTrM= +github.com/pborman/getopt v0.0.0-20170112200414-7148bc3a4c30/go.mod h1:85jBQOZwpVEaDAr341tbn15RS4fCAsIst0qp7i8ex1o= github.com/pelletier/go-toml/v2 v2.2.3 h1:YmeHyLY8mFWbdkNWwpr+qIL2bEqT0o95WSdkNHvL12M= github.com/pelletier/go-toml/v2 v2.2.3/go.mod h1:MfCQTFTvCcUyyvvwm1+G6H/jORL20Xlb6rzQu9GuUkc= github.com/perimeterx/marshmallow v1.1.4/go.mod h1:dsXbUu8CRzfYP5a87xpp0xq9S3u0Vchtcl8we9tYaXw= @@ -432,6 +435,10 @@ github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/sagikazarmark/locafero v0.7.0 h1:5MqpDsTGNDhY8sGp0Aowyf0qKsPrhewaLSsFaodPcyo= github.com/sagikazarmark/locafero v0.7.0/go.mod h1:2za3Cg5rMaTMoG/2Ulr9AwtFaIppKXTRYnozin4aB5k= +github.com/samber/lo v1.49.1 h1:4BIFyVfuQSEpluc7Fua+j1NolZHiEHEpaSEKdsH0tew= +github.com/samber/lo v1.49.1/go.mod h1:dO6KHFzUKXgP8LDhU0oI8d2hekjXnGOu0DB8Jecxd6o= +github.com/samber/oops v1.17.0 h1:9NT8ISe8qqOV5HAuRQstlgYwUf3RsIiMDefSbUq+2hE= +github.com/samber/oops v1.17.0/go.mod h1:8eXgMAJcDXRAijQsFRhfy/EHDOTiSvwkg6khFqFK078= github.com/schollz/progressbar/v3 v3.18.0 h1:uXdoHABRFmNIjUfte/Ex7WtuyVslrw2wVPQmCN62HpA= github.com/schollz/progressbar/v3 v3.18.0/go.mod h1:IsO3lpbaGuzh8zIMzgY3+J8l4C8GjO0Y9S69eFvNsec= github.com/shirou/gopsutil/v4 v4.25.4 h1:cdtFO363VEOOFrUCjZRh4XVJkb548lyF0q0uTeMqYPw= diff --git a/internal/bots/okr/webservice.go b/internal/bots/okr/webservice.go index 7ba3f417..780e67b2 100644 --- a/internal/bots/okr/webservice.go +++ b/internal/bots/okr/webservice.go @@ -39,7 +39,7 @@ func objectiveList(ctx *fiber.Ctx) error { list, err := store.Database.ListObjectives(uid, topic) if err != nil { - return ctx.JSON(protocol.NewFailedResponseWithError(protocol.ErrDatabaseReadError, err)) + return ctx.JSON(protocol.NewFailedResponse(protocol.ErrDatabaseReadError.Wrap(err))) } return ctx.JSON(protocol.NewSuccessResponse(list)) } @@ -61,7 +61,7 @@ func objectiveDetail(ctx *fiber.Ctx) error { obj, err := store.Database.GetObjectiveBySequence(uid, topic, sequence) if err != nil { - return ctx.JSON(protocol.NewFailedResponseWithError(protocol.ErrDatabaseReadError, err)) + return ctx.JSON(protocol.NewFailedResponse(protocol.ErrDatabaseReadError.Wrap(err))) } return ctx.JSON(protocol.NewSuccessResponse(obj)) } @@ -83,13 +83,13 @@ func objectiveCreate(ctx *fiber.Ctx) error { item := new(model.Objective) err := ctx.BodyParser(&item) if err != nil { - return ctx.JSON(protocol.NewFailedResponseWithError(protocol.ErrBadParam, err)) + return ctx.JSON(protocol.NewFailedResponse(protocol.ErrBadParam.Wrap(err))) } // check if item.IsPlan > 0 { if item.PlanStart.IsZero() || item.PlanEnd.IsZero() { - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrParamVerificationFailed)) + return ctx.JSON(protocol.NewFailedResponse(protocol.ErrParamVerificationFailed.New("is plan emtpy"))) } } @@ -97,7 +97,7 @@ func objectiveCreate(ctx *fiber.Ctx) error { item.Topic = topic _, err = store.Database.CreateObjective(item) if err != nil { - return ctx.JSON(protocol.NewFailedResponseWithError(protocol.ErrDatabaseWriteError, err)) + return ctx.JSON(protocol.NewFailedResponse(protocol.ErrDatabaseWriteError.Wrap(err))) } return ctx.JSON(protocol.NewSuccessResponse(nil)) } @@ -121,14 +121,14 @@ func objectiveUpdate(ctx *fiber.Ctx) error { item := new(model.Objective) err := ctx.BodyParser(&item) if err != nil { - return ctx.JSON(protocol.NewFailedResponseWithError(protocol.ErrBadParam, err)) + return ctx.JSON(protocol.NewFailedResponse(protocol.ErrBadParam.Wrap(err))) } item.UID = uid.String() item.Topic = topic item.Sequence = int32(sequence) err = store.Database.UpdateObjective(item) if err != nil { - return ctx.JSON(protocol.NewFailedResponseWithError(protocol.ErrDatabaseWriteError, err)) + return ctx.JSON(protocol.NewFailedResponse(protocol.ErrDatabaseWriteError.Wrap(err))) } return ctx.JSON(protocol.NewSuccessResponse(nil)) } @@ -150,7 +150,7 @@ func objectiveDelete(ctx *fiber.Ctx) error { err := store.Database.DeleteObjectiveBySequence(uid, topic, sequence) if err != nil { - return ctx.JSON(protocol.NewFailedResponseWithError(protocol.ErrDatabaseWriteError, err)) + return ctx.JSON(protocol.NewFailedResponse(protocol.ErrDatabaseWriteError.Wrap(err))) } return ctx.JSON(protocol.NewSuccessResponse(nil)) } @@ -172,13 +172,13 @@ func keyResultCreate(ctx *fiber.Ctx) error { item := new(model.KeyResult) err := ctx.BodyParser(&item) if err != nil { - return ctx.JSON(protocol.NewFailedResponseWithError(protocol.ErrBadParam, err)) + return ctx.JSON(protocol.NewFailedResponse(protocol.ErrBadParam.Wrap(err))) } item.UID = uid.String() item.Topic = topic _, err = store.Database.CreateKeyResult(item) if err != nil { - return ctx.JSON(protocol.NewFailedResponseWithError(protocol.ErrDatabaseWriteError, err)) + return ctx.JSON(protocol.NewFailedResponse(protocol.ErrDatabaseWriteError.Wrap(err))) } return ctx.JSON(protocol.NewSuccessResponse(nil)) } @@ -202,14 +202,14 @@ func keyResultUpdate(ctx *fiber.Ctx) error { item := new(model.KeyResult) err := ctx.BodyParser(&item) if err != nil { - return ctx.JSON(protocol.NewFailedResponseWithError(protocol.ErrBadParam, err)) + return ctx.JSON(protocol.NewFailedResponse(protocol.ErrBadParam.Wrap(err))) } item.UID = uid.String() item.Topic = topic item.Sequence = int32(sequence) err = store.Database.UpdateKeyResult(item) if err != nil { - return ctx.JSON(protocol.NewFailedResponseWithError(protocol.ErrDatabaseWriteError, err)) + return ctx.JSON(protocol.NewFailedResponse(protocol.ErrDatabaseWriteError.Wrap(err))) } return ctx.JSON(protocol.NewSuccessResponse(nil)) } @@ -231,7 +231,7 @@ func keyResultDelete(ctx *fiber.Ctx) error { err := store.Database.DeleteKeyResultBySequence(uid, topic, sequence) if err != nil { - return ctx.JSON(protocol.NewFailedResponseWithError(protocol.ErrDatabaseWriteError, err)) + return ctx.JSON(protocol.NewFailedResponse(protocol.ErrDatabaseWriteError.Wrap(err))) } return ctx.JSON(protocol.NewSuccessResponse(nil)) } @@ -249,12 +249,12 @@ func keyResultDelete(ctx *fiber.Ctx) error { func keyResultValueList(ctx *fiber.Ctx) error { keyResultId := route.GetIntParam(ctx, "id") if keyResultId == 0 { - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrBadParam)) + return ctx.JSON(protocol.NewFailedResponse(protocol.ErrBadParam.New("id empty"))) } list, err := store.Database.GetKeyResultValues(keyResultId) if err != nil { - return ctx.JSON(protocol.NewFailedResponseWithError(protocol.ErrDatabaseReadError, err)) + return ctx.JSON(protocol.NewFailedResponse(protocol.ErrDatabaseReadError.Wrap(err))) } return ctx.JSON(protocol.NewSuccessResponse(list)) } @@ -273,18 +273,18 @@ func keyResultValueList(ctx *fiber.Ctx) error { func keyResultValueCreate(ctx *fiber.Ctx) error { keyResultId := route.GetIntParam(ctx, "id") if keyResultId == 0 { - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrBadParam)) + return ctx.JSON(protocol.NewFailedResponse(protocol.ErrBadParam.New("id empty"))) } item := new(model.KeyResultValue) err := ctx.BodyParser(&item) if err != nil { - return ctx.JSON(protocol.NewFailedResponseWithError(protocol.ErrBadParam, err)) + return ctx.JSON(protocol.NewFailedResponse(protocol.ErrBadParam.Wrap(err))) } item.KeyResultID = keyResultId _, err = store.Database.CreateKeyResultValue(item) if err != nil { - return ctx.JSON(protocol.NewFailedResponseWithError(protocol.ErrDatabaseWriteError, err)) + return ctx.JSON(protocol.NewFailedResponse(protocol.ErrDatabaseWriteError.Wrap(err))) } return ctx.JSON(protocol.NewSuccessResponse(nil)) } @@ -302,12 +302,12 @@ func keyResultValueCreate(ctx *fiber.Ctx) error { func keyResultValueDelete(ctx *fiber.Ctx) error { keyResultValueId := route.GetIntParam(ctx, "id") if keyResultValueId == 0 { - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrBadParam)) + return ctx.JSON(protocol.NewFailedResponse(protocol.ErrBadParam.New("id emtpy"))) } err := store.Database.DeleteKeyResultValue(keyResultValueId) if err != nil { - return ctx.JSON(protocol.NewFailedResponseWithError(protocol.ErrDatabaseWriteError, err)) + return ctx.JSON(protocol.NewFailedResponse(protocol.ErrDatabaseWriteError.Wrap(err))) } return ctx.JSON(protocol.NewSuccessResponse(nil)) } @@ -325,12 +325,12 @@ func keyResultValueDelete(ctx *fiber.Ctx) error { func keyResultValue(ctx *fiber.Ctx) error { keyResultValueId := route.GetIntParam(ctx, "id") if keyResultValueId == 0 { - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrBadParam)) + return ctx.JSON(protocol.NewFailedResponse(protocol.ErrBadParam.New("id emtpy"))) } item, err := store.Database.GetKeyResultValue(keyResultValueId) if err != nil { - return ctx.JSON(protocol.NewFailedResponseWithError(protocol.ErrDatabaseReadError, err)) + return ctx.JSON(protocol.NewFailedResponse(protocol.ErrDatabaseReadError.Wrap(err))) } return ctx.JSON(protocol.NewSuccessResponse(item)) } diff --git a/internal/bots/workflow/webservice.go b/internal/bots/workflow/webservice.go index 0a4ee19e..55eadbcf 100644 --- a/internal/bots/workflow/webservice.go +++ b/internal/bots/workflow/webservice.go @@ -81,7 +81,7 @@ func workflowList(ctx *fiber.Ctx) error { list, err := store.Database.ListWorkflows(uid, topic) if err != nil { - return ctx.JSON(protocol.NewFailedResponseWithError(protocol.ErrDatabaseReadError, err)) + return ctx.JSON(protocol.NewFailedResponse(protocol.ErrDatabaseReadError.Wrap(err))) } return ctx.JSON(protocol.NewSuccessResponse(list)) } @@ -101,7 +101,7 @@ func workflowDetail(ctx *fiber.Ctx) error { item, err := store.Database.GetWorkflow(id) if err != nil { - return ctx.JSON(protocol.NewFailedResponseWithError(protocol.ErrDatabaseReadError, err)) + return ctx.JSON(protocol.NewFailedResponse(protocol.ErrDatabaseReadError.Wrap(err))) } return ctx.JSON(protocol.NewSuccessResponse(item)) } @@ -123,23 +123,23 @@ func workflowCreate(ctx *fiber.Ctx) error { script := new(model.WorkflowScript) err := ctx.BodyParser(&script) if err != nil { - return ctx.JSON(protocol.NewFailedResponseWithError(protocol.ErrBadParam, err)) + return ctx.JSON(protocol.NewFailedResponse(protocol.ErrBadParam.Wrap(err))) } if script.Lang != model.WorkflowScriptYaml { - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrUnsupported)) + return ctx.JSON(protocol.NewFailedResponse(protocol.ErrUnsupported.New("script type error"))) } wf, triggers, dag, err := ParseYamlWorkflow(script.Code) if err != nil { - return ctx.JSON(protocol.NewFailedResponseWithError(protocol.ErrBadParam, err)) + return ctx.JSON(protocol.NewFailedResponse(protocol.ErrBadParam.Wrap(err))) } wf.UID = uid.String() wf.Topic = topic _, err = store.Database.CreateWorkflow(wf, script, dag, triggers) if err != nil { - return ctx.JSON(protocol.NewFailedResponseWithError(protocol.ErrDatabaseWriteError, err)) + return ctx.JSON(protocol.NewFailedResponse(protocol.ErrDatabaseWriteError.Wrap(err))) } return ctx.JSON(protocol.NewSuccessResponse(types.KV{"id": wf.ID})) } @@ -163,16 +163,16 @@ func workflowUpdate(ctx *fiber.Ctx) error { script := new(model.WorkflowScript) err := ctx.BodyParser(&script) if err != nil { - return ctx.JSON(protocol.NewFailedResponseWithError(protocol.ErrBadParam, err)) + return ctx.JSON(protocol.NewFailedResponse(protocol.ErrBadParam.Wrap(err))) } if script.Lang != model.WorkflowScriptYaml { - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrUnsupported)) + return ctx.JSON(protocol.NewFailedResponse(protocol.ErrUnsupported.New("script type error"))) } wf, triggers, dag, err := ParseYamlWorkflow(script.Code) if err != nil { - return ctx.JSON(protocol.NewFailedResponseWithError(protocol.ErrBadParam, err)) + return ctx.JSON(protocol.NewFailedResponse(protocol.ErrBadParam.Wrap(err))) } // item := new(model.Workflow) @@ -183,7 +183,7 @@ func workflowUpdate(ctx *fiber.Ctx) error { // item.Describe = wf.Describe err = store.Database.UpdateWorkflow(wf, script, dag, triggers) if err != nil { - return ctx.JSON(protocol.NewFailedResponseWithError(protocol.ErrDatabaseWriteError, err)) + return ctx.JSON(protocol.NewFailedResponse(protocol.ErrDatabaseWriteError.Wrap(err))) } return ctx.JSON(protocol.NewSuccessResponse(nil)) @@ -204,7 +204,7 @@ func workflowDelete(ctx *fiber.Ctx) error { err := store.Database.DeleteWorkflow(id) if err != nil { - return ctx.JSON(protocol.NewFailedResponseWithError(protocol.ErrDatabaseWriteError, err)) + return ctx.JSON(protocol.NewFailedResponse(protocol.ErrDatabaseWriteError.Wrap(err))) } return ctx.JSON(protocol.NewSuccessResponse(nil)) } @@ -224,7 +224,7 @@ func workflowTriggerList(ctx *fiber.Ctx) error { item, err := store.Database.GetWorkflow(id) if err != nil { - return ctx.JSON(protocol.NewFailedResponseWithError(protocol.ErrDatabaseReadError, err)) + return ctx.JSON(protocol.NewFailedResponse(protocol.ErrDatabaseReadError.Wrap(err))) } return ctx.JSON(protocol.NewSuccessResponse(item.Triggers)) } @@ -244,7 +244,7 @@ func workflowJobList(ctx *fiber.Ctx) error { list, err := store.Database.GetJobsByWorkflowId(id) if err != nil { - return ctx.JSON(protocol.NewFailedResponseWithError(protocol.ErrDatabaseReadError, err)) + return ctx.JSON(protocol.NewFailedResponse(protocol.ErrDatabaseReadError.Wrap(err))) } return ctx.JSON(protocol.NewSuccessResponse(list)) } @@ -264,7 +264,7 @@ func workflowJobDetail(ctx *fiber.Ctx) error { item, err := store.Database.GetJob(id) if err != nil { - return ctx.JSON(protocol.NewFailedResponseWithError(protocol.ErrDatabaseReadError, err)) + return ctx.JSON(protocol.NewFailedResponse(protocol.ErrDatabaseReadError.Wrap(err))) } return ctx.JSON(protocol.NewSuccessResponse(item)) } @@ -298,7 +298,7 @@ func workflowScriptDetail(ctx *fiber.Ctx) error { item, err := store.Database.GetWorkflowScriptByWorkflowId(id) if err != nil { - return ctx.JSON(protocol.NewFailedResponseWithError(protocol.ErrDatabaseReadError, err)) + return ctx.JSON(protocol.NewFailedResponse(protocol.ErrDatabaseReadError.Wrap(err))) } return ctx.JSON(protocol.NewSuccessResponse(item)) } diff --git a/internal/platforms/platforms.go b/internal/platforms/platforms.go index 59ea42ed..d169311f 100644 --- a/internal/platforms/platforms.go +++ b/internal/platforms/platforms.go @@ -3,7 +3,6 @@ package platforms import ( "errors" "fmt" - "gopkg.in/yaml.v3" "github.com/flowline-io/flowbot/internal/store" "github.com/flowline-io/flowbot/internal/store/model" @@ -11,6 +10,7 @@ import ( "github.com/flowline-io/flowbot/pkg/types" "github.com/flowline-io/flowbot/pkg/types/protocol" "github.com/flowline-io/flowbot/pkg/utils" + "gopkg.in/yaml.v3" "gorm.io/gorm" ) @@ -26,7 +26,7 @@ func (c *Caller) Do(req protocol.Request) protocol.Response { case protocol.SendMessageAction: return c.Action.SendMessage(req) } - return protocol.NewFailedResponse(protocol.ErrUnsupportedAction) + return protocol.NewFailedResponse(protocol.ErrUnsupportedAction.New("error action")) } func MessageConvert(data any) protocol.Message { diff --git a/internal/platforms/slack/action.go b/internal/platforms/slack/action.go index ecc7b54c..00fb6818 100644 --- a/internal/platforms/slack/action.go +++ b/internal/platforms/slack/action.go @@ -14,19 +14,19 @@ type Action struct { } func (a *Action) GetLatestEvents(_ protocol.Request) protocol.Response { - return protocol.NewFailedResponse(protocol.ErrUnsupportedAction) + return protocol.NewFailedResponse(protocol.ErrUnsupportedAction.New("unsupported action")) } func (a *Action) GetSupportedActions(_ protocol.Request) protocol.Response { - return protocol.NewFailedResponse(protocol.ErrUnsupportedAction) + return protocol.NewFailedResponse(protocol.ErrUnsupportedAction.New("unsupported action")) } func (a *Action) GetStatus(_ protocol.Request) protocol.Response { - return protocol.NewFailedResponse(protocol.ErrUnsupportedAction) + return protocol.NewFailedResponse(protocol.ErrUnsupportedAction.New("unsupported action")) } func (a *Action) GetVersion(_ protocol.Request) protocol.Response { - return protocol.NewFailedResponse(protocol.ErrUnsupportedAction) + return protocol.NewFailedResponse(protocol.ErrUnsupportedAction.New("unsupported action")) } func (a *Action) SendMessage(req protocol.Request) protocol.Response { @@ -34,7 +34,7 @@ func (a *Action) SendMessage(req protocol.Request) protocol.Response { message, _ := types.KV(req.Params).Any("message") content, ok := message.(protocol.Message) if !ok { - return protocol.NewFailedResponse(protocol.ErrBadSegmentType) + return protocol.NewFailedResponse(protocol.ErrBadSegmentType.New("message type error")) } if len(content) == 0 { return protocol.NewSuccessResponse(nil) @@ -45,34 +45,34 @@ func (a *Action) SendMessage(req protocol.Request) protocol.Response { }) if err != nil { flog.Error(fmt.Errorf("failed to send message to %s, %w", channel, err)) - return protocol.NewFailedResponse(protocol.ErrInternalHandler) + return protocol.NewFailedResponse(protocol.ErrInternalHandler.New("send message error")) } return protocol.NewSuccessResponse(nil) } func (a *Action) GetUserInfo(_ protocol.Request) protocol.Response { - return protocol.NewFailedResponse(protocol.ErrUnsupportedAction) + return protocol.NewFailedResponse(protocol.ErrUnsupportedAction.New("unsupported action")) } func (a *Action) CreateChannel(_ protocol.Request) protocol.Response { - return protocol.NewFailedResponse(protocol.ErrUnsupportedAction) + return protocol.NewFailedResponse(protocol.ErrUnsupportedAction.New("unsupported action")) } func (a *Action) GetChannelInfo(_ protocol.Request) protocol.Response { - return protocol.NewFailedResponse(protocol.ErrUnsupportedAction) + return protocol.NewFailedResponse(protocol.ErrUnsupportedAction.New("unsupported action")) } func (a *Action) GetChannelList(_ protocol.Request) protocol.Response { - return protocol.NewFailedResponse(protocol.ErrUnsupportedAction) + return protocol.NewFailedResponse(protocol.ErrUnsupportedAction.New("unsupported action")) } func (a *Action) RegisterChannels(_ protocol.Request) protocol.Response { - return protocol.NewFailedResponse(protocol.ErrUnsupportedAction) + return protocol.NewFailedResponse(protocol.ErrUnsupportedAction.New("unsupported action")) } func (a *Action) RegisterSlashCommands(_ protocol.Request) protocol.Response { - return protocol.NewFailedResponse(protocol.ErrUnsupportedAction) + return protocol.NewFailedResponse(protocol.ErrUnsupportedAction.New("unsupported action")) } func (a *Action) makeRequest(in *request) error { diff --git a/internal/server/http.go b/internal/server/http.go index 804a9753..60820287 100644 --- a/internal/server/http.go +++ b/internal/server/http.go @@ -32,7 +32,7 @@ func newHTTPServer() *fiber.App { // Send custom error page if err != nil { return ctx.Status(fiber.StatusBadRequest). - JSON(protocol.NewFailedResponseWithError(protocol.ErrBadRequest, err)) + JSON(protocol.NewFailedResponse(protocol.ErrBadRequest.Wrap(err))) } // Return from handler diff --git a/internal/server/router.go b/internal/server/router.go index 320478b3..332676c8 100644 --- a/internal/server/router.go +++ b/internal/server/router.go @@ -3,7 +3,6 @@ package server import ( "bytes" "errors" - "fmt" "net/http" "strconv" "strings" @@ -28,6 +27,7 @@ import ( "github.com/go-echarts/go-echarts/v2/opts" "github.com/gofiber/fiber/v2" "github.com/maxence-charriere/go-app/v10/pkg/app" + "github.com/samber/oops" "github.com/valyala/fasthttp/fasthttpadaptor" "gorm.io/gorm" ) @@ -72,23 +72,23 @@ func (c *Controller) storeOAuth(ctx *fiber.Ctx) error { p, err := store.Database.ParameterGet(flag) if err != nil { - return ctx.JSON(protocol.NewFailedResponseWithError(protocol.ErrFlagError, err)) + return ctx.JSON(protocol.NewFailedResponse(protocol.ErrFlagError.Wrap(err))) } if p.IsExpired() { - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrFlagExpired)) + return ctx.JSON(protocol.NewFailedResponse(protocol.ErrFlagExpired.New("oauth error"))) } uid, _ := types.KV(p.Params).String("uid") topic, _ := types.KV(p.Params).String("topic") if uid == "" { - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrBadParam)) + return ctx.JSON(protocol.NewFailedResponse(protocol.ErrBadParam.New("uid empty"))) } // code -> token provider := newProvider(name) tk, err := provider.GetAccessToken(ctx) if err != nil { - return ctx.JSON(protocol.NewFailedResponseWithError(protocol.ErrOAuthError, err)) + return ctx.JSON(protocol.NewFailedResponse(protocol.ErrOAuthError.Wrap(err))) } // store @@ -103,7 +103,7 @@ func (c *Controller) storeOAuth(ctx *fiber.Ctx) error { Extra: model.JSON(extra), }) if err != nil { - return ctx.JSON(protocol.NewFailedResponseWithError(protocol.ErrOAuthError, err)) + return ctx.JSON(protocol.NewFailedResponse(protocol.ErrOAuthError.Wrap(err))) } return ctx.SendString("ok") @@ -114,7 +114,7 @@ func (c *Controller) getPage(ctx *fiber.Ctx) error { p, err := store.Database.PageGet(id) if err != nil { - return ctx.JSON(protocol.NewFailedResponseWithError(protocol.ErrNotFound, err)) + return ctx.JSON(protocol.NewFailedResponse(protocol.ErrNotFound.Wrap(err))) } title, _ := types.KV(p.Schema).String("title") @@ -134,12 +134,12 @@ func (c *Controller) getPage(ctx *fiber.Ctx) error { case model.PageChart: d, err := sonic.Marshal(p.Schema) if err != nil { - return ctx.JSON(protocol.NewFailedResponseWithError(protocol.ErrBadRequest, err)) + return ctx.JSON(protocol.NewFailedResponse(protocol.ErrBadParam.Wrap(err))) } var msg types.ChartMsg err = sonic.Unmarshal(d, &msg) if err != nil { - return ctx.JSON(protocol.NewFailedResponseWithError(protocol.ErrBadRequest, err)) + return ctx.JSON(protocol.NewFailedResponse(protocol.ErrBadParam.Wrap(err))) } line := charts.NewLine() @@ -159,7 +159,7 @@ func (c *Controller) getPage(ctx *fiber.Ctx) error { _ = line.Render(buf) return ctx.Send(buf.Bytes()) default: - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrBadRequest)) + return ctx.JSON(protocol.NewFailedResponse(protocol.ErrBadRequest.New("error type"))) } return ctx.SendString(page.RenderComponent(title, comp)) @@ -171,10 +171,10 @@ func (c *Controller) renderPage(ctx *fiber.Ctx) error { p, err := store.Database.ParameterGet(flag) if err != nil { - return ctx.JSON(protocol.NewFailedResponseWithError(protocol.ErrFlagError, err)) + return ctx.JSON(protocol.NewFailedResponse(protocol.ErrFlagError.Wrap(err))) } if p.IsExpired() { - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrFlagExpired)) + return ctx.JSON(protocol.NewFailedResponse(protocol.ErrFlagExpired.New("page error"))) } args := types.KV{} @@ -201,15 +201,15 @@ func (c *Controller) renderPage(ctx *fiber.Ctx) error { _, botHandler := bots.FindRuleAndHandler[pageRule.Rule](pageRuleId, bots.List()) if botHandler == nil { - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrNotFound)) + return ctx.JSON(protocol.NewFailedResponse(protocol.ErrNotFound.New("bot not found"))) } html, err := botHandler.Page(typesCtx, flag, args) if err != nil { if errors.Is(err, gorm.ErrRecordNotFound) { - return ctx.JSON(protocol.NewFailedResponseWithError(protocol.ErrNotFound, err)) + return ctx.JSON(protocol.NewFailedResponse(protocol.ErrNotFound.New("page not found"))) } - return ctx.JSON(protocol.NewFailedResponseWithError(protocol.ErrBadRequest, err)) + return ctx.JSON(protocol.NewFailedResponse(protocol.ErrBadParam.Wrap(err))) } ctx.Set("Content-Type", "text/html") return ctx.SendString(html) @@ -222,25 +222,25 @@ func (c *Controller) postForm(ctx *fiber.Ctx) error { formData, err := store.Database.FormGet(formId) if err != nil { - return ctx.JSON(protocol.NewFailedResponseWithError(protocol.ErrBadRequest, err)) + return ctx.JSON(protocol.NewFailedResponse(protocol.ErrBadParam.Wrap(err))) } if formData.State == model.FormStateSubmitSuccess || formData.State == model.FormStateSubmitFailed { - return ctx.JSON(protocol.NewFailedResponseWithError(protocol.ErrBadParam, errors.New("error form state"))) + return ctx.JSON(protocol.NewFailedResponse(protocol.ErrBadParam.New("error form state"))) } values := make(types.KV) d, err := sonic.Marshal(formData.Schema) if err != nil { - return ctx.JSON(protocol.NewFailedResponseWithError(protocol.ErrBadRequest, err)) + return ctx.JSON(protocol.NewFailedResponse(protocol.ErrBadParam.Wrap(err))) } var formMsg types.FormMsg err = sonic.Unmarshal(d, &formMsg) if err != nil { - return ctx.JSON(protocol.NewFailedResponseWithError(protocol.ErrBadRequest, err)) + return ctx.JSON(protocol.NewFailedResponse(protocol.ErrBadParam.Wrap(err))) } f, err := ctx.MultipartForm() if err != nil { - return ctx.JSON(protocol.NewFailedResponseWithError(protocol.ErrBadRequest, err)) + return ctx.JSON(protocol.NewFailedResponse(protocol.ErrBadParam.Wrap(err))) } pf := f.Value for _, field := range formMsg.Field { @@ -289,7 +289,7 @@ func (c *Controller) postForm(ctx *fiber.Ctx) error { formBuilder.Data = values err = formBuilder.Validate() if err != nil { - return ctx.JSON(protocol.NewFailedResponseWithError(protocol.ErrBadRequest, err)) + return ctx.JSON(protocol.NewFailedResponse(protocol.ErrBadParam.Wrap(err))) } botCtx := types.Context{ @@ -304,20 +304,20 @@ func (c *Controller) postForm(ctx *fiber.Ctx) error { // get bot handler formRuleId, ok := types.KV(formData.Schema).String("id") if !ok { - return ctx.JSON(protocol.NewFailedResponseWithError(protocol.ErrBadParam, fmt.Errorf("form %s %s", formId, "error form rule id"))) + return ctx.JSON(protocol.NewFailedResponse(protocol.ErrBadParam.Errorf("form %s %s", formId, "error form rule id"))) } _, botHandler := bots.FindRuleAndHandler[formRule.Rule](formRuleId, bots.List()) if botHandler != nil { if !botHandler.IsReady() { - return ctx.JSON(protocol.NewFailedResponseWithError(protocol.ErrBadParam, fmt.Errorf("bot %s unavailable", topic))) + return ctx.JSON(protocol.NewFailedResponse(protocol.ErrBadParam.Errorf("bot %s unavailable", topic))) } // form message payload, err := botHandler.Form(botCtx, values) if err != nil { - return ctx.JSON(protocol.NewFailedResponseWithError(protocol.ErrBadRequest, err)) + return ctx.JSON(protocol.NewFailedResponse(protocol.ErrBadParam.Wrap(err))) } // stats @@ -336,24 +336,24 @@ func (c *Controller) postForm(ctx *fiber.Ctx) error { func (c *Controller) agentData(ctx *fiber.Ctx) error { var r http.Request if err := fasthttpadaptor.ConvertRequest(ctx.Context(), &r, true); err != nil { - return ctx.Status(http.StatusInternalServerError).JSON(protocol.NewFailedResponseWithError(protocol.ErrInternalServerError, err)) + return ctx.Status(http.StatusInternalServerError).JSON(protocol.NewFailedResponse(protocol.ErrInternalServerError.Wrap(err))) } // authorization uid, isValid := route.CheckAccessToken(route.GetAccessToken(&r)) if !isValid { - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrNotAuthorized)) + return ctx.JSON(protocol.NewFailedResponse(protocol.ErrNotAuthorized.New("token not valided"))) } var data types.AgentData err := sonic.Unmarshal(ctx.Body(), &data) if err != nil { - return ctx.JSON(protocol.NewFailedResponseWithError(protocol.ErrBadRequest, err)) + return ctx.JSON(protocol.NewFailedResponse(protocol.ErrBadParam.Wrap(err))) } result, err := agentAction(uid, data) if err != nil { flog.Error(err) - return ctx.JSON(protocol.NewFailedResponseWithError(protocol.ErrBadRequest, err)) + return ctx.JSON(protocol.NewFailedResponse(protocol.ErrBadParam.Wrap(err))) } return ctx.JSON(protocol.NewSuccessResponse(result)) @@ -370,9 +370,9 @@ func (c *Controller) platformCallback(ctx *fiber.Ctx) error { err = c.driver.HttpServer(ctx) } if err != nil { - var protocolError *protocol.Error - if errors.As(err, protocolError) { - return ctx.JSON(protocol.NewFailedResponseWithError(protocolError, err)) + var e oops.OopsError + if errors.As(err, &e) { + return ctx.JSON(protocol.NewFailedResponse(e)) } return err } @@ -389,7 +389,7 @@ func (c *Controller) doWebhook(ctx *fiber.Ctx) error { webhookRule, botHandler := bots.FindRuleAndHandler[webhook.Rule](flag, bots.List()) if botHandler == nil { - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrNotFound)) + return ctx.JSON(protocol.NewFailedResponse(protocol.ErrNotFound.New("bot not found"))) } typesCtx := types.Context{} @@ -419,14 +419,14 @@ func (c *Controller) doWebhook(ctx *fiber.Ctx) error { secret = strings.TrimPrefix(val, "Bearer ") } if secret == "" { - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrParamVerificationFailed)) + return ctx.JSON(protocol.NewFailedResponse(protocol.ErrParamVerificationFailed.New("secret not verification"))) } find, err = store.Database.GetWebhookBySecret(secret) if err != nil { - return ctx.JSON(protocol.NewFailedResponseWithError(protocol.ErrNotAuthorized, err)) + return ctx.JSON(protocol.NewFailedResponse(protocol.ErrNotAuthorized.Wrap(err))) } if find.State != model.WebhookActive { - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrAccessDenied)) + return ctx.JSON(protocol.NewFailedResponse(protocol.ErrAccessDenied.New("inactive"))) } typesCtx.AsUser = types.Uid(find.UID) @@ -447,7 +447,7 @@ func (c *Controller) doWebhook(ctx *fiber.Ctx) error { payload, err := botHandler.Webhook(typesCtx, data) if err != nil { - return ctx.JSON(protocol.NewFailedResponseWithError(protocol.ErrFlagError, err)) + return ctx.JSON(protocol.NewFailedResponse(protocol.ErrFlagError.Wrap(err))) } if find != nil { diff --git a/pkg/media/fs/filesys.go b/pkg/media/fs/filesys.go index 7693c1b9..618c4123 100644 --- a/pkg/media/fs/filesys.go +++ b/pkg/media/fs/filesys.go @@ -114,7 +114,7 @@ func (fh *fshandler) Upload(fdef *types.FileDef, file io.ReadSeeker) (string, in func (fh *fshandler) Download(url string) (*types.FileDef, media.ReadSeekCloser, error) { fid := fh.GetIdFromUrl(url) if fid.IsZero() { - return nil, nil, protocol.ErrNotFound + return nil, nil, protocol.ErrNotFound.New("fid not found") } fd, err := fh.getFileRecord(fid) @@ -127,7 +127,7 @@ func (fh *fshandler) Download(url string) (*types.FileDef, media.ReadSeekCloser, if err != nil { if os.IsNotExist(err) { // If the file is not found, send 404 instead of the default 500 - err = protocol.ErrNotFound + err = protocol.ErrNotFound.New("file not found") } return nil, nil, fmt.Errorf("failed to open file %v, %w", fd.Location, err) } @@ -161,7 +161,7 @@ func (fh *fshandler) getFileRecord(fid types.Uid) (*types.FileDef, error) { return nil, fmt.Errorf("file not found %v, %w", fid, err) } if fd == nil { - return nil, protocol.ErrNotFound + return nil, protocol.ErrNotFound.New("fid not found") } return fd, nil } diff --git a/pkg/media/minio/minio.go b/pkg/media/minio/minio.go index 13ee7db4..b0bf3dc4 100644 --- a/pkg/media/minio/minio.go +++ b/pkg/media/minio/minio.go @@ -159,7 +159,7 @@ func (ah *handler) Upload(fdef *types.FileDef, file io.ReadSeeker) (string, int6 // Download processes request for file download. // The returned ReadSeekCloser must be closed after use. func (ah *handler) Download(_ string) (*types.FileDef, media.ReadSeekCloser, error) { - return nil, nil, protocol.ErrUnsupported + return nil, nil, protocol.ErrUnsupported.New("unsupport download") } // Delete deletes files from aws by provided slice of locations. diff --git a/pkg/route/route.go b/pkg/route/route.go index 27079b02..db6cb6ec 100644 --- a/pkg/route/route.go +++ b/pkg/route/route.go @@ -1,7 +1,6 @@ package route import ( - "errors" "net/http" "strconv" "strings" @@ -94,17 +93,17 @@ func Authorize(authLevel AuthLevel, handler fiber.Handler) fiber.Handler { // Check API flag var r http.Request if err := fasthttpadaptor.ConvertRequest(ctx.Context(), &r, true); err != nil { - return ctx.Status(http.StatusInternalServerError).JSON(protocol.NewFailedResponseWithError(protocol.ErrInternalServerError, err)) + return ctx.Status(http.StatusInternalServerError).JSON(protocol.NewFailedResponse(protocol.ErrInternalServerError.Wrap(err))) } accessToken := GetAccessToken(&r) if accessToken == "" { - return ctx.Status(http.StatusUnauthorized).JSON(protocol.NewFailedResponseWithError(protocol.ErrParamVerificationFailed, errors.New("Missing token"))) + return ctx.Status(http.StatusUnauthorized).JSON(protocol.NewFailedResponse(protocol.ErrParamVerificationFailed.New("Missing token"))) } p, err := store.Database.ParameterGet(accessToken) if err != nil || p.ID <= 0 || p.IsExpired() { - return ctx.Status(http.StatusUnauthorized).JSON(protocol.NewFailedResponse(protocol.ErrFlagExpired)) + return ctx.Status(http.StatusUnauthorized).JSON(protocol.NewFailedResponse(protocol.ErrFlagExpired.New("parameter error"))) } topic, _ := types.KV(p.Params).String(topicKey) @@ -112,7 +111,7 @@ func Authorize(authLevel AuthLevel, handler fiber.Handler) fiber.Handler { uid := types.Uid(u) if uid.IsZero() { - return ctx.Status(http.StatusUnauthorized).JSON(protocol.NewFailedResponse(protocol.ErrNotAuthorized)) + return ctx.Status(http.StatusUnauthorized).JSON(protocol.NewFailedResponse(protocol.ErrNotAuthorized.New("uid zeror"))) } // Set uid and topic diff --git a/pkg/types/protocol/action.go b/pkg/types/protocol/action.go index 64a21313..c0958856 100644 --- a/pkg/types/protocol/action.go +++ b/pkg/types/protocol/action.go @@ -1,7 +1,11 @@ package protocol import ( + "errors" "fmt" + "strconv" + + "github.com/samber/oops" ) type ResponseStatus string @@ -38,7 +42,7 @@ type Response struct { // indicating successful and unsuccessful execution, respectively. Status ResponseStatus `json:"status"` // The return code, which must conform to the return code rules defined later on this page - RetCode int64 `json:"retcode,omitempty"` + RetCode string `json:"retcode,omitempty"` // Response data Data any `json:"data,omitempty"` // Error message, it is recommended to fill in a human-readable error message when the action fails to execute, @@ -46,25 +50,9 @@ type Response struct { Message string `json:"message,omitempty"` } -type Error struct { - Code int64 `json:"code"` - Message string `json:"message"` -} - -func NewError(code int64, message string) *Error { - return &Error{Code: code, Message: message} -} - -func (e Error) Error() string { - return fmt.Sprintf("%d: %s", e.Code, e.Message) -} - -func (e Error) GetCode() int64 { - return e.Code -} - -func (e Error) GetMessage() string { - return e.Message +func NewError(code int64, message string) oops.OopsErrorBuilder { + return oops.Code(strconv.FormatInt(code, 10)). + Public(message) } // Request Error (10xxx) @@ -178,24 +166,35 @@ var ErrAccessDenied = NewError(60007, "access denied") func NewSuccessResponse(data any) Response { return Response{ Status: Success, - RetCode: SuccessCode, + RetCode: strconv.Itoa(int(SuccessCode)), Data: data, } } -func NewFailedResponse(e *Error) Response { - return Response{ - Status: Failed, - RetCode: e.GetCode(), - Message: e.GetMessage(), +func NewFailedResponse(err error) Response { + if err == nil { + return Response{ + Status: Failed, + RetCode: "10000", + Message: "Unknown Error", + } + } + var e oops.OopsError + if errors.As(err, &e) { + message := e.Public() + if e.Error() != "" { + message = fmt.Sprintf("%s (%s)", e.Public(), e.Error()) + } + return Response{ + Status: Failed, + RetCode: e.Code(), + Message: message, + } } -} -func NewFailedResponseWithError(e *Error, err error) Response { - // return failed response return Response{ Status: Failed, - RetCode: e.GetCode(), - Message: fmt.Sprintf("%s (%s)", e.GetMessage(), err.Error()), + RetCode: "10000", + Message: e.Error(), } } From 0499f062ca46c6e6d92d1aa0c71cd49aad5cd90c Mon Sep 17 00:00:00 2001 From: sysatom Date: Sat, 10 May 2025 01:02:13 +0800 Subject: [PATCH 066/125] =?UTF-8?q?=F0=9F=94=A7=20fix:=20Correct=20JSON=20?= =?UTF-8?q?response=20in=20webservice.go=20for=20database=20errors=20?= =?UTF-8?q?=F0=9F=94=A7=20fix:=20Correct=20JSON=20response=20in=20route.go?= =?UTF-8?q?=20for=20parameter=20errors=20=F0=9F=94=A7=20fix:=20Correct=20J?= =?UTF-8?q?SON=20response=20in=20protocol/action.go=20for=20response=20cre?= =?UTF-8?q?ation=20=F0=9F=94=A7=20fix:=20Correct=20JSON=20response=20in=20?= =?UTF-8?q?okr/webservice.go=20for=20database=20errors=20=F0=9F=94=A7=20fi?= =?UTF-8?q?x:=20Correct=20JSON=20response=20in=20router.go=20for=20various?= =?UTF-8?q?=20errors=20=F0=9F=94=A7=20fix:=20Correct=20JSON=20response=20i?= =?UTF-8?q?n=20http.go=20for=20error=20handling?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/bots/okr/webservice.go | 44 +++++++++---------- internal/bots/workflow/webservice.go | 30 ++++++------- internal/server/http.go | 20 +++++++-- internal/server/router.go | 66 ++++++++++++++-------------- pkg/route/route.go | 8 ++-- pkg/types/protocol/action.go | 7 +-- 6 files changed, 92 insertions(+), 83 deletions(-) diff --git a/internal/bots/okr/webservice.go b/internal/bots/okr/webservice.go index 780e67b2..07749e64 100644 --- a/internal/bots/okr/webservice.go +++ b/internal/bots/okr/webservice.go @@ -39,7 +39,7 @@ func objectiveList(ctx *fiber.Ctx) error { list, err := store.Database.ListObjectives(uid, topic) if err != nil { - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrDatabaseReadError.Wrap(err))) + return protocol.ErrDatabaseReadError.Wrap(err) } return ctx.JSON(protocol.NewSuccessResponse(list)) } @@ -61,7 +61,7 @@ func objectiveDetail(ctx *fiber.Ctx) error { obj, err := store.Database.GetObjectiveBySequence(uid, topic, sequence) if err != nil { - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrDatabaseReadError.Wrap(err))) + return protocol.ErrDatabaseReadError.Wrap(err) } return ctx.JSON(protocol.NewSuccessResponse(obj)) } @@ -83,13 +83,13 @@ func objectiveCreate(ctx *fiber.Ctx) error { item := new(model.Objective) err := ctx.BodyParser(&item) if err != nil { - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrBadParam.Wrap(err))) + return protocol.ErrBadParam.Wrap(err) } // check if item.IsPlan > 0 { if item.PlanStart.IsZero() || item.PlanEnd.IsZero() { - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrParamVerificationFailed.New("is plan emtpy"))) + return protocol.ErrParamVerificationFailed.New("is plan emtpy") } } @@ -97,7 +97,7 @@ func objectiveCreate(ctx *fiber.Ctx) error { item.Topic = topic _, err = store.Database.CreateObjective(item) if err != nil { - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrDatabaseWriteError.Wrap(err))) + return protocol.ErrDatabaseWriteError.Wrap(err) } return ctx.JSON(protocol.NewSuccessResponse(nil)) } @@ -121,14 +121,14 @@ func objectiveUpdate(ctx *fiber.Ctx) error { item := new(model.Objective) err := ctx.BodyParser(&item) if err != nil { - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrBadParam.Wrap(err))) + return protocol.ErrBadParam.Wrap(err) } item.UID = uid.String() item.Topic = topic item.Sequence = int32(sequence) err = store.Database.UpdateObjective(item) if err != nil { - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrDatabaseWriteError.Wrap(err))) + return protocol.ErrDatabaseWriteError.Wrap(err) } return ctx.JSON(protocol.NewSuccessResponse(nil)) } @@ -150,7 +150,7 @@ func objectiveDelete(ctx *fiber.Ctx) error { err := store.Database.DeleteObjectiveBySequence(uid, topic, sequence) if err != nil { - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrDatabaseWriteError.Wrap(err))) + return protocol.ErrDatabaseWriteError.Wrap(err) } return ctx.JSON(protocol.NewSuccessResponse(nil)) } @@ -172,13 +172,13 @@ func keyResultCreate(ctx *fiber.Ctx) error { item := new(model.KeyResult) err := ctx.BodyParser(&item) if err != nil { - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrBadParam.Wrap(err))) + return protocol.ErrBadParam.Wrap(err) } item.UID = uid.String() item.Topic = topic _, err = store.Database.CreateKeyResult(item) if err != nil { - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrDatabaseWriteError.Wrap(err))) + return protocol.ErrDatabaseWriteError.Wrap(err) } return ctx.JSON(protocol.NewSuccessResponse(nil)) } @@ -202,14 +202,14 @@ func keyResultUpdate(ctx *fiber.Ctx) error { item := new(model.KeyResult) err := ctx.BodyParser(&item) if err != nil { - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrBadParam.Wrap(err))) + return protocol.ErrBadParam.Wrap(err) } item.UID = uid.String() item.Topic = topic item.Sequence = int32(sequence) err = store.Database.UpdateKeyResult(item) if err != nil { - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrDatabaseWriteError.Wrap(err))) + return protocol.ErrDatabaseWriteError.Wrap(err) } return ctx.JSON(protocol.NewSuccessResponse(nil)) } @@ -231,7 +231,7 @@ func keyResultDelete(ctx *fiber.Ctx) error { err := store.Database.DeleteKeyResultBySequence(uid, topic, sequence) if err != nil { - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrDatabaseWriteError.Wrap(err))) + return protocol.ErrDatabaseWriteError.Wrap(err) } return ctx.JSON(protocol.NewSuccessResponse(nil)) } @@ -249,12 +249,12 @@ func keyResultDelete(ctx *fiber.Ctx) error { func keyResultValueList(ctx *fiber.Ctx) error { keyResultId := route.GetIntParam(ctx, "id") if keyResultId == 0 { - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrBadParam.New("id empty"))) + return protocol.ErrBadParam.New("id empty") } list, err := store.Database.GetKeyResultValues(keyResultId) if err != nil { - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrDatabaseReadError.Wrap(err))) + return protocol.ErrDatabaseReadError.Wrap(err) } return ctx.JSON(protocol.NewSuccessResponse(list)) } @@ -273,18 +273,18 @@ func keyResultValueList(ctx *fiber.Ctx) error { func keyResultValueCreate(ctx *fiber.Ctx) error { keyResultId := route.GetIntParam(ctx, "id") if keyResultId == 0 { - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrBadParam.New("id empty"))) + return protocol.ErrBadParam.New("id empty") } item := new(model.KeyResultValue) err := ctx.BodyParser(&item) if err != nil { - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrBadParam.Wrap(err))) + return protocol.ErrBadParam.Wrap(err) } item.KeyResultID = keyResultId _, err = store.Database.CreateKeyResultValue(item) if err != nil { - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrDatabaseWriteError.Wrap(err))) + return protocol.ErrDatabaseWriteError.Wrap(err) } return ctx.JSON(protocol.NewSuccessResponse(nil)) } @@ -302,12 +302,12 @@ func keyResultValueCreate(ctx *fiber.Ctx) error { func keyResultValueDelete(ctx *fiber.Ctx) error { keyResultValueId := route.GetIntParam(ctx, "id") if keyResultValueId == 0 { - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrBadParam.New("id emtpy"))) + return protocol.ErrBadParam.New("id emtpy") } err := store.Database.DeleteKeyResultValue(keyResultValueId) if err != nil { - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrDatabaseWriteError.Wrap(err))) + return protocol.ErrDatabaseWriteError.Wrap(err) } return ctx.JSON(protocol.NewSuccessResponse(nil)) } @@ -325,12 +325,12 @@ func keyResultValueDelete(ctx *fiber.Ctx) error { func keyResultValue(ctx *fiber.Ctx) error { keyResultValueId := route.GetIntParam(ctx, "id") if keyResultValueId == 0 { - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrBadParam.New("id emtpy"))) + return protocol.ErrBadParam.New("id emtpy") } item, err := store.Database.GetKeyResultValue(keyResultValueId) if err != nil { - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrDatabaseReadError.Wrap(err))) + return protocol.ErrDatabaseReadError.Wrap(err) } return ctx.JSON(protocol.NewSuccessResponse(item)) } diff --git a/internal/bots/workflow/webservice.go b/internal/bots/workflow/webservice.go index 55eadbcf..d5c6f724 100644 --- a/internal/bots/workflow/webservice.go +++ b/internal/bots/workflow/webservice.go @@ -81,7 +81,7 @@ func workflowList(ctx *fiber.Ctx) error { list, err := store.Database.ListWorkflows(uid, topic) if err != nil { - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrDatabaseReadError.Wrap(err))) + return protocol.ErrDatabaseReadError.Wrap(err) } return ctx.JSON(protocol.NewSuccessResponse(list)) } @@ -101,7 +101,7 @@ func workflowDetail(ctx *fiber.Ctx) error { item, err := store.Database.GetWorkflow(id) if err != nil { - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrDatabaseReadError.Wrap(err))) + return protocol.ErrDatabaseReadError.Wrap(err) } return ctx.JSON(protocol.NewSuccessResponse(item)) } @@ -123,23 +123,23 @@ func workflowCreate(ctx *fiber.Ctx) error { script := new(model.WorkflowScript) err := ctx.BodyParser(&script) if err != nil { - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrBadParam.Wrap(err))) + return protocol.ErrBadParam.Wrap(err) } if script.Lang != model.WorkflowScriptYaml { - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrUnsupported.New("script type error"))) + return protocol.ErrUnsupported.New("script type error") } wf, triggers, dag, err := ParseYamlWorkflow(script.Code) if err != nil { - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrBadParam.Wrap(err))) + return protocol.ErrBadParam.Wrap(err) } wf.UID = uid.String() wf.Topic = topic _, err = store.Database.CreateWorkflow(wf, script, dag, triggers) if err != nil { - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrDatabaseWriteError.Wrap(err))) + return protocol.ErrDatabaseWriteError.Wrap(err) } return ctx.JSON(protocol.NewSuccessResponse(types.KV{"id": wf.ID})) } @@ -163,16 +163,16 @@ func workflowUpdate(ctx *fiber.Ctx) error { script := new(model.WorkflowScript) err := ctx.BodyParser(&script) if err != nil { - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrBadParam.Wrap(err))) + return protocol.ErrBadParam.Wrap(err) } if script.Lang != model.WorkflowScriptYaml { - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrUnsupported.New("script type error"))) + return protocol.ErrUnsupported.New("script type error") } wf, triggers, dag, err := ParseYamlWorkflow(script.Code) if err != nil { - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrBadParam.Wrap(err))) + return protocol.ErrBadParam.Wrap(err) } // item := new(model.Workflow) @@ -183,7 +183,7 @@ func workflowUpdate(ctx *fiber.Ctx) error { // item.Describe = wf.Describe err = store.Database.UpdateWorkflow(wf, script, dag, triggers) if err != nil { - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrDatabaseWriteError.Wrap(err))) + return protocol.ErrDatabaseWriteError.Wrap(err) } return ctx.JSON(protocol.NewSuccessResponse(nil)) @@ -204,7 +204,7 @@ func workflowDelete(ctx *fiber.Ctx) error { err := store.Database.DeleteWorkflow(id) if err != nil { - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrDatabaseWriteError.Wrap(err))) + return protocol.ErrDatabaseWriteError.Wrap(err) } return ctx.JSON(protocol.NewSuccessResponse(nil)) } @@ -224,7 +224,7 @@ func workflowTriggerList(ctx *fiber.Ctx) error { item, err := store.Database.GetWorkflow(id) if err != nil { - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrDatabaseReadError.Wrap(err))) + return protocol.ErrDatabaseReadError.Wrap(err) } return ctx.JSON(protocol.NewSuccessResponse(item.Triggers)) } @@ -244,7 +244,7 @@ func workflowJobList(ctx *fiber.Ctx) error { list, err := store.Database.GetJobsByWorkflowId(id) if err != nil { - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrDatabaseReadError.Wrap(err))) + return protocol.ErrDatabaseReadError.Wrap(err) } return ctx.JSON(protocol.NewSuccessResponse(list)) } @@ -264,7 +264,7 @@ func workflowJobDetail(ctx *fiber.Ctx) error { item, err := store.Database.GetJob(id) if err != nil { - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrDatabaseReadError.Wrap(err))) + return protocol.ErrDatabaseReadError.Wrap(err) } return ctx.JSON(protocol.NewSuccessResponse(item)) } @@ -298,7 +298,7 @@ func workflowScriptDetail(ctx *fiber.Ctx) error { item, err := store.Database.GetWorkflowScriptByWorkflowId(id) if err != nil { - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrDatabaseReadError.Wrap(err))) + return protocol.ErrDatabaseReadError.Wrap(err) } return ctx.JSON(protocol.NewSuccessResponse(item)) } diff --git a/internal/server/http.go b/internal/server/http.go index 60820287..db575fc4 100644 --- a/internal/server/http.go +++ b/internal/server/http.go @@ -1,9 +1,7 @@ package server import ( - "net/http" - "time" - + "errors" "github.com/bytedance/sonic" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/types/protocol" @@ -15,6 +13,9 @@ import ( "github.com/gofiber/fiber/v2/middleware/limiter" "github.com/gofiber/fiber/v2/middleware/recover" "github.com/gofiber/fiber/v2/middleware/requestid" + "github.com/samber/oops" + "net/http" + "time" ) func newHTTPServer() *fiber.App { @@ -29,7 +30,18 @@ func newHTTPServer() *fiber.App { WriteTimeout: 90 * time.Second, ErrorHandler: func(ctx *fiber.Ctx, err error) error { - // Send custom error page + // custom error + var e oops.OopsError + if errors.As(err, &e) { + if e.Code() == oops.OopsError(protocol.ErrNotAuthorized).Code() { + return ctx.Status(fiber.StatusUnauthorized). + JSON(protocol.NewFailedResponse(e)) + } + return ctx.Status(fiber.StatusBadRequest). + JSON(protocol.NewFailedResponse(e)) + } + + // other error if err != nil { return ctx.Status(fiber.StatusBadRequest). JSON(protocol.NewFailedResponse(protocol.ErrBadRequest.Wrap(err))) diff --git a/internal/server/router.go b/internal/server/router.go index 332676c8..4161298d 100644 --- a/internal/server/router.go +++ b/internal/server/router.go @@ -72,23 +72,23 @@ func (c *Controller) storeOAuth(ctx *fiber.Ctx) error { p, err := store.Database.ParameterGet(flag) if err != nil { - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrFlagError.Wrap(err))) + return protocol.ErrFlagError.Wrap(err) } if p.IsExpired() { - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrFlagExpired.New("oauth error"))) + return protocol.ErrFlagExpired.New("oauth error") } uid, _ := types.KV(p.Params).String("uid") topic, _ := types.KV(p.Params).String("topic") if uid == "" { - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrBadParam.New("uid empty"))) + return protocol.ErrBadParam.New("uid empty") } // code -> token provider := newProvider(name) tk, err := provider.GetAccessToken(ctx) if err != nil { - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrOAuthError.Wrap(err))) + return protocol.ErrOAuthError.Wrap(err) } // store @@ -103,7 +103,7 @@ func (c *Controller) storeOAuth(ctx *fiber.Ctx) error { Extra: model.JSON(extra), }) if err != nil { - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrOAuthError.Wrap(err))) + return protocol.ErrOAuthError.Wrap(err) } return ctx.SendString("ok") @@ -114,7 +114,7 @@ func (c *Controller) getPage(ctx *fiber.Ctx) error { p, err := store.Database.PageGet(id) if err != nil { - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrNotFound.Wrap(err))) + return protocol.ErrNotFound.Wrap(err) } title, _ := types.KV(p.Schema).String("title") @@ -134,12 +134,12 @@ func (c *Controller) getPage(ctx *fiber.Ctx) error { case model.PageChart: d, err := sonic.Marshal(p.Schema) if err != nil { - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrBadParam.Wrap(err))) + return protocol.ErrBadParam.Wrap(err) } var msg types.ChartMsg err = sonic.Unmarshal(d, &msg) if err != nil { - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrBadParam.Wrap(err))) + return protocol.ErrBadParam.Wrap(err) } line := charts.NewLine() @@ -159,7 +159,7 @@ func (c *Controller) getPage(ctx *fiber.Ctx) error { _ = line.Render(buf) return ctx.Send(buf.Bytes()) default: - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrBadRequest.New("error type"))) + return protocol.ErrBadRequest.New("error type") } return ctx.SendString(page.RenderComponent(title, comp)) @@ -171,10 +171,10 @@ func (c *Controller) renderPage(ctx *fiber.Ctx) error { p, err := store.Database.ParameterGet(flag) if err != nil { - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrFlagError.Wrap(err))) + return protocol.ErrFlagError.Wrap(err) } if p.IsExpired() { - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrFlagExpired.New("page error"))) + return protocol.ErrFlagExpired.New("page error") } args := types.KV{} @@ -201,15 +201,15 @@ func (c *Controller) renderPage(ctx *fiber.Ctx) error { _, botHandler := bots.FindRuleAndHandler[pageRule.Rule](pageRuleId, bots.List()) if botHandler == nil { - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrNotFound.New("bot not found"))) + return protocol.ErrNotFound.New("bot not found") } html, err := botHandler.Page(typesCtx, flag, args) if err != nil { if errors.Is(err, gorm.ErrRecordNotFound) { - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrNotFound.New("page not found"))) + return protocol.ErrNotFound.New("page not found") } - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrBadParam.Wrap(err))) + return protocol.ErrBadParam.Wrap(err) } ctx.Set("Content-Type", "text/html") return ctx.SendString(html) @@ -222,25 +222,25 @@ func (c *Controller) postForm(ctx *fiber.Ctx) error { formData, err := store.Database.FormGet(formId) if err != nil { - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrBadParam.Wrap(err))) + return protocol.ErrBadParam.Wrap(err) } if formData.State == model.FormStateSubmitSuccess || formData.State == model.FormStateSubmitFailed { - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrBadParam.New("error form state"))) + return protocol.ErrBadParam.New("error form state") } values := make(types.KV) d, err := sonic.Marshal(formData.Schema) if err != nil { - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrBadParam.Wrap(err))) + return protocol.ErrBadParam.Wrap(err) } var formMsg types.FormMsg err = sonic.Unmarshal(d, &formMsg) if err != nil { - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrBadParam.Wrap(err))) + return protocol.ErrBadParam.Wrap(err) } f, err := ctx.MultipartForm() if err != nil { - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrBadParam.Wrap(err))) + return protocol.ErrBadParam.Wrap(err) } pf := f.Value for _, field := range formMsg.Field { @@ -289,7 +289,7 @@ func (c *Controller) postForm(ctx *fiber.Ctx) error { formBuilder.Data = values err = formBuilder.Validate() if err != nil { - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrBadParam.Wrap(err))) + return protocol.ErrBadParam.Wrap(err) } botCtx := types.Context{ @@ -304,20 +304,20 @@ func (c *Controller) postForm(ctx *fiber.Ctx) error { // get bot handler formRuleId, ok := types.KV(formData.Schema).String("id") if !ok { - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrBadParam.Errorf("form %s %s", formId, "error form rule id"))) + return protocol.ErrBadParam.Errorf("form %s %s", formId, "error form rule id") } _, botHandler := bots.FindRuleAndHandler[formRule.Rule](formRuleId, bots.List()) if botHandler != nil { if !botHandler.IsReady() { - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrBadParam.Errorf("bot %s unavailable", topic))) + return protocol.ErrBadParam.Errorf("bot %s unavailable", topic) } // form message payload, err := botHandler.Form(botCtx, values) if err != nil { - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrBadParam.Wrap(err))) + return protocol.ErrBadParam.Wrap(err) } // stats @@ -336,24 +336,24 @@ func (c *Controller) postForm(ctx *fiber.Ctx) error { func (c *Controller) agentData(ctx *fiber.Ctx) error { var r http.Request if err := fasthttpadaptor.ConvertRequest(ctx.Context(), &r, true); err != nil { - return ctx.Status(http.StatusInternalServerError).JSON(protocol.NewFailedResponse(protocol.ErrInternalServerError.Wrap(err))) + return protocol.ErrInternalServerError.Wrap(err) } // authorization uid, isValid := route.CheckAccessToken(route.GetAccessToken(&r)) if !isValid { - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrNotAuthorized.New("token not valided"))) + return protocol.ErrNotAuthorized.New("token not valided") } var data types.AgentData err := sonic.Unmarshal(ctx.Body(), &data) if err != nil { - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrBadParam.Wrap(err))) + return protocol.ErrBadParam.Wrap(err) } result, err := agentAction(uid, data) if err != nil { flog.Error(err) - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrBadParam.Wrap(err))) + return protocol.ErrBadParam.Wrap(err) } return ctx.JSON(protocol.NewSuccessResponse(result)) @@ -372,7 +372,7 @@ func (c *Controller) platformCallback(ctx *fiber.Ctx) error { if err != nil { var e oops.OopsError if errors.As(err, &e) { - return ctx.JSON(protocol.NewFailedResponse(e)) + return e } return err } @@ -389,7 +389,7 @@ func (c *Controller) doWebhook(ctx *fiber.Ctx) error { webhookRule, botHandler := bots.FindRuleAndHandler[webhook.Rule](flag, bots.List()) if botHandler == nil { - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrNotFound.New("bot not found"))) + return protocol.ErrNotFound.New("bot not found") } typesCtx := types.Context{} @@ -419,14 +419,14 @@ func (c *Controller) doWebhook(ctx *fiber.Ctx) error { secret = strings.TrimPrefix(val, "Bearer ") } if secret == "" { - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrParamVerificationFailed.New("secret not verification"))) + return protocol.ErrParamVerificationFailed.New("secret not verification") } find, err = store.Database.GetWebhookBySecret(secret) if err != nil { - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrNotAuthorized.Wrap(err))) + return protocol.ErrNotAuthorized.Wrap(err) } if find.State != model.WebhookActive { - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrAccessDenied.New("inactive"))) + return protocol.ErrAccessDenied.New("inactive") } typesCtx.AsUser = types.Uid(find.UID) @@ -447,7 +447,7 @@ func (c *Controller) doWebhook(ctx *fiber.Ctx) error { payload, err := botHandler.Webhook(typesCtx, data) if err != nil { - return ctx.JSON(protocol.NewFailedResponse(protocol.ErrFlagError.Wrap(err))) + return protocol.ErrFlagError.Wrap(err) } if find != nil { diff --git a/pkg/route/route.go b/pkg/route/route.go index db6cb6ec..0f121f1a 100644 --- a/pkg/route/route.go +++ b/pkg/route/route.go @@ -93,17 +93,17 @@ func Authorize(authLevel AuthLevel, handler fiber.Handler) fiber.Handler { // Check API flag var r http.Request if err := fasthttpadaptor.ConvertRequest(ctx.Context(), &r, true); err != nil { - return ctx.Status(http.StatusInternalServerError).JSON(protocol.NewFailedResponse(protocol.ErrInternalServerError.Wrap(err))) + return protocol.ErrNotAuthorized.Wrap(err) } accessToken := GetAccessToken(&r) if accessToken == "" { - return ctx.Status(http.StatusUnauthorized).JSON(protocol.NewFailedResponse(protocol.ErrParamVerificationFailed.New("Missing token"))) + return protocol.ErrNotAuthorized.New("Missing token") } p, err := store.Database.ParameterGet(accessToken) if err != nil || p.ID <= 0 || p.IsExpired() { - return ctx.Status(http.StatusUnauthorized).JSON(protocol.NewFailedResponse(protocol.ErrFlagExpired.New("parameter error"))) + return protocol.ErrNotAuthorized.New("parameter error") } topic, _ := types.KV(p.Params).String(topicKey) @@ -111,7 +111,7 @@ func Authorize(authLevel AuthLevel, handler fiber.Handler) fiber.Handler { uid := types.Uid(u) if uid.IsZero() { - return ctx.Status(http.StatusUnauthorized).JSON(protocol.NewFailedResponse(protocol.ErrNotAuthorized.New("uid zeror"))) + return protocol.ErrNotAuthorized.New("uid empty") } // Set uid and topic diff --git a/pkg/types/protocol/action.go b/pkg/types/protocol/action.go index c0958856..c3bd0e41 100644 --- a/pkg/types/protocol/action.go +++ b/pkg/types/protocol/action.go @@ -13,8 +13,6 @@ type ResponseStatus string const ( Success ResponseStatus = "ok" Failed ResponseStatus = "failed" - - SuccessCode = int64(0) ) const ( @@ -165,9 +163,8 @@ var ErrAccessDenied = NewError(60007, "access denied") func NewSuccessResponse(data any) Response { return Response{ - Status: Success, - RetCode: strconv.Itoa(int(SuccessCode)), - Data: data, + Status: Success, + Data: data, } } From c3c7ab921d4bb8b94621e886caba64e0f84e455f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 9 May 2025 17:12:28 +0000 Subject: [PATCH 067/125] build(deps): bump github.com/cloudwego/eino from 0.3.29 to 0.3.30 Bumps [github.com/cloudwego/eino](https://github.com/cloudwego/eino) from 0.3.29 to 0.3.30. - [Release notes](https://github.com/cloudwego/eino/releases) - [Commits](https://github.com/cloudwego/eino/compare/v0.3.29...v0.3.30) --- updated-dependencies: - dependency-name: github.com/cloudwego/eino dependency-version: 0.3.30 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 3b7b32d9..4cb41acc 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,7 @@ require ( github.com/bwmarrin/discordgo v0.28.1 github.com/bytedance/sonic v1.13.2 github.com/cenkalti/backoff v2.2.1+incompatible - github.com/cloudwego/eino v0.3.29 + github.com/cloudwego/eino v0.3.30 github.com/cloudwego/eino-ext/components/model/openai v0.0.0-20250507115047-b20720df8528 github.com/creachadair/jrpc2 v1.3.1 github.com/dgraph-io/ristretto/v2 v2.2.0 diff --git a/go.sum b/go.sum index 8f829025..eb53a806 100644 --- a/go.sum +++ b/go.sum @@ -65,8 +65,8 @@ github.com/chengxilo/virtualterm v1.0.4 h1:Z6IpERbRVlfB8WkOmtbHiDbBANU7cimRIof7m github.com/chengxilo/virtualterm v1.0.4/go.mod h1:DyxxBZz/x1iqJjFxTFcr6/x+jSpqN0iwWCOK1q10rlY= github.com/cloudwego/base64x v0.1.5 h1:XPciSp1xaq2VCSt6lF0phncD4koWyULpl5bUxbfCyP4= github.com/cloudwego/base64x v0.1.5/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w= -github.com/cloudwego/eino v0.3.29 h1:yPiV/bMjxvQzBZlmDFF71Sly59y3HSNpdfOPQWayrYM= -github.com/cloudwego/eino v0.3.29/go.mod h1:wUjz990apdsaOraOXdh6CdhVXq8DJsOvLsVlxNTcNfY= +github.com/cloudwego/eino v0.3.30 h1:oQxEqkpu+nCl5hrzbEIMxX1Dogtbyed7gYAnTM6uUZY= +github.com/cloudwego/eino v0.3.30/go.mod h1:wUjz990apdsaOraOXdh6CdhVXq8DJsOvLsVlxNTcNfY= github.com/cloudwego/eino-ext/components/model/openai v0.0.0-20250507115047-b20720df8528 h1:LWlv4+NUNKVG2ojRtEbMDhExS45DH1t+kXakBCB3+Cw= github.com/cloudwego/eino-ext/components/model/openai v0.0.0-20250507115047-b20720df8528/go.mod h1:uXIWTFbaAbZ1128EIXjFc4S+tDqmz1idMZd5qt5kkwU= github.com/cloudwego/eino-ext/libs/acl/openai v0.0.0-20250422092704-54e372e1fa3d h1:unNqPz9vuJmJCZAw5YKFcszRX9e3CdVEjh0lR6QArxk= From 970b77ace6b9b913b6aa455804bc19181ec4edd6 Mon Sep 17 00:00:00 2001 From: sysatom Date: Sat, 10 May 2025 01:36:05 +0800 Subject: [PATCH 068/125] =?UTF-8?q?=F0=9F=9B=A0=EF=B8=8F=20refactor(chatbo?= =?UTF-8?q?t):=20Rename=20internal=20package=20to=20chatbot=20and=20update?= =?UTF-8?q?=20imports?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/bots/agent/bot.go | 10 ++-- internal/bots/anki/bot.go | 18 +++---- internal/bots/anki/command.go | 4 +- internal/bots/bookmark/bot.go | 20 +++---- internal/bots/bookmark/command.go | 4 +- internal/bots/clipboard/bot.go | 14 ++--- internal/bots/clipboard/command.go | 4 +- internal/bots/cloudflare/bot.go | 18 +++---- internal/bots/cloudflare/command.go | 8 +-- internal/bots/dev/bot.go | 52 +++++++++--------- internal/bots/dev/command.go | 12 ++--- internal/bots/dev/webhook.go | 4 +- internal/bots/finance/bot.go | 24 ++++----- internal/bots/finance/command.go | 4 +- internal/bots/gitea/bot.go | 20 +++---- internal/bots/github/bot.go | 26 ++++----- internal/bots/github/command.go | 8 +-- internal/bots/kanban/bot.go | 24 ++++----- internal/bots/modules.go | 50 +++++++++++++++++ internal/bots/notify/bot.go | 24 ++++----- internal/bots/notify/command.go | 4 +- internal/bots/obsidian/bot.go | 14 ++--- internal/bots/okr/bot.go | 22 ++++---- internal/bots/okr/command.go | 26 ++++----- internal/bots/reader/bot.go | 20 +++---- internal/bots/search/bot.go | 26 ++++----- internal/bots/search/command.go | 4 +- internal/bots/server/bot.go | 22 ++++---- internal/bots/server/command.go | 4 +- internal/bots/torrent/bot.go | 16 +++--- internal/bots/user/bot.go | 14 ++--- internal/bots/webhook/bot.go | 12 ++--- internal/bots/webhook/command.go | 6 +-- internal/bots/workflow/bot.go | 26 ++++----- internal/bots/workflow/command.go | 6 +-- internal/bots/workflow/form.go | 6 +-- internal/bots/workflow/webservice.go | 6 +-- internal/server/chatbot.go | 60 +++------------------ internal/server/event.go | 4 +- internal/server/func.go | 16 +++--- internal/server/modules.go | 3 +- internal/server/router.go | 10 ++-- internal/workflow/fsm.go | 6 +-- {internal/bots => pkg/chatbot}/bot.go | 2 +- {internal/bots => pkg/chatbot}/interface.go | 2 +- 45 files changed, 345 insertions(+), 340 deletions(-) create mode 100644 internal/bots/modules.go rename {internal/bots => pkg/chatbot}/bot.go (99%) rename {internal/bots => pkg/chatbot}/interface.go (99%) diff --git a/internal/bots/agent/bot.go b/internal/bots/agent/bot.go index 8d7cda2e..a537216d 100644 --- a/internal/bots/agent/bot.go +++ b/internal/bots/agent/bot.go @@ -5,7 +5,7 @@ import ( "errors" "github.com/bytedance/sonic" - "github.com/flowline-io/flowbot/internal/bots" + "github.com/flowline-io/flowbot/pkg/chatbot" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/types" ) @@ -15,12 +15,12 @@ const Name = "agent" var handler bot func Register() { - bots.Register(Name, &handler) + chatbot.Register(Name, &handler) } type bot struct { initialized bool - bots.Base + chatbot.Base } type configType struct { @@ -52,6 +52,6 @@ func (bot) IsReady() bool { return handler.initialized } -func (b bot) Command(ctx types.Context, content interface{}) (types.MsgPayload, error) { - return bots.RunCommand(commandRules, ctx, content) +func (bot) Command(ctx types.Context, content interface{}) (types.MsgPayload, error) { + return chatbot.RunCommand(commandRules, ctx, content) } diff --git a/internal/bots/anki/bot.go b/internal/bots/anki/bot.go index 7594e21b..83fc3b59 100644 --- a/internal/bots/anki/bot.go +++ b/internal/bots/anki/bot.go @@ -5,7 +5,7 @@ import ( "errors" "github.com/bytedance/sonic" - "github.com/flowline-io/flowbot/internal/bots" + "github.com/flowline-io/flowbot/pkg/chatbot" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/types" "github.com/flowline-io/flowbot/pkg/types/ruleset/cron" @@ -16,12 +16,12 @@ const Name = "anki" var handler bot func Register() { - bots.Register(Name, &handler) + chatbot.Register(Name, &handler) } type bot struct { initialized bool - bots.Base + chatbot.Base } type configType struct { @@ -53,14 +53,14 @@ func (bot) IsReady() bool { return handler.initialized } -func (b bot) Command(ctx types.Context, content interface{}) (types.MsgPayload, error) { - return bots.RunCommand(commandRules, ctx, content) +func (bot) Command(ctx types.Context, content interface{}) (types.MsgPayload, error) { + return chatbot.RunCommand(commandRules, ctx, content) } -func (b bot) Cron() (*cron.Ruleset, error) { - return bots.RunCron(cronRules, Name) +func (bot) Cron() (*cron.Ruleset, error) { + return chatbot.RunCron(cronRules, Name) } -func (b bot) Collect(ctx types.Context, content types.KV) (types.MsgPayload, error) { - return bots.RunCollect(collectRules, ctx, content) +func (bot) Collect(ctx types.Context, content types.KV) (types.MsgPayload, error) { + return chatbot.RunCollect(collectRules, ctx, content) } diff --git a/internal/bots/anki/command.go b/internal/bots/anki/command.go index 02a9fc47..40dd2e64 100644 --- a/internal/bots/anki/command.go +++ b/internal/bots/anki/command.go @@ -1,9 +1,9 @@ package anki import ( - "github.com/flowline-io/flowbot/internal/bots" "github.com/flowline-io/flowbot/internal/store" "github.com/flowline-io/flowbot/internal/store/model" + "github.com/flowline-io/flowbot/pkg/chatbot" "github.com/flowline-io/flowbot/pkg/parser" "github.com/flowline-io/flowbot/pkg/types" "github.com/flowline-io/flowbot/pkg/types/ruleset/command" @@ -22,7 +22,7 @@ var commandRules = []command.Rule{ if !ok { return types.TextMsg{Text: "Empty"} } - return bots.StorePage(ctx, model.PageHtml, "Anki collection statistics", types.HtmlMsg{Raw: html}) + return chatbot.StorePage(ctx, model.PageHtml, "Anki collection statistics", types.HtmlMsg{Raw: html}) }, }, } diff --git a/internal/bots/bookmark/bot.go b/internal/bots/bookmark/bot.go index 2287be29..1b7519e3 100644 --- a/internal/bots/bookmark/bot.go +++ b/internal/bots/bookmark/bot.go @@ -5,7 +5,7 @@ import ( "errors" "github.com/bytedance/sonic" - "github.com/flowline-io/flowbot/internal/bots" + "github.com/flowline-io/flowbot/pkg/chatbot" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/types" "github.com/flowline-io/flowbot/pkg/types/ruleset/cron" @@ -17,12 +17,12 @@ var handler bot var Config configType func Register() { - bots.Register(Name, &handler) + chatbot.Register(Name, &handler) } type bot struct { initialized bool - bots.Base + chatbot.Base } type configType struct { @@ -53,7 +53,7 @@ func (bot) IsReady() bool { return handler.initialized } -func (b bot) Rules() []interface{} { +func (bot) Rules() []interface{} { return []interface{}{ commandRules, cronRules, @@ -61,14 +61,14 @@ func (b bot) Rules() []interface{} { } } -func (b bot) Command(ctx types.Context, content interface{}) (types.MsgPayload, error) { - return bots.RunCommand(commandRules, ctx, content) +func (bot) Command(ctx types.Context, content interface{}) (types.MsgPayload, error) { + return chatbot.RunCommand(commandRules, ctx, content) } -func (b bot) Cron() (*cron.Ruleset, error) { - return bots.RunCron(cronRules, Name) +func (bot) Cron() (*cron.Ruleset, error) { + return chatbot.RunCron(cronRules, Name) } -func (b bot) Event(ctx types.Context, param types.KV) error { - return bots.RunEvent(eventRules, ctx, param) +func (bot) Event(ctx types.Context, param types.KV) error { + return chatbot.RunEvent(eventRules, ctx, param) } diff --git a/internal/bots/bookmark/command.go b/internal/bots/bookmark/command.go index e19baa07..841d730c 100644 --- a/internal/bots/bookmark/command.go +++ b/internal/bots/bookmark/command.go @@ -1,8 +1,8 @@ package bookmark import ( - "github.com/flowline-io/flowbot/internal/bots" "github.com/flowline-io/flowbot/internal/store/model" + "github.com/flowline-io/flowbot/pkg/chatbot" "github.com/flowline-io/flowbot/pkg/parser" "github.com/flowline-io/flowbot/pkg/providers/hoarder" "github.com/flowline-io/flowbot/pkg/types" @@ -29,7 +29,7 @@ var commandRules = []command.Rule{ } } - return bots.StorePage(ctx, model.PageTable, "Newest Bookmark List", types.TableMsg{ + return chatbot.StorePage(ctx, model.PageTable, "Newest Bookmark List", types.TableMsg{ Title: "Newest Bookmark List", Header: header, Row: row, diff --git a/internal/bots/clipboard/bot.go b/internal/bots/clipboard/bot.go index 660755d3..1f89016c 100644 --- a/internal/bots/clipboard/bot.go +++ b/internal/bots/clipboard/bot.go @@ -5,7 +5,7 @@ import ( "errors" "github.com/bytedance/sonic" - "github.com/flowline-io/flowbot/internal/bots" + "github.com/flowline-io/flowbot/pkg/chatbot" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/types" "github.com/flowline-io/flowbot/pkg/types/ruleset/instruct" @@ -16,12 +16,12 @@ const Name = "clipboard" var handler bot func Register() { - bots.Register(Name, &handler) + chatbot.Register(Name, &handler) } type bot struct { initialized bool - bots.Base + chatbot.Base } type configType struct { @@ -53,17 +53,17 @@ func (bot) IsReady() bool { return handler.initialized } -func (b bot) Rules() []interface{} { +func (bot) Rules() []interface{} { return []interface{}{ commandRules, instructRules, } } -func (b bot) Command(ctx types.Context, content interface{}) (types.MsgPayload, error) { - return bots.RunCommand(commandRules, ctx, content) +func (bot) Command(ctx types.Context, content interface{}) (types.MsgPayload, error) { + return chatbot.RunCommand(commandRules, ctx, content) } -func (b bot) Instruct() (instruct.Ruleset, error) { +func (bot) Instruct() (instruct.Ruleset, error) { return instructRules, nil } diff --git a/internal/bots/clipboard/command.go b/internal/bots/clipboard/command.go index ecbf0248..9c0fc347 100644 --- a/internal/bots/clipboard/command.go +++ b/internal/bots/clipboard/command.go @@ -1,7 +1,7 @@ package clipboard import ( - "github.com/flowline-io/flowbot/internal/bots" + "github.com/flowline-io/flowbot/pkg/chatbot" "github.com/flowline-io/flowbot/pkg/parser" "github.com/flowline-io/flowbot/pkg/types" "github.com/flowline-io/flowbot/pkg/types/ruleset/command" @@ -15,7 +15,7 @@ var commandRules = []command.Rule{ txt, _ := tokens[1].Value.String() data := types.KV{} data["txt"] = txt - return bots.InstructMsg(ctx, ShareInstruct, data) + return chatbot.InstructMsg(ctx, ShareInstruct, data) }, }, } diff --git a/internal/bots/cloudflare/bot.go b/internal/bots/cloudflare/bot.go index c6a56e3f..f96ab391 100644 --- a/internal/bots/cloudflare/bot.go +++ b/internal/bots/cloudflare/bot.go @@ -5,7 +5,7 @@ import ( "errors" "github.com/bytedance/sonic" - "github.com/flowline-io/flowbot/internal/bots" + "github.com/flowline-io/flowbot/pkg/chatbot" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/types" ) @@ -15,12 +15,12 @@ const Name = "cloudflare" var handler bot func Register() { - bots.Register(Name, &handler) + chatbot.Register(Name, &handler) } type bot struct { initialized bool - bots.Base + chatbot.Base } type configType struct { @@ -54,22 +54,22 @@ func (bot) IsReady() bool { func (bot) Bootstrap() error { // load setting rule - formRules = append(formRules, bots.SettingCovertForm(Name, settingRules)) + formRules = append(formRules, chatbot.SettingCovertForm(Name, settingRules)) return nil } -func (b bot) Rules() []interface{} { +func (bot) Rules() []interface{} { return []interface{}{ commandRules, formRules, } } -func (b bot) Command(ctx types.Context, content interface{}) (types.MsgPayload, error) { - return bots.RunCommand(commandRules, ctx, content) +func (bot) Command(ctx types.Context, content interface{}) (types.MsgPayload, error) { + return chatbot.RunCommand(commandRules, ctx, content) } -func (b bot) Form(ctx types.Context, values types.KV) (types.MsgPayload, error) { - return bots.RunForm(formRules, ctx, values) +func (bot) Form(ctx types.Context, values types.KV) (types.MsgPayload, error) { + return chatbot.RunForm(formRules, ctx, values) } diff --git a/internal/bots/cloudflare/command.go b/internal/bots/cloudflare/command.go index b7852b70..7a9e68ea 100644 --- a/internal/bots/cloudflare/command.go +++ b/internal/bots/cloudflare/command.go @@ -3,7 +3,7 @@ package cloudflare import ( "time" - "github.com/flowline-io/flowbot/internal/bots" + "github.com/flowline-io/flowbot/pkg/chatbot" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/parser" "github.com/flowline-io/flowbot/pkg/providers/cloudflare" @@ -16,16 +16,16 @@ var commandRules = []command.Rule{ Define: "cloudflare setting", Help: `cloudflare setting`, Handler: func(ctx types.Context, tokens []*parser.Token) types.MsgPayload { - return bots.SettingMsg(ctx, Name) + return chatbot.SettingMsg(ctx, Name) }, }, { Define: "cloudflare test", Help: "Test", Handler: func(ctx types.Context, tokens []*parser.Token) types.MsgPayload { - c1, _ := bots.SettingGet(ctx, Name, tokenSettingKey) + c1, _ := chatbot.SettingGet(ctx, Name, tokenSettingKey) tokenValue, _ := c1.StringValue() - c2, _ := bots.SettingGet(ctx, Name, zoneIdSettingKey) + c2, _ := chatbot.SettingGet(ctx, Name, zoneIdSettingKey) zoneIdValue, _ := c2.StringValue() if tokenValue == "" || zoneIdValue == "" { diff --git a/internal/bots/dev/bot.go b/internal/bots/dev/bot.go index 0694c200..ef7f6a56 100644 --- a/internal/bots/dev/bot.go +++ b/internal/bots/dev/bot.go @@ -5,7 +5,7 @@ import ( "errors" "github.com/bytedance/sonic" - "github.com/flowline-io/flowbot/internal/bots" + "github.com/flowline-io/flowbot/pkg/chatbot" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/types" "github.com/flowline-io/flowbot/pkg/types/ruleset/cron" @@ -19,12 +19,12 @@ var handler bot var config configType func Register() { - bots.Register(Name, &handler) + chatbot.Register(Name, &handler) } type bot struct { initialized bool - bots.Base + chatbot.Base } type configType struct { @@ -58,16 +58,16 @@ func (bot) IsReady() bool { func (bot) Bootstrap() error { // load setting rule - formRules = append(formRules, bots.SettingCovertForm(Name, settingRules)) + formRules = append(formRules, chatbot.SettingCovertForm(Name, settingRules)) return nil } func (bot) Webservice(app *fiber.App) { - bots.Webservice(app, Name, webserviceRules) + chatbot.Webservice(app, Name, webserviceRules) } -func (b bot) Rules() []interface{} { +func (bot) Rules() []interface{} { return []interface{}{ commandRules, formRules, @@ -82,46 +82,46 @@ func (b bot) Rules() []interface{} { } } -func (b bot) Input(_ types.Context, _ types.KV, _ interface{}) (types.MsgPayload, error) { +func (bot) Input(_ types.Context, _ types.KV, _ interface{}) (types.MsgPayload, error) { return types.TextMsg{Text: "Input"}, nil } -func (b bot) Command(ctx types.Context, content interface{}) (types.MsgPayload, error) { - return bots.RunCommand(commandRules, ctx, content) +func (bot) Command(ctx types.Context, content interface{}) (types.MsgPayload, error) { + return chatbot.RunCommand(commandRules, ctx, content) } -func (b bot) Form(ctx types.Context, values types.KV) (types.MsgPayload, error) { - return bots.RunForm(formRules, ctx, values) +func (bot) Form(ctx types.Context, values types.KV) (types.MsgPayload, error) { + return chatbot.RunForm(formRules, ctx, values) } -func (b bot) Cron() (*cron.Ruleset, error) { - return bots.RunCron(cronRules, Name) +func (bot) Cron() (*cron.Ruleset, error) { + return chatbot.RunCron(cronRules, Name) } -func (b bot) Collect(ctx types.Context, content types.KV) (types.MsgPayload, error) { - return bots.RunCollect(collectRules, ctx, content) +func (bot) Collect(ctx types.Context, content types.KV) (types.MsgPayload, error) { + return chatbot.RunCollect(collectRules, ctx, content) } -func (b bot) Instruct() (instruct.Ruleset, error) { +func (bot) Instruct() (instruct.Ruleset, error) { return instructRules, nil } -func (b bot) Page(ctx types.Context, flag string, args types.KV) (string, error) { - return bots.RunPage(pageRules, ctx, flag, args) +func (bot) Page(ctx types.Context, flag string, args types.KV) (string, error) { + return chatbot.RunPage(pageRules, ctx, flag, args) } -func (b bot) Workflow(ctx types.Context, input types.KV) (types.KV, error) { - return bots.RunWorkflow(workflowRules, ctx, input) +func (bot) Workflow(ctx types.Context, input types.KV) (types.KV, error) { + return chatbot.RunWorkflow(workflowRules, ctx, input) } -func (b bot) Webhook(ctx types.Context, data []byte) (types.MsgPayload, error) { - return bots.RunWebhook(webhookRules, ctx, data) +func (bot) Webhook(ctx types.Context, data []byte) (types.MsgPayload, error) { + return chatbot.RunWebhook(webhookRules, ctx, data) } -func (b bot) Tool(ctx types.Context, argumentsInJSON string) (string, error) { - return bots.RunTool(toolRules, ctx, argumentsInJSON) +func (bot) Tool(ctx types.Context, argumentsInJSON string) (string, error) { + return chatbot.RunTool(toolRules, ctx, argumentsInJSON) } -func (b bot) Event(ctx types.Context, param types.KV) error { - return bots.RunEvent(eventRules, ctx, param) +func (bot) Event(ctx types.Context, param types.KV) error { + return chatbot.RunEvent(eventRules, ctx, param) } diff --git a/internal/bots/dev/command.go b/internal/bots/dev/command.go index 9878af7f..71f7b350 100644 --- a/internal/bots/dev/command.go +++ b/internal/bots/dev/command.go @@ -7,8 +7,8 @@ import ( "time" "github.com/flowline-io/flowbot/internal/agents" - "github.com/flowline-io/flowbot/internal/bots" "github.com/flowline-io/flowbot/internal/store" + "github.com/flowline-io/flowbot/pkg/chatbot" "github.com/flowline-io/flowbot/pkg/event" "github.com/flowline-io/flowbot/pkg/executer" "github.com/flowline-io/flowbot/pkg/executer/runtime" @@ -30,7 +30,7 @@ var commandRules = []command.Rule{ Define: "dev setting", Help: `[example] setting`, Handler: func(ctx types.Context, tokens []*parser.Token) types.MsgPayload { - return bots.SettingMsg(ctx, Name) + return chatbot.SettingMsg(ctx, Name) }, }, { @@ -44,7 +44,7 @@ var commandRules = []command.Rule{ Define: "form test", Help: `[example] form`, Handler: func(ctx types.Context, tokens []*parser.Token) types.MsgPayload { - return bots.FormMsg(ctx, devFormID) + return chatbot.FormMsg(ctx, devFormID) }, }, { @@ -65,14 +65,14 @@ var commandRules = []command.Rule{ Handler: func(ctx types.Context, tokens []*parser.Token) types.MsgPayload { data := types.KV{} data["txt"] = "example" - return bots.InstructMsg(ctx, ExampleInstructID, data) + return chatbot.InstructMsg(ctx, ExampleInstructID, data) }, }, { Define: "page test", Help: `[example] dev page`, Handler: func(ctx types.Context, tokens []*parser.Token) types.MsgPayload { - url, err := bots.PageURL(ctx, devPageId, nil, 24*time.Hour) + url, err := chatbot.PageURL(ctx, devPageId, nil, 24*time.Hour) if err != nil { return types.TextMsg{Text: "error"} } @@ -124,7 +124,7 @@ var commandRules = []command.Rule{ Define: "slash test", Help: `[example] Slash example`, Handler: func(ctx types.Context, tokens []*parser.Token) types.MsgPayload { - url, err := bots.Shortcut("test", "https://example.com") + url, err := chatbot.Shortcut("test", "https://example.com") if err != nil { return types.TextMsg{Text: "error"} } diff --git a/internal/bots/dev/webhook.go b/internal/bots/dev/webhook.go index 6cb2a440..2a74dbbb 100644 --- a/internal/bots/dev/webhook.go +++ b/internal/bots/dev/webhook.go @@ -6,7 +6,7 @@ import ( "time" "github.com/flowline-io/flowbot/internal/agents" - "github.com/flowline-io/flowbot/internal/bots" + "github.com/flowline-io/flowbot/pkg/chatbot" "github.com/flowline-io/flowbot/pkg/event" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/types" @@ -57,7 +57,7 @@ var webhookRules = []webhook.Rule{ // run agent go func() { - tools, err := bots.AvailableTools(ctx) + tools, err := chatbot.AvailableTools(ctx) if err != nil { flog.Error(err) return diff --git a/internal/bots/finance/bot.go b/internal/bots/finance/bot.go index ab2a2464..23fea589 100644 --- a/internal/bots/finance/bot.go +++ b/internal/bots/finance/bot.go @@ -7,7 +7,7 @@ import ( "github.com/flowline-io/flowbot/pkg/types/ruleset/cron" "github.com/bytedance/sonic" - "github.com/flowline-io/flowbot/internal/bots" + "github.com/flowline-io/flowbot/pkg/chatbot" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/types" ) @@ -17,12 +17,12 @@ const Name = "finance" var handler bot func Register() { - bots.Register(Name, &handler) + chatbot.Register(Name, &handler) } type bot struct { initialized bool - bots.Base + chatbot.Base } type configType struct { @@ -54,7 +54,7 @@ func (bot) IsReady() bool { return handler.initialized } -func (b bot) Rules() []interface{} { +func (bot) Rules() []interface{} { return []interface{}{ commandRules, cronRules, @@ -63,17 +63,17 @@ func (b bot) Rules() []interface{} { } } -func (b bot) Command(ctx types.Context, content interface{}) (types.MsgPayload, error) { - return bots.RunCommand(commandRules, ctx, content) +func (bot) Command(ctx types.Context, content interface{}) (types.MsgPayload, error) { + return chatbot.RunCommand(commandRules, ctx, content) } -func (b bot) Cron() (*cron.Ruleset, error) { - return bots.RunCron(cronRules, Name) +func (bot) Cron() (*cron.Ruleset, error) { + return chatbot.RunCron(cronRules, Name) } -func (b bot) Webhook(ctx types.Context, data []byte) (types.MsgPayload, error) { - return bots.RunWebhook(webhookRules, ctx, data) +func (bot) Webhook(ctx types.Context, data []byte) (types.MsgPayload, error) { + return chatbot.RunWebhook(webhookRules, ctx, data) } -func (b bot) Form(ctx types.Context, values types.KV) (types.MsgPayload, error) { - return bots.RunForm(formRules, ctx, values) +func (bot) Form(ctx types.Context, values types.KV) (types.MsgPayload, error) { + return chatbot.RunForm(formRules, ctx, values) } diff --git a/internal/bots/finance/command.go b/internal/bots/finance/command.go index 7bc59007..99825379 100644 --- a/internal/bots/finance/command.go +++ b/internal/bots/finance/command.go @@ -1,7 +1,7 @@ package finance import ( - "github.com/flowline-io/flowbot/internal/bots" + "github.com/flowline-io/flowbot/pkg/chatbot" "github.com/flowline-io/flowbot/pkg/parser" "github.com/flowline-io/flowbot/pkg/providers/wallos" "github.com/flowline-io/flowbot/pkg/types" @@ -29,7 +29,7 @@ var commandRules = []command.Rule{ Define: "bill", Help: `Import bill`, Handler: func(ctx types.Context, tokens []*parser.Token) types.MsgPayload { - return bots.FormMsg(ctx, importBillFormID) + return chatbot.FormMsg(ctx, importBillFormID) }, }, } diff --git a/internal/bots/gitea/bot.go b/internal/bots/gitea/bot.go index ff9e3d53..7433b8cd 100644 --- a/internal/bots/gitea/bot.go +++ b/internal/bots/gitea/bot.go @@ -5,7 +5,7 @@ import ( "errors" "github.com/bytedance/sonic" - "github.com/flowline-io/flowbot/internal/bots" + "github.com/flowline-io/flowbot/pkg/chatbot" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/types" "github.com/flowline-io/flowbot/pkg/types/ruleset/cron" @@ -16,12 +16,12 @@ const Name = "gitea" var handler bot func Register() { - bots.Register(Name, &handler) + chatbot.Register(Name, &handler) } type bot struct { initialized bool - bots.Base + chatbot.Base } type configType struct { @@ -57,21 +57,21 @@ func (bot) Bootstrap() error { return nil } -func (b bot) Rules() []interface{} { +func (bot) Rules() []interface{} { return []interface{}{ commandRules, webhookRules, } } -func (b bot) Command(ctx types.Context, content interface{}) (types.MsgPayload, error) { - return bots.RunCommand(commandRules, ctx, content) +func (bot) Command(ctx types.Context, content interface{}) (types.MsgPayload, error) { + return chatbot.RunCommand(commandRules, ctx, content) } -func (b bot) Cron() (*cron.Ruleset, error) { - return bots.RunCron(cronRules, Name) +func (bot) Cron() (*cron.Ruleset, error) { + return chatbot.RunCron(cronRules, Name) } -func (b bot) Webhook(ctx types.Context, data []byte) (types.MsgPayload, error) { - return bots.RunWebhook(webhookRules, ctx, data) +func (bot) Webhook(ctx types.Context, data []byte) (types.MsgPayload, error) { + return chatbot.RunWebhook(webhookRules, ctx, data) } diff --git a/internal/bots/github/bot.go b/internal/bots/github/bot.go index 341adf8f..20deab5e 100644 --- a/internal/bots/github/bot.go +++ b/internal/bots/github/bot.go @@ -5,7 +5,7 @@ import ( "errors" "github.com/bytedance/sonic" - "github.com/flowline-io/flowbot/internal/bots" + "github.com/flowline-io/flowbot/pkg/chatbot" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/types" "github.com/flowline-io/flowbot/pkg/types/ruleset/cron" @@ -17,12 +17,12 @@ var handler bot var Config configType func Register() { - bots.Register(Name, &handler) + chatbot.Register(Name, &handler) } type bot struct { initialized bool - bots.Base + chatbot.Base } type configType struct { @@ -55,12 +55,12 @@ func (bot) IsReady() bool { func (bot) Bootstrap() error { // load setting rule - formRules = append(formRules, bots.SettingCovertForm(Name, settingRules)) + formRules = append(formRules, chatbot.SettingCovertForm(Name, settingRules)) return nil } -func (b bot) Rules() []interface{} { +func (bot) Rules() []interface{} { return []interface{}{ commandRules, formRules, @@ -68,18 +68,18 @@ func (b bot) Rules() []interface{} { } } -func (b bot) Command(ctx types.Context, content interface{}) (types.MsgPayload, error) { - return bots.RunCommand(commandRules, ctx, content) +func (bot) Command(ctx types.Context, content interface{}) (types.MsgPayload, error) { + return chatbot.RunCommand(commandRules, ctx, content) } -func (b bot) Cron() (*cron.Ruleset, error) { - return bots.RunCron(cronRules, Name) +func (bot) Cron() (*cron.Ruleset, error) { + return chatbot.RunCron(cronRules, Name) } -func (b bot) Form(ctx types.Context, values types.KV) (types.MsgPayload, error) { - return bots.RunForm(formRules, ctx, values) +func (bot) Form(ctx types.Context, values types.KV) (types.MsgPayload, error) { + return chatbot.RunForm(formRules, ctx, values) } -func (b bot) Webhook(ctx types.Context, data []byte) (types.MsgPayload, error) { - return bots.RunWebhook(webhookRules, ctx, data) +func (bot) Webhook(ctx types.Context, data []byte) (types.MsgPayload, error) { + return chatbot.RunWebhook(webhookRules, ctx, data) } diff --git a/internal/bots/github/command.go b/internal/bots/github/command.go index 721608a7..8d59a780 100644 --- a/internal/bots/github/command.go +++ b/internal/bots/github/command.go @@ -6,8 +6,8 @@ import ( "strings" "time" - "github.com/flowline-io/flowbot/internal/bots" "github.com/flowline-io/flowbot/internal/store" + "github.com/flowline-io/flowbot/pkg/chatbot" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/parser" "github.com/flowline-io/flowbot/pkg/providers" @@ -22,7 +22,7 @@ var commandRules = []command.Rule{ Define: "github setting", Help: `Bot setting`, Handler: func(ctx types.Context, tokens []*parser.Token) types.MsgPayload { - return bots.SettingMsg(ctx, Name) + return chatbot.SettingMsg(ctx, Name) }, }, { @@ -38,7 +38,7 @@ var commandRules = []command.Rule{ return types.TextMsg{Text: "App is authorized"} } - flag, err := bots.StoreParameter(types.KV{ + flag, err := chatbot.StoreParameter(types.KV{ "uid": ctx.AsUser.String(), "topic": ctx.Topic, }, time.Now().Add(time.Hour)) @@ -112,7 +112,7 @@ var commandRules = []command.Rule{ } // repo value - j, err := bots.SettingGet(ctx, Name, repoSettingKey) + j, err := chatbot.SettingGet(ctx, Name, repoSettingKey) if err != nil { return nil } diff --git a/internal/bots/kanban/bot.go b/internal/bots/kanban/bot.go index bae12816..4a3e1471 100755 --- a/internal/bots/kanban/bot.go +++ b/internal/bots/kanban/bot.go @@ -5,7 +5,7 @@ import ( "errors" "github.com/bytedance/sonic" - "github.com/flowline-io/flowbot/internal/bots" + "github.com/flowline-io/flowbot/pkg/chatbot" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/types" "github.com/flowline-io/flowbot/pkg/types/ruleset/cron" @@ -16,12 +16,12 @@ const Name = "kanban" var handler bot func Register() { - bots.Register(Name, &handler) + chatbot.Register(Name, &handler) } type bot struct { initialized bool - bots.Base + chatbot.Base } type configType struct { @@ -57,7 +57,7 @@ func (bot) Bootstrap() error { return nil } -func (b bot) Rules() []interface{} { +func (bot) Rules() []interface{} { return []interface{}{ commandRules, cronRules, @@ -66,18 +66,18 @@ func (b bot) Rules() []interface{} { } } -func (b bot) Command(ctx types.Context, content interface{}) (types.MsgPayload, error) { - return bots.RunCommand(commandRules, ctx, content) +func (bot) Command(ctx types.Context, content interface{}) (types.MsgPayload, error) { + return chatbot.RunCommand(commandRules, ctx, content) } -func (b bot) Cron() (*cron.Ruleset, error) { - return bots.RunCron(cronRules, Name) +func (bot) Cron() (*cron.Ruleset, error) { + return chatbot.RunCron(cronRules, Name) } -func (b bot) Webhook(ctx types.Context, data []byte) (types.MsgPayload, error) { - return bots.RunWebhook(webhookRules, ctx, data) +func (bot) Webhook(ctx types.Context, data []byte) (types.MsgPayload, error) { + return chatbot.RunWebhook(webhookRules, ctx, data) } -func (b bot) Event(ctx types.Context, param types.KV) error { - return bots.RunEvent(eventRules, ctx, param) +func (bot) Event(ctx types.Context, param types.KV) error { + return chatbot.RunEvent(eventRules, ctx, param) } diff --git a/internal/bots/modules.go b/internal/bots/modules.go new file mode 100644 index 00000000..632d82dc --- /dev/null +++ b/internal/bots/modules.go @@ -0,0 +1,50 @@ +package bots + +import ( + "github.com/flowline-io/flowbot/internal/bots/agent" + "github.com/flowline-io/flowbot/internal/bots/anki" + "github.com/flowline-io/flowbot/internal/bots/bookmark" + "github.com/flowline-io/flowbot/internal/bots/clipboard" + "github.com/flowline-io/flowbot/internal/bots/cloudflare" + "github.com/flowline-io/flowbot/internal/bots/dev" + "github.com/flowline-io/flowbot/internal/bots/finance" + "github.com/flowline-io/flowbot/internal/bots/gitea" + "github.com/flowline-io/flowbot/internal/bots/github" + "github.com/flowline-io/flowbot/internal/bots/kanban" + "github.com/flowline-io/flowbot/internal/bots/notify" + "github.com/flowline-io/flowbot/internal/bots/obsidian" + "github.com/flowline-io/flowbot/internal/bots/okr" + "github.com/flowline-io/flowbot/internal/bots/reader" + "github.com/flowline-io/flowbot/internal/bots/search" + "github.com/flowline-io/flowbot/internal/bots/server" + "github.com/flowline-io/flowbot/internal/bots/torrent" + "github.com/flowline-io/flowbot/internal/bots/user" + "github.com/flowline-io/flowbot/internal/bots/webhook" + "github.com/flowline-io/flowbot/internal/bots/workflow" + "go.uber.org/fx" +) + +var Modules = fx.Options( + fx.Invoke( + agent.Register, + anki.Register, + bookmark.Register, + clipboard.Register, + cloudflare.Register, + dev.Register, + finance.Register, + gitea.Register, + github.Register, + kanban.Register, + notify.Register, + obsidian.Register, + okr.Register, + reader.Register, + search.Register, + server.Register, + torrent.Register, + user.Register, + webhook.Register, + workflow.Register, + ), +) diff --git a/internal/bots/notify/bot.go b/internal/bots/notify/bot.go index 298057a5..cd8b638a 100644 --- a/internal/bots/notify/bot.go +++ b/internal/bots/notify/bot.go @@ -5,7 +5,7 @@ import ( "errors" "github.com/bytedance/sonic" - "github.com/flowline-io/flowbot/internal/bots" + "github.com/flowline-io/flowbot/pkg/chatbot" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/types" "github.com/flowline-io/flowbot/pkg/types/ruleset/cron" @@ -16,12 +16,12 @@ const Name = "notify" var handler bot func Register() { - bots.Register(Name, &handler) + chatbot.Register(Name, &handler) } type bot struct { initialized bool - bots.Base + chatbot.Base } type configType struct { @@ -57,7 +57,7 @@ func (bot) Bootstrap() error { return nil } -func (b bot) Rules() []interface{} { +func (bot) Rules() []interface{} { return []interface{}{ commandRules, formRules, @@ -66,18 +66,18 @@ func (b bot) Rules() []interface{} { } } -func (b bot) Command(ctx types.Context, content interface{}) (types.MsgPayload, error) { - return bots.RunCommand(commandRules, ctx, content) +func (bot) Command(ctx types.Context, content interface{}) (types.MsgPayload, error) { + return chatbot.RunCommand(commandRules, ctx, content) } -func (b bot) Cron() (*cron.Ruleset, error) { - return bots.RunCron(cronRules, Name) +func (bot) Cron() (*cron.Ruleset, error) { + return chatbot.RunCron(cronRules, Name) } -func (b bot) Form(ctx types.Context, values types.KV) (types.MsgPayload, error) { - return bots.RunForm(formRules, ctx, values) +func (bot) Form(ctx types.Context, values types.KV) (types.MsgPayload, error) { + return chatbot.RunForm(formRules, ctx, values) } -func (b bot) Workflow(ctx types.Context, input types.KV) (types.KV, error) { - return bots.RunWorkflow(workflowRules, ctx, input) +func (bot) Workflow(ctx types.Context, input types.KV) (types.KV, error) { + return chatbot.RunWorkflow(workflowRules, ctx, input) } diff --git a/internal/bots/notify/command.go b/internal/bots/notify/command.go index 9e5e6e56..661c7b66 100644 --- a/internal/bots/notify/command.go +++ b/internal/bots/notify/command.go @@ -2,8 +2,8 @@ package notify import ( "fmt" - "github.com/flowline-io/flowbot/internal/bots" "github.com/flowline-io/flowbot/internal/store" + "github.com/flowline-io/flowbot/pkg/chatbot" "github.com/flowline-io/flowbot/pkg/parser" "github.com/flowline-io/flowbot/pkg/types" "github.com/flowline-io/flowbot/pkg/types/ruleset/command" @@ -43,7 +43,7 @@ var commandRules = []command.Rule{ Define: "notify config", Help: `Create notify`, Handler: func(ctx types.Context, tokens []*parser.Token) types.MsgPayload { - return bots.FormMsg(ctx, createNotifyFormID) + return chatbot.FormMsg(ctx, createNotifyFormID) }, }, } diff --git a/internal/bots/obsidian/bot.go b/internal/bots/obsidian/bot.go index bbe1ee5d..9ffc7518 100644 --- a/internal/bots/obsidian/bot.go +++ b/internal/bots/obsidian/bot.go @@ -5,7 +5,7 @@ import ( "errors" "github.com/bytedance/sonic" - "github.com/flowline-io/flowbot/internal/bots" + "github.com/flowline-io/flowbot/pkg/chatbot" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/types" ) @@ -15,12 +15,12 @@ const Name = "obsidian" var handler bot func Register() { - bots.Register(Name, &handler) + chatbot.Register(Name, &handler) } type bot struct { initialized bool - bots.Base + chatbot.Base } type configType struct { @@ -52,10 +52,10 @@ func (bot) IsReady() bool { return handler.initialized } -func (b bot) Command(ctx types.Context, content interface{}) (types.MsgPayload, error) { - return bots.RunCommand(commandRules, ctx, content) +func (bot) Command(ctx types.Context, content interface{}) (types.MsgPayload, error) { + return chatbot.RunCommand(commandRules, ctx, content) } -func (b bot) Collect(ctx types.Context, content types.KV) (types.MsgPayload, error) { - return bots.RunCollect(collectRules, ctx, content) +func (bot) Collect(ctx types.Context, content types.KV) (types.MsgPayload, error) { + return chatbot.RunCollect(collectRules, ctx, content) } diff --git a/internal/bots/okr/bot.go b/internal/bots/okr/bot.go index dc688abc..1bae2a38 100644 --- a/internal/bots/okr/bot.go +++ b/internal/bots/okr/bot.go @@ -5,7 +5,7 @@ import ( "errors" "github.com/bytedance/sonic" - "github.com/flowline-io/flowbot/internal/bots" + "github.com/flowline-io/flowbot/pkg/chatbot" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/types" "github.com/gofiber/fiber/v2" @@ -16,12 +16,12 @@ const Name = "okr" var handler bot func Register() { - bots.Register(Name, &handler) + chatbot.Register(Name, &handler) } type bot struct { initialized bool - bots.Base + chatbot.Base } type configType struct { @@ -53,7 +53,7 @@ func (bot) IsReady() bool { return handler.initialized } -func (b bot) Rules() []interface{} { +func (bot) Rules() []interface{} { return []interface{}{ commandRules, formRules, @@ -62,17 +62,17 @@ func (b bot) Rules() []interface{} { } func (bot) Webservice(app *fiber.App) { - bots.Webservice(app, Name, webserviceRules) + chatbot.Webservice(app, Name, webserviceRules) } -func (b bot) Command(ctx types.Context, content interface{}) (types.MsgPayload, error) { - return bots.RunCommand(commandRules, ctx, content) +func (bot) Command(ctx types.Context, content interface{}) (types.MsgPayload, error) { + return chatbot.RunCommand(commandRules, ctx, content) } -func (b bot) Form(ctx types.Context, values types.KV) (types.MsgPayload, error) { - return bots.RunForm(formRules, ctx, values) +func (bot) Form(ctx types.Context, values types.KV) (types.MsgPayload, error) { + return chatbot.RunForm(formRules, ctx, values) } -func (b bot) Page(ctx types.Context, flag string, args types.KV) (string, error) { - return bots.RunPage(pageRules, ctx, flag, args) +func (bot) Page(ctx types.Context, flag string, args types.KV) (string, error) { + return chatbot.RunPage(pageRules, ctx, flag, args) } diff --git a/internal/bots/okr/command.go b/internal/bots/okr/command.go index 7f44c13c..97a1e2d6 100644 --- a/internal/bots/okr/command.go +++ b/internal/bots/okr/command.go @@ -6,9 +6,9 @@ import ( "strconv" "time" - "github.com/flowline-io/flowbot/internal/bots" "github.com/flowline-io/flowbot/internal/store" "github.com/flowline-io/flowbot/internal/store/model" + "github.com/flowline-io/flowbot/pkg/chatbot" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/parser" "github.com/flowline-io/flowbot/pkg/types" @@ -39,7 +39,7 @@ var commandRules = []command.Rule{ return types.TextMsg{Text: "Empty"} } - return bots.StorePage(ctx, model.PageTable, "Objectives", types.TableMsg{Title: "Objectives", Header: header, Row: row}) + return chatbot.StorePage(ctx, model.PageTable, "Objectives", types.TableMsg{Title: "Objectives", Header: header, Row: row}) }, }, { @@ -50,7 +50,7 @@ var commandRules = []command.Rule{ sequence, _ := tokens[1].Value.Int64() param["sequence"] = sequence - url, err := bots.PageURL(ctx, okrPageId, param, 24*time.Hour) + url, err := chatbot.PageURL(ctx, okrPageId, param, 24*time.Hour) if err != nil { return types.TextMsg{Text: "error"} } @@ -85,7 +85,7 @@ var commandRules = []command.Rule{ return nil } - return bots.StoreForm(ctx, types.FormMsg{ + return chatbot.StoreForm(ctx, types.FormMsg{ ID: UpdateObjectiveFormID, Title: fmt.Sprintf("Update Objective #%d", sequence), Field: []types.FormField{ @@ -132,7 +132,7 @@ var commandRules = []command.Rule{ Define: `obj create`, Help: `Create Objective`, Handler: func(ctx types.Context, tokens []*parser.Token) types.MsgPayload { - return bots.StoreForm(ctx, types.FormMsg{ + return chatbot.StoreForm(ctx, types.FormMsg{ ID: CreateObjectiveFormID, Title: "Create Objective", Field: []types.FormField{ @@ -202,7 +202,7 @@ var commandRules = []command.Rule{ } } - return bots.StorePage(ctx, model.PageTable, "KeyResults", types.TableMsg{ + return chatbot.StorePage(ctx, model.PageTable, "KeyResults", types.TableMsg{ Title: "KeyResults", Header: header, Row: row, @@ -213,7 +213,7 @@ var commandRules = []command.Rule{ Define: `kr create`, Help: `Create KeyResult`, Handler: func(ctx types.Context, tokens []*parser.Token) types.MsgPayload { - return bots.StoreForm(ctx, types.FormMsg{ + return chatbot.StoreForm(ctx, types.FormMsg{ ID: CreateKeyResultFormID, Title: "Create Key Result", Field: []types.FormField{ @@ -303,7 +303,7 @@ var commandRules = []command.Rule{ return nil } - return bots.StoreForm(ctx, types.FormMsg{ + return chatbot.StoreForm(ctx, types.FormMsg{ ID: UpdateKeyResultFormID, Title: fmt.Sprintf("Update KeyResult #%d", sequence), Field: []types.FormField{ @@ -351,7 +351,7 @@ var commandRules = []command.Rule{ Define: `kr value`, Help: `Create KeyResult value`, Handler: func(ctx types.Context, tokens []*parser.Token) types.MsgPayload { - return bots.StoreForm(ctx, types.FormMsg{ + return chatbot.StoreForm(ctx, types.FormMsg{ ID: CreateKeyResultValueFormID, Title: "Create Key Result value", Field: []types.FormField{ @@ -399,7 +399,7 @@ var commandRules = []command.Rule{ } title := fmt.Sprintf("KeyResult #%d Values", sequence) - return bots.StorePage(ctx, model.PageTable, title, types.TableMsg{ + return chatbot.StorePage(ctx, model.PageTable, title, types.TableMsg{ Title: title, Header: header, Row: row, @@ -426,7 +426,7 @@ var commandRules = []command.Rule{ Define: `todo create`, Help: "Create Todo something", Handler: func(ctx types.Context, tokens []*parser.Token) types.MsgPayload { - return bots.StoreForm(ctx, types.FormMsg{ + return chatbot.StoreForm(ctx, types.FormMsg{ ID: CreateTodoFormID, Title: "Create todo", Field: []types.FormField{ @@ -470,7 +470,7 @@ var commandRules = []command.Rule{ return nil } - return bots.StoreForm(ctx, types.FormMsg{ + return chatbot.StoreForm(ctx, types.FormMsg{ ID: UpdateTodoFormID, Title: fmt.Sprintf("Update Todo #%d", sequence), Field: []types.FormField{ @@ -545,7 +545,7 @@ var commandRules = []command.Rule{ } } - return bots.StorePage(ctx, model.PageTable, "Counters", types.TableMsg{ + return chatbot.StorePage(ctx, model.PageTable, "Counters", types.TableMsg{ Title: "Counters", Header: header, Row: row, diff --git a/internal/bots/reader/bot.go b/internal/bots/reader/bot.go index 905c9408..8c5d7fea 100644 --- a/internal/bots/reader/bot.go +++ b/internal/bots/reader/bot.go @@ -5,7 +5,7 @@ import ( "errors" "github.com/bytedance/sonic" - "github.com/flowline-io/flowbot/internal/bots" + "github.com/flowline-io/flowbot/pkg/chatbot" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/types" "github.com/flowline-io/flowbot/pkg/types/ruleset/cron" @@ -16,12 +16,12 @@ const Name = "reader" var handler bot func Register() { - bots.Register(Name, &handler) + chatbot.Register(Name, &handler) } type bot struct { initialized bool - bots.Base + chatbot.Base } type configType struct { @@ -57,7 +57,7 @@ func (bot) Bootstrap() error { return nil } -func (b bot) Rules() []interface{} { +func (bot) Rules() []interface{} { return []interface{}{ commandRules, cronRules, @@ -65,14 +65,14 @@ func (b bot) Rules() []interface{} { } } -func (b bot) Command(ctx types.Context, content interface{}) (types.MsgPayload, error) { - return bots.RunCommand(commandRules, ctx, content) +func (bot) Command(ctx types.Context, content interface{}) (types.MsgPayload, error) { + return chatbot.RunCommand(commandRules, ctx, content) } -func (b bot) Cron() (*cron.Ruleset, error) { - return bots.RunCron(cronRules, Name) +func (bot) Cron() (*cron.Ruleset, error) { + return chatbot.RunCron(cronRules, Name) } -func (b bot) Webhook(ctx types.Context, data []byte) (types.MsgPayload, error) { - return bots.RunWebhook(webhookRules, ctx, data) +func (bot) Webhook(ctx types.Context, data []byte) (types.MsgPayload, error) { + return chatbot.RunWebhook(webhookRules, ctx, data) } diff --git a/internal/bots/search/bot.go b/internal/bots/search/bot.go index 8d4a9e1f..cd09e1c8 100755 --- a/internal/bots/search/bot.go +++ b/internal/bots/search/bot.go @@ -5,7 +5,7 @@ import ( "errors" "github.com/bytedance/sonic" - "github.com/flowline-io/flowbot/internal/bots" + "github.com/flowline-io/flowbot/pkg/chatbot" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/types" "github.com/flowline-io/flowbot/pkg/types/ruleset/cron" @@ -17,12 +17,12 @@ const Name = "search" var handler bot func Register() { - bots.Register(Name, &handler) + chatbot.Register(Name, &handler) } type bot struct { initialized bool - bots.Base + chatbot.Base } type configType struct { @@ -58,7 +58,7 @@ func (bot) Bootstrap() error { return nil } -func (b bot) Rules() []interface{} { +func (bot) Rules() []interface{} { return []interface{}{ commandRules, cronRules, @@ -68,22 +68,22 @@ func (b bot) Rules() []interface{} { } } -func (b bot) Command(ctx types.Context, content interface{}) (types.MsgPayload, error) { - return bots.RunCommand(commandRules, ctx, content) +func (bot) Command(ctx types.Context, content interface{}) (types.MsgPayload, error) { + return chatbot.RunCommand(commandRules, ctx, content) } -func (b bot) Cron() (*cron.Ruleset, error) { - return bots.RunCron(cronRules, Name) +func (bot) Cron() (*cron.Ruleset, error) { + return chatbot.RunCron(cronRules, Name) } -func (b bot) Collect(ctx types.Context, content types.KV) (types.MsgPayload, error) { - return bots.RunCollect(collectRules, ctx, content) +func (bot) Collect(ctx types.Context, content types.KV) (types.MsgPayload, error) { + return chatbot.RunCollect(collectRules, ctx, content) } func (bot) Webservice(app *fiber.App) { - bots.Webservice(app, Name, webserviceRules) + chatbot.Webservice(app, Name, webserviceRules) } -func (b bot) Page(ctx types.Context, flag string, args types.KV) (string, error) { - return bots.RunPage(pageRules, ctx, flag, args) +func (bot) Page(ctx types.Context, flag string, args types.KV) (string, error) { + return chatbot.RunPage(pageRules, ctx, flag, args) } diff --git a/internal/bots/search/command.go b/internal/bots/search/command.go index 49680002..dde97d17 100755 --- a/internal/bots/search/command.go +++ b/internal/bots/search/command.go @@ -1,7 +1,7 @@ package search import ( - "github.com/flowline-io/flowbot/internal/bots" + "github.com/flowline-io/flowbot/pkg/chatbot" "github.com/flowline-io/flowbot/pkg/parser" "github.com/flowline-io/flowbot/pkg/types" "github.com/flowline-io/flowbot/pkg/types/ruleset/command" @@ -13,7 +13,7 @@ var commandRules = []command.Rule{ Define: "search", Help: `Search page`, Handler: func(ctx types.Context, tokens []*parser.Token) types.MsgPayload { - url, err := bots.PageURL(ctx, searchPageId, nil, 24*time.Hour) + url, err := chatbot.PageURL(ctx, searchPageId, nil, 24*time.Hour) if err != nil { return types.TextMsg{Text: "error"} } diff --git a/internal/bots/server/bot.go b/internal/bots/server/bot.go index 0ab0e350..ce36eeab 100644 --- a/internal/bots/server/bot.go +++ b/internal/bots/server/bot.go @@ -7,7 +7,7 @@ import ( "github.com/gofiber/fiber/v2" "github.com/bytedance/sonic" - "github.com/flowline-io/flowbot/internal/bots" + "github.com/flowline-io/flowbot/pkg/chatbot" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/types" "github.com/flowline-io/flowbot/pkg/types/ruleset/cron" @@ -18,12 +18,12 @@ const Name = "server" var handler bot func Register() { - bots.Register(Name, &handler) + chatbot.Register(Name, &handler) } type bot struct { initialized bool - bots.Base + chatbot.Base } type configType struct { @@ -55,7 +55,7 @@ func (bot) IsReady() bool { return handler.initialized } -func (b bot) Rules() []interface{} { +func (bot) Rules() []interface{} { return []interface{}{ commandRules, collectRules, @@ -63,18 +63,18 @@ func (b bot) Rules() []interface{} { } } -func (b bot) Command(ctx types.Context, content interface{}) (types.MsgPayload, error) { - return bots.RunCommand(commandRules, ctx, content) +func (bot) Command(ctx types.Context, content interface{}) (types.MsgPayload, error) { + return chatbot.RunCommand(commandRules, ctx, content) } -func (b bot) Collect(ctx types.Context, content types.KV) (types.MsgPayload, error) { - return bots.RunCollect(collectRules, ctx, content) +func (bot) Collect(ctx types.Context, content types.KV) (types.MsgPayload, error) { + return chatbot.RunCollect(collectRules, ctx, content) } -func (b bot) Cron() (*cron.Ruleset, error) { - return bots.RunCron(cronRules, Name) +func (bot) Cron() (*cron.Ruleset, error) { + return chatbot.RunCron(cronRules, Name) } func (bot) Webservice(app *fiber.App) { - bots.Webservice(app, Name, webserviceRules) + chatbot.Webservice(app, Name, webserviceRules) } diff --git a/internal/bots/server/command.go b/internal/bots/server/command.go index bb1c78a8..1b4def6b 100644 --- a/internal/bots/server/command.go +++ b/internal/bots/server/command.go @@ -10,9 +10,9 @@ import ( "strings" "time" - "github.com/flowline-io/flowbot/internal/bots" "github.com/flowline-io/flowbot/internal/store" "github.com/flowline-io/flowbot/internal/workflow" + "github.com/flowline-io/flowbot/pkg/chatbot" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/notify" "github.com/flowline-io/flowbot/pkg/parser" @@ -108,7 +108,7 @@ var commandRules = []command.Rule{ Help: `all bot instruct`, Handler: func(ctx types.Context, tokens []*parser.Token) types.MsgPayload { models := make(types.KV) - for name, bot := range bots.List() { + for name, bot := range chatbot.List() { ruleset, _ := bot.Instruct() for _, rule := range ruleset { models[fmt.Sprintf("(%s) %s", name, rule.Id)] = fmt.Sprintf("[%s]", strings.Join(rule.Args, ",")) diff --git a/internal/bots/torrent/bot.go b/internal/bots/torrent/bot.go index bd374df7..2c5b8910 100644 --- a/internal/bots/torrent/bot.go +++ b/internal/bots/torrent/bot.go @@ -5,7 +5,7 @@ import ( "errors" "github.com/bytedance/sonic" - "github.com/flowline-io/flowbot/internal/bots" + "github.com/flowline-io/flowbot/pkg/chatbot" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/types" "github.com/flowline-io/flowbot/pkg/types/ruleset/cron" @@ -16,12 +16,12 @@ const Name = "torrent" var handler bot func Register() { - bots.Register(Name, &handler) + chatbot.Register(Name, &handler) } type bot struct { initialized bool - bots.Base + chatbot.Base } type configType struct { @@ -57,17 +57,17 @@ func (bot) Bootstrap() error { return nil } -func (b bot) Rules() []interface{} { +func (bot) Rules() []interface{} { return []interface{}{ commandRules, cronRules, } } -func (b bot) Command(ctx types.Context, content interface{}) (types.MsgPayload, error) { - return bots.RunCommand(commandRules, ctx, content) +func (bot) Command(ctx types.Context, content interface{}) (types.MsgPayload, error) { + return chatbot.RunCommand(commandRules, ctx, content) } -func (b bot) Cron() (*cron.Ruleset, error) { - return bots.RunCron(cronRules, Name) +func (bot) Cron() (*cron.Ruleset, error) { + return chatbot.RunCron(cronRules, Name) } diff --git a/internal/bots/user/bot.go b/internal/bots/user/bot.go index 9e2e0c20..972adc10 100644 --- a/internal/bots/user/bot.go +++ b/internal/bots/user/bot.go @@ -5,7 +5,7 @@ import ( "errors" "github.com/bytedance/sonic" - "github.com/flowline-io/flowbot/internal/bots" + "github.com/flowline-io/flowbot/pkg/chatbot" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/types" "github.com/gofiber/fiber/v2" @@ -16,12 +16,12 @@ const Name = "user" var handler bot func Register() { - bots.Register(Name, &handler) + chatbot.Register(Name, &handler) } type bot struct { initialized bool - bots.Base + chatbot.Base } type configType struct { @@ -54,16 +54,16 @@ func (bot) IsReady() bool { } func (bot) Webservice(app *fiber.App) { - bots.Webservice(app, Name, webserviceRules) + chatbot.Webservice(app, Name, webserviceRules) } -func (b bot) Rules() []interface{} { +func (bot) Rules() []interface{} { return []interface{}{ commandRules, webserviceRules, } } -func (b bot) Command(ctx types.Context, content interface{}) (types.MsgPayload, error) { - return bots.RunCommand(commandRules, ctx, content) +func (bot) Command(ctx types.Context, content interface{}) (types.MsgPayload, error) { + return chatbot.RunCommand(commandRules, ctx, content) } diff --git a/internal/bots/webhook/bot.go b/internal/bots/webhook/bot.go index ac951ebe..a5915516 100644 --- a/internal/bots/webhook/bot.go +++ b/internal/bots/webhook/bot.go @@ -5,7 +5,7 @@ import ( "errors" "github.com/bytedance/sonic" - "github.com/flowline-io/flowbot/internal/bots" + "github.com/flowline-io/flowbot/pkg/chatbot" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/types" ) @@ -15,12 +15,12 @@ const Name = "webhook" var handler bot func Register() { - bots.Register(Name, &handler) + chatbot.Register(Name, &handler) } type bot struct { initialized bool - bots.Base + chatbot.Base } type configType struct { @@ -52,12 +52,12 @@ func (bot) IsReady() bool { return handler.initialized } -func (b bot) Rules() []interface{} { +func (bot) Rules() []interface{} { return []interface{}{ commandRules, } } -func (b bot) Command(ctx types.Context, content interface{}) (types.MsgPayload, error) { - return bots.RunCommand(commandRules, ctx, content) +func (bot) Command(ctx types.Context, content interface{}) (types.MsgPayload, error) { + return chatbot.RunCommand(commandRules, ctx, content) } diff --git a/internal/bots/webhook/command.go b/internal/bots/webhook/command.go index ca242618..824446b0 100644 --- a/internal/bots/webhook/command.go +++ b/internal/bots/webhook/command.go @@ -4,9 +4,9 @@ import ( "errors" "fmt" - "github.com/flowline-io/flowbot/internal/bots" "github.com/flowline-io/flowbot/internal/store" "github.com/flowline-io/flowbot/internal/store/model" + "github.com/flowline-io/flowbot/pkg/chatbot" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/parser" "github.com/flowline-io/flowbot/pkg/types" @@ -45,8 +45,8 @@ var commandRules = []command.Rule{ flag, _ := tokens[2].Value.String() var webhookRule webhook.Rule - var botHandler bots.Handler - for _, handler := range bots.List() { + var botHandler chatbot.Handler + for _, handler := range chatbot.List() { for _, item := range handler.Rules() { switch v := item.(type) { case []webhook.Rule: diff --git a/internal/bots/workflow/bot.go b/internal/bots/workflow/bot.go index 6474a3a8..cafd2918 100644 --- a/internal/bots/workflow/bot.go +++ b/internal/bots/workflow/bot.go @@ -5,7 +5,7 @@ import ( "errors" "github.com/bytedance/sonic" - "github.com/flowline-io/flowbot/internal/bots" + "github.com/flowline-io/flowbot/pkg/chatbot" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/types" "github.com/flowline-io/flowbot/pkg/types/ruleset/cron" @@ -17,12 +17,12 @@ const Name = "workflow" var handler bot func Register() { - bots.Register(Name, &handler) + chatbot.Register(Name, &handler) } type bot struct { initialized bool - bots.Base + chatbot.Base } type configType struct { @@ -54,7 +54,7 @@ func (bot) IsReady() bool { return handler.initialized } -func (b bot) Rules() []interface{} { +func (bot) Rules() []interface{} { return []interface{}{ commandRules, formRules, @@ -64,22 +64,22 @@ func (b bot) Rules() []interface{} { } } -func (b bot) Command(ctx types.Context, content interface{}) (types.MsgPayload, error) { - return bots.RunCommand(commandRules, ctx, content) +func (bot) Command(ctx types.Context, content interface{}) (types.MsgPayload, error) { + return chatbot.RunCommand(commandRules, ctx, content) } func (bot) Webservice(app *fiber.App) { - bots.Webservice(app, Name, webserviceRules) + chatbot.Webservice(app, Name, webserviceRules) } -func (b bot) Form(ctx types.Context, values types.KV) (types.MsgPayload, error) { - return bots.RunForm(formRules, ctx, values) +func (bot) Form(ctx types.Context, values types.KV) (types.MsgPayload, error) { + return chatbot.RunForm(formRules, ctx, values) } -func (b bot) Cron() (*cron.Ruleset, error) { - return bots.RunCron(cronRules, Name) +func (bot) Cron() (*cron.Ruleset, error) { + return chatbot.RunCron(cronRules, Name) } -func (b bot) Workflow(ctx types.Context, input types.KV) (types.KV, error) { - return bots.RunWorkflow(workflowRules, ctx, input) +func (bot) Workflow(ctx types.Context, input types.KV) (types.KV, error) { + return chatbot.RunWorkflow(workflowRules, ctx, input) } diff --git a/internal/bots/workflow/command.go b/internal/bots/workflow/command.go index 91539df3..8de1289b 100755 --- a/internal/bots/workflow/command.go +++ b/internal/bots/workflow/command.go @@ -8,10 +8,10 @@ import ( "time" "github.com/dustin/go-humanize" - "github.com/flowline-io/flowbot/internal/bots" "github.com/flowline-io/flowbot/internal/store" "github.com/flowline-io/flowbot/internal/store/model" "github.com/flowline-io/flowbot/internal/workflow" + "github.com/flowline-io/flowbot/pkg/chatbot" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/parser" "github.com/flowline-io/flowbot/pkg/types" @@ -25,14 +25,14 @@ var commandRules = []command.Rule{ Define: "task run", Help: `Run one task`, Handler: func(ctx types.Context, tokens []*parser.Token) types.MsgPayload { - return bots.FormMsg(ctx, runOneTaskFormID) + return chatbot.FormMsg(ctx, runOneTaskFormID) }, }, { Define: "task create", Help: `Create one task`, Handler: func(ctx types.Context, tokens []*parser.Token) types.MsgPayload { - return bots.FormMsg(ctx, createOneTaskFormID) + return chatbot.FormMsg(ctx, createOneTaskFormID) }, }, { diff --git a/internal/bots/workflow/form.go b/internal/bots/workflow/form.go index 5867acc1..23b08670 100644 --- a/internal/bots/workflow/form.go +++ b/internal/bots/workflow/form.go @@ -5,9 +5,9 @@ import ( "strings" "github.com/bytedance/sonic" - "github.com/flowline-io/flowbot/internal/bots" "github.com/flowline-io/flowbot/internal/store" "github.com/flowline-io/flowbot/internal/store/model" + "github.com/flowline-io/flowbot/pkg/chatbot" "github.com/flowline-io/flowbot/pkg/types" "github.com/flowline-io/flowbot/pkg/types/ruleset/form" "github.com/flowline-io/flowbot/pkg/types/ruleset/workflow" @@ -69,8 +69,8 @@ var formRules = []form.Rule{ ruleId = action[0] botName = action[1] - var botHandler bots.Handler - for name, handler := range bots.List() { + var botHandler chatbot.Handler + for name, handler := range chatbot.List() { if botName != name { continue } diff --git a/internal/bots/workflow/webservice.go b/internal/bots/workflow/webservice.go index d5c6f724..8775c955 100644 --- a/internal/bots/workflow/webservice.go +++ b/internal/bots/workflow/webservice.go @@ -1,9 +1,9 @@ package workflow import ( - "github.com/flowline-io/flowbot/internal/bots" "github.com/flowline-io/flowbot/internal/store" "github.com/flowline-io/flowbot/internal/store/model" + "github.com/flowline-io/flowbot/pkg/chatbot" "github.com/flowline-io/flowbot/pkg/route" "github.com/flowline-io/flowbot/pkg/types" "github.com/flowline-io/flowbot/pkg/types/protocol" @@ -40,8 +40,8 @@ var webserviceRules = []webservice.Rule{ // @Security ApiKeyAuth // @Router /workflow/actions [get] func actions(ctx *fiber.Ctx) error { - result := make(map[string][]rule, len(bots.List())) - for name, botHandler := range bots.List() { + result := make(map[string][]rule, len(chatbot.List())) + for name, botHandler := range chatbot.List() { var list []rule for _, item := range botHandler.Rules() { switch v := item.(type) { diff --git a/internal/server/chatbot.go b/internal/server/chatbot.go index 2bd4e820..961af11c 100644 --- a/internal/server/chatbot.go +++ b/internal/server/chatbot.go @@ -3,31 +3,10 @@ package server import ( "context" "fmt" - "github.com/bytedance/sonic" - "github.com/flowline-io/flowbot/internal/bots" - "github.com/flowline-io/flowbot/internal/bots/agent" - "github.com/flowline-io/flowbot/internal/bots/anki" - "github.com/flowline-io/flowbot/internal/bots/bookmark" - "github.com/flowline-io/flowbot/internal/bots/clipboard" - "github.com/flowline-io/flowbot/internal/bots/cloudflare" - "github.com/flowline-io/flowbot/internal/bots/dev" - "github.com/flowline-io/flowbot/internal/bots/finance" - "github.com/flowline-io/flowbot/internal/bots/gitea" - "github.com/flowline-io/flowbot/internal/bots/github" - "github.com/flowline-io/flowbot/internal/bots/kanban" - "github.com/flowline-io/flowbot/internal/bots/notify" - "github.com/flowline-io/flowbot/internal/bots/obsidian" - "github.com/flowline-io/flowbot/internal/bots/okr" - "github.com/flowline-io/flowbot/internal/bots/reader" - "github.com/flowline-io/flowbot/internal/bots/search" - "github.com/flowline-io/flowbot/internal/bots/server" - "github.com/flowline-io/flowbot/internal/bots/torrent" - "github.com/flowline-io/flowbot/internal/bots/user" - "github.com/flowline-io/flowbot/internal/bots/webhook" - "github.com/flowline-io/flowbot/internal/bots/workflow" "github.com/flowline-io/flowbot/internal/store" "github.com/flowline-io/flowbot/internal/store/model" + "github.com/flowline-io/flowbot/pkg/chatbot" "github.com/flowline-io/flowbot/pkg/config" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/providers" @@ -39,31 +18,6 @@ import ( "go.uber.org/fx" ) -var BotsModules = fx.Options( - fx.Invoke( - agent.Register, - anki.Register, - bookmark.Register, - clipboard.Register, - cloudflare.Register, - dev.Register, - finance.Register, - gitea.Register, - github.Register, - kanban.Register, - notify.Register, - obsidian.Register, - okr.Register, - reader.Register, - search.Register, - server.Register, - torrent.Register, - user.Register, - webhook.Register, - workflow.Register, - ), -) - func handleChatbot(lc fx.Lifecycle, _ config.Type, _ store.Adapter, _ *redis.Client) error { // Initialize bots initializeBot(config.App.Bots, config.App.Vendors) @@ -98,7 +52,7 @@ func initializeBot(botsConfig interface{}, vendorsConfig interface{}) { providers.Configs = v // init bots - err = bots.Init(b) + err = chatbot.Init(b) if err != nil { flog.Fatal("Failed to initialize bot: %v", err) } @@ -107,26 +61,26 @@ func initializeBot(botsConfig interface{}, vendorsConfig interface{}) { registerBot() // bootstrap bots - err = bots.Bootstrap() + err = chatbot.Bootstrap() if err != nil { flog.Fatal("Failed to bootstrap bot: %v", err) } // bot cron - globals.cronRuleset, err = bots.Cron() + globals.cronRuleset, err = chatbot.Cron() if err != nil { flog.Fatal("Failed to bot cron: %v", err) } - stats.BotTotalCounter().Set(uint64(len(bots.List()))) - rdb.SetInt64(stats.BotTotalStatsName, int64(len(bots.List()))) + stats.BotTotalCounter().Set(uint64(len(chatbot.List()))) + rdb.SetInt64(stats.BotTotalStatsName, int64(len(chatbot.List()))) } // register bots func registerBot() { // register bots registerBots := sets.NewString() - for name, handler := range bots.List() { + for name, handler := range chatbot.List() { registerBots.Insert(name) state := model.BotInactive diff --git a/internal/server/event.go b/internal/server/event.go index 5c573f26..903ccb7d 100644 --- a/internal/server/event.go +++ b/internal/server/event.go @@ -3,12 +3,12 @@ package server import ( "context" "fmt" + "github.com/flowline-io/flowbot/pkg/chatbot" "strings" "time" "github.com/ThreeDotsLabs/watermill/message" "github.com/bytedance/sonic" - "github.com/flowline-io/flowbot/internal/bots" "github.com/flowline-io/flowbot/internal/platforms" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/types" @@ -128,7 +128,7 @@ func onBotRunEventHandler(msg *message.Message) error { } ctx.SetTimeout(10 * time.Minute) - for name, handle := range bots.List() { + for name, handle := range chatbot.List() { err = handle.Event(ctx, be.Param) if err != nil { return fmt.Errorf("bot %s event %s error %w", name, be.EventName, err) diff --git a/internal/server/func.go b/internal/server/func.go index b7a64e6c..2e835b12 100644 --- a/internal/server/func.go +++ b/internal/server/func.go @@ -4,12 +4,12 @@ import ( "context" "errors" "fmt" + "github.com/flowline-io/flowbot/pkg/chatbot" "strings" "time" "github.com/cloudwego/eino/schema" "github.com/flowline-io/flowbot/internal/agents" - "github.com/flowline-io/flowbot/internal/bots" "github.com/flowline-io/flowbot/internal/platforms" "github.com/flowline-io/flowbot/internal/store" "github.com/flowline-io/flowbot/internal/store/model" @@ -121,7 +121,7 @@ func directIncomingMessage(caller *platforms.Caller, e protocol.Event) { } // behavior - bots.Behavior(uid, bots.MessageBotIncomingBehavior, 1) + chatbot.Behavior(uid, chatbot.MessageBotIncomingBehavior, 1) // user auth record todo @@ -180,7 +180,7 @@ func directIncomingMessage(caller *platforms.Caller, e protocol.Event) { // help command if strings.ToLower(msg.AltMessage) == "help" { m := make(types.KV) - for name, handle := range bots.List() { + for name, handle := range chatbot.List() { for _, item := range handle.Rules() { switch v := item.(type) { case []command.Rule: @@ -200,7 +200,7 @@ func directIncomingMessage(caller *platforms.Caller, e protocol.Event) { // rule chat if session == "" { - for name, handle := range bots.List() { + for name, handle := range chatbot.List() { if !handle.IsReady() { flog.Info("bot %s unavailable", name) continue @@ -232,7 +232,7 @@ func directIncomingMessage(caller *platforms.Caller, e protocol.Event) { // tool chat if payload == nil && session == "" { - tools, err := bots.AvailableTools(ctx) + tools, err := chatbot.AvailableTools(ctx) if err != nil { flog.Error(err) return @@ -371,13 +371,13 @@ func groupIncomingMessage(caller *platforms.Caller, e protocol.Event) { _, _ = fmt.Println(ctx) // behavior - bots.Behavior(uid, bots.MessageGroupIncomingBehavior, 1) + chatbot.Behavior(uid, chatbot.MessageGroupIncomingBehavior, 1) // user auth record todo var payload types.MsgPayload - for name, handle := range bots.List() { + for name, handle := range chatbot.List() { if !handle.IsReady() { flog.Info("bot %s unavailable", name) continue @@ -458,7 +458,7 @@ func agentAction(uid types.Uid, data types.AgentData) (interface{}, error) { return nil, errors.New("error collect id") } - for name, handle := range bots.List() { + for name, handle := range chatbot.List() { if !handle.IsReady() { flog.Info("bot %s unavailable", name) continue diff --git a/internal/server/modules.go b/internal/server/modules.go index aceccc01..4a061a72 100644 --- a/internal/server/modules.go +++ b/internal/server/modules.go @@ -1,6 +1,7 @@ package server import ( + "github.com/flowline-io/flowbot/internal/bots" "github.com/flowline-io/flowbot/internal/platforms/slack" "github.com/flowline-io/flowbot/internal/workflow" "github.com/flowline-io/flowbot/pkg/cache" @@ -12,7 +13,7 @@ import ( ) var Modules = fx.Options( - BotsModules, + bots.Modules, NotifyModules, MediaModules, fx.Provide( diff --git a/internal/server/router.go b/internal/server/router.go index 4161298d..a44518f9 100644 --- a/internal/server/router.go +++ b/internal/server/router.go @@ -3,12 +3,12 @@ package server import ( "bytes" "errors" + "github.com/flowline-io/flowbot/pkg/chatbot" "net/http" "strconv" "strings" "github.com/bytedance/sonic" - "github.com/flowline-io/flowbot/internal/bots" "github.com/flowline-io/flowbot/internal/platforms/slack" "github.com/flowline-io/flowbot/internal/platforms/tailchat" "github.com/flowline-io/flowbot/internal/store" @@ -34,7 +34,7 @@ import ( func handleRoutes(a *fiber.App, ctl *Controller) { // Webservice - for _, bot := range bots.List() { + for _, bot := range chatbot.List() { bot.Webservice(a) } @@ -198,7 +198,7 @@ func (c *Controller) renderPage(ctx *fiber.Ctx) error { PageRuleId: pageRuleId, } - _, botHandler := bots.FindRuleAndHandler[pageRule.Rule](pageRuleId, bots.List()) + _, botHandler := chatbot.FindRuleAndHandler[pageRule.Rule](pageRuleId, chatbot.List()) if botHandler == nil { return protocol.ErrNotFound.New("bot not found") @@ -307,7 +307,7 @@ func (c *Controller) postForm(ctx *fiber.Ctx) error { return protocol.ErrBadParam.Errorf("form %s %s", formId, "error form rule id") } - _, botHandler := bots.FindRuleAndHandler[formRule.Rule](formRuleId, bots.List()) + _, botHandler := chatbot.FindRuleAndHandler[formRule.Rule](formRuleId, chatbot.List()) if botHandler != nil { if !botHandler.IsReady() { @@ -386,7 +386,7 @@ func (c *Controller) doWebhook(ctx *fiber.Ctx) error { flog.Info("[webhook] incoming %s flag: %s", method, flag) - webhookRule, botHandler := bots.FindRuleAndHandler[webhook.Rule](flag, bots.List()) + webhookRule, botHandler := chatbot.FindRuleAndHandler[webhook.Rule](flag, chatbot.List()) if botHandler == nil { return protocol.ErrNotFound.New("bot not found") diff --git a/internal/workflow/fsm.go b/internal/workflow/fsm.go index c0fc3db3..e05bf2d3 100644 --- a/internal/workflow/fsm.go +++ b/internal/workflow/fsm.go @@ -4,9 +4,9 @@ import ( "context" "errors" "fmt" - "github.com/flowline-io/flowbot/internal/bots" "github.com/flowline-io/flowbot/internal/store" "github.com/flowline-io/flowbot/internal/store/model" + "github.com/flowline-io/flowbot/pkg/chatbot" "github.com/flowline-io/flowbot/pkg/dag" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/types" @@ -344,8 +344,8 @@ func NewStepFSM(state model.StepState) *fsm.FSM { bot, _ := types.KV(step.Action).String("bot") ruleId, _ := types.KV(step.Action).String("rule_id") - var botHandler bots.Handler - for name, handler := range bots.List() { + var botHandler chatbot.Handler + for name, handler := range chatbot.List() { if bot != name { continue } diff --git a/internal/bots/bot.go b/pkg/chatbot/bot.go similarity index 99% rename from internal/bots/bot.go rename to pkg/chatbot/bot.go index 9312ae00..001465b8 100644 --- a/internal/bots/bot.go +++ b/pkg/chatbot/bot.go @@ -1,4 +1,4 @@ -package bots +package chatbot import ( "encoding/json" diff --git a/internal/bots/interface.go b/pkg/chatbot/interface.go similarity index 99% rename from internal/bots/interface.go rename to pkg/chatbot/interface.go index 988592ad..b5c9e799 100644 --- a/internal/bots/interface.go +++ b/pkg/chatbot/interface.go @@ -1,4 +1,4 @@ -package bots +package chatbot import ( "encoding/json" From 9b3d8149fc0907bf9fddf1c0bf18451b3d505e6c Mon Sep 17 00:00:00 2001 From: sysatom Date: Sat, 10 May 2025 01:40:12 +0800 Subject: [PATCH 069/125] =?UTF-8?q?=F0=9F=9B=A0=EF=B8=8F=20fix(pkg/chatbot?= =?UTF-8?q?/bot.go):=20Add=20constants=20for=20message=20behaviors=20and?= =?UTF-8?q?=20refactor=20Bootstrap=20and=20List=20functions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/chatbot/bot.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/pkg/chatbot/bot.go b/pkg/chatbot/bot.go index 001465b8..3dd12464 100644 --- a/pkg/chatbot/bot.go +++ b/pkg/chatbot/bot.go @@ -32,6 +32,11 @@ import ( "gorm.io/gorm" ) +const ( + MessageBotIncomingBehavior = "message_bot_incoming" + MessageGroupIncomingBehavior = "message_group_incoming" +) + var handlers map[string]Handler func Register(name string, bot Handler) { @@ -476,11 +481,6 @@ func SettingMsg(ctx types.Context, id string) types.MsgPayload { return FormMsg(ctx, fmt.Sprintf("%s_setting", id)) } -const ( - MessageBotIncomingBehavior = "message_bot_incoming" - MessageGroupIncomingBehavior = "message_group_incoming" -) - func Behavior(uid types.Uid, flag string, number int) { b, err := store.Database.BehaviorGet(uid, flag) if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) { @@ -603,6 +603,7 @@ func Init(jsonconf json.RawMessage) error { return nil } +// Bootstrap bots bootstrap func Bootstrap() error { for _, bot := range handlers { if !bot.IsReady() { @@ -630,6 +631,7 @@ func Cron() ([]*cron.Ruleset, error) { return rss, nil } +// List registered handlers func List() map[string]Handler { return handlers } From 6526dec5dab8d73cfc7478d66247bbce5692127e Mon Sep 17 00:00:00 2001 From: sysatom Date: Sat, 10 May 2025 01:41:24 +0800 Subject: [PATCH 070/125] =?UTF-8?q?=F0=9F=94=A7=20fix=20typo=20in=20IsRead?= =?UTF-8?q?y=20method=20comment?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/chatbot/interface.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/chatbot/interface.go b/pkg/chatbot/interface.go index b5c9e799..58af71f6 100644 --- a/pkg/chatbot/interface.go +++ b/pkg/chatbot/interface.go @@ -13,7 +13,7 @@ type Handler interface { // Init initializes the bot. Init(jsonconf json.RawMessage) error - // IsReady сhecks if the bot is initialized. + // IsReady checks if the bot is initialized. IsReady() bool // Bootstrap Lifecycle hook From c47154ecd91192da28878169078816a515782bb0 Mon Sep 17 00:00:00 2001 From: sysatom Date: Sat, 10 May 2025 01:42:17 +0800 Subject: [PATCH 071/125] =?UTF-8?q?=F0=9F=8E=A8=20feat(media.go):=20Update?= =?UTF-8?q?=20interface=20comment=20to=20reflect=20correct=20terminology?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/media/media.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/media/media.go b/pkg/media/media.go index 8143a5c4..458fd0f9 100644 --- a/pkg/media/media.go +++ b/pkg/media/media.go @@ -18,7 +18,7 @@ type ReadSeekCloser interface { io.Closer } -// Handler is an interface which must be implemented by media handlers (uploaders-downloaders). +// Handler is an interface which must be implemented by media handlers (uploader-downloader). type Handler interface { // Init initializes the media upload handler. Init(jsconf string) error From 1cf94b77f530540548b4bc746d3e25f07e7f29c0 Mon Sep 17 00:00:00 2001 From: sysatom Date: Sun, 11 May 2025 11:29:22 +0800 Subject: [PATCH 072/125] =?UTF-8?q?=F0=9F=9A=80=20feat(rdb/metrics.go):=20?= =?UTF-8?q?Implement=20SetMetricsInt64=20and=20GetMetricsInt64=20functions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/bots/bookmark/cron.go | 2 +- internal/bots/gitea/cron.go | 2 +- internal/bots/kanban/cron.go | 2 +- internal/bots/reader/cron.go | 2 +- internal/bots/server/cron.go | 6 +++--- internal/bots/torrent/cron.go | 2 +- internal/bots/user/webservice.go | 18 +++++++++--------- internal/server/chatbot.go | 2 +- pkg/rdb/metrics.go | 23 +++++++++++++++++++++++ pkg/rdb/rdb.go | 12 ------------ 10 files changed, 41 insertions(+), 30 deletions(-) create mode 100644 pkg/rdb/metrics.go diff --git a/internal/bots/bookmark/cron.go b/internal/bots/bookmark/cron.go index 538f5456..67d71fd5 100644 --- a/internal/bots/bookmark/cron.go +++ b/internal/bots/bookmark/cron.go @@ -72,7 +72,7 @@ var cronRules = []cron.Rule{ bookmarkTotal++ } stats.BookmarkTotalCounter().Set(uint64(bookmarkTotal)) - rdb.SetInt64(stats.BookmarkTotalStatsName, int64(bookmarkTotal)) + rdb.SetMetricsInt64(stats.BookmarkTotalStatsName, int64(bookmarkTotal)) return nil }, diff --git a/internal/bots/gitea/cron.go b/internal/bots/gitea/cron.go index a418f65f..30f5d9b2 100644 --- a/internal/bots/gitea/cron.go +++ b/internal/bots/gitea/cron.go @@ -34,7 +34,7 @@ var cronRules = []cron.Rule{ return nil } stats.GiteaIssueTotalCounter("open").Set(uint64(len(issues))) - rdb.SetInt64(stats.GiteaIssueTotalStatsName, int64(len(issues))) + rdb.SetMetricsInt64(stats.GiteaIssueTotalStatsName, int64(len(issues))) return nil }, diff --git a/internal/bots/kanban/cron.go b/internal/bots/kanban/cron.go index f35b6cd9..35e6b37b 100755 --- a/internal/bots/kanban/cron.go +++ b/internal/bots/kanban/cron.go @@ -25,7 +25,7 @@ var cronRules = []cron.Rule{ taskTotal := len(list) stats.KanbanTaskTotalCounter().Set(uint64(taskTotal)) - rdb.SetInt64(stats.KanbanTaskTotalStatsName, int64(taskTotal)) + rdb.SetMetricsInt64(stats.KanbanTaskTotalStatsName, int64(taskTotal)) return nil }, diff --git a/internal/bots/reader/cron.go b/internal/bots/reader/cron.go index 9a92a087..baf030ac 100644 --- a/internal/bots/reader/cron.go +++ b/internal/bots/reader/cron.go @@ -38,7 +38,7 @@ var cronRules = []cron.Rule{ return nil } stats.ReaderUnreadTotalCounter().Set(uint64(result.Total)) - rdb.SetInt64(stats.ReaderUnreadTotalStatsName, int64(result.Total)) + rdb.SetMetricsInt64(stats.ReaderUnreadTotalStatsName, int64(result.Total)) return nil }, diff --git a/internal/bots/server/cron.go b/internal/bots/server/cron.go index 2c736939..fe36a153 100644 --- a/internal/bots/server/cron.go +++ b/internal/bots/server/cron.go @@ -79,7 +79,7 @@ var cronRules = []cron.Rule{ total++ } - rdb.SetInt64(stats.DockerContainerTotalStatsName, total) + rdb.SetMetricsInt64(stats.DockerContainerTotalStatsName, total) stats.DockerContainerTotalCounter().Set(uint64(total)) return nil @@ -110,8 +110,8 @@ var cronRules = []cron.Rule{ } } } - rdb.SetInt64(stats.MonitorUpTotalStatsName, up) - rdb.SetInt64(stats.MonitorDownTotalStatsName, down) + rdb.SetMetricsInt64(stats.MonitorUpTotalStatsName, up) + rdb.SetMetricsInt64(stats.MonitorDownTotalStatsName, down) return nil }, diff --git a/internal/bots/torrent/cron.go b/internal/bots/torrent/cron.go index 6579af88..2b267d30 100644 --- a/internal/bots/torrent/cron.go +++ b/internal/bots/torrent/cron.go @@ -53,7 +53,7 @@ var cronRules = []cron.Rule{ stats.TorrentStatusTotalCounter(status).Set(amount) } stats.TorrentDownloadTotalCounter().Set(uint64(len(list))) - rdb.SetInt64(stats.TorrentDownloadTotalStatsName, int64(len(list))) + rdb.SetMetricsInt64(stats.TorrentDownloadTotalStatsName, int64(len(list))) return nil }, diff --git a/internal/bots/user/webservice.go b/internal/bots/user/webservice.go index 5720526c..c3f0087d 100644 --- a/internal/bots/user/webservice.go +++ b/internal/bots/user/webservice.go @@ -46,15 +46,15 @@ func dashboard(ctx *fiber.Ctx) error { // @Router /user/metrics [get] func metrics(ctx *fiber.Ctx) error { return ctx.JSON(protocol.NewSuccessResponse(types.KV{ - stats.BotTotalStatsName: rdb.GetInt64(stats.BotTotalStatsName), - stats.BookmarkTotalStatsName: rdb.GetInt64(stats.BookmarkTotalStatsName), - stats.TorrentDownloadTotalStatsName: rdb.GetInt64(stats.TorrentDownloadTotalStatsName), - stats.GiteaIssueTotalStatsName: rdb.GetInt64(stats.GiteaIssueTotalStatsName), - stats.ReaderUnreadTotalStatsName: rdb.GetInt64(stats.ReaderUnreadTotalStatsName), - stats.KanbanTaskTotalStatsName: rdb.GetInt64(stats.KanbanTaskTotalStatsName), - stats.MonitorUpTotalStatsName: rdb.GetInt64(stats.MonitorUpTotalStatsName), - stats.MonitorDownTotalStatsName: rdb.GetInt64(stats.MonitorDownTotalStatsName), - stats.DockerContainerTotalStatsName: rdb.GetInt64(stats.DockerContainerTotalStatsName), + stats.BotTotalStatsName: rdb.GetMetricsInt64(stats.BotTotalStatsName), + stats.BookmarkTotalStatsName: rdb.GetMetricsInt64(stats.BookmarkTotalStatsName), + stats.TorrentDownloadTotalStatsName: rdb.GetMetricsInt64(stats.TorrentDownloadTotalStatsName), + stats.GiteaIssueTotalStatsName: rdb.GetMetricsInt64(stats.GiteaIssueTotalStatsName), + stats.ReaderUnreadTotalStatsName: rdb.GetMetricsInt64(stats.ReaderUnreadTotalStatsName), + stats.KanbanTaskTotalStatsName: rdb.GetMetricsInt64(stats.KanbanTaskTotalStatsName), + stats.MonitorUpTotalStatsName: rdb.GetMetricsInt64(stats.MonitorUpTotalStatsName), + stats.MonitorDownTotalStatsName: rdb.GetMetricsInt64(stats.MonitorDownTotalStatsName), + stats.DockerContainerTotalStatsName: rdb.GetMetricsInt64(stats.DockerContainerTotalStatsName), })) } diff --git a/internal/server/chatbot.go b/internal/server/chatbot.go index 961af11c..88de8d2e 100644 --- a/internal/server/chatbot.go +++ b/internal/server/chatbot.go @@ -73,7 +73,7 @@ func initializeBot(botsConfig interface{}, vendorsConfig interface{}) { } stats.BotTotalCounter().Set(uint64(len(chatbot.List()))) - rdb.SetInt64(stats.BotTotalStatsName, int64(len(chatbot.List()))) + rdb.SetMetricsInt64(stats.BotTotalStatsName, int64(len(chatbot.List()))) } // register bots diff --git a/pkg/rdb/metrics.go b/pkg/rdb/metrics.go new file mode 100644 index 00000000..dac1d5c8 --- /dev/null +++ b/pkg/rdb/metrics.go @@ -0,0 +1,23 @@ +package rdb + +import ( + "context" + "fmt" + "github.com/flowline-io/flowbot/pkg/flog" +) + +func SetMetricsInt64(key string, value int64) { + Client.Set(context.Background(), metricsKey(key), value, 0) +} + +func GetMetricsInt64(key string) int64 { + r, err := Client.Get(context.Background(), metricsKey(key)).Int64() + if err != nil { + flog.Error(err) + } + return r +} + +func metricsKey(key string) string { + return fmt.Sprintf("metrics:%s", key) +} diff --git a/pkg/rdb/rdb.go b/pkg/rdb/rdb.go index 881ff75e..1e826d33 100644 --- a/pkg/rdb/rdb.go +++ b/pkg/rdb/rdb.go @@ -63,15 +63,3 @@ func Shutdown() { flog.Warn("redis connection already lost: %v", err) } } - -func SetInt64(key string, value int64) { - Client.Set(context.Background(), key, value, 0) -} - -func GetInt64(key string) int64 { - r, err := Client.Get(context.Background(), key).Int64() - if err != nil { - flog.Error(err) - } - return r -} From 58ab1e981926dce9bff46a2081dfe5c5aa46c07c Mon Sep 17 00:00:00 2001 From: sysatom Date: Sun, 11 May 2025 11:54:41 +0800 Subject: [PATCH 073/125] =?UTF-8?q?=F0=9F=94=A7=20fix(rdb/unique.go):=20Im?= =?UTF-8?q?plement=20BloomUnique=20for=20efficient=20uniqueness=20check?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/bots/bookmark/cron.go | 2 +- internal/bots/dev/command.go | 42 ++++++++++++------------------ internal/bots/workflow/workflow.go | 2 +- pkg/rdb/unique.go | 29 +++++++++------------ 4 files changed, 32 insertions(+), 43 deletions(-) diff --git a/internal/bots/bookmark/cron.go b/internal/bots/bookmark/cron.go index 67d71fd5..ec050f4f 100644 --- a/internal/bots/bookmark/cron.go +++ b/internal/bots/bookmark/cron.go @@ -131,7 +131,7 @@ var cronRules = []cron.Rule{ } // filter - ok, err := rdb.UniqueString(ctx.Context(), "bookmarks:task:filter", bookmark.Id) + ok, err := rdb.BloomUniqueString(ctx.Context(), "bookmarks:task:filter", bookmark.Id) if err != nil { flog.Error(fmt.Errorf("cron bookmarks_task unique error %w", err)) continue diff --git a/internal/bots/dev/command.go b/internal/bots/dev/command.go index 71f7b350..f52c7a5a 100644 --- a/internal/bots/dev/command.go +++ b/internal/bots/dev/command.go @@ -3,6 +3,7 @@ package dev import ( "context" "fmt" + "github.com/flowline-io/flowbot/pkg/rdb" "os" "time" @@ -15,11 +16,8 @@ import ( "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/notify" "github.com/flowline-io/flowbot/pkg/parser" - "github.com/flowline-io/flowbot/pkg/providers/gitea" - "github.com/flowline-io/flowbot/pkg/providers/hoarder" "github.com/flowline-io/flowbot/pkg/providers/safeline" "github.com/flowline-io/flowbot/pkg/providers/transmission" - "github.com/flowline-io/flowbot/pkg/search" "github.com/flowline-io/flowbot/pkg/types" "github.com/flowline-io/flowbot/pkg/types/ruleset/command" "github.com/flowline-io/flowbot/pkg/utils" @@ -233,29 +231,23 @@ var commandRules = []command.Rule{ Define: "test", Help: `[example] test`, Handler: func(ctx types.Context, tokens []*parser.Token) types.MsgPayload { - flog.Info("dev bot environment config: %s", config.Environment) + key := "test:filter" + ok, err := rdb.BloomUniqueString(ctx.Context(), key, "1") + _, _ = fmt.Println(ok, err) + ok, err = rdb.BloomUniqueString(ctx.Context(), key, "2") + _, _ = fmt.Println(ok, err) + ok, err = rdb.BloomUniqueString(ctx.Context(), key, "1") + _, _ = fmt.Println(ok, err) + + key = "test:list:filter" + result, err := rdb.BloomUnique(ctx.Context(), key, []any{"1", "2"}) + _, _ = fmt.Println(result, err) + result, err = rdb.BloomUnique(ctx.Context(), key, []any{"2", "3"}) + _, _ = fmt.Println(result, err) + result, err = rdb.BloomUnique(ctx.Context(), key, []any{"1", "3"}) + _, _ = fmt.Println(result, err) - err := search.Instance.AddDocument(types.Document{ - SourceId: types.Id(), - Source: hoarder.ID, - Title: "the title....", - Description: "the description....", - Url: "/url/test", - Timestamp: time.Now().Unix(), - }) - if err != nil { - return types.TextMsg{Text: err.Error()} - } - - list, total, err := search.Instance.Search(gitea.ID, "title", 1, 10) - if err != nil { - return types.TextMsg{Text: err.Error()} - } - - return types.InfoMsg{ - Title: fmt.Sprintf("documents %v", total), - Model: list, - } + return types.TextMsg{Text: "ok"} }, }, } diff --git a/internal/bots/workflow/workflow.go b/internal/bots/workflow/workflow.go index 4d0bf89d..df4a7759 100644 --- a/internal/bots/workflow/workflow.go +++ b/internal/bots/workflow/workflow.go @@ -166,7 +166,7 @@ var workflowRules = []workflow.Rule{ return nil, fmt.Errorf("%s step, empty data", uniqueWorkflowActionID) } if v, ok := list.([]any); ok { - result, err := rdb.Unique(ctx.Context(), id, v) + result, err := rdb.BloomUnique(ctx.Context(), id, v) if err != nil { return nil, fmt.Errorf("%s step, unique failed, %w", uniqueWorkflowActionID, err) } diff --git a/pkg/rdb/unique.go b/pkg/rdb/unique.go index f20dca67..34dba5a2 100644 --- a/pkg/rdb/unique.go +++ b/pkg/rdb/unique.go @@ -4,16 +4,16 @@ import ( "context" "fmt" "github.com/flowline-io/flowbot/pkg/flog" - "github.com/flowline-io/flowbot/pkg/types" "github.com/flowline-io/flowbot/pkg/utils" json "github.com/json-iterator/go" ) -func Unique(ctx context.Context, id string, latest []any) ([]types.KV, error) { - result := make([]types.KV, 0) - uniqueKey := fmt.Sprintf("unique:%s", id) +func BloomUnique(ctx context.Context, id string, latest []any) ([]any, error) { + result := make([]any, 0) + uniqueKey := fmt.Sprintf("bloom:unique:%s", id) + Client.BFReserve(ctx, uniqueKey, 0.001, 1000000) - for _, item := range latest { + for i, item := range latest { val, err := kvHash(item) if err != nil { return nil, fmt.Errorf("failed to hash kv: %w", err) @@ -21,16 +21,12 @@ func Unique(ctx context.Context, id string, latest []any) ([]types.KV, error) { if len(val) == 0 { continue } - b, err := Client.SAdd(ctx, uniqueKey, val).Result() + b, err := Client.BFAdd(ctx, uniqueKey, val).Result() if err != nil { return nil, fmt.Errorf("failed to set unique key: %w", err) } - if b == 1 { - kv, ok := item.(map[string]any) - if !ok { - continue - } - result = append(result, kv) + if b { + result = append(result, latest[i]) flog.Info("[unique] key: %s added: %s", id, val) } } @@ -46,13 +42,14 @@ func kvHash(item any) (string, error) { return utils.SHA1(utils.BytesToString(b)), nil } -func UniqueString(ctx context.Context, id string, latest string) (bool, error) { - uniqueKey := fmt.Sprintf("unique:%s", id) - b, err := Client.SAdd(ctx, uniqueKey, latest).Result() +func BloomUniqueString(ctx context.Context, id string, latest string) (bool, error) { + uniqueKey := fmt.Sprintf("bloom:unique:%s", id) + Client.BFReserve(ctx, uniqueKey, 0.001, 1000000) + b, err := Client.BFAdd(ctx, uniqueKey, latest).Result() if err != nil { return false, fmt.Errorf("failed to set unique key: %w", err) } - if b == 1 { + if b { return true, nil } From 03ecb3126cdc3fe3f37de43c83f733aff4338114 Mon Sep 17 00:00:00 2001 From: sysatom Date: Sun, 11 May 2025 12:08:26 +0800 Subject: [PATCH 074/125] =?UTF-8?q?=F0=9F=90=9B=20fix:=20Replace=20`store.?= =?UTF-8?q?FS`=20with=20`store.FileSystem`=20in=20multiple=20files.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/bots/dev/command.go | 9 ++++----- internal/bots/server/command.go | 2 +- internal/bots/server/webservice.go | 2 +- internal/store/store.go | 6 +++--- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/internal/bots/dev/command.go b/internal/bots/dev/command.go index f52c7a5a..20c06ce4 100644 --- a/internal/bots/dev/command.go +++ b/internal/bots/dev/command.go @@ -3,10 +3,6 @@ package dev import ( "context" "fmt" - "github.com/flowline-io/flowbot/pkg/rdb" - "os" - "time" - "github.com/flowline-io/flowbot/internal/agents" "github.com/flowline-io/flowbot/internal/store" "github.com/flowline-io/flowbot/pkg/chatbot" @@ -18,9 +14,12 @@ import ( "github.com/flowline-io/flowbot/pkg/parser" "github.com/flowline-io/flowbot/pkg/providers/safeline" "github.com/flowline-io/flowbot/pkg/providers/transmission" + "github.com/flowline-io/flowbot/pkg/rdb" "github.com/flowline-io/flowbot/pkg/types" "github.com/flowline-io/flowbot/pkg/types/ruleset/command" "github.com/flowline-io/flowbot/pkg/utils" + "os" + "time" ) var commandRules = []command.Rule{ @@ -185,7 +184,7 @@ var commandRules = []command.Rule{ } fileSize := fileStat.Size() - url, size, err := store.FS.Upload(&types.FileDef{ + url, size, err := store.FileSystem.Upload(&types.FileDef{ User: ctx.AsUser.String(), Size: fileSize, MimeType: "text/markdown", diff --git a/internal/bots/server/command.go b/internal/bots/server/command.go index 1b4def6b..924ef160 100644 --- a/internal/bots/server/command.go +++ b/internal/bots/server/command.go @@ -187,7 +187,7 @@ var commandRules = []command.Rule{ if err != nil { return types.TextMsg{Text: err.Error()} } - _, _, err = store.FS.Upload(&types.FileDef{ + _, _, err = store.FileSystem.Upload(&types.FileDef{ User: ctx.AsUser.String(), Size: f.Size(), MimeType: "text/plain", diff --git a/internal/bots/server/webservice.go b/internal/bots/server/webservice.go index 19587e2b..9ab2beb4 100644 --- a/internal/bots/server/webservice.go +++ b/internal/bots/server/webservice.go @@ -39,7 +39,7 @@ func upload(ctx *fiber.Ctx) error { continue } - url, _, err := store.FS.Upload(&types.FileDef{ + url, _, err := store.FileSystem.Upload(&types.FileDef{ ObjHeader: types.ObjHeader{ Id: types.Id(), }, diff --git a/internal/store/store.go b/internal/store/store.go index 12796597..cd8c6435 100644 --- a/internal/store/store.go +++ b/internal/store/store.go @@ -82,8 +82,8 @@ func Migrate() error { return nil } -// FS Media handler -var FS media.Handler +// FileSystem Media handler +var FileSystem media.Handler // Registered media/file handlers. var fileHandlers map[string]media.Handler @@ -111,7 +111,7 @@ func UseMediaHandler(name, config string) error { flog.Fatal("UseMediaHandler: unknown handler %s", name) return fmt.Errorf("unknown handler %s", name) } - FS = mediaHandler + FileSystem = mediaHandler return mediaHandler.Init(config) } From 6925362263039772380557cd1bb9b97099fc191b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 12 May 2025 16:12:00 +0000 Subject: [PATCH 075/125] build(deps): bump github.com/cloudwego/eino from 0.3.30 to 0.3.31 Bumps [github.com/cloudwego/eino](https://github.com/cloudwego/eino) from 0.3.30 to 0.3.31. - [Release notes](https://github.com/cloudwego/eino/releases) - [Commits](https://github.com/cloudwego/eino/compare/v0.3.30...v0.3.31) --- updated-dependencies: - dependency-name: github.com/cloudwego/eino dependency-version: 0.3.31 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 4cb41acc..0e82e670 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,7 @@ require ( github.com/bwmarrin/discordgo v0.28.1 github.com/bytedance/sonic v1.13.2 github.com/cenkalti/backoff v2.2.1+incompatible - github.com/cloudwego/eino v0.3.30 + github.com/cloudwego/eino v0.3.31 github.com/cloudwego/eino-ext/components/model/openai v0.0.0-20250507115047-b20720df8528 github.com/creachadair/jrpc2 v1.3.1 github.com/dgraph-io/ristretto/v2 v2.2.0 diff --git a/go.sum b/go.sum index eb53a806..f9f82fe6 100644 --- a/go.sum +++ b/go.sum @@ -65,8 +65,8 @@ github.com/chengxilo/virtualterm v1.0.4 h1:Z6IpERbRVlfB8WkOmtbHiDbBANU7cimRIof7m github.com/chengxilo/virtualterm v1.0.4/go.mod h1:DyxxBZz/x1iqJjFxTFcr6/x+jSpqN0iwWCOK1q10rlY= github.com/cloudwego/base64x v0.1.5 h1:XPciSp1xaq2VCSt6lF0phncD4koWyULpl5bUxbfCyP4= github.com/cloudwego/base64x v0.1.5/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w= -github.com/cloudwego/eino v0.3.30 h1:oQxEqkpu+nCl5hrzbEIMxX1Dogtbyed7gYAnTM6uUZY= -github.com/cloudwego/eino v0.3.30/go.mod h1:wUjz990apdsaOraOXdh6CdhVXq8DJsOvLsVlxNTcNfY= +github.com/cloudwego/eino v0.3.31 h1:CByfu37j7YjYp+T/aS2oCffPCOY986F3Jbb6a6BfO4Y= +github.com/cloudwego/eino v0.3.31/go.mod h1:wUjz990apdsaOraOXdh6CdhVXq8DJsOvLsVlxNTcNfY= github.com/cloudwego/eino-ext/components/model/openai v0.0.0-20250507115047-b20720df8528 h1:LWlv4+NUNKVG2ojRtEbMDhExS45DH1t+kXakBCB3+Cw= github.com/cloudwego/eino-ext/components/model/openai v0.0.0-20250507115047-b20720df8528/go.mod h1:uXIWTFbaAbZ1128EIXjFc4S+tDqmz1idMZd5qt5kkwU= github.com/cloudwego/eino-ext/libs/acl/openai v0.0.0-20250422092704-54e372e1fa3d h1:unNqPz9vuJmJCZAw5YKFcszRX9e3CdVEjh0lR6QArxk= From 8a9b4829f2d976eceb450c721eb5d695def1b635 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 12 May 2025 16:13:48 +0000 Subject: [PATCH 076/125] build(deps): bump github.com/VictoriaMetrics/metrics Bumps [github.com/VictoriaMetrics/metrics](https://github.com/VictoriaMetrics/metrics) from 1.36.0 to 1.37.0. - [Commits](https://github.com/VictoriaMetrics/metrics/compare/v1.36.0...v1.37.0) --- updated-dependencies: - dependency-name: github.com/VictoriaMetrics/metrics dependency-version: 1.37.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 4cb41acc..d6060bb8 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/RealAlexandreAI/json-repair v0.0.14 github.com/ThreeDotsLabs/watermill v1.4.6 github.com/ThreeDotsLabs/watermill-redisstream v1.4.2 - github.com/VictoriaMetrics/metrics v1.36.0 + github.com/VictoriaMetrics/metrics v1.37.0 github.com/allegro/bigcache/v3 v3.1.0 github.com/bsm/redislock v0.9.4 github.com/bwmarrin/discordgo v0.28.1 diff --git a/go.sum b/go.sum index eb53a806..7773d367 100644 --- a/go.sum +++ b/go.sum @@ -24,8 +24,8 @@ github.com/ThreeDotsLabs/watermill v1.4.6 h1:rWoXlxdBgUyg/bZ3OO0pON+nESVd9r6tnLT github.com/ThreeDotsLabs/watermill v1.4.6/go.mod h1:lBnrLbxOjeMRgcJbv+UiZr8Ylz8RkJ4m6i/VN/Nk+to= github.com/ThreeDotsLabs/watermill-redisstream v1.4.2 h1:FY6tsBcbhbJpKDOssU4bfybstqY0hQHwiZmVq9qyILQ= github.com/ThreeDotsLabs/watermill-redisstream v1.4.2/go.mod h1:69++855LyB+ckYDe60PiJLBcUrpckfDE2WwyzuVJRCk= -github.com/VictoriaMetrics/metrics v1.36.0 h1:f3SZMpLgIG4hJm2zfDs6wicxQ/QNWBZekY5rEGgbHKs= -github.com/VictoriaMetrics/metrics v1.36.0/go.mod h1:r7hveu6xMdUACXvB8TYdAj8WEsKzWB0EkpJN+RDtOf8= +github.com/VictoriaMetrics/metrics v1.37.0 h1:u5Yr+HFofQyn7kgmmkufgkX0nEA6G1oEyK2eaKsVaUM= +github.com/VictoriaMetrics/metrics v1.37.0/go.mod h1:r7hveu6xMdUACXvB8TYdAj8WEsKzWB0EkpJN+RDtOf8= github.com/airbrake/gobrake v3.6.1+incompatible/go.mod h1:wM4gu3Cn0W0K7GUuVWnlXZU11AGBXMILnrdOU8Kn00o= github.com/allegro/bigcache/v3 v3.1.0 h1:H2Vp8VOvxcrB91o86fUSVJFqeuz8kpyyB02eH3bSzwk= github.com/allegro/bigcache/v3 v3.1.0/go.mod h1:aPyh7jEvrog9zAwx5N7+JUQX5dZTSGpxF1LAR4dr35I= From 8c5cf050c9d20c8a651c1b08b52a5362f37f555b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 14 May 2025 17:04:14 +0000 Subject: [PATCH 077/125] build(deps): bump github.com/cloudwego/eino from 0.3.31 to 0.3.33 Bumps [github.com/cloudwego/eino](https://github.com/cloudwego/eino) from 0.3.31 to 0.3.33. - [Release notes](https://github.com/cloudwego/eino/releases) - [Commits](https://github.com/cloudwego/eino/compare/v0.3.31...v0.3.33) --- updated-dependencies: - dependency-name: github.com/cloudwego/eino dependency-version: 0.3.33 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index ea104fc7..e3255c26 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,7 @@ require ( github.com/bwmarrin/discordgo v0.28.1 github.com/bytedance/sonic v1.13.2 github.com/cenkalti/backoff v2.2.1+incompatible - github.com/cloudwego/eino v0.3.31 + github.com/cloudwego/eino v0.3.33 github.com/cloudwego/eino-ext/components/model/openai v0.0.0-20250507115047-b20720df8528 github.com/creachadair/jrpc2 v1.3.1 github.com/dgraph-io/ristretto/v2 v2.2.0 diff --git a/go.sum b/go.sum index b482b40b..c740d8da 100644 --- a/go.sum +++ b/go.sum @@ -65,8 +65,8 @@ github.com/chengxilo/virtualterm v1.0.4 h1:Z6IpERbRVlfB8WkOmtbHiDbBANU7cimRIof7m github.com/chengxilo/virtualterm v1.0.4/go.mod h1:DyxxBZz/x1iqJjFxTFcr6/x+jSpqN0iwWCOK1q10rlY= github.com/cloudwego/base64x v0.1.5 h1:XPciSp1xaq2VCSt6lF0phncD4koWyULpl5bUxbfCyP4= github.com/cloudwego/base64x v0.1.5/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w= -github.com/cloudwego/eino v0.3.31 h1:CByfu37j7YjYp+T/aS2oCffPCOY986F3Jbb6a6BfO4Y= -github.com/cloudwego/eino v0.3.31/go.mod h1:wUjz990apdsaOraOXdh6CdhVXq8DJsOvLsVlxNTcNfY= +github.com/cloudwego/eino v0.3.33 h1:C7BXUiLfyVDt0u+77B9X47nJ2OqzPPJ4kzTjRy+QuQ8= +github.com/cloudwego/eino v0.3.33/go.mod h1:wUjz990apdsaOraOXdh6CdhVXq8DJsOvLsVlxNTcNfY= github.com/cloudwego/eino-ext/components/model/openai v0.0.0-20250507115047-b20720df8528 h1:LWlv4+NUNKVG2ojRtEbMDhExS45DH1t+kXakBCB3+Cw= github.com/cloudwego/eino-ext/components/model/openai v0.0.0-20250507115047-b20720df8528/go.mod h1:uXIWTFbaAbZ1128EIXjFc4S+tDqmz1idMZd5qt5kkwU= github.com/cloudwego/eino-ext/libs/acl/openai v0.0.0-20250422092704-54e372e1fa3d h1:unNqPz9vuJmJCZAw5YKFcszRX9e3CdVEjh0lR6QArxk= From cc493f40cb8dc402bd477476461bb510a25046fb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 14 May 2025 17:04:19 +0000 Subject: [PATCH 078/125] build(deps): bump github.com/expr-lang/expr from 1.17.2 to 1.17.3 Bumps [github.com/expr-lang/expr](https://github.com/expr-lang/expr) from 1.17.2 to 1.17.3. - [Release notes](https://github.com/expr-lang/expr/releases) - [Commits](https://github.com/expr-lang/expr/compare/v1.17.2...v1.17.3) --- updated-dependencies: - dependency-name: github.com/expr-lang/expr dependency-version: 1.17.3 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index ea104fc7..999648c4 100644 --- a/go.mod +++ b/go.mod @@ -24,7 +24,7 @@ require ( github.com/docker/go-units v0.5.0 github.com/dustin/go-humanize v1.0.1 github.com/emicklei/go-restful/v3 v3.12.2 - github.com/expr-lang/expr v1.17.2 + github.com/expr-lang/expr v1.17.3 github.com/fsnotify/fsnotify v1.9.0 github.com/gen2brain/beeep v0.0.0-20240516210008-9c006672e7f4 github.com/go-echarts/go-echarts/v2 v2.5.4 diff --git a/go.sum b/go.sum index b482b40b..36dcc228 100644 --- a/go.sum +++ b/go.sum @@ -116,8 +116,8 @@ github.com/emicklei/go-restful/v3 v3.12.2 h1:DhwDP0vY3k8ZzE0RunuJy8GhNpPL6zqLkDf github.com/emicklei/go-restful/v3 v3.12.2/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= -github.com/expr-lang/expr v1.17.2 h1:o0A99O/Px+/DTjEnQiodAgOIK9PPxL8DtXhBRKC+Iso= -github.com/expr-lang/expr v1.17.2/go.mod h1:8/vRC7+7HBzESEqt5kKpYXxrxkr31SaO8r40VO/1IT4= +github.com/expr-lang/expr v1.17.3 h1:myeTTuDFz7k6eFe/JPlep/UsiIjVhG61FMHFu63U7j0= +github.com/expr-lang/expr v1.17.3/go.mod h1:8/vRC7+7HBzESEqt5kKpYXxrxkr31SaO8r40VO/1IT4= github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw= From b73e0339c8df9ed87c5c30e0dd56afce6cb51ef3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 14 May 2025 17:04:33 +0000 Subject: [PATCH 079/125] build(deps): bump go.uber.org/fx from 1.23.0 to 1.24.0 Bumps [go.uber.org/fx](https://github.com/uber-go/fx) from 1.23.0 to 1.24.0. - [Release notes](https://github.com/uber-go/fx/releases) - [Changelog](https://github.com/uber-go/fx/blob/master/CHANGELOG.md) - [Commits](https://github.com/uber-go/fx/compare/v1.23.0...v1.24.0) --- updated-dependencies: - dependency-name: go.uber.org/fx dependency-version: 1.24.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 4 ++-- go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index ea104fc7..85400a13 100644 --- a/go.mod +++ b/go.mod @@ -70,7 +70,7 @@ require ( github.com/urfave/cli/v2 v2.27.6 github.com/valyala/fasthttp v1.62.0 go.uber.org/automaxprocs v1.6.0 - go.uber.org/fx v1.23.0 + go.uber.org/fx v1.24.0 golang.org/x/crypto v0.38.0 golang.org/x/exp v0.0.0-20250218142911-aa4b98e5adaa golang.org/x/sys v0.33.0 @@ -211,7 +211,7 @@ require ( go.opentelemetry.io/otel/metric v1.29.0 // indirect go.opentelemetry.io/otel/trace v1.29.0 // indirect go.uber.org/atomic v1.9.0 // indirect - go.uber.org/dig v1.18.0 // indirect + go.uber.org/dig v1.19.0 // indirect go.uber.org/multierr v1.10.0 // indirect go.uber.org/zap v1.26.0 // indirect golang.org/x/arch v0.14.0 // indirect diff --git a/go.sum b/go.sum index b482b40b..43385f6f 100644 --- a/go.sum +++ b/go.sum @@ -553,10 +553,10 @@ go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE= go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/automaxprocs v1.6.0 h1:O3y2/QNTOdbF+e/dpXNNW7Rx2hZ4sTIPyybbxyNqTUs= go.uber.org/automaxprocs v1.6.0/go.mod h1:ifeIMSnPZuznNm6jmdzmU3/bfk01Fe2fotchwEFJ8r8= -go.uber.org/dig v1.18.0 h1:imUL1UiY0Mg4bqbFfsRQO5G4CGRBec/ZujWTvSVp3pw= -go.uber.org/dig v1.18.0/go.mod h1:Us0rSJiThwCv2GteUN0Q7OKvU7n5J4dxZ9JKUXozFdE= -go.uber.org/fx v1.23.0 h1:lIr/gYWQGfTwGcSXWXu4vP5Ws6iqnNEIY+F/aFzCKTg= -go.uber.org/fx v1.23.0/go.mod h1:o/D9n+2mLP6v1EG+qsdT1O8wKopYAsqZasju97SDFCU= +go.uber.org/dig v1.19.0 h1:BACLhebsYdpQ7IROQ1AGPjrXcP5dF80U3gKoFzbaq/4= +go.uber.org/dig v1.19.0/go.mod h1:Us0rSJiThwCv2GteUN0Q7OKvU7n5J4dxZ9JKUXozFdE= +go.uber.org/fx v1.24.0 h1:wE8mruvpg2kiiL1Vqd0CC+tr0/24XIB10Iwp2lLWzkg= +go.uber.org/fx v1.24.0/go.mod h1:AmDeGyS+ZARGKM4tlH4FY2Jr63VjbEDJHtqXTGP5hbo= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.uber.org/mock v0.4.0 h1:VcM4ZOtdbR4f6VXfiOpwpVJDL6lCReaZ6mw31wqh7KU= From 329949b2f958928bff9dabb58042f1c086e30fef Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 14 May 2025 17:04:38 +0000 Subject: [PATCH 080/125] build(deps): bump github.com/ThreeDotsLabs/watermill-redisstream Bumps [github.com/ThreeDotsLabs/watermill-redisstream](https://github.com/ThreeDotsLabs/watermill-redisstream) from 1.4.2 to 1.4.3. - [Release notes](https://github.com/ThreeDotsLabs/watermill-redisstream/releases) - [Commits](https://github.com/ThreeDotsLabs/watermill-redisstream/compare/v1.4.2...v1.4.3) --- updated-dependencies: - dependency-name: github.com/ThreeDotsLabs/watermill-redisstream dependency-version: 1.4.3 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index ea104fc7..30ca49c2 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/PuerkitoBio/goquery v1.10.3 github.com/RealAlexandreAI/json-repair v0.0.14 github.com/ThreeDotsLabs/watermill v1.4.6 - github.com/ThreeDotsLabs/watermill-redisstream v1.4.2 + github.com/ThreeDotsLabs/watermill-redisstream v1.4.3 github.com/VictoriaMetrics/metrics v1.37.0 github.com/allegro/bigcache/v3 v3.1.0 github.com/bsm/redislock v0.9.4 diff --git a/go.sum b/go.sum index b482b40b..da274178 100644 --- a/go.sum +++ b/go.sum @@ -22,8 +22,8 @@ github.com/Rican7/retry v0.3.1 h1:scY4IbO8swckzoA/11HgBwaZRJEyY9vaNJshcdhp1Mc= github.com/Rican7/retry v0.3.1/go.mod h1:CxSDrhAyXmTMeEuRAnArMu1FHu48vtfjLREWqVl7Vw0= github.com/ThreeDotsLabs/watermill v1.4.6 h1:rWoXlxdBgUyg/bZ3OO0pON+nESVd9r6tnLTgkZ6CYrU= github.com/ThreeDotsLabs/watermill v1.4.6/go.mod h1:lBnrLbxOjeMRgcJbv+UiZr8Ylz8RkJ4m6i/VN/Nk+to= -github.com/ThreeDotsLabs/watermill-redisstream v1.4.2 h1:FY6tsBcbhbJpKDOssU4bfybstqY0hQHwiZmVq9qyILQ= -github.com/ThreeDotsLabs/watermill-redisstream v1.4.2/go.mod h1:69++855LyB+ckYDe60PiJLBcUrpckfDE2WwyzuVJRCk= +github.com/ThreeDotsLabs/watermill-redisstream v1.4.3 h1:h/0qsW4y2H6mJ397bTBagqjv6Fp6gbgdweyquHHjwvw= +github.com/ThreeDotsLabs/watermill-redisstream v1.4.3/go.mod h1:69++855LyB+ckYDe60PiJLBcUrpckfDE2WwyzuVJRCk= github.com/VictoriaMetrics/metrics v1.37.0 h1:u5Yr+HFofQyn7kgmmkufgkX0nEA6G1oEyK2eaKsVaUM= github.com/VictoriaMetrics/metrics v1.37.0/go.mod h1:r7hveu6xMdUACXvB8TYdAj8WEsKzWB0EkpJN+RDtOf8= github.com/airbrake/gobrake v3.6.1+incompatible/go.mod h1:wM4gu3Cn0W0K7GUuVWnlXZU11AGBXMILnrdOU8Kn00o= From fefb9151ffe22135851893b4d57222ecd2551b3e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 15 May 2025 16:51:21 +0000 Subject: [PATCH 081/125] build(deps): bump github.com/prometheus/common from 0.63.0 to 0.64.0 Bumps [github.com/prometheus/common](https://github.com/prometheus/common) from 0.63.0 to 0.64.0. - [Release notes](https://github.com/prometheus/common/releases) - [Changelog](https://github.com/prometheus/common/blob/main/RELEASE.md) - [Commits](https://github.com/prometheus/common/compare/v0.63.0...v0.64.0) --- updated-dependencies: - dependency-name: github.com/prometheus/common dependency-version: 0.64.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 43f7b046..f3eebe3c 100644 --- a/go.mod +++ b/go.mod @@ -54,7 +54,7 @@ require ( github.com/montanaflynn/stats v0.7.1 github.com/pkoukk/tiktoken-go v0.1.7 github.com/prometheus/client_model v0.6.2 - github.com/prometheus/common v0.63.0 + github.com/prometheus/common v0.64.0 github.com/redis/go-redis/v9 v9.8.0 github.com/robfig/cron/v3 v3.0.1 github.com/rs/zerolog v1.34.0 diff --git a/go.sum b/go.sum index 9d2c3ec4..ca06d23b 100644 --- a/go.sum +++ b/go.sum @@ -415,8 +415,8 @@ github.com/prashantv/gostub v1.1.0 h1:BTyx3RfQjRHnUWaGF9oQos79AlQ5k8WNktv7VGvVH4 github.com/prashantv/gostub v1.1.0/go.mod h1:A5zLQHz7ieHGG7is6LLXLz7I8+3LZzsrV0P1IAHhP5U= github.com/prometheus/client_model v0.6.2 h1:oBsgwpGs7iVziMvrGhE53c/GrLUsZdHnqNwqPLxwZyk= github.com/prometheus/client_model v0.6.2/go.mod h1:y3m2F6Gdpfy6Ut/GBsUqTWZqCUvMVzSfMLjcu6wAwpE= -github.com/prometheus/common v0.63.0 h1:YR/EIY1o3mEFP/kZCD7iDMnLPlGyuU2Gb3HIcXnA98k= -github.com/prometheus/common v0.63.0/go.mod h1:VVFF/fBIoToEnWRVkYoXEkq3R3paCoxG9PXP74SnV18= +github.com/prometheus/common v0.64.0 h1:pdZeA+g617P7oGv1CzdTzyeShxAGrTBsolKNOLQPGO4= +github.com/prometheus/common v0.64.0/go.mod h1:0gZns+BLRQ3V6NdaerOhMbwwRbNh9hkGINtQAsP5GS8= github.com/redis/go-redis/v9 v9.8.0 h1:q3nRvjrlge/6UD7eTu/DSg2uYiU2mCL0G/uzBWqhicI= github.com/redis/go-redis/v9 v9.8.0/go.mod h1:huWgSWd8mW6+m0VPhJjSSQ+d6Nh1VICQ6Q5lHuCH/Iw= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= From 115e4812dbfea11b41449365888c0d85d1a2cbb8 Mon Sep 17 00:00:00 2001 From: sysatom Date: Sat, 17 May 2025 01:54:12 +0800 Subject: [PATCH 082/125] =?UTF-8?q?=F0=9F=A4=96=20feat(prompt.go):=20Updat?= =?UTF-8?q?e=20default=20templates=20to=20use=20Flowbot=20language=20setti?= =?UTF-8?q?ng=20=F0=9F=8C=90=20=F0=9F=A4=96=20feat(model.go):=20Implement?= =?UTF-8?q?=20GetModel=20function=20for=20dynamic=20model=20selection=20?= =?UTF-8?q?=F0=9F=8E=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/config.yaml | 40 ++++++++++++++++++++++++------ internal/agents/agent.go | 37 +++++++++++++++++++++++---- internal/agents/model.go | 35 +++++++++++++++++--------- internal/agents/prompt.go | 4 +-- internal/bots/bookmark/utils.go | 8 +++--- internal/bots/dev/command.go | 2 +- internal/bots/dev/webhook.go | 2 +- internal/bots/finance/utils.go | 2 +- internal/bots/gitea/utils.go | 4 +-- internal/bots/reader/cron.go | 7 +++--- internal/bots/reader/utils.go | 4 +-- internal/bots/workflow/workflow.go | 2 +- internal/server/func.go | 4 +-- internal/store/store.go | 2 +- pkg/config/config.go | 34 +++++++++++++++++-------- 15 files changed, 132 insertions(+), 55 deletions(-) diff --git a/docs/config.yaml b/docs/config.yaml index ce00565b..e0e81b6b 100644 --- a/docs/config.yaml +++ b/docs/config.yaml @@ -106,17 +106,43 @@ alarm: # Slack webhook URL slack_webhook: "" -# AI agent configuration -agent: - token: "" - base_url: "" - model: "" - tool_model: "" - language: "" +# Model configuration +models: + - protocol: "openai" # openai, openai-compatible, ollama + base_url: "https://api.openai.com/v1" + api_key: "" + model_names: + - "chatgpt-4" + - "chatgpt-3.5-turbo" + +# Agent configuration +agents: + - name: "chat" + enabled: true + model: "" + - name: "react" + enabled: true + model: "" + - name: "repo-review-comment" + enabled: true + model: "" + - name: "news-summary" + enabled: true + model: "" + - name: "bill-classify" + enabled: true + model: "" + - name: "extract-tags" + enabled: true + model: "" + - name: "similar-tags" + enabled: true + model: "" # Flowbot configuration flowbot: url: "" + lang: "english" # Platform integration configuration platform: diff --git a/internal/agents/agent.go b/internal/agents/agent.go index 83edcdd2..34940a84 100644 --- a/internal/agents/agent.go +++ b/internal/agents/agent.go @@ -3,14 +3,41 @@ package agents import ( "context" "fmt" - "github.com/cloudwego/eino/components/tool" "github.com/cloudwego/eino/compose" "github.com/cloudwego/eino/flow/agent/react" + "github.com/flowline-io/flowbot/pkg/config" + "sync" +) + +const ( + AgentChat = "chat" + AgentReact = "react" + AgentRepoReviewComment = "repo-review-comment" + AgentNewsSummary = "news-summary" + AgentBillClassify = "bill-classify" + AgentExtractTags = "extract-tags" + AgentSimilarTags = "similar-tags" ) -func ReactAgent(ctx context.Context, tools []tool.BaseTool) (*react.Agent, error) { - llm, err := ChatModel(ctx, ToolcallModel()) +var agents = make(map[string]config.Agent) +var loadOnceAgents = sync.Once{} + +func AgentModelName(name string) string { + loadOnceAgents.Do(func() { + for _, item := range config.App.Agents { + agents[item.Name] = item + } + }) + a, ok := agents[name] + if !ok || a.Enabled == false { + return "" + } + return a.Model +} + +func ReactAgent(ctx context.Context, modelName string, tools []tool.BaseTool) (*react.Agent, error) { + llm, err := ChatModel(ctx, modelName) if err != nil { return nil, fmt.Errorf("chat model failed, %w", err) } @@ -27,7 +54,7 @@ func ReactAgent(ctx context.Context, tools []tool.BaseTool) (*react.Agent, error return agent, nil } -func LLMGenerate(ctx context.Context, prompt string) (string, error) { +func LLMGenerate(ctx context.Context, modelName, prompt string) (string, error) { messages, err := BaseTemplate().Format(ctx, map[string]any{ "content": prompt, }) @@ -36,7 +63,7 @@ func LLMGenerate(ctx context.Context, prompt string) (string, error) { return "", fmt.Errorf("prompt format failed, %w", err) } - llm, err := ChatModel(ctx, Model()) + llm, err := ChatModel(ctx, modelName) if err != nil { return "", fmt.Errorf("chat model failed, %w", err) } diff --git a/internal/agents/model.go b/internal/agents/model.go index e6a1f1c2..f649e901 100644 --- a/internal/agents/model.go +++ b/internal/agents/model.go @@ -2,26 +2,37 @@ package agents import ( "context" - "time" - + "fmt" "github.com/cloudwego/eino-ext/components/model/openai" "github.com/cloudwego/eino/components/model" "github.com/flowline-io/flowbot/pkg/config" + "sync" + "time" ) +var models = make(map[string]config.Model) +var loadOnceModels = sync.Once{} + +func GetModel(modelName string) config.Model { + loadOnceModels.Do(func() { + for i, item := range config.App.Models { + for _, name := range item.ModelNames { + models[name] = config.App.Models[i] + } + } + }) + return models[modelName] +} + func ChatModel(ctx context.Context, modelName string) (model.ToolCallingChatModel, error) { + if modelName == "" { + return nil, fmt.Errorf("model or agent disabled") + } + m := GetModel(modelName) return openai.NewChatModel(ctx, &openai.ChatModelConfig{ - BaseURL: config.App.Agent.BaseUrl, - APIKey: config.App.Agent.Token, + BaseURL: m.BaseUrl, + APIKey: m.ApiKey, Model: modelName, Timeout: 10 * time.Minute, }) } - -func Model() string { - return config.App.Agent.Model -} - -func ToolcallModel() string { - return config.App.Agent.ToolModel -} diff --git a/internal/agents/prompt.go b/internal/agents/prompt.go index e3cec95b..2b1b483a 100644 --- a/internal/agents/prompt.go +++ b/internal/agents/prompt.go @@ -9,7 +9,7 @@ import ( func DefaultTemplate() prompt.ChatTemplate { return prompt.FromMessages(schema.FString, - schema.SystemMessage(fmt.Sprintf("You are a helpful assistant. Please answer in %s.", config.App.Agent.Language)), + schema.SystemMessage(fmt.Sprintf("You are a helpful assistant. Please answer in %s.", config.App.Flowbot.Language)), schema.MessagesPlaceholder("chat_history", true), schema.UserMessage("{content}"), ) @@ -17,7 +17,7 @@ func DefaultTemplate() prompt.ChatTemplate { func DefaultMultiChatTemplate() prompt.ChatTemplate { return prompt.FromMessages(schema.FString, - schema.SystemMessage(fmt.Sprintf("You are a helpful assistant. Please answer in %s.", config.App.Agent.Language)), + schema.SystemMessage(fmt.Sprintf("You are a helpful assistant. Please answer in %s.", config.App.Flowbot.Language)), schema.MessagesPlaceholder("chat_history", true), ) } diff --git a/internal/bots/bookmark/utils.go b/internal/bots/bookmark/utils.go index 7c5473bd..9291c76d 100644 --- a/internal/bots/bookmark/utils.go +++ b/internal/bots/bookmark/utils.go @@ -48,13 +48,13 @@ func extractTags(ctx context.Context, bookmark hoarder.Bookmark) ([]string, erro schema.UserMessage(tagsPrompt), ).Format(ctx, map[string]any{ "content": content, - "language": config.App.Agent.Language, + "language": config.App.Flowbot.Language, }) if err != nil { return nil, fmt.Errorf("%s bot, prompt format failed, %w", Name, err) } - llm, err := agents.ChatModel(ctx, agents.Model()) + llm, err := agents.ChatModel(ctx, agents.AgentModelName(agents.AgentExtractTags)) if err != nil { return nil, fmt.Errorf("%s bot, chat model failed, %w", Name, err) } @@ -103,13 +103,13 @@ func analyzeSimilarTags(ctx context.Context, tags []string) (map[string]string, schema.UserMessage(similarTagsPrompt), ).Format(ctx, map[string]any{ "tags": strings.Join(tags, "\n"), - "language": config.App.Agent.Language, + "language": config.App.Flowbot.Language, }) if err != nil { return nil, fmt.Errorf("%s bot, prompt format failed, %w", Name, err) } - llm, err := agents.ChatModel(ctx, agents.Model()) + llm, err := agents.ChatModel(ctx, agents.AgentModelName(agents.AgentSimilarTags)) if err != nil { return nil, fmt.Errorf("%s bot, chat model failed, %w", Name, err) } diff --git a/internal/bots/dev/command.go b/internal/bots/dev/command.go index 20c06ce4..1fb2ea6c 100644 --- a/internal/bots/dev/command.go +++ b/internal/bots/dev/command.go @@ -140,7 +140,7 @@ var commandRules = []command.Rule{ return types.TextMsg{Text: err.Error()} } - llm, err := agents.ChatModel(ctx.Context(), agents.Model()) + llm, err := agents.ChatModel(ctx.Context(), agents.AgentModelName(agents.AgentChat)) if err != nil { return types.TextMsg{Text: err.Error()} } diff --git a/internal/bots/dev/webhook.go b/internal/bots/dev/webhook.go index 2a74dbbb..cbb16861 100644 --- a/internal/bots/dev/webhook.go +++ b/internal/bots/dev/webhook.go @@ -63,7 +63,7 @@ var webhookRules = []webhook.Rule{ return } ctx.SetTimeout(10 * time.Minute) - agent, err := agents.ReactAgent(ctx.Context(), tools) + agent, err := agents.ReactAgent(ctx.Context(), agents.AgentModelName(agents.AgentReact), tools) if err != nil { flog.Error(err) return diff --git a/internal/bots/finance/utils.go b/internal/bots/finance/utils.go index f28dcb6a..a63b739a 100644 --- a/internal/bots/finance/utils.go +++ b/internal/bots/finance/utils.go @@ -31,7 +31,7 @@ The bill text is as follows: func billParser(ctx context.Context, billText string) (string, error) { template := billPrompt + billText - llm, err := agents.ChatModel(ctx, agents.Model()) + llm, err := agents.ChatModel(ctx, agents.AgentModelName(agents.AgentBillClassify)) if err != nil { return "", fmt.Errorf("chat model failed, %w", err) } diff --git a/internal/bots/gitea/utils.go b/internal/bots/gitea/utils.go index 0c3b6f2f..e7a95e88 100644 --- a/internal/bots/gitea/utils.go +++ b/internal/bots/gitea/utils.go @@ -164,7 +164,7 @@ func llmAnalyzeCode(ctx context.Context, codeContext CodeContext) (*ReviewResult "{commit_message}", codeContext.Metadata["commit_message"]), "{diff}", chunk.Diff), "{files_context}", filesContextStr.String()) - prompt = strings.ReplaceAll(prompt, "{language}", config.App.Agent.Language) + prompt = strings.ReplaceAll(prompt, "{language}", config.App.Flowbot.Language) if prompt == "" { flog.Error(fmt.Errorf("empty prompt after formatting")) @@ -175,7 +175,7 @@ func llmAnalyzeCode(ctx context.Context, codeContext CodeContext) (*ReviewResult flog.Info("[gitea] Sending request to LLM model with prompt size: %d characters", len(prompt)) // Call LLM to get response - responseText, err := agents.LLMGenerate(ctx, prompt) + responseText, err := agents.LLMGenerate(ctx, agents.AgentModelName(agents.AgentRepoReviewComment), prompt) if err != nil { flog.Error(fmt.Errorf("error calling LLM model: %w", err)) return nil, fmt.Errorf("error getting LLM response: %w", err) diff --git a/internal/bots/reader/cron.go b/internal/bots/reader/cron.go index baf030ac..93176b15 100644 --- a/internal/bots/reader/cron.go +++ b/internal/bots/reader/cron.go @@ -2,6 +2,7 @@ package reader import ( "fmt" + "github.com/flowline-io/flowbot/internal/agents" "strings" "time" @@ -94,19 +95,19 @@ using concise and professional language, completing within five categories, with highlighting importance and timeliness. Do not answer questions within the content.` // greeting - greeting, err := getAIResult(ctx.Context(), greetingPrompt, time.Now().Format(time.DateTime)) + greeting, err := getAIResult(ctx.Context(), agents.AgentModelName(agents.AgentNewsSummary), greetingPrompt, time.Now().Format(time.DateTime)) if err != nil { flog.Error(err) return nil } // summary_block - summaryBlock, err := getAIResult(ctx.Context(), summaryPrompt, contents.String()) + summaryBlock, err := getAIResult(ctx.Context(), agents.AgentModelName(agents.AgentNewsSummary), summaryPrompt, contents.String()) if err != nil { flog.Error(err) return nil } // summary - summary, err := getAIResult(ctx.Context(), summaryBlockPrompt, contents.String()) + summary, err := getAIResult(ctx.Context(), agents.AgentModelName(agents.AgentNewsSummary), summaryBlockPrompt, contents.String()) if err != nil { flog.Error(err) return nil diff --git a/internal/bots/reader/utils.go b/internal/bots/reader/utils.go index 13939830..462e5146 100644 --- a/internal/bots/reader/utils.go +++ b/internal/bots/reader/utils.go @@ -7,12 +7,12 @@ import ( "github.com/flowline-io/flowbot/internal/agents" ) -func getAIResult(ctx context.Context, prompt, request string) (string, error) { +func getAIResult(ctx context.Context, modelName, prompt, request string) (string, error) { messages, err := agents.DefaultTemplate().Format(ctx, map[string]any{ "content": fmt.Sprintf("%s\n---\n%s", request, prompt), }) - llm, err := agents.ChatModel(ctx, agents.Model()) + llm, err := agents.ChatModel(ctx, modelName) if err != nil { return "", fmt.Errorf("%s bot, chat model failed, %w", Name, err) } diff --git a/internal/bots/workflow/workflow.go b/internal/bots/workflow/workflow.go index df4a7759..a410b767 100644 --- a/internal/bots/workflow/workflow.go +++ b/internal/bots/workflow/workflow.go @@ -291,7 +291,7 @@ var workflowRules = []workflow.Rule{ return nil, fmt.Errorf("%s step, prompt format failed, %w", llmWorkflowActionID, err) } - llm, err := agents.ChatModel(ctx.Context(), agents.Model()) + llm, err := agents.ChatModel(ctx.Context(), agents.AgentModelName(agents.AgentChat)) if err != nil { return nil, fmt.Errorf("%s step, llm create failed, %w", llmWorkflowActionID, err) } diff --git a/internal/server/func.go b/internal/server/func.go index 2e835b12..d4756f83 100644 --- a/internal/server/func.go +++ b/internal/server/func.go @@ -237,7 +237,7 @@ func directIncomingMessage(caller *platforms.Caller, e protocol.Event) { flog.Error(err) return } - agent, err := agents.ReactAgent(ctx.Context(), tools) + agent, err := agents.ReactAgent(ctx.Context(), agents.AgentModelName(agents.AgentReact), tools) if err != nil { flog.Error(err) return @@ -287,7 +287,7 @@ func directIncomingMessage(caller *platforms.Caller, e protocol.Event) { return } - llm, err := agents.ChatModel(ctx.Context(), agents.Model()) + llm, err := agents.ChatModel(ctx.Context(), agents.AgentModelName(agents.AgentChat)) if err != nil { flog.Error(fmt.Errorf("failed to get chat model: %w", err)) return diff --git a/internal/store/store.go b/internal/store/store.go index cd8c6435..caa3912d 100644 --- a/internal/store/store.go +++ b/internal/store/store.go @@ -115,7 +115,7 @@ func UseMediaHandler(name, config string) error { return mediaHandler.Init(config) } -// PersistentStorageInterface defines methods used for interation with persistent storage. +// PersistentStorageInterface defines methods used for interaction with persistent storage. type PersistentStorageInterface interface { Open(jsonConfig config.StoreType) error Close() error diff --git a/pkg/config/config.go b/pkg/config/config.go index 1bd013af..3bb70655 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -68,8 +68,11 @@ type Type struct { // Alarm Alarm Alarm `json:"alarm" yaml:"alarm" mapstructure:"alarm"` - // Agent - Agent Agent `json:"agent" yaml:"agent" mapstructure:"agent"` + // Models + Models []Model `json:"models" yaml:"models" mapstructure:"models"` + + // Agents + Agents []Agent `json:"agents" yaml:"agents" mapstructure:"agents"` } // Large file handler config. @@ -234,6 +237,8 @@ type Flowbot struct { URL string `json:"url" yaml:"url" mapstructure:"url"` // Flowbot channel path ChannelPath string `json:"channel_path" yaml:"channel_path" mapstructure:"channel_path"` + // language + Language string `json:"language" yaml:"language" mapstructure:"language"` } type Alarm struct { @@ -244,16 +249,23 @@ type Alarm struct { } type Agent struct { - // Agent token - Token string `json:"token" yaml:"token" mapstructure:"token"` - // Agent base URL - BaseUrl string `json:"base_url" yaml:"base_url" mapstructure:"base_url"` - // Agent model + // Agent Name + Name string `json:"name" yaml:"name" mapstructure:"name"` + // Enabled + Enabled bool `json:"enabled" yaml:"enabled" mapstructure:"enabled"` + // Use model Model string `json:"model" yaml:"model" mapstructure:"model"` - // Agent tool model - ToolModel string `json:"tool_model" yaml:"tool_model" mapstructure:"tool_model"` - // Agent language - Language string `json:"language" yaml:"language" mapstructure:"language"` +} + +type Model struct { + // Protocol + Protocol string `json:"protocol" yaml:"protocol" mapstructure:"protocol"` + // Base URL + BaseUrl string `json:"base_url" yaml:"base_url" mapstructure:"base_url"` + // API key + ApiKey string `json:"api_key" yaml:"api_key" mapstructure:"api_key"` + // Useful model names + ModelNames []string `json:"model_names" yaml:"model_names" mapstructure:"model_names"` } func Load(path ...string) { From aa988e4b703215a37786346abf6e4148465b8280 Mon Sep 17 00:00:00 2001 From: sysatom Date: Sat, 17 May 2025 02:05:38 +0800 Subject: [PATCH 083/125] =?UTF-8?q?=F0=9F=94=A7=20fix:=20Enable=20chat=20a?= =?UTF-8?q?gent=20check=20in=20workflow=20=F0=9F=94=A7=20fix:=20Enable=20e?= =?UTF-8?q?xtract=20tags=20agent=20in=20cron=20=F0=9F=94=A7=20fix:=20Enabl?= =?UTF-8?q?e=20repo=20review=20comment=20agent=20in=20gitea=20hook=20?= =?UTF-8?q?=F0=9F=94=A7=20fix:=20Enable=20bill=20classify=20agent=20in=20f?= =?UTF-8?q?inance=20utils=20=F0=9F=94=A7=20fix:=20Enable=20news=20summary?= =?UTF-8?q?=20agent=20in=20reader=20cron=20=F0=9F=94=A7=20fix:=20Enable=20?= =?UTF-8?q?react=20agent=20in=20dev=20webhook=20=F0=9F=94=A7=20fix:=20Enab?= =?UTF-8?q?le=20chat=20agent=20in=20dev=20command?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/agents/agent.go | 15 ++++++++++++++- internal/bots/bookmark/cron.go | 11 +++++++++++ internal/bots/dev/command.go | 3 +++ internal/bots/dev/webhook.go | 3 +++ internal/bots/finance/utils.go | 7 ++++++- internal/bots/gitea/hook.go | 5 +++++ internal/bots/reader/cron.go | 5 +++++ internal/bots/workflow/workflow.go | 3 +++ 8 files changed, 50 insertions(+), 2 deletions(-) diff --git a/internal/agents/agent.go b/internal/agents/agent.go index 34940a84..2f27908b 100644 --- a/internal/agents/agent.go +++ b/internal/agents/agent.go @@ -23,12 +23,16 @@ const ( var agents = make(map[string]config.Agent) var loadOnceAgents = sync.Once{} -func AgentModelName(name string) string { +func loadAgents() { loadOnceAgents.Do(func() { for _, item := range config.App.Agents { agents[item.Name] = item } }) +} + +func AgentModelName(name string) string { + loadAgents() a, ok := agents[name] if !ok || a.Enabled == false { return "" @@ -36,6 +40,15 @@ func AgentModelName(name string) string { return a.Model } +func AgentEnabled(name string) bool { + loadAgents() + a, ok := agents[name] + if !ok || a.Enabled == false { + return false + } + return true +} + func ReactAgent(ctx context.Context, modelName string, tools []tool.BaseTool) (*react.Agent, error) { llm, err := ChatModel(ctx, modelName) if err != nil { diff --git a/internal/bots/bookmark/cron.go b/internal/bots/bookmark/cron.go index ec050f4f..3783b0cd 100644 --- a/internal/bots/bookmark/cron.go +++ b/internal/bots/bookmark/cron.go @@ -2,6 +2,7 @@ package bookmark import ( "fmt" + "github.com/flowline-io/flowbot/internal/agents" "time" "github.com/flowline-io/flowbot/pkg/config" @@ -22,6 +23,11 @@ var cronRules = []cron.Rule{ Scope: cron.CronScopeSystem, When: "0 2 * * *", Action: func(ctx types.Context) []types.MsgPayload { + if !agents.AgentEnabled(agents.AgentExtractTags) { + flog.Info("agent extract tags disabled") + return nil + } + client := hoarder.GetClient() resp, err := client.GetAllBookmarks(nil) if err != nil { @@ -166,6 +172,11 @@ var cronRules = []cron.Rule{ Scope: cron.CronScopeSystem, When: "0 2 * * *", Action: func(ctx types.Context) []types.MsgPayload { + if !agents.AgentEnabled(agents.AgentSimilarTags) { + flog.Info("agent similar tags disabled") + return nil + } + // Get all tags client := hoarder.GetClient() tags, err := client.GetAllTags() diff --git a/internal/bots/dev/command.go b/internal/bots/dev/command.go index 1fb2ea6c..ffaf7499 100644 --- a/internal/bots/dev/command.go +++ b/internal/bots/dev/command.go @@ -133,6 +133,9 @@ var commandRules = []command.Rule{ Define: "llm test", Help: `[example] LLM example`, Handler: func(ctx types.Context, tokens []*parser.Token) types.MsgPayload { + if !agents.AgentEnabled(agents.AgentChat) { + return types.TextMsg{Text: "agent chat disabled"} + } messages, err := agents.DefaultTemplate().Format(ctx.Context(), map[string]any{ "content": "Who was the first man to walk on the moon?", }) diff --git a/internal/bots/dev/webhook.go b/internal/bots/dev/webhook.go index cbb16861..e9f91464 100644 --- a/internal/bots/dev/webhook.go +++ b/internal/bots/dev/webhook.go @@ -34,6 +34,9 @@ var webhookRules = []webhook.Rule{ if ctx.Method != http.MethodPost { return types.TextMsg{Text: "error method"} } + if !agents.AgentEnabled(agents.AgentReact) { + return types.TextMsg{Text: "agent react disabled"} + } var param struct { Text string `json:"text"` diff --git a/internal/bots/finance/utils.go b/internal/bots/finance/utils.go index a63b739a..9ecc5bd9 100644 --- a/internal/bots/finance/utils.go +++ b/internal/bots/finance/utils.go @@ -3,13 +3,18 @@ package finance import ( "context" "fmt" - "github.com/cloudwego/eino/components/prompt" "github.com/cloudwego/eino/schema" "github.com/flowline-io/flowbot/internal/agents" + "github.com/flowline-io/flowbot/pkg/flog" ) func classify(ctx context.Context) { + if !agents.AgentEnabled(agents.AgentBillClassify) { + flog.Info("agent bill classify disabled") + return + } + template := prompt.FromMessages(schema.GoTemplate, schema.UserMessage(`Given i want to categorize transactions on my bank account into this categories: {{.categories}} In which category would a transaction from "{{.destination_name}}" with the subject "{{.description}}" fall into? diff --git a/internal/bots/gitea/hook.go b/internal/bots/gitea/hook.go index a65c4ff4..da6819da 100644 --- a/internal/bots/gitea/hook.go +++ b/internal/bots/gitea/hook.go @@ -2,6 +2,7 @@ package gitea import ( "fmt" + "github.com/flowline-io/flowbot/internal/agents" "time" "github.com/flowline-io/flowbot/pkg/config" @@ -24,6 +25,10 @@ func hookIssueClosed(ctx types.Context, issue *gitea.IssuePayload) error { } func hookPush(ctx types.Context, payload *gitea.RepoPayload) error { + if !agents.AgentEnabled(agents.AgentRepoReviewComment) { + return fmt.Errorf("agent repo review comment disabled") + } + ctx.SetTimeout(10 * time.Minute) owner := payload.Repository.Owner.UserName repo := payload.Repository.Name diff --git a/internal/bots/reader/cron.go b/internal/bots/reader/cron.go index 93176b15..e028837e 100644 --- a/internal/bots/reader/cron.go +++ b/internal/bots/reader/cron.go @@ -49,6 +49,11 @@ var cronRules = []cron.Rule{ Scope: cron.CronScopeUser, When: "0 9 * * *", Action: func(ctx types.Context) []types.MsgPayload { + if !agents.AgentEnabled(agents.AgentNewsSummary) { + flog.Info("agent news summary disabled") + return nil + } + client := miniflux.GetClient() resp, err := client.GetEntries(&rssClient.Filter{Status: rssClient.EntryStatusUnread, Limit: 10000}) diff --git a/internal/bots/workflow/workflow.go b/internal/bots/workflow/workflow.go index a410b767..b593a205 100644 --- a/internal/bots/workflow/workflow.go +++ b/internal/bots/workflow/workflow.go @@ -273,6 +273,9 @@ var workflowRules = []workflow.Rule{ InputSchema: nil, OutputSchema: nil, Run: func(ctx types.Context, input types.KV) (types.KV, error) { + if !agents.AgentEnabled(agents.AgentChat) { + return nil, fmt.Errorf("%s step, agent chat disabled", llmWorkflowActionID) + } ctx.SetTimeout(10 * time.Minute) promptVal, _ := input.String("prompt") if promptVal == "" { From 28d8018759261a2c2733e0b6c466d520f671f695 Mon Sep 17 00:00:00 2001 From: sysatom Date: Sat, 17 May 2025 11:50:27 +0800 Subject: [PATCH 084/125] =?UTF-8?q?=F0=9F=90=B6=20feat(model.go):=20Add=20?= =?UTF-8?q?model=20provider=20support=20for=20OpenAI,=20Ollama,=20and=20Op?= =?UTF-8?q?enAI=20Compatible=20=F0=9F=90=B6=20feat(config.go):=20Update=20?= =?UTF-8?q?Model=20configuration=20to=20use=20'provider'=20instead=20of=20?= =?UTF-8?q?'protocol'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/config.yaml | 2 +- go.mod | 4 +++- go.sum | 11 ++++++++--- internal/agents/model.go | 38 ++++++++++++++++++++++++++++++++------ pkg/config/config.go | 4 ++-- 5 files changed, 46 insertions(+), 13 deletions(-) diff --git a/docs/config.yaml b/docs/config.yaml index e0e81b6b..8befd493 100644 --- a/docs/config.yaml +++ b/docs/config.yaml @@ -108,7 +108,7 @@ alarm: # Model configuration models: - - protocol: "openai" # openai, openai-compatible, ollama + - provider: "openai" # openai, openai-compatible, ollama ... base_url: "https://api.openai.com/v1" api_key: "" model_names: diff --git a/go.mod b/go.mod index f3eebe3c..ff2e19e8 100644 --- a/go.mod +++ b/go.mod @@ -16,6 +16,7 @@ require ( github.com/bytedance/sonic v1.13.2 github.com/cenkalti/backoff v2.2.1+incompatible github.com/cloudwego/eino v0.3.33 + github.com/cloudwego/eino-ext/components/model/ollama v0.0.0-20250514085234-473e80da5261 github.com/cloudwego/eino-ext/components/model/openai v0.0.0-20250507115047-b20720df8528 github.com/creachadair/jrpc2 v1.3.1 github.com/dgraph-io/ristretto/v2 v2.2.0 @@ -107,7 +108,7 @@ require ( github.com/davidmz/go-pageant v1.0.2 // indirect github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect github.com/distribution/reference v0.6.0 // indirect - github.com/dlclark/regexp2 v1.10.0 // indirect + github.com/dlclark/regexp2 v1.11.4 // indirect github.com/docker/go-connections v0.5.0 // indirect github.com/ebitengine/purego v0.8.2 // indirect github.com/emirpasic/gods v1.18.1 // indirect @@ -169,6 +170,7 @@ require ( github.com/oklog/ulid v1.3.1 // indirect github.com/oklog/ulid/v2 v2.1.0 // indirect github.com/olekukonko/tablewriter v0.0.5 // indirect + github.com/ollama/ollama v0.5.12 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect github.com/opencontainers/image-spec v1.1.0 // indirect github.com/pelletier/go-toml/v2 v2.2.3 // indirect diff --git a/go.sum b/go.sum index ca06d23b..007f3144 100644 --- a/go.sum +++ b/go.sum @@ -67,6 +67,8 @@ github.com/cloudwego/base64x v0.1.5 h1:XPciSp1xaq2VCSt6lF0phncD4koWyULpl5bUxbfCy github.com/cloudwego/base64x v0.1.5/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w= github.com/cloudwego/eino v0.3.33 h1:C7BXUiLfyVDt0u+77B9X47nJ2OqzPPJ4kzTjRy+QuQ8= github.com/cloudwego/eino v0.3.33/go.mod h1:wUjz990apdsaOraOXdh6CdhVXq8DJsOvLsVlxNTcNfY= +github.com/cloudwego/eino-ext/components/model/ollama v0.0.0-20250514085234-473e80da5261 h1:LPzVDc6RsrMR4mPmpe5kHMn4b3bfmFMc2koSaHRH6dQ= +github.com/cloudwego/eino-ext/components/model/ollama v0.0.0-20250514085234-473e80da5261/go.mod h1:giNUFqA+V7xrm/EDvH7JFnDqoWI+e2m1SVAnReU+Fd8= github.com/cloudwego/eino-ext/components/model/openai v0.0.0-20250507115047-b20720df8528 h1:LWlv4+NUNKVG2ojRtEbMDhExS45DH1t+kXakBCB3+Cw= github.com/cloudwego/eino-ext/components/model/openai v0.0.0-20250507115047-b20720df8528/go.mod h1:uXIWTFbaAbZ1128EIXjFc4S+tDqmz1idMZd5qt5kkwU= github.com/cloudwego/eino-ext/libs/acl/openai v0.0.0-20250422092704-54e372e1fa3d h1:unNqPz9vuJmJCZAw5YKFcszRX9e3CdVEjh0lR6QArxk= @@ -98,8 +100,8 @@ github.com/dhui/dktest v0.4.5 h1:uUfYBIVREmj/Rw6MvgmqNAYzTiKOHJak+enB5Di73MM= github.com/dhui/dktest v0.4.5/go.mod h1:tmcyeHDKagvlDrz7gDKq4UAJOLIfVZYkfD5OnHDwcCo= github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5QvfrDyIgxBk= github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E= -github.com/dlclark/regexp2 v1.10.0 h1:+/GIL799phkJqYW+3YbOd8LCcbHzT0Pbo8zl70MHsq0= -github.com/dlclark/regexp2 v1.10.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= +github.com/dlclark/regexp2 v1.11.4 h1:rPYF9/LECdNymJufQKmri9gV604RvvABwgOA8un7yAo= +github.com/dlclark/regexp2 v1.11.4/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= github.com/docker/cli v28.1.1+incompatible h1:eyUemzeI45DY7eDPuwUcmDyDj1pM98oD5MdSpiItp8k= github.com/docker/cli v28.1.1+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= github.com/docker/docker v28.1.1+incompatible h1:49M11BFLsVO1gxY9UX9p/zwkE/rswggs8AdFmXQw51I= @@ -386,6 +388,8 @@ github.com/oklog/ulid/v2 v2.1.0 h1:+9lhoxAP56we25tyYETBBY1YLA2SaoLvUFgrP2miPJU= github.com/oklog/ulid/v2 v2.1.0/go.mod h1:rcEKHmBBKfef9DhnvX7y1HZBYxjXb0cP5ExxNsTT1QQ= github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= +github.com/ollama/ollama v0.5.12 h1:qM+k/ozyHLJzEQoAEPrUQ0qXqsgDEEdpIVwuwScrd2U= +github.com/ollama/ollama v0.5.12/go.mod h1:ibdmDvb/TjKY1OArBWIazL3pd1DHTk8eG2MMjEkWhiI= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.8.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= @@ -506,8 +510,9 @@ github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= github.com/ugorji/go v1.2.7 h1:qYhyWUUd6WbiM+C6JZAUkIJt/1WrjzNHY9+KCIjVqTo= github.com/ugorji/go v1.2.7/go.mod h1:nF9osbDWLy6bDVv/Rtoh6QgnvNDpmCalQV5urGCCS6M= -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/urfave/cli/v2 v2.27.6 h1:VdRdS98FNhKZ8/Az8B7MTyGQmpIr36O1EHybx/LaZ4g= github.com/urfave/cli/v2 v2.27.6/go.mod h1:3Sevf16NykTbInEnD0yKkjDAeZDS0A6bzhBH5hrMvTQ= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= diff --git a/internal/agents/model.go b/internal/agents/model.go index f649e901..1c12b237 100644 --- a/internal/agents/model.go +++ b/internal/agents/model.go @@ -3,6 +3,7 @@ package agents import ( "context" "fmt" + "github.com/cloudwego/eino-ext/components/model/ollama" "github.com/cloudwego/eino-ext/components/model/openai" "github.com/cloudwego/eino/components/model" "github.com/flowline-io/flowbot/pkg/config" @@ -10,6 +11,12 @@ import ( "time" ) +const ( + ProviderOpenAI = "openai" + ProviderOpenAICompatible = "openai-compatible" + ProviderOllama = "ollama" +) + var models = make(map[string]config.Model) var loadOnceModels = sync.Once{} @@ -28,11 +35,30 @@ func ChatModel(ctx context.Context, modelName string) (model.ToolCallingChatMode if modelName == "" { return nil, fmt.Errorf("model or agent disabled") } + timeout := 10 * time.Minute + m := GetModel(modelName) - return openai.NewChatModel(ctx, &openai.ChatModelConfig{ - BaseURL: m.BaseUrl, - APIKey: m.ApiKey, - Model: modelName, - Timeout: 10 * time.Minute, - }) + switch m.Provider { + case ProviderOpenAI: + return openai.NewChatModel(ctx, &openai.ChatModelConfig{ + APIKey: m.ApiKey, + Model: modelName, + Timeout: timeout, + }) + case ProviderOpenAICompatible: + return openai.NewChatModel(ctx, &openai.ChatModelConfig{ + BaseURL: m.BaseUrl, + APIKey: m.ApiKey, + Model: modelName, + Timeout: timeout, + }) + case ProviderOllama: + return ollama.NewChatModel(ctx, &ollama.ChatModelConfig{ + BaseURL: m.BaseUrl, + Model: modelName, + Timeout: timeout, + }) + } + + return nil, fmt.Errorf("model provider not found") } diff --git a/pkg/config/config.go b/pkg/config/config.go index 3bb70655..b1a7077e 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -258,8 +258,8 @@ type Agent struct { } type Model struct { - // Protocol - Protocol string `json:"protocol" yaml:"protocol" mapstructure:"protocol"` + // Provider + Provider string `json:"provider" yaml:"provider" mapstructure:"provider"` // Base URL BaseUrl string `json:"base_url" yaml:"base_url" mapstructure:"base_url"` // API key From c9aced3941ea0383ee46104061feb1fe6bcc8f91 Mon Sep 17 00:00:00 2001 From: sysatom Date: Mon, 19 May 2025 11:51:35 +0800 Subject: [PATCH 085/125] opt: main fx --- cmd/main.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/cmd/main.go b/cmd/main.go index 088e9cd4..77f8ad1b 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -20,11 +20,7 @@ import ( // @name X-AccessToken // @description access token func main() { - // server.Run() fx.New( server.Modules, - // fx.WithLogger(func(log *zap.Logger) fxevent.Logger { - // return &fxevent.ZapLogger{Logger: log} - // }), ).Run() } From a5bd6f6bb92fc75008918bbfa435393fed526cec Mon Sep 17 00:00:00 2001 From: sysatom Date: Mon, 19 May 2025 13:44:17 +0800 Subject: [PATCH 086/125] opt: agent check --- internal/agents/agent.go | 7 +++++-- internal/bots/gitea/hook.go | 6 ++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/internal/agents/agent.go b/internal/agents/agent.go index 2f27908b..443eeecb 100644 --- a/internal/agents/agent.go +++ b/internal/agents/agent.go @@ -34,7 +34,7 @@ func loadAgents() { func AgentModelName(name string) string { loadAgents() a, ok := agents[name] - if !ok || a.Enabled == false { + if !ok || !a.Enabled { return "" } return a.Model @@ -43,7 +43,10 @@ func AgentModelName(name string) string { func AgentEnabled(name string) bool { loadAgents() a, ok := agents[name] - if !ok || a.Enabled == false { + if !ok || !a.Enabled { + return false + } + if a.Model == "" { return false } return true diff --git a/internal/bots/gitea/hook.go b/internal/bots/gitea/hook.go index da6819da..912bb841 100644 --- a/internal/bots/gitea/hook.go +++ b/internal/bots/gitea/hook.go @@ -2,11 +2,12 @@ package gitea import ( "fmt" - "github.com/flowline-io/flowbot/internal/agents" "time" + "github.com/flowline-io/flowbot/internal/agents" "github.com/flowline-io/flowbot/pkg/config" "github.com/flowline-io/flowbot/pkg/event" + "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/providers/gitea" "github.com/flowline-io/flowbot/pkg/providers/kanboard" "github.com/flowline-io/flowbot/pkg/types" @@ -26,7 +27,8 @@ func hookIssueClosed(ctx types.Context, issue *gitea.IssuePayload) error { func hookPush(ctx types.Context, payload *gitea.RepoPayload) error { if !agents.AgentEnabled(agents.AgentRepoReviewComment) { - return fmt.Errorf("agent repo review comment disabled") + flog.Info("agent repo review comment disabled") + return nil } ctx.SetTimeout(10 * time.Minute) From c6477d6e73ab606116d1e81dc0f9bdb8153cf8fa Mon Sep 17 00:00:00 2001 From: sysatom Date: Mon, 19 May 2025 14:05:39 +0800 Subject: [PATCH 087/125] fix: archives.format DEPRECATED --- .goreleaser.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 6615286e..fb21efd3 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -32,7 +32,7 @@ builds: - -s -w -X github.com/flowline-io/flowbot/version.Buildstamp={{.Date}} archives: - - format: binary + - formats: [ 'binary' ] # this name template makes the OS and Arch compatible with the results of `uname`. name_template: >- {{ .ProjectName }}_{{ .Os }}_{{ .Arch }} From 732301482c7f8750463545d207c7c6194f9af2f5 Mon Sep 17 00:00:00 2001 From: sysatom Date: Mon, 19 May 2025 16:03:08 +0800 Subject: [PATCH 088/125] feat: MCP server --- .goreleaser.yaml | 2 +- go.mod | 2 + go.sum | 4 ++ internal/agents/mcp/prompt.go | 96 +++++++++++++++++++++++++++++++++ internal/agents/mcp/resource.go | 71 ++++++++++++++++++++++++ internal/agents/mcp/server.go | 38 +++++++++++++ internal/agents/mcp/tool.go | 51 ++++++++++++++++++ internal/server/modules.go | 3 ++ internal/server/router.go | 9 +++- 9 files changed, 273 insertions(+), 3 deletions(-) create mode 100644 internal/agents/mcp/prompt.go create mode 100644 internal/agents/mcp/resource.go create mode 100644 internal/agents/mcp/server.go create mode 100644 internal/agents/mcp/tool.go diff --git a/.goreleaser.yaml b/.goreleaser.yaml index fb21efd3..28aaa30a 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -32,7 +32,7 @@ builds: - -s -w -X github.com/flowline-io/flowbot/version.Buildstamp={{.Date}} archives: - - formats: [ 'binary' ] + - formats: ["binary"] # this name template makes the OS and Arch compatible with the results of `uname`. name_template: >- {{ .ProjectName }}_{{ .Os }}_{{ .Arch }} diff --git a/go.mod b/go.mod index ff2e19e8..412d417e 100644 --- a/go.mod +++ b/go.mod @@ -47,6 +47,7 @@ require ( github.com/json-iterator/go v1.1.12 github.com/lithammer/shortuuid/v4 v4.2.0 github.com/looplab/fsm v1.0.3 + github.com/mark3labs/mcp-go v0.28.0 github.com/maxence-charriere/go-app/v10 v10.1.3 github.com/meilisearch/meilisearch-go v0.32.0 github.com/minio/minio-go/v7 v7.0.91 @@ -206,6 +207,7 @@ require ( github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect github.com/yargevad/filepathx v1.0.0 // indirect + github.com/yosida95/uritemplate/v3 v3.0.2 // indirect github.com/yusufpapurcu/wmi v1.2.4 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0 // indirect go.opentelemetry.io/otel v1.29.0 // indirect diff --git a/go.sum b/go.sum index 007f3144..ec60b794 100644 --- a/go.sum +++ b/go.sum @@ -319,6 +319,8 @@ github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJ github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= github.com/mailru/easyjson v0.9.0 h1:PrnmzHw7262yW8sTBwxi1PdJA3Iw/EKBa8psRf7d9a4= github.com/mailru/easyjson v0.9.0/go.mod h1:1+xMtQp2MRNVL/V1bOzuP3aP8VNwRW55fQUto+XFtTU= +github.com/mark3labs/mcp-go v0.28.0 h1:7yl4y5D1KYU2f/9Uxp7xfLIggfunHoESCRbrjcytcLM= +github.com/mark3labs/mcp-go v0.28.0/go.mod h1:rXqOudj/djTORU/ThxYx8fqEVj/5pvTuuebQ2RC7uk4= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= @@ -533,6 +535,8 @@ github.com/xyproto/randomstring v1.0.5 h1:YtlWPoRdgMu3NZtP45drfy1GKoojuR7hmRcnhZ github.com/xyproto/randomstring v1.0.5/go.mod h1:rgmS5DeNXLivK7YprL0pY+lTuhNQW3iGxZ18UQApw/E= github.com/yargevad/filepathx v1.0.0 h1:SYcT+N3tYGi+NvazubCNlvgIPbzAk7i7y2dwg3I5FYc= github.com/yargevad/filepathx v1.0.0/go.mod h1:BprfX/gpYNJHJfc35GjRRpVcwWXS89gGulUIU5tK3tA= +github.com/yosida95/uritemplate/v3 v3.0.2 h1:Ed3Oyj9yrmi9087+NczuL5BwkIc4wvTb5zIM+UJPGz4= +github.com/yosida95/uritemplate/v3 v3.0.2/go.mod h1:ILOh0sOhIJR3+L/8afwt/kE++YT040gmv5BQTMR2HP4= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= diff --git a/internal/agents/mcp/prompt.go b/internal/agents/mcp/prompt.go new file mode 100644 index 00000000..5befb272 --- /dev/null +++ b/internal/agents/mcp/prompt.go @@ -0,0 +1,96 @@ +package mcp + +import ( + "context" + "fmt" + + "github.com/mark3labs/mcp-go/mcp" + "github.com/mark3labs/mcp-go/server" +) + +func Prompts(s *server.MCPServer) { + // Simple greeting prompt + s.AddPrompt(mcp.NewPrompt("greeting", + mcp.WithPromptDescription("A friendly greeting prompt"), + mcp.WithArgument("name", + mcp.ArgumentDescription("Name of the person to greet"), + ), + ), func(ctx context.Context, request mcp.GetPromptRequest) (*mcp.GetPromptResult, error) { + name := request.Params.Arguments["name"] + if name == "" { + name = "friend" + } + + return mcp.NewGetPromptResult( + "A friendly greeting", + []mcp.PromptMessage{ + mcp.NewPromptMessage( + mcp.RoleAssistant, + mcp.NewTextContent(fmt.Sprintf("Hello, %s! How can I help you today?", name)), + ), + }, + ), nil + }) + + // Code review prompt with embedded resource + s.AddPrompt(mcp.NewPrompt("code_review", + mcp.WithPromptDescription("Code review assistance"), + mcp.WithArgument("pr_number", + mcp.ArgumentDescription("Pull request number to review"), + mcp.RequiredArgument(), + ), + ), func(ctx context.Context, request mcp.GetPromptRequest) (*mcp.GetPromptResult, error) { + prNumber := request.Params.Arguments["pr_number"] + if prNumber == "" { + return nil, fmt.Errorf("pr_number is required") + } + + return mcp.NewGetPromptResult( + "Code review assistance", + []mcp.PromptMessage{ + mcp.NewPromptMessage( + mcp.RoleUser, + mcp.NewTextContent("Review the changes and provide constructive feedback."), + ), + mcp.NewPromptMessage( + mcp.RoleAssistant, + mcp.NewEmbeddedResource(mcp.TextResourceContents{ + URI: fmt.Sprintf("git://pulls/%s/diff", prNumber), + MIMEType: "text/x-diff", + }), + ), + }, + ), nil + }) + + // Database query builder prompt + s.AddPrompt(mcp.NewPrompt("query_builder", + mcp.WithPromptDescription("SQL query builder assistance"), + mcp.WithArgument("table", + mcp.ArgumentDescription("Name of the table to query"), + mcp.RequiredArgument(), + ), + ), func(ctx context.Context, request mcp.GetPromptRequest) (*mcp.GetPromptResult, error) { + tableName := request.Params.Arguments["table"] + if tableName == "" { + return nil, fmt.Errorf("table name is required") + } + + return mcp.NewGetPromptResult( + "SQL query builder assistance", + []mcp.PromptMessage{ + mcp.NewPromptMessage( + mcp.RoleUser, + mcp.NewTextContent("Help construct efficient and safe queries for the provided schema."), + ), + mcp.NewPromptMessage( + mcp.RoleUser, + mcp.NewEmbeddedResource(mcp.TextResourceContents{ + URI: fmt.Sprintf("db://schema/%s", tableName), + MIMEType: "application/json", + }), + ), + }, + ), nil + }) +} diff --git a/internal/agents/mcp/resource.go b/internal/agents/mcp/resource.go new file mode 100644 index 00000000..cf20d498 --- /dev/null +++ b/internal/agents/mcp/resource.go @@ -0,0 +1,71 @@ +package mcp + +import ( + "context" + "os" + + "github.com/mark3labs/mcp-go/mcp" + "github.com/mark3labs/mcp-go/server" +) + +func Resources(s *server.MCPServer) { + // Static resource example - exposing a README file + resource := mcp.NewResource( + "docs://readme", + "Project README", + mcp.WithResourceDescription("The project's README file"), + mcp.WithMIMEType("text/markdown"), + ) + + // Add resource with its handler + s.AddResource(resource, func(ctx context.Context, request mcp.ReadResourceRequest) ([]mcp.ResourceContents, error) { + content, err := os.ReadFile("README.md") + if err != nil { + return nil, err + } + + return []mcp.ResourceContents{ + mcp.TextResourceContents{ + URI: "docs://readme", + MIMEType: "text/markdown", + Text: string(content), + }, + }, nil + }) + + // Dynamic resource example - user profiles by ID + template := mcp.NewResourceTemplate( + "users://{id}/profile", + "User Profile", + mcp.WithTemplateDescription("Returns user profile information"), + mcp.WithTemplateMIMEType("application/json"), + ) + + // Add template with its handler + s.AddResourceTemplate(template, func(ctx context.Context, request mcp.ReadResourceRequest) ([]mcp.ResourceContents, error) { + // Extract ID from the URI using regex matching + // The server automatically matches URIs to templates + userID := extractIDFromURI(request.Params.URI) + + profile, err := getUserProfile(userID) // Your DB/API call here + if err != nil { + return nil, err + } + + return []mcp.ResourceContents{ + mcp.TextResourceContents{ + URI: request.Params.URI, + MIMEType: "application/json", + Text: profile, + }, + }, nil + }) +} + +func getUserProfile(_ any) (string, error) { + return "{\"name\": \"John Doe\", \"age\": 30}", nil +} + +func extractIDFromURI(_ string) any { + return "1" +} diff --git a/internal/agents/mcp/server.go b/internal/agents/mcp/server.go new file mode 100644 index 00000000..e725aca9 --- /dev/null +++ b/internal/agents/mcp/server.go @@ -0,0 +1,38 @@ +package mcp + +import ( + "net/http" + + "github.com/flowline-io/flowbot/pkg/config" + "github.com/flowline-io/flowbot/version" + "github.com/mark3labs/mcp-go/server" +) + +func NewServer() *server.MCPServer { + s := server.NewMCPServer( + "Flowbot MCP Server", + version.Buildtags, + ) + + // register resources + Resources(s) + // register tools + Tools(s) + // register prompts + Prompts(s) + + return s +} + +func NewSSEServer(_ config.Type, mcpServer *server.MCPServer) *server.SSEServer { + sseServer := server.NewSSEServer( + mcpServer, + server.WithDynamicBasePath(func(r *http.Request, sessionID string) string { + return "/mcp/" + }), + server.WithBaseURL(config.App.Flowbot.URL), + server.WithUseFullURLForMessageEndpoint(true), + ) + + return sseServer +} diff --git a/internal/agents/mcp/tool.go b/internal/agents/mcp/tool.go new file mode 100644 index 00000000..6e196bc6 --- /dev/null +++ b/internal/agents/mcp/tool.go @@ -0,0 +1,51 @@ +package mcp + +import ( + "context" + + "github.com/mark3labs/mcp-go/mcp" + "github.com/mark3labs/mcp-go/server" +) + +func Tools(s *server.MCPServer) { + calculatorTool := mcp.NewTool("calculate", + mcp.WithDescription("Perform basic arithmetic calculations"), + mcp.WithString("operation", + mcp.Required(), + mcp.Description("The arithmetic operation to perform"), + mcp.Enum("add", "subtract", "multiply", "divide"), + ), + mcp.WithNumber("x", + mcp.Required(), + mcp.Description("First number"), + ), + mcp.WithNumber("y", + mcp.Required(), + mcp.Description("Second number"), + ), + ) + + s.AddTool(calculatorTool, func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) { + args := request.Params.Arguments + op := args["operation"].(string) + x := args["x"].(float64) + y := args["y"].(float64) + + var result float64 + switch op { + case "add": + result = x + y + case "subtract": + result = x - y + case "multiply": + result = x * y + case "divide": + if y == 0 { + return mcp.NewToolResultError("cannot divide by zero"), nil + } + result = x / y + } + + return mcp.FormatNumberResult(result), nil + }) +} diff --git a/internal/server/modules.go b/internal/server/modules.go index 4a061a72..c0230e8a 100644 --- a/internal/server/modules.go +++ b/internal/server/modules.go @@ -1,6 +1,7 @@ package server import ( + "github.com/flowline-io/flowbot/internal/agents/mcp" "github.com/flowline-io/flowbot/internal/bots" "github.com/flowline-io/flowbot/internal/platforms/slack" "github.com/flowline-io/flowbot/internal/workflow" @@ -28,6 +29,8 @@ var Modules = fx.Options( workflow.NewManager, workflow.NewCronTaskManager, slack.NewDriver, + mcp.NewServer, + mcp.NewSSEServer, newController, newDatabaseAdapter, newHTTPServer, diff --git a/internal/server/router.go b/internal/server/router.go index a44518f9..4c405f52 100644 --- a/internal/server/router.go +++ b/internal/server/router.go @@ -3,7 +3,6 @@ package server import ( "bytes" "errors" - "github.com/flowline-io/flowbot/pkg/chatbot" "net/http" "strconv" "strings" @@ -13,6 +12,7 @@ import ( "github.com/flowline-io/flowbot/internal/platforms/tailchat" "github.com/flowline-io/flowbot/internal/store" "github.com/flowline-io/flowbot/internal/store/model" + "github.com/flowline-io/flowbot/pkg/chatbot" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/page" "github.com/flowline-io/flowbot/pkg/page/form" @@ -26,13 +26,15 @@ import ( "github.com/go-echarts/go-echarts/v2/charts" "github.com/go-echarts/go-echarts/v2/opts" "github.com/gofiber/fiber/v2" + "github.com/gofiber/fiber/v2/middleware/adaptor" + "github.com/mark3labs/mcp-go/server" "github.com/maxence-charriere/go-app/v10/pkg/app" "github.com/samber/oops" "github.com/valyala/fasthttp/fasthttpadaptor" "gorm.io/gorm" ) -func handleRoutes(a *fiber.App, ctl *Controller) { +func handleRoutes(a *fiber.App, mcpSSE *server.SSEServer, ctl *Controller) { // Webservice for _, bot := range chatbot.List() { bot.Webservice(a) @@ -52,6 +54,9 @@ func handleRoutes(a *fiber.App, ctl *Controller) { a.All("/webhook/:flag", ctl.doWebhook) // platform a.All("/chatbot/:platform", ctl.platformCallback) + // mcp + a.All("/mcp/sse", adaptor.HTTPHandler(mcpSSE.SSEHandler())) + a.All("/mcp/message", adaptor.HTTPHandler(mcpSSE.MessageHandler())) } // handler From d38e402d82036bc430fcef177e8f6bdf270cf710 Mon Sep 17 00:00:00 2001 From: sysatom Date: Mon, 19 May 2025 23:44:58 +0800 Subject: [PATCH 089/125] feat: scc --- taskfile.yaml | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/taskfile.yaml b/taskfile.yaml index e8810e4d..cdc961ab 100644 --- a/taskfile.yaml +++ b/taskfile.yaml @@ -6,7 +6,7 @@ tasks: - task: swagger - task: format - task: lint - - task: cloc + - task: scc - echo "Both done" check: @@ -35,9 +35,11 @@ tasks: cloc: cmds: - - cloc --exclude-dir=node_modules --exclude-ext=json --out=./cloc/{{ now.Format "2006-01-02" }}.txt . - generates: - - ./cloc/{{ now.Format "2006-01-02" }}.txt + - cloc --exclude-dir=node_modules --exclude-ext=json . + + scc: + cmds: + - scc > ./cloc/{{ now.Format "2006-01-02" }}.txt lint: cmds: @@ -61,10 +63,7 @@ tasks: - go install github.com/goreleaser/goreleaser/v2@latest - go install github.com/air-verse/air@latest - go install github.com/securego/gosec/v2/cmd/gosec@latest - - cmd: winget install AlDanial.Cloc - platforms: [windows] - - cmd: sudo apt install cloc - platforms: [linux] + - go install github.com/boyter/scc/v3@latest - npm install -g prettier secure: From c65e102f4147a9c9a04dfc0fca357d75fb8895da Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 19 May 2025 16:31:46 +0000 Subject: [PATCH 090/125] build(deps): bump github.com/cloudwego/eino from 0.3.33 to 0.3.34 Bumps [github.com/cloudwego/eino](https://github.com/cloudwego/eino) from 0.3.33 to 0.3.34. - [Release notes](https://github.com/cloudwego/eino/releases) - [Commits](https://github.com/cloudwego/eino/compare/v0.3.33...v0.3.34) --- updated-dependencies: - dependency-name: github.com/cloudwego/eino dependency-version: 0.3.34 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 412d417e..e8c8fc06 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,7 @@ require ( github.com/bwmarrin/discordgo v0.28.1 github.com/bytedance/sonic v1.13.2 github.com/cenkalti/backoff v2.2.1+incompatible - github.com/cloudwego/eino v0.3.33 + github.com/cloudwego/eino v0.3.34 github.com/cloudwego/eino-ext/components/model/ollama v0.0.0-20250514085234-473e80da5261 github.com/cloudwego/eino-ext/components/model/openai v0.0.0-20250507115047-b20720df8528 github.com/creachadair/jrpc2 v1.3.1 diff --git a/go.sum b/go.sum index ec60b794..b4ad2600 100644 --- a/go.sum +++ b/go.sum @@ -65,8 +65,8 @@ github.com/chengxilo/virtualterm v1.0.4 h1:Z6IpERbRVlfB8WkOmtbHiDbBANU7cimRIof7m github.com/chengxilo/virtualterm v1.0.4/go.mod h1:DyxxBZz/x1iqJjFxTFcr6/x+jSpqN0iwWCOK1q10rlY= github.com/cloudwego/base64x v0.1.5 h1:XPciSp1xaq2VCSt6lF0phncD4koWyULpl5bUxbfCyP4= github.com/cloudwego/base64x v0.1.5/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w= -github.com/cloudwego/eino v0.3.33 h1:C7BXUiLfyVDt0u+77B9X47nJ2OqzPPJ4kzTjRy+QuQ8= -github.com/cloudwego/eino v0.3.33/go.mod h1:wUjz990apdsaOraOXdh6CdhVXq8DJsOvLsVlxNTcNfY= +github.com/cloudwego/eino v0.3.34 h1:2LNcE0x04rlrJrdCDxjlBD10WvHs/V3h+QBTZUKKBxY= +github.com/cloudwego/eino v0.3.34/go.mod h1:wUjz990apdsaOraOXdh6CdhVXq8DJsOvLsVlxNTcNfY= github.com/cloudwego/eino-ext/components/model/ollama v0.0.0-20250514085234-473e80da5261 h1:LPzVDc6RsrMR4mPmpe5kHMn4b3bfmFMc2koSaHRH6dQ= github.com/cloudwego/eino-ext/components/model/ollama v0.0.0-20250514085234-473e80da5261/go.mod h1:giNUFqA+V7xrm/EDvH7JFnDqoWI+e2m1SVAnReU+Fd8= github.com/cloudwego/eino-ext/components/model/openai v0.0.0-20250507115047-b20720df8528 h1:LWlv4+NUNKVG2ojRtEbMDhExS45DH1t+kXakBCB3+Cw= From 49b2ed2e6efd3e3a9ceb539ca15166507dd9f5de Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 19 May 2025 16:34:49 +0000 Subject: [PATCH 091/125] build(deps): bump github.com/minio/minio-go/v7 from 7.0.91 to 7.0.92 Bumps [github.com/minio/minio-go/v7](https://github.com/minio/minio-go) from 7.0.91 to 7.0.92. - [Release notes](https://github.com/minio/minio-go/releases) - [Commits](https://github.com/minio/minio-go/compare/v7.0.91...v7.0.92) --- updated-dependencies: - dependency-name: github.com/minio/minio-go/v7 dependency-version: 7.0.92 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 4 ++-- go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 412d417e..63fb56ed 100644 --- a/go.mod +++ b/go.mod @@ -50,7 +50,7 @@ require ( github.com/mark3labs/mcp-go v0.28.0 github.com/maxence-charriere/go-app/v10 v10.1.3 github.com/meilisearch/meilisearch-go v0.32.0 - github.com/minio/minio-go/v7 v7.0.91 + github.com/minio/minio-go/v7 v7.0.92 github.com/minio/selfupdate v0.6.0 github.com/mmcdole/gofeed v1.3.0 github.com/montanaflynn/stats v0.7.1 @@ -197,7 +197,7 @@ require ( github.com/tadvi/systray v0.0.0-20190226123456-11a2b8fa57af // indirect github.com/tidwall/match v1.1.1 // indirect github.com/tidwall/pretty v1.2.0 // indirect - github.com/tinylib/msgp v1.2.5 // indirect + github.com/tinylib/msgp v1.3.0 // indirect github.com/tklauser/go-sysconf v0.3.12 // indirect github.com/tklauser/numcpus v0.6.1 // indirect github.com/twitchyliquid64/golang-asm v0.15.1 // indirect diff --git a/go.sum b/go.sum index ec60b794..eca2060b 100644 --- a/go.sum +++ b/go.sum @@ -348,8 +348,8 @@ github.com/minio/crc64nvme v1.0.1 h1:DHQPrYPdqK7jQG/Ls5CTBZWeex/2FMS3G5XGkycuFrY github.com/minio/crc64nvme v1.0.1/go.mod h1:eVfm2fAzLlxMdUGc0EEBGSMmPwmXD5XiNRpnu9J3bvg= github.com/minio/md5-simd v1.1.2 h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34= github.com/minio/md5-simd v1.1.2/go.mod h1:MzdKDxYpY2BT9XQFocsiZf/NKVtR7nkE4RoEpN+20RM= -github.com/minio/minio-go/v7 v7.0.91 h1:tWLZnEfo3OZl5PoXQwcwTAPNNrjyWwOh6cbZitW5JQc= -github.com/minio/minio-go/v7 v7.0.91/go.mod h1:uvMUcGrpgeSAAI6+sD3818508nUyMULw94j2Nxku/Go= +github.com/minio/minio-go/v7 v7.0.92 h1:jpBFWyRS3p8P/9tsRc+NuvqoFi7qAmTCFPoRFmobbVw= +github.com/minio/minio-go/v7 v7.0.92/go.mod h1:vTIc8DNcnAZIhyFsk8EB90AbPjj3j68aWIEQCiPj7d0= github.com/minio/selfupdate v0.6.0 h1:i76PgT0K5xO9+hjzKcacQtO7+MjJ4JKA8Ak8XQ9DDwU= github.com/minio/selfupdate v0.6.0/go.mod h1:bO02GTIPCMQFTEvE5h4DjYB58bCoZ35XLeBf0buTDdM= github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db h1:62I3jR2EmQ4l5rM/4FEfDWcRD+abF5XlKShorW5LRoQ= @@ -502,8 +502,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/tinylib/msgp v1.2.5 h1:WeQg1whrXRFiZusidTQqzETkRpGjFjcIhW6uqWH09po= -github.com/tinylib/msgp v1.2.5/go.mod h1:ykjzy2wzgrlvpDCRc4LA8UXy6D8bzMSuAF3WD57Gok0= +github.com/tinylib/msgp v1.3.0 h1:ULuf7GPooDaIlbyvgAxBV/FI7ynli6LZ1/nVUNu+0ww= +github.com/tinylib/msgp v1.3.0/go.mod h1:ykjzy2wzgrlvpDCRc4LA8UXy6D8bzMSuAF3WD57Gok0= github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU= github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI= github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk= From 035ea3f89ca0bc8afa808f45cfbc2fb75e22c0b7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 20 May 2025 16:17:30 +0000 Subject: [PATCH 092/125] build(deps): bump github.com/cloudwego/eino from 0.3.34 to 0.3.35 Bumps [github.com/cloudwego/eino](https://github.com/cloudwego/eino) from 0.3.34 to 0.3.35. - [Release notes](https://github.com/cloudwego/eino/releases) - [Commits](https://github.com/cloudwego/eino/compare/v0.3.34...v0.3.35) --- updated-dependencies: - dependency-name: github.com/cloudwego/eino dependency-version: 0.3.35 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 4bc0c0d1..33441c76 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,7 @@ require ( github.com/bwmarrin/discordgo v0.28.1 github.com/bytedance/sonic v1.13.2 github.com/cenkalti/backoff v2.2.1+incompatible - github.com/cloudwego/eino v0.3.34 + github.com/cloudwego/eino v0.3.35 github.com/cloudwego/eino-ext/components/model/ollama v0.0.0-20250514085234-473e80da5261 github.com/cloudwego/eino-ext/components/model/openai v0.0.0-20250507115047-b20720df8528 github.com/creachadair/jrpc2 v1.3.1 diff --git a/go.sum b/go.sum index 307faf3f..ba83634b 100644 --- a/go.sum +++ b/go.sum @@ -65,8 +65,8 @@ github.com/chengxilo/virtualterm v1.0.4 h1:Z6IpERbRVlfB8WkOmtbHiDbBANU7cimRIof7m github.com/chengxilo/virtualterm v1.0.4/go.mod h1:DyxxBZz/x1iqJjFxTFcr6/x+jSpqN0iwWCOK1q10rlY= github.com/cloudwego/base64x v0.1.5 h1:XPciSp1xaq2VCSt6lF0phncD4koWyULpl5bUxbfCyP4= github.com/cloudwego/base64x v0.1.5/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w= -github.com/cloudwego/eino v0.3.34 h1:2LNcE0x04rlrJrdCDxjlBD10WvHs/V3h+QBTZUKKBxY= -github.com/cloudwego/eino v0.3.34/go.mod h1:wUjz990apdsaOraOXdh6CdhVXq8DJsOvLsVlxNTcNfY= +github.com/cloudwego/eino v0.3.35 h1:5m3WN5fREhwKpGM/KkdoJ5+SJiq1E2UykEhbggaqHnU= +github.com/cloudwego/eino v0.3.35/go.mod h1:wUjz990apdsaOraOXdh6CdhVXq8DJsOvLsVlxNTcNfY= github.com/cloudwego/eino-ext/components/model/ollama v0.0.0-20250514085234-473e80da5261 h1:LPzVDc6RsrMR4mPmpe5kHMn4b3bfmFMc2koSaHRH6dQ= github.com/cloudwego/eino-ext/components/model/ollama v0.0.0-20250514085234-473e80da5261/go.mod h1:giNUFqA+V7xrm/EDvH7JFnDqoWI+e2m1SVAnReU+Fd8= github.com/cloudwego/eino-ext/components/model/openai v0.0.0-20250507115047-b20720df8528 h1:LWlv4+NUNKVG2ojRtEbMDhExS45DH1t+kXakBCB3+Cw= From b5a72ca9dbaa74938a41e6f327e91ea3b6021144 Mon Sep 17 00:00:00 2001 From: sysatom Date: Wed, 21 May 2025 00:41:52 +0800 Subject: [PATCH 093/125] =?UTF-8?q?=F0=9F=90=9B=20fix(tool.go):=20Replace?= =?UTF-8?q?=20direct=20access=20with=20GetArguments()=20method=20?= =?UTF-8?q?=F0=9F=9A=80=20update(go.mod):=20Upgrade=20mcp-go=20to=20v0.29.?= =?UTF-8?q?0=20=F0=9F=9A=A8=20update(go.sum):=20Update=20mcp-go=20hash=20t?= =?UTF-8?q?o=20match=20new=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- go.mod | 2 +- go.sum | 4 ++-- internal/agents/mcp/tool.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index 33441c76..be6099b2 100644 --- a/go.mod +++ b/go.mod @@ -47,7 +47,7 @@ require ( github.com/json-iterator/go v1.1.12 github.com/lithammer/shortuuid/v4 v4.2.0 github.com/looplab/fsm v1.0.3 - github.com/mark3labs/mcp-go v0.28.0 + github.com/mark3labs/mcp-go v0.29.0 github.com/maxence-charriere/go-app/v10 v10.1.3 github.com/meilisearch/meilisearch-go v0.32.0 github.com/minio/minio-go/v7 v7.0.92 diff --git a/go.sum b/go.sum index ba83634b..1c518550 100644 --- a/go.sum +++ b/go.sum @@ -319,8 +319,8 @@ github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJ github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= github.com/mailru/easyjson v0.9.0 h1:PrnmzHw7262yW8sTBwxi1PdJA3Iw/EKBa8psRf7d9a4= github.com/mailru/easyjson v0.9.0/go.mod h1:1+xMtQp2MRNVL/V1bOzuP3aP8VNwRW55fQUto+XFtTU= -github.com/mark3labs/mcp-go v0.28.0 h1:7yl4y5D1KYU2f/9Uxp7xfLIggfunHoESCRbrjcytcLM= -github.com/mark3labs/mcp-go v0.28.0/go.mod h1:rXqOudj/djTORU/ThxYx8fqEVj/5pvTuuebQ2RC7uk4= +github.com/mark3labs/mcp-go v0.29.0 h1:sH1NBcumKskhxqYzhXfGc201D7P76TVXiT0fGVhabeI= +github.com/mark3labs/mcp-go v0.29.0/go.mod h1:rXqOudj/djTORU/ThxYx8fqEVj/5pvTuuebQ2RC7uk4= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= diff --git a/internal/agents/mcp/tool.go b/internal/agents/mcp/tool.go index 6e196bc6..5603b2de 100644 --- a/internal/agents/mcp/tool.go +++ b/internal/agents/mcp/tool.go @@ -26,7 +26,7 @@ func Tools(s *server.MCPServer) { ) s.AddTool(calculatorTool, func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) { - args := request.Params.Arguments + args := request.GetArguments() op := args["operation"].(string) x := args["x"].(float64) y := args["y"].(float64) From 1f8d0434c3082bce25e52ec2caf3036648d12438 Mon Sep 17 00:00:00 2001 From: sysatom Date: Wed, 21 May 2025 01:05:12 +0800 Subject: [PATCH 094/125] =?UTF-8?q?=F0=9F=94=A7=20fix:=20Replace=20depreca?= =?UTF-8?q?ted=20`utils.FindOne`=20with=20`lo.Find`=20in=20multiple=20file?= =?UTF-8?q?s=20=F0=9F=94=A7=20fix:=20Correct=20typo=20in=20`GenerateRandom?= =?UTF-8?q?String`=20function=20name=20to=20`RandomString`=20=F0=9F=94=A7?= =?UTF-8?q?=20fix:=20Update=20`eino-ext`=20dependencies=20to=20latest=20ve?= =?UTF-8?q?rsions=20=F0=9F=94=A7=20fix:=20Remove=20unused=20`utils`=20func?= =?UTF-8?q?tions=20from=20`pkg/utils/slice.go`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/agent/updater/updater.go | 12 +++--- go.mod | 8 ++-- go.sum | 16 ++++---- internal/bots/agent/command.go | 4 +- internal/bots/webhook/command.go | 2 +- internal/bots/workflow/utils.go | 3 +- pkg/chatbot/bot.go | 2 +- pkg/utils/network.go | 63 ++++++++++++++++++++++++++++++++ pkg/utils/slice.go | 19 ---------- pkg/utils/string.go | 12 +++--- pkg/utils/utils.go | 63 -------------------------------- 11 files changed, 93 insertions(+), 111 deletions(-) diff --git a/cmd/agent/updater/updater.go b/cmd/agent/updater/updater.go index b62d691b..3095daa1 100644 --- a/cmd/agent/updater/updater.go +++ b/cmd/agent/updater/updater.go @@ -4,6 +4,7 @@ import ( "context" "crypto/sha256" "fmt" + "github.com/samber/lo" "io" "net/http" "os" @@ -12,7 +13,6 @@ import ( "github.com/Masterminds/semver/v3" "github.com/flowline-io/flowbot/pkg/flog" - "github.com/flowline-io/flowbot/pkg/utils" "github.com/flowline-io/flowbot/version" "github.com/google/go-github/v66/github" "github.com/minio/selfupdate" @@ -46,10 +46,10 @@ func UpdateSelf() (bool, error) { return false, err } - asset := utils.FindOne(release.Assets, func(asset **github.ReleaseAsset) bool { - return *(*asset).Name == execName() + asset, ok := lo.Find(release.Assets, func(item *github.ReleaseAsset) bool { + return *item.Name == execName() }) - if asset == nil { + if !ok || asset == nil { return false, nil } @@ -61,10 +61,10 @@ func UpdateSelf() (bool, error) { } flog.Info("Verifying checksum...") - checksumAsset := utils.FindOne(release.Assets, func(asset **github.ReleaseAsset) bool { + checksumAsset, ok := lo.Find(release.Assets, func(asset *github.ReleaseAsset) bool { return *(*asset).Name == checksumsName() }) - if checksumAsset == nil { + if !ok || checksumAsset == nil { return false, nil } diff --git a/go.mod b/go.mod index be6099b2..a17cb417 100644 --- a/go.mod +++ b/go.mod @@ -16,8 +16,8 @@ require ( github.com/bytedance/sonic v1.13.2 github.com/cenkalti/backoff v2.2.1+incompatible github.com/cloudwego/eino v0.3.35 - github.com/cloudwego/eino-ext/components/model/ollama v0.0.0-20250514085234-473e80da5261 - github.com/cloudwego/eino-ext/components/model/openai v0.0.0-20250507115047-b20720df8528 + github.com/cloudwego/eino-ext/components/model/ollama v0.0.0-20250520101807-b2008771903a + github.com/cloudwego/eino-ext/components/model/openai v0.0.0-20250520101807-b2008771903a github.com/creachadair/jrpc2 v1.3.1 github.com/dgraph-io/ristretto/v2 v2.2.0 github.com/docker/cli v28.1.1+incompatible @@ -60,6 +60,7 @@ require ( github.com/redis/go-redis/v9 v9.8.0 github.com/robfig/cron/v3 v3.0.1 github.com/rs/zerolog v1.34.0 + github.com/samber/lo v1.50.0 github.com/samber/oops v1.17.0 github.com/schollz/progressbar/v3 v3.18.0 github.com/shirou/gopsutil/v4 v4.25.4 @@ -101,7 +102,7 @@ require ( github.com/cenkalti/backoff/v3 v3.2.2 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/cloudwego/base64x v0.1.5 // indirect - github.com/cloudwego/eino-ext/libs/acl/openai v0.0.0-20250422092704-54e372e1fa3d // indirect + github.com/cloudwego/eino-ext/libs/acl/openai v0.0.0-20250519084852-38fafa73d9ea // indirect github.com/containerd/log v0.1.0 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.5 // indirect github.com/creachadair/mds v0.23.0 // indirect @@ -184,7 +185,6 @@ require ( github.com/rs/xid v1.6.0 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/sagikazarmark/locafero v0.7.0 // indirect - github.com/samber/lo v1.49.1 // indirect github.com/sirupsen/logrus v1.9.3 // indirect github.com/slongfield/pyfmt v0.0.0-20220222012616-ea85ff4c361f // indirect github.com/sony/gobreaker v1.0.0 // indirect diff --git a/go.sum b/go.sum index 1c518550..7ec219e0 100644 --- a/go.sum +++ b/go.sum @@ -67,12 +67,12 @@ github.com/cloudwego/base64x v0.1.5 h1:XPciSp1xaq2VCSt6lF0phncD4koWyULpl5bUxbfCy github.com/cloudwego/base64x v0.1.5/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w= github.com/cloudwego/eino v0.3.35 h1:5m3WN5fREhwKpGM/KkdoJ5+SJiq1E2UykEhbggaqHnU= github.com/cloudwego/eino v0.3.35/go.mod h1:wUjz990apdsaOraOXdh6CdhVXq8DJsOvLsVlxNTcNfY= -github.com/cloudwego/eino-ext/components/model/ollama v0.0.0-20250514085234-473e80da5261 h1:LPzVDc6RsrMR4mPmpe5kHMn4b3bfmFMc2koSaHRH6dQ= -github.com/cloudwego/eino-ext/components/model/ollama v0.0.0-20250514085234-473e80da5261/go.mod h1:giNUFqA+V7xrm/EDvH7JFnDqoWI+e2m1SVAnReU+Fd8= -github.com/cloudwego/eino-ext/components/model/openai v0.0.0-20250507115047-b20720df8528 h1:LWlv4+NUNKVG2ojRtEbMDhExS45DH1t+kXakBCB3+Cw= -github.com/cloudwego/eino-ext/components/model/openai v0.0.0-20250507115047-b20720df8528/go.mod h1:uXIWTFbaAbZ1128EIXjFc4S+tDqmz1idMZd5qt5kkwU= -github.com/cloudwego/eino-ext/libs/acl/openai v0.0.0-20250422092704-54e372e1fa3d h1:unNqPz9vuJmJCZAw5YKFcszRX9e3CdVEjh0lR6QArxk= -github.com/cloudwego/eino-ext/libs/acl/openai v0.0.0-20250422092704-54e372e1fa3d/go.mod h1:Ye0YAqpESCxMlnALNrjeNJjhS9q2PIdxVdJbtFeni8o= +github.com/cloudwego/eino-ext/components/model/ollama v0.0.0-20250520101807-b2008771903a h1:+/VYbeXv7bCdm0Wk183zIj9MjtF8yVaO1aDQyjfhf6c= +github.com/cloudwego/eino-ext/components/model/ollama v0.0.0-20250520101807-b2008771903a/go.mod h1:giNUFqA+V7xrm/EDvH7JFnDqoWI+e2m1SVAnReU+Fd8= +github.com/cloudwego/eino-ext/components/model/openai v0.0.0-20250520101807-b2008771903a h1:mpUCTgxWY34WyXopxMZcZPMJtg05tOCswxoRRXqT+lQ= +github.com/cloudwego/eino-ext/components/model/openai v0.0.0-20250520101807-b2008771903a/go.mod h1:LNe4KWTiK8uGf21d1nL1MR9PfFadDOiiHRrCcHMUYyM= +github.com/cloudwego/eino-ext/libs/acl/openai v0.0.0-20250519084852-38fafa73d9ea h1:FojwJhddzbKAshizfGOYwCR9HPvaCSCM1P6Vlfr4fKo= +github.com/cloudwego/eino-ext/libs/acl/openai v0.0.0-20250519084852-38fafa73d9ea/go.mod h1:21bzzKhB1SSBr2jUaEBvNs75ZxSWSfIyM3oF2RB1ELs= github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY= github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I= github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo= @@ -441,8 +441,8 @@ github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/sagikazarmark/locafero v0.7.0 h1:5MqpDsTGNDhY8sGp0Aowyf0qKsPrhewaLSsFaodPcyo= github.com/sagikazarmark/locafero v0.7.0/go.mod h1:2za3Cg5rMaTMoG/2Ulr9AwtFaIppKXTRYnozin4aB5k= -github.com/samber/lo v1.49.1 h1:4BIFyVfuQSEpluc7Fua+j1NolZHiEHEpaSEKdsH0tew= -github.com/samber/lo v1.49.1/go.mod h1:dO6KHFzUKXgP8LDhU0oI8d2hekjXnGOu0DB8Jecxd6o= +github.com/samber/lo v1.50.0 h1:XrG0xOeHs+4FQ8gJR97zDz5uOFMW7OwFWiFVzqopKgY= +github.com/samber/lo v1.50.0/go.mod h1:RjZyNk6WSnUFRKK6EyOhsRJMqft3G+pg7dCWHQCWvsc= github.com/samber/oops v1.17.0 h1:9NT8ISe8qqOV5HAuRQstlgYwUf3RsIiMDefSbUq+2hE= github.com/samber/oops v1.17.0/go.mod h1:8eXgMAJcDXRAijQsFRhfy/EHDOTiSvwkg6khFqFK078= github.com/schollz/progressbar/v3 v3.18.0 h1:uXdoHABRFmNIjUfte/Ex7WtuyVslrw2wVPQmCN62HpA= diff --git a/internal/bots/agent/command.go b/internal/bots/agent/command.go index 0916ba2b..5010de95 100644 --- a/internal/bots/agent/command.go +++ b/internal/bots/agent/command.go @@ -27,7 +27,7 @@ var commandRules = []command.Rule{ } idValue, ok := value.String("value") if !ok || idValue == "" { - idValue, err = utils.GenerateRandomString(25) + idValue, err = utils.RandomString(25) if err != nil { return types.TextMsg{Text: "generate error"} } @@ -73,7 +73,7 @@ var commandRules = []command.Rule{ } // new token - idValue, err = utils.GenerateRandomString(25) + idValue, err = utils.RandomString(25) if err != nil { return types.TextMsg{Text: "generate error"} } diff --git a/internal/bots/webhook/command.go b/internal/bots/webhook/command.go index 824446b0..e25f0f17 100644 --- a/internal/bots/webhook/command.go +++ b/internal/bots/webhook/command.go @@ -78,7 +78,7 @@ var commandRules = []command.Rule{ return types.TextMsg{Text: find.Secret} } - secret, err := utils.GenerateRandomString(32) + secret, err := utils.RandomString(32) if err != nil { flog.Error(err) return types.TextMsg{Text: "generate secret failed"} diff --git a/internal/bots/workflow/utils.go b/internal/bots/workflow/utils.go index 69ddc400..e9ee4760 100644 --- a/internal/bots/workflow/utils.go +++ b/internal/bots/workflow/utils.go @@ -3,6 +3,7 @@ package workflow import ( "errors" "fmt" + "github.com/samber/lo" "regexp" "strings" @@ -105,7 +106,7 @@ func MetaDataValidate(meta types.WorkflowMetadata) (err error) { return } for _, trigger := range meta.Triggers { - if !utils.InStringSlice([]string{ + if !lo.Contains([]string{ string(model.TriggerManual), string(model.TriggerCron), string(model.TriggerWebhook), diff --git a/pkg/chatbot/bot.go b/pkg/chatbot/bot.go index 3dd12464..a2acde89 100644 --- a/pkg/chatbot/bot.go +++ b/pkg/chatbot/bot.go @@ -511,7 +511,7 @@ func Webservice(app *fiber.App, name string, ruleset webservice.Ruleset) { func Shortcut(title, link string) (string, error) { endpoint, _ := providers.GetConfig(slash.ID, slash.EndpointKey) - name, err := utils.GenerateRandomString(6) + name, err := utils.RandomString(6) if err != nil { return "", err } diff --git a/pkg/utils/network.go b/pkg/utils/network.go index 2ce405c1..c9cdcb66 100644 --- a/pkg/utils/network.go +++ b/pkg/utils/network.go @@ -2,6 +2,8 @@ package utils import ( "net" + "net/http" + "strings" "time" ) @@ -15,3 +17,64 @@ func PortAvailable(port string) bool { } return true } + +// NetListener creates net.Listener for tcp and unix domains: +// if addr is in the form "unix:/run/flowbot.sock" it's a unix socket, otherwise TCP host:port. +func NetListener(addr string) (net.Listener, error) { + addrParts := strings.SplitN(addr, ":", 2) + if len(addrParts) == 2 && addrParts[0] == "unix" { + return net.Listen("unix", addrParts[1]) + } + return net.Listen("tcp", addr) +} + +// IsUnixAddr Check if specified address is a unix socket like "unix:/run/flowbot.sock". +func IsUnixAddr(addr string) bool { + addrParts := strings.SplitN(addr, ":", 2) + return len(addrParts) == 2 && addrParts[0] == "unix" +} + +var privateIPBlocks []*net.IPNet + +func IsRoutableIP(ipStr string) bool { + ip := net.ParseIP(ipStr) + if ip == nil { + return false + } + + if ip.IsLoopback() || ip.IsLinkLocalUnicast() || ip.IsLinkLocalMulticast() { + return false + } + + if privateIPBlocks == nil { + for _, cidr := range []string{ + "10.0.0.0/8", // RFC1918 + "172.16.0.0/12", // RFC1918 + "192.168.0.0/16", // RFC1918 + "fc00::/7", // RFC4193, IPv6 unique local addr + } { + _, block, _ := net.ParseCIDR(cidr) + privateIPBlocks = append(privateIPBlocks, block) + } + } + + for _, block := range privateIPBlocks { + if block.Contains(ip) { + return false + } + } + return true +} + +// GetRemoteAddr Obtain IP address of the client. +func GetRemoteAddr(req *http.Request) string { + var addr string + addr = req.Header.Get("X-Forwarded-For") + if !IsRoutableIP(addr) { + addr = "" + } + if addr != "" { + return addr + } + return req.RemoteAddr +} diff --git a/pkg/utils/slice.go b/pkg/utils/slice.go index 9ad7d9eb..0ee66004 100644 --- a/pkg/utils/slice.go +++ b/pkg/utils/slice.go @@ -22,22 +22,3 @@ func SameStringSlice(x, y []string) bool { } return len(diff) == 0 } - -func InStringSlice(x []string, find string) bool { - for _, s := range x { - if find == s { - return true - } - } - return false -} - -func FindOne[T any](slice []T, filter func(*T) bool) (element *T) { - for i := 0; i < len(slice); i++ { - if filter(&slice[i]) { - return &slice[i] - } - } - - return nil -} diff --git a/pkg/utils/string.go b/pkg/utils/string.go index fe442abc..688adb61 100644 --- a/pkg/utils/string.go +++ b/pkg/utils/string.go @@ -18,6 +18,11 @@ import ( "github.com/google/uuid" ) +const ( + letters = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" + urlRegex = `https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)` +) + func HasHan(txt string) bool { for _, runeValue := range txt { if unicode.Is(unicode.Han, runeValue) { @@ -27,7 +32,7 @@ func HasHan(txt string) bool { return false } -func GenerateRandomString(n int) (string, error) { +func RandomString(n int) (string, error) { ret := make([]byte, n) for i := 0; i < n; i++ { num, err := rand.Int(rand.Reader, big.NewInt(int64(len(letters)))) @@ -40,11 +45,6 @@ func GenerateRandomString(n int) (string, error) { return string(ret), nil } -const ( - letters = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" - urlRegex = `https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)` -) - func IsUrl(text string) bool { re := regexp.MustCompile("^" + urlRegex + "$") return re.MatchString(text) diff --git a/pkg/utils/utils.go b/pkg/utils/utils.go index d203c20a..e895c11a 100644 --- a/pkg/utils/utils.go +++ b/pkg/utils/utils.go @@ -3,8 +3,6 @@ package utils import ( - "net" - "net/http" "path/filepath" "reflect" "sort" @@ -186,64 +184,3 @@ func MergeMaps(dst, src map[string]any) (map[string]any, bool) { return dst, changed } - -// NetListener creates net.Listener for tcp and unix domains: -// if addr is in the form "unix:/run/flowbot.sock" it's a unix socket, otherwise TCP host:port. -func NetListener(addr string) (net.Listener, error) { - addrParts := strings.SplitN(addr, ":", 2) - if len(addrParts) == 2 && addrParts[0] == "unix" { - return net.Listen("unix", addrParts[1]) - } - return net.Listen("tcp", addr) -} - -// IsUnixAddr Check if specified address is a unix socket like "unix:/run/flowbot.sock". -func IsUnixAddr(addr string) bool { - addrParts := strings.SplitN(addr, ":", 2) - return len(addrParts) == 2 && addrParts[0] == "unix" -} - -var privateIPBlocks []*net.IPNet - -func IsRoutableIP(ipStr string) bool { - ip := net.ParseIP(ipStr) - if ip == nil { - return false - } - - if ip.IsLoopback() || ip.IsLinkLocalUnicast() || ip.IsLinkLocalMulticast() { - return false - } - - if privateIPBlocks == nil { - for _, cidr := range []string{ - "10.0.0.0/8", // RFC1918 - "172.16.0.0/12", // RFC1918 - "192.168.0.0/16", // RFC1918 - "fc00::/7", // RFC4193, IPv6 unique local addr - } { - _, block, _ := net.ParseCIDR(cidr) - privateIPBlocks = append(privateIPBlocks, block) - } - } - - for _, block := range privateIPBlocks { - if block.Contains(ip) { - return false - } - } - return true -} - -// GetRemoteAddr Obtain IP address of the client. -func GetRemoteAddr(req *http.Request) string { - var addr string - addr = req.Header.Get("X-Forwarded-For") - if !IsRoutableIP(addr) { - addr = "" - } - if addr != "" { - return addr - } - return req.RemoteAddr -} From 2b65b2e6fe22cbbd1a811402c1c9c2d596fca309 Mon Sep 17 00:00:00 2001 From: sysatom Date: Wed, 21 May 2025 01:10:42 +0800 Subject: [PATCH 095/125] =?UTF-8?q?=F0=9F=9A=A8=20del:=20Remove=20HTML=20a?= =?UTF-8?q?nd=20pprof=20functions=20from=20codebase:=20Clean=20up=20unused?= =?UTF-8?q?=20code,=20improve=20maintainability.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/pprofs/http_pprof.go | 55 ---------------------------------------- pkg/utils/html.go | 9 ------- pkg/utils/slice_test.go | 52 ------------------------------------- 3 files changed, 116 deletions(-) delete mode 100644 pkg/pprofs/http_pprof.go delete mode 100644 pkg/utils/html.go diff --git a/pkg/pprofs/http_pprof.go b/pkg/pprofs/http_pprof.go deleted file mode 100644 index dc47a34f..00000000 --- a/pkg/pprofs/http_pprof.go +++ /dev/null @@ -1,55 +0,0 @@ -// Debug tooling. Dumps named profile in response to HTTP request at -// http(s)://// -// See godoc for the list of possible profile names: https://golang.org/pkg/runtime/pprof/#Profile - -package pprofs - -import ( - "fmt" - "net/http" - "path" - "runtime/pprof" - "strings" - - "github.com/flowline-io/flowbot/pkg/flog" - "github.com/gofiber/fiber/v2" - "github.com/gofiber/fiber/v2/middleware/adaptor" -) - -var pprofHttpRoot string - -// ServePprof Expose debug profiling at the given URL path. -func ServePprof(app *fiber.App, serveAt string) { - if serveAt == "" || serveAt == "-" { - return - } - - pprofHttpRoot = path.Clean("/"+serveAt) + "/" - app.All(pprofHttpRoot, adaptor.HTTPHandlerFunc(profileHandler)) - - flog.Info("pprof: profiling info exposed at '%s'", pprofHttpRoot) -} - -func profileHandler(wrt http.ResponseWriter, req *http.Request) { - wrt.Header().Set("X-Content-Type-Options", "nosniff") - wrt.Header().Set("Content-Type", "text/plain; charset=utf-8") - - profileName := strings.TrimPrefix(req.URL.Path, pprofHttpRoot) - - profile := pprof.Lookup(profileName) - if profile == nil { - servePprofError(wrt, http.StatusNotFound, "Unknown profile '"+profileName+"'") - return - } - - // Respond with the requested profile. - _ = profile.WriteTo(wrt, 2) -} - -func servePprofError(wrt http.ResponseWriter, status int, txt string) { - wrt.Header().Set("Content-Type", "text/plain; charset=utf-8") - wrt.Header().Set("X-Go-Pprof", "1") - wrt.Header().Del("Content-Disposition") - wrt.WriteHeader(status) - _, _ = fmt.Fprintln(wrt, txt) -} diff --git a/pkg/utils/html.go b/pkg/utils/html.go deleted file mode 100644 index d2bd66d3..00000000 --- a/pkg/utils/html.go +++ /dev/null @@ -1,9 +0,0 @@ -package utils - -import ( - "jaytaylor.com/html2text" -) - -func Html2Text(html string) (string, error) { - return html2text.FromString(html, html2text.Options{TextOnly: true}) -} diff --git a/pkg/utils/slice_test.go b/pkg/utils/slice_test.go index e65575bc..581efa4d 100644 --- a/pkg/utils/slice_test.go +++ b/pkg/utils/slice_test.go @@ -37,55 +37,3 @@ func TestSameStringSlice(t *testing.T) { }) } } - -func TestInStringSlice(t *testing.T) { - type args struct { - x []string - find string - } - tests := []struct { - name string - args args - want bool - }{ - { - name: "find", - args: args{ - x: []string{"a", "b", "c", "d", "e"}, - find: "c", - }, - want: true, - }, - { - name: "not-find", - args: args{ - x: []string{"a", "b", "c", "d", "e"}, - find: "f", - }, - want: false, - }, - { - name: "not-find", - args: args{ - x: []string{}, - find: "f", - }, - want: false, - }, - { - name: "not-find", - args: args{ - x: []string{}, - find: "", - }, - want: false, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := InStringSlice(tt.args.x, tt.args.find); got != tt.want { - t.Errorf("InStringSlice() = %v, want %v", got, tt.want) - } - }) - } -} From 5b68567c33b7808a3bb30bf16e83970f96348023 Mon Sep 17 00:00:00 2001 From: sysatom Date: Wed, 21 May 2025 01:10:54 +0800 Subject: [PATCH 096/125] =?UTF-8?q?=F0=9F=9A=A7=20fix:=20remove=20outdated?= =?UTF-8?q?=20dependencies=20from=20go.mod=20and=20go.sum?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- go.mod | 3 --- go.sum | 7 ------- 2 files changed, 10 deletions(-) diff --git a/go.mod b/go.mod index a17cb417..b7e56e2b 100644 --- a/go.mod +++ b/go.mod @@ -85,7 +85,6 @@ require ( gorm.io/gorm v1.26.1 gorm.io/plugin/dbresolver v1.6.0 gotest.tools/v3 v3.5.2 - jaytaylor.com/html2text v0.0.0-20230321000545-74c2419ad056 miniflux.app/v2 v2.2.8 ) @@ -171,7 +170,6 @@ require ( github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d // indirect github.com/oklog/ulid v1.3.1 // indirect github.com/oklog/ulid/v2 v2.1.0 // indirect - github.com/olekukonko/tablewriter v0.0.5 // indirect github.com/ollama/ollama v0.5.12 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect github.com/opencontainers/image-spec v1.1.0 // indirect @@ -191,7 +189,6 @@ require ( github.com/sourcegraph/conc v0.3.0 // indirect github.com/spf13/afero v1.12.0 // indirect github.com/spf13/cast v1.7.1 // indirect - github.com/ssor/bom v0.0.0-20170718123548-6386211fdfcf // indirect github.com/subosito/gotenv v1.6.0 // indirect github.com/swaggo/files/v2 v2.0.2 // indirect github.com/tadvi/systray v0.0.0-20190226123456-11a2b8fa57af // indirect diff --git a/go.sum b/go.sum index 7ec219e0..6847bf76 100644 --- a/go.sum +++ b/go.sum @@ -327,7 +327,6 @@ github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/ github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= -github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= 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/mattn/go-sqlite3 v1.14.8/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= @@ -388,8 +387,6 @@ github.com/oklog/ulid v1.3.1 h1:EGfNDEx6MqHz8B3uNV6QAib1UR2Lm97sHi3ocA6ESJ4= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= github.com/oklog/ulid/v2 v2.1.0 h1:+9lhoxAP56we25tyYETBBY1YLA2SaoLvUFgrP2miPJU= github.com/oklog/ulid/v2 v2.1.0/go.mod h1:rcEKHmBBKfef9DhnvX7y1HZBYxjXb0cP5ExxNsTT1QQ= -github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= -github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/ollama/ollama v0.5.12 h1:qM+k/ozyHLJzEQoAEPrUQ0qXqsgDEEdpIVwuwScrd2U= github.com/ollama/ollama v0.5.12/go.mod h1:ibdmDvb/TjKY1OArBWIazL3pd1DHTk8eG2MMjEkWhiI= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= @@ -472,8 +469,6 @@ github.com/spf13/pflag v1.0.6 h1:jFzHGLGAlb3ruxLB8MhbI6A8+AQX/2eW4qeyNZXNp2o= github.com/spf13/pflag v1.0.6/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/viper v1.20.1 h1:ZMi+z/lvLyPSCoNtFCpqjy0S4kPbirhpTMwl8BkW9X4= github.com/spf13/viper v1.20.1/go.mod h1:P9Mdzt1zoHIG8m2eZQinpiBjo6kCmZSKBClNNqjJvu4= -github.com/ssor/bom v0.0.0-20170718123548-6386211fdfcf h1:pvbZ0lM0XWPBqUKqFU8cmavspvIl9nulOYwdy6IFRRo= -github.com/ssor/bom v0.0.0-20170718123548-6386211fdfcf/go.mod h1:RJID2RhlZKId02nZ62WenDCkgHFerpIOmW0iT7GKmXM= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= @@ -752,8 +747,6 @@ gorm.io/plugin/dbresolver v1.6.0 h1:XvKDeOtTn1EIX6s4SrKpEH82q0gXVemhYjbYZFGFVcw= gorm.io/plugin/dbresolver v1.6.0/go.mod h1:tctw63jdrOezFR9HmrKnPkmig3m5Edem9fdxk9bQSzM= gotest.tools/v3 v3.5.2 h1:7koQfIKdy+I8UTetycgUqXWSDwpgv193Ka+qRsmBY8Q= gotest.tools/v3 v3.5.2/go.mod h1:LtdLGcnqToBH83WByAAi/wiwSFCArdFIUV/xxN4pcjA= -jaytaylor.com/html2text v0.0.0-20230321000545-74c2419ad056 h1:6YFJoB+0fUH6X3xU/G2tQqCYg+PkGtnZ5nMR5rpw72g= -jaytaylor.com/html2text v0.0.0-20230321000545-74c2419ad056/go.mod h1:OxvTsCwKosqQ1q7B+8FwXqg4rKZ/UG9dUW+g/VL2xH4= miniflux.app/v2 v2.2.8 h1:SsWBlyK7hiBJ5fkNeOgK1p872a4/qDJMOyTH2iSWIsA= miniflux.app/v2 v2.2.8/go.mod h1:30vy970xFSfHePD/W+SKFz1vnzQx9rqo9/xeFP/GDlE= nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50= From 9f1febf5e8cf4379e7b117c5a431ec0bf4bb6f28 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 21 May 2025 16:10:16 +0000 Subject: [PATCH 097/125] build(deps): bump github.com/cloudwego/eino from 0.3.35 to 0.3.36 Bumps [github.com/cloudwego/eino](https://github.com/cloudwego/eino) from 0.3.35 to 0.3.36. - [Release notes](https://github.com/cloudwego/eino/releases) - [Commits](https://github.com/cloudwego/eino/compare/v0.3.35...v0.3.36) --- updated-dependencies: - dependency-name: github.com/cloudwego/eino dependency-version: 0.3.36 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index b7e56e2b..1982f975 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,7 @@ require ( github.com/bwmarrin/discordgo v0.28.1 github.com/bytedance/sonic v1.13.2 github.com/cenkalti/backoff v2.2.1+incompatible - github.com/cloudwego/eino v0.3.35 + github.com/cloudwego/eino v0.3.36 github.com/cloudwego/eino-ext/components/model/ollama v0.0.0-20250520101807-b2008771903a github.com/cloudwego/eino-ext/components/model/openai v0.0.0-20250520101807-b2008771903a github.com/creachadair/jrpc2 v1.3.1 diff --git a/go.sum b/go.sum index 6847bf76..63e48446 100644 --- a/go.sum +++ b/go.sum @@ -65,8 +65,8 @@ github.com/chengxilo/virtualterm v1.0.4 h1:Z6IpERbRVlfB8WkOmtbHiDbBANU7cimRIof7m github.com/chengxilo/virtualterm v1.0.4/go.mod h1:DyxxBZz/x1iqJjFxTFcr6/x+jSpqN0iwWCOK1q10rlY= github.com/cloudwego/base64x v0.1.5 h1:XPciSp1xaq2VCSt6lF0phncD4koWyULpl5bUxbfCyP4= github.com/cloudwego/base64x v0.1.5/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w= -github.com/cloudwego/eino v0.3.35 h1:5m3WN5fREhwKpGM/KkdoJ5+SJiq1E2UykEhbggaqHnU= -github.com/cloudwego/eino v0.3.35/go.mod h1:wUjz990apdsaOraOXdh6CdhVXq8DJsOvLsVlxNTcNfY= +github.com/cloudwego/eino v0.3.36 h1:Wvt4oCy/RM/vHUixKTF5gJPCFvU4TARKPl52wJvatXI= +github.com/cloudwego/eino v0.3.36/go.mod h1:wUjz990apdsaOraOXdh6CdhVXq8DJsOvLsVlxNTcNfY= github.com/cloudwego/eino-ext/components/model/ollama v0.0.0-20250520101807-b2008771903a h1:+/VYbeXv7bCdm0Wk183zIj9MjtF8yVaO1aDQyjfhf6c= github.com/cloudwego/eino-ext/components/model/ollama v0.0.0-20250520101807-b2008771903a/go.mod h1:giNUFqA+V7xrm/EDvH7JFnDqoWI+e2m1SVAnReU+Fd8= github.com/cloudwego/eino-ext/components/model/openai v0.0.0-20250520101807-b2008771903a h1:mpUCTgxWY34WyXopxMZcZPMJtg05tOCswxoRRXqT+lQ= From 59dba7b53383678560c08918bc144b9984f1df4c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 22 May 2025 10:08:04 +0000 Subject: [PATCH 098/125] build(deps): bump github.com/samber/oops from 1.17.0 to 1.18.0 Bumps [github.com/samber/oops](https://github.com/samber/oops) from 1.17.0 to 1.18.0. - [Release notes](https://github.com/samber/oops/releases) - [Commits](https://github.com/samber/oops/compare/v1.17.0...v1.18.0) --- updated-dependencies: - dependency-name: github.com/samber/oops dependency-version: 1.18.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 1982f975..0793e763 100644 --- a/go.mod +++ b/go.mod @@ -61,7 +61,7 @@ require ( github.com/robfig/cron/v3 v3.0.1 github.com/rs/zerolog v1.34.0 github.com/samber/lo v1.50.0 - github.com/samber/oops v1.17.0 + github.com/samber/oops v1.18.0 github.com/schollz/progressbar/v3 v3.18.0 github.com/shirou/gopsutil/v4 v4.25.4 github.com/slack-go/slack v0.16.0 diff --git a/go.sum b/go.sum index 63e48446..3d290a06 100644 --- a/go.sum +++ b/go.sum @@ -440,8 +440,8 @@ github.com/sagikazarmark/locafero v0.7.0 h1:5MqpDsTGNDhY8sGp0Aowyf0qKsPrhewaLSsF github.com/sagikazarmark/locafero v0.7.0/go.mod h1:2za3Cg5rMaTMoG/2Ulr9AwtFaIppKXTRYnozin4aB5k= github.com/samber/lo v1.50.0 h1:XrG0xOeHs+4FQ8gJR97zDz5uOFMW7OwFWiFVzqopKgY= github.com/samber/lo v1.50.0/go.mod h1:RjZyNk6WSnUFRKK6EyOhsRJMqft3G+pg7dCWHQCWvsc= -github.com/samber/oops v1.17.0 h1:9NT8ISe8qqOV5HAuRQstlgYwUf3RsIiMDefSbUq+2hE= -github.com/samber/oops v1.17.0/go.mod h1:8eXgMAJcDXRAijQsFRhfy/EHDOTiSvwkg6khFqFK078= +github.com/samber/oops v1.18.0 h1:NnoCdxlOg/ajFos8HIC0+dV8S6cZRcrjW1WrfZe+GOc= +github.com/samber/oops v1.18.0/go.mod h1:DcZbba2s+PzSx14vY6HjvhV1FDsGOZ1TJg7T/ZZARBQ= github.com/schollz/progressbar/v3 v3.18.0 h1:uXdoHABRFmNIjUfte/Ex7WtuyVslrw2wVPQmCN62HpA= github.com/schollz/progressbar/v3 v3.18.0/go.mod h1:IsO3lpbaGuzh8zIMzgY3+J8l4C8GjO0Y9S69eFvNsec= github.com/shirou/gopsutil/v4 v4.25.4 h1:cdtFO363VEOOFrUCjZRh4XVJkb548lyF0q0uTeMqYPw= From 1b0a3da784b3bfa63f78fb7902063ef8ffe2df5f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 22 May 2025 10:08:18 +0000 Subject: [PATCH 099/125] build(deps): bump github.com/gofiber/fiber/v2 from 2.52.6 to 2.52.8 Bumps [github.com/gofiber/fiber/v2](https://github.com/gofiber/fiber) from 2.52.6 to 2.52.8. - [Release notes](https://github.com/gofiber/fiber/releases) - [Commits](https://github.com/gofiber/fiber/compare/v2.52.6...v2.52.8) --- updated-dependencies: - dependency-name: github.com/gofiber/fiber/v2 dependency-version: 2.52.8 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 1982f975..667d6004 100644 --- a/go.mod +++ b/go.mod @@ -34,7 +34,7 @@ require ( github.com/go-sql-driver/mysql v1.9.2 github.com/goccy/go-json v0.10.5 github.com/gofiber/contrib/fiberzerolog v1.0.3 - github.com/gofiber/fiber/v2 v2.52.6 + github.com/gofiber/fiber/v2 v2.52.8 github.com/gofiber/swagger v1.1.1 github.com/golang-migrate/migrate/v4 v4.18.3 github.com/google/go-github/v66 v66.0.0 diff --git a/go.sum b/go.sum index 63e48446..8940ea4c 100644 --- a/go.sum +++ b/go.sum @@ -192,8 +192,8 @@ github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk= github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/gofiber/contrib/fiberzerolog v1.0.3 h1:Z97hA5bNfThtZjEYG12g9YcT8I/cmCikNgmE4uzFk0U= github.com/gofiber/contrib/fiberzerolog v1.0.3/go.mod h1:0MD+NNFy0nZwiSo4dSVW7WwWVzOyuATNXwhJwgOP8uM= -github.com/gofiber/fiber/v2 v2.52.6 h1:Rfp+ILPiYSvvVuIPvxrBns+HJp8qGLDnLJawAu27XVI= -github.com/gofiber/fiber/v2 v2.52.6/go.mod h1:YEcBbO/FB+5M1IZNBP9FO3J9281zgPAreiI1oqg8nDw= +github.com/gofiber/fiber/v2 v2.52.8 h1:xl4jJQ0BV5EJTA2aWiKw/VddRpHrKeZLF0QPUxqn0x4= +github.com/gofiber/fiber/v2 v2.52.8/go.mod h1:YEcBbO/FB+5M1IZNBP9FO3J9281zgPAreiI1oqg8nDw= github.com/gofiber/swagger v1.1.1 h1:FZVhVQQ9s1ZKLHL/O0loLh49bYB5l1HEAgxDlcTtkRA= github.com/gofiber/swagger v1.1.1/go.mod h1:vtvY/sQAMc/lGTUCg0lqmBL7Ht9O7uzChpbvJeJQINw= github.com/gofrs/uuid v3.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= From 07885529576a7653a8d31ab6f7f969a62d39efb0 Mon Sep 17 00:00:00 2001 From: sysatom Date: Thu, 22 May 2025 18:29:53 +0800 Subject: [PATCH 100/125] feat: actionlint task --- taskfile.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/taskfile.yaml b/taskfile.yaml index cdc961ab..8fad43a3 100644 --- a/taskfile.yaml +++ b/taskfile.yaml @@ -44,6 +44,7 @@ tasks: lint: cmds: - revive -config revive.toml -formatter friendly ./... + - task: lint:action swagger: cmds: @@ -64,6 +65,7 @@ tasks: - go install github.com/air-verse/air@latest - go install github.com/securego/gosec/v2/cmd/gosec@latest - go install github.com/boyter/scc/v3@latest + - go install github.com/rhysd/actionlint/cmd/actionlint@latest - npm install -g prettier secure: @@ -106,3 +108,7 @@ tasks: gosec: cmds: - gosec ./... + + lint:action: + cmds: + - actionlint From 2fc9e9ad3be6b833100f8ef2f9aff7d3774b701c Mon Sep 17 00:00:00 2001 From: sysatom Date: Thu, 22 May 2025 18:41:04 +0800 Subject: [PATCH 101/125] feat: task desc --- taskfile.yaml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/taskfile.yaml b/taskfile.yaml index 8fad43a3..590a730c 100644 --- a/taskfile.yaml +++ b/taskfile.yaml @@ -1,6 +1,7 @@ version: "3" tasks: default: + desc: Default task cmds: - task: tidy - task: swagger @@ -10,6 +11,7 @@ tasks: - echo "Both done" check: + desc: check something cmds: - task: lint - task: secure @@ -18,40 +20,49 @@ tasks: - echo "Both done" build: + desc: Build flowbot cmds: - go build -v -o tmp github.com/flowline-io/flowbot/cmd build:agent: + desc: Build agent cmds: - go build -v -o tmp github.com/flowline-io/flowbot/cmd/agent run: + desc: Run flowbot cmds: - go run -tags swagger github.com/flowline-io/flowbot/cmd run:agent: + desc: Run agent cmds: - go run github.com/flowline-io/flowbot/cmd/agent cloc: + desc: Count lines of code cmds: - cloc --exclude-dir=node_modules --exclude-ext=json . scc: + desc: Sloc, Cloc and Code cmds: - scc > ./cloc/{{ now.Format "2006-01-02" }}.txt lint: + desc: Static checker cmds: - revive -config revive.toml -formatter friendly ./... - task: lint:action swagger: + desc: generate swagger cmds: - swag init -g cmd/main.go - swag fmt -g cmd/main.go tools: + desc: install tools cmds: - go install github.com/go-task/task/v3/cmd/task@latest - go install github.com/mgechev/revive@latest @@ -69,46 +80,57 @@ tasks: - npm install -g prettier secure: + desc: Go vulnerability checker cmds: - govulncheck ./... dao: + desc: generate dao cmds: - go run github.com/flowline-io/flowbot/cmd/composer dao migrate: + desc: migrate database cmds: - go run github.com/flowline-io/flowbot/cmd/composer migrate import migration: + desc: create migration cmds: - go run github.com/flowline-io/flowbot/cmd/composer migrate migration -name {{ .CLI_ARGS }} tidy: + desc: Cleans up your Go module dependencies cmds: - go mod tidy leak: + desc: Find secrets with Gitleaks cmds: - gitleaks git -v snapshot: + desc: release snapshot cmds: - goreleaser release --snapshot --clean format: + desc: Format code cmds: - go fmt ./... - npx prettier --write . air: + desc: Live reload for Go apps cmds: - air --build.cmd "go build -o flowbot cmd/main.go" --build.bin "./flowbot" gosec: + desc: Go security checker cmds: - gosec ./... lint:action: + desc: Static checker for GitHub Actions workflow files cmds: - actionlint From 00ee454ee4fe51a8564cca8acdee46ad08321b27 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 22 May 2025 16:18:54 +0000 Subject: [PATCH 102/125] build(deps): bump github.com/cloudwego/eino from 0.3.36 to 0.3.37 Bumps [github.com/cloudwego/eino](https://github.com/cloudwego/eino) from 0.3.36 to 0.3.37. - [Release notes](https://github.com/cloudwego/eino/releases) - [Commits](https://github.com/cloudwego/eino/compare/v0.3.36...v0.3.37) --- updated-dependencies: - dependency-name: github.com/cloudwego/eino dependency-version: 0.3.37 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index fd387b9f..f58c02c6 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,7 @@ require ( github.com/bwmarrin/discordgo v0.28.1 github.com/bytedance/sonic v1.13.2 github.com/cenkalti/backoff v2.2.1+incompatible - github.com/cloudwego/eino v0.3.36 + github.com/cloudwego/eino v0.3.37 github.com/cloudwego/eino-ext/components/model/ollama v0.0.0-20250520101807-b2008771903a github.com/cloudwego/eino-ext/components/model/openai v0.0.0-20250520101807-b2008771903a github.com/creachadair/jrpc2 v1.3.1 diff --git a/go.sum b/go.sum index a3cc51e7..181c8006 100644 --- a/go.sum +++ b/go.sum @@ -65,8 +65,8 @@ github.com/chengxilo/virtualterm v1.0.4 h1:Z6IpERbRVlfB8WkOmtbHiDbBANU7cimRIof7m github.com/chengxilo/virtualterm v1.0.4/go.mod h1:DyxxBZz/x1iqJjFxTFcr6/x+jSpqN0iwWCOK1q10rlY= github.com/cloudwego/base64x v0.1.5 h1:XPciSp1xaq2VCSt6lF0phncD4koWyULpl5bUxbfCyP4= github.com/cloudwego/base64x v0.1.5/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w= -github.com/cloudwego/eino v0.3.36 h1:Wvt4oCy/RM/vHUixKTF5gJPCFvU4TARKPl52wJvatXI= -github.com/cloudwego/eino v0.3.36/go.mod h1:wUjz990apdsaOraOXdh6CdhVXq8DJsOvLsVlxNTcNfY= +github.com/cloudwego/eino v0.3.37 h1:UliGEzM88vVMmG9g2kZCyosaVbg7Rz0dNARs1c0HVs8= +github.com/cloudwego/eino v0.3.37/go.mod h1:wUjz990apdsaOraOXdh6CdhVXq8DJsOvLsVlxNTcNfY= github.com/cloudwego/eino-ext/components/model/ollama v0.0.0-20250520101807-b2008771903a h1:+/VYbeXv7bCdm0Wk183zIj9MjtF8yVaO1aDQyjfhf6c= github.com/cloudwego/eino-ext/components/model/ollama v0.0.0-20250520101807-b2008771903a/go.mod h1:giNUFqA+V7xrm/EDvH7JFnDqoWI+e2m1SVAnReU+Fd8= github.com/cloudwego/eino-ext/components/model/openai v0.0.0-20250520101807-b2008771903a h1:mpUCTgxWY34WyXopxMZcZPMJtg05tOCswxoRRXqT+lQ= From 816d3209b18c5c680ab5bd6116377c88273c6f9b Mon Sep 17 00:00:00 2001 From: sysatom Date: Fri, 23 May 2025 13:48:17 +0800 Subject: [PATCH 103/125] fix: build action --- .github/workflows/build.yml | 1 + taskfile.yaml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 699be220..d0368d25 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -33,6 +33,7 @@ jobs: go mod download go install github.com/go-task/task/v3/cmd/task@latest go install github.com/mgechev/revive@latest + go install github.com/rhysd/actionlint/cmd/actionlint@latest task lint - name: Build server diff --git a/taskfile.yaml b/taskfile.yaml index 590a730c..c4b391d5 100644 --- a/taskfile.yaml +++ b/taskfile.yaml @@ -100,7 +100,7 @@ tasks: - go run github.com/flowline-io/flowbot/cmd/composer migrate migration -name {{ .CLI_ARGS }} tidy: - desc: Cleans up your Go module dependencies + desc: Cleans up your Go module dependencies cmds: - go mod tidy From 81870830dc28e45b5fc2491b0b2cbdf44673e062 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 26 May 2025 16:49:48 +0000 Subject: [PATCH 104/125] build(deps): bump github.com/slack-go/slack from 0.16.0 to 0.17.0 Bumps [github.com/slack-go/slack](https://github.com/slack-go/slack) from 0.16.0 to 0.17.0. - [Release notes](https://github.com/slack-go/slack/releases) - [Changelog](https://github.com/slack-go/slack/blob/master/history.go) - [Commits](https://github.com/slack-go/slack/compare/v0.16.0...v0.17.0) --- updated-dependencies: - dependency-name: github.com/slack-go/slack dependency-version: 0.17.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 4 ++-- go.sum | 13 ++++++------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index f58c02c6..cfcd29c1 100644 --- a/go.mod +++ b/go.mod @@ -64,7 +64,7 @@ require ( github.com/samber/oops v1.18.0 github.com/schollz/progressbar/v3 v3.18.0 github.com/shirou/gopsutil/v4 v4.25.4 - github.com/slack-go/slack v0.16.0 + github.com/slack-go/slack v0.17.0 github.com/spf13/pflag v1.0.6 github.com/spf13/viper v1.20.1 github.com/stretchr/testify v1.10.0 @@ -136,7 +136,7 @@ require ( github.com/google/go-cmp v0.7.0 // indirect github.com/google/go-querystring v1.1.0 // indirect github.com/goph/emperror v0.17.2 // indirect - github.com/gorilla/websocket v1.5.1 // indirect + github.com/gorilla/websocket v1.5.3 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect diff --git a/go.sum b/go.sum index 181c8006..cfb1deec 100644 --- a/go.sum +++ b/go.sum @@ -177,10 +177,10 @@ github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9 github.com/go-sql-driver/mysql v1.8.1/go.mod h1:wEBSXgmK//2ZFJyE+qWnIsVGmvmEKlqwuVSjsCm7DZg= github.com/go-sql-driver/mysql v1.9.2 h1:4cNKDYQ1I84SXslGddlsrMhc8k4LeDVj6Ad6WRjiHuU= github.com/go-sql-driver/mysql v1.9.2/go.mod h1:qn46aNg1333BRMNU69Lq93t8du/dwxI64Gl8i5p1WMU= -github.com/go-test/deep v1.0.4/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= github.com/go-test/deep v1.0.8/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE= -github.com/go-test/deep v1.1.0 h1:WOcxcdHcvdgThNXjw0t76K42FXTU7HpNQWHpA2HHNlg= github.com/go-test/deep v1.1.0/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE= +github.com/go-test/deep v1.1.1 h1:0r/53hagsehfO4bzD2Pgr/+RgHqhmf+k1Bpse2cTu1U= +github.com/go-test/deep v1.1.1/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE= github.com/go-toast/toast v0.0.0-20190211030409-01e6764cf0a4 h1:qZNfIGkIANxGv/OqtnntR4DfOY2+BgwR60cAcu/i3SE= github.com/go-toast/toast v0.0.0-20190211030409-01e6764cf0a4/go.mod h1:kW3HQ4UdaAyrUCSSDR4xUzBKW6O2iA4uHhk7AtyYp10= github.com/go-viper/mapstructure/v2 v2.2.1 h1:ZAaOCxANMuZx5RCeg0mBdEZk7DZasvvZIxtHqx8aGss= @@ -216,7 +216,6 @@ github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6 github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= @@ -235,8 +234,8 @@ github.com/gopherjs/gopherjs v1.17.2 h1:fQnZVsXk8uxXIStYb0N4bGk7jeyTalG/wsZjQ25d github.com/gopherjs/gopherjs v1.17.2/go.mod h1:pRRIvn/QzFLrKfvEz3qUuEhtE/zLCWfreZ6J5gM2i+k= github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= -github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY= -github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY= +github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg= +github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 h1:YBftPWNWd4WwGqtY2yeZL2ef8rHAxPBD8KFhJpmcqms= github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0/go.mod h1:YN5jB8ie0yfIUg6VvR9Kz84aCaG7AsGZnLjhHbUqwPg= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= @@ -449,8 +448,8 @@ github.com/shirou/gopsutil/v4 v4.25.4/go.mod h1:xbuxyoZj+UsgnZrENu3lQivsngRR5Bdj github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= -github.com/slack-go/slack v0.16.0 h1:khp/WCFv+Hb/B/AJaAwvcxKun0hM6grN0bUZ8xG60P8= -github.com/slack-go/slack v0.16.0/go.mod h1:hlGi5oXA+Gt+yWTPP0plCdRKmjsDxecdHxYQdlMQKOw= +github.com/slack-go/slack v0.17.0 h1:Vqd4GGIcwwgEu80GBs3cXoPPho5bkDGSFnuZbSG0NhA= +github.com/slack-go/slack v0.17.0/go.mod h1:X+UqOufi3LYQHDnMG1vxf0J8asC6+WllXrVrhl8/Prk= github.com/slongfield/pyfmt v0.0.0-20220222012616-ea85ff4c361f h1:Z2cODYsUxQPofhpYRMQVwWz4yUVpHF+vPi+eUdruUYI= github.com/slongfield/pyfmt v0.0.0-20220222012616-ea85ff4c361f/go.mod h1:JqzWyvTuI2X4+9wOHmKSQCYxybB/8j6Ko43qVmXDuZg= github.com/smarty/assertions v1.15.0 h1:cR//PqUBUiQRakZWqBiFFQ9wb8emQGDb0HeGdqGByCY= From af4c5a6084cc72dd90d11d22a188025411ceffe6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 26 May 2025 16:49:56 +0000 Subject: [PATCH 105/125] build(deps): bump github.com/bwmarrin/discordgo from 0.28.1 to 0.29.0 Bumps [github.com/bwmarrin/discordgo](https://github.com/bwmarrin/discordgo) from 0.28.1 to 0.29.0. - [Release notes](https://github.com/bwmarrin/discordgo/releases) - [Commits](https://github.com/bwmarrin/discordgo/compare/v0.28.1...v0.29.0) --- updated-dependencies: - dependency-name: github.com/bwmarrin/discordgo dependency-version: 0.29.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index f58c02c6..ec42cd94 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/VictoriaMetrics/metrics v1.37.0 github.com/allegro/bigcache/v3 v3.1.0 github.com/bsm/redislock v0.9.4 - github.com/bwmarrin/discordgo v0.28.1 + github.com/bwmarrin/discordgo v0.29.0 github.com/bytedance/sonic v1.13.2 github.com/cenkalti/backoff v2.2.1+incompatible github.com/cloudwego/eino v0.3.37 diff --git a/go.sum b/go.sum index 181c8006..4f6f7079 100644 --- a/go.sum +++ b/go.sum @@ -43,8 +43,8 @@ github.com/bsm/redislock v0.9.4 h1:X/Wse1DPpiQgHbVYRE9zv6m070UcKoOGekgvpNhiSvw= github.com/bsm/redislock v0.9.4/go.mod h1:Epf7AJLiSFwLCiZcfi6pWFO/8eAYrYpQXFxEDPoDeAk= github.com/bugsnag/bugsnag-go v1.4.0/go.mod h1:2oa8nejYd4cQ/b0hMIopN0lCRxU0bueqREvZLWFrtK8= github.com/bugsnag/panicwrap v1.2.0/go.mod h1:D/8v3kj0zr8ZAKg1AQ6crr+5VwKN5eIywRkfhyM/+dE= -github.com/bwmarrin/discordgo v0.28.1 h1:gXsuo2GBO7NbR6uqmrrBDplPUx2T3nzu775q/Rd1aG4= -github.com/bwmarrin/discordgo v0.28.1/go.mod h1:NJZpH+1AfhIcyQsPeuBKsUtYrRnjkyu0kIVMCHkZtRY= +github.com/bwmarrin/discordgo v0.29.0 h1:FmWeXFaKUwrcL3Cx65c20bTRW+vOb6k8AnaP+EgjDno= +github.com/bwmarrin/discordgo v0.29.0/go.mod h1:NJZpH+1AfhIcyQsPeuBKsUtYrRnjkyu0kIVMCHkZtRY= github.com/bytedance/mockey v1.2.13 h1:jokWZAm/pUEbD939Rhznz615MKUCZNuvCFQlJ2+ntoo= github.com/bytedance/mockey v1.2.13/go.mod h1:1BPHF9sol5R1ud/+0VEHGQq/+i2lN+GTsr3O2Q9IENY= github.com/bytedance/sonic v1.13.2 h1:8/H1FempDZqC4VqjptGo14QQlJx8VdZJegxs6wwfqpQ= From 9fdd70857fe37fbb38890a1154ed1c82a391a2e3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 26 May 2025 16:49:59 +0000 Subject: [PATCH 106/125] build(deps): bump github.com/mark3labs/mcp-go from 0.29.0 to 0.30.0 Bumps [github.com/mark3labs/mcp-go](https://github.com/mark3labs/mcp-go) from 0.29.0 to 0.30.0. - [Release notes](https://github.com/mark3labs/mcp-go/releases) - [Commits](https://github.com/mark3labs/mcp-go/compare/v0.29.0...v0.30.0) --- updated-dependencies: - dependency-name: github.com/mark3labs/mcp-go dependency-version: 0.30.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index f58c02c6..8d01c1e4 100644 --- a/go.mod +++ b/go.mod @@ -47,7 +47,7 @@ require ( github.com/json-iterator/go v1.1.12 github.com/lithammer/shortuuid/v4 v4.2.0 github.com/looplab/fsm v1.0.3 - github.com/mark3labs/mcp-go v0.29.0 + github.com/mark3labs/mcp-go v0.30.0 github.com/maxence-charriere/go-app/v10 v10.1.3 github.com/meilisearch/meilisearch-go v0.32.0 github.com/minio/minio-go/v7 v7.0.92 diff --git a/go.sum b/go.sum index 181c8006..a26fc8ef 100644 --- a/go.sum +++ b/go.sum @@ -319,8 +319,8 @@ github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJ github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= github.com/mailru/easyjson v0.9.0 h1:PrnmzHw7262yW8sTBwxi1PdJA3Iw/EKBa8psRf7d9a4= github.com/mailru/easyjson v0.9.0/go.mod h1:1+xMtQp2MRNVL/V1bOzuP3aP8VNwRW55fQUto+XFtTU= -github.com/mark3labs/mcp-go v0.29.0 h1:sH1NBcumKskhxqYzhXfGc201D7P76TVXiT0fGVhabeI= -github.com/mark3labs/mcp-go v0.29.0/go.mod h1:rXqOudj/djTORU/ThxYx8fqEVj/5pvTuuebQ2RC7uk4= +github.com/mark3labs/mcp-go v0.30.0 h1:Taz7fiefkxY/l8jz1nA90V+WdM2eoMtlvwfWforVYbo= +github.com/mark3labs/mcp-go v0.30.0/go.mod h1:rXqOudj/djTORU/ThxYx8fqEVj/5pvTuuebQ2RC7uk4= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= From 1e3014a9918d6549e43455c0387d7836e2fb8105 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 26 May 2025 16:50:04 +0000 Subject: [PATCH 107/125] build(deps): bump gorm.io/gorm from 1.26.1 to 1.30.0 Bumps [gorm.io/gorm](https://github.com/go-gorm/gorm) from 1.26.1 to 1.30.0. - [Release notes](https://github.com/go-gorm/gorm/releases) - [Commits](https://github.com/go-gorm/gorm/compare/v1.26.1...v1.30.0) --- updated-dependencies: - dependency-name: gorm.io/gorm dependency-version: 1.30.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index f58c02c6..0eb71a26 100644 --- a/go.mod +++ b/go.mod @@ -82,7 +82,7 @@ require ( gopkg.in/yaml.v3 v3.0.1 gorm.io/driver/mysql v1.5.7 gorm.io/gen v0.3.27 - gorm.io/gorm v1.26.1 + gorm.io/gorm v1.30.0 gorm.io/plugin/dbresolver v1.6.0 gotest.tools/v3 v3.5.2 miniflux.app/v2 v2.2.8 diff --git a/go.sum b/go.sum index 181c8006..91abd023 100644 --- a/go.sum +++ b/go.sum @@ -739,8 +739,8 @@ gorm.io/gen v0.3.27/go.mod h1:9zquz2xD1f3Eb/eHq4oLn2z6vDVvQlCY5S3uMBLv4EA= gorm.io/gorm v1.21.15/go.mod h1:F+OptMscr0P2F2qU97WT1WimdH9GaQPoDW7AYd5i2Y0= gorm.io/gorm v1.22.2/go.mod h1:F+OptMscr0P2F2qU97WT1WimdH9GaQPoDW7AYd5i2Y0= gorm.io/gorm v1.25.7/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8= -gorm.io/gorm v1.26.1 h1:ghB2gUI9FkS46luZtn6DLZ0f6ooBJ5IbVej2ENFDjRw= -gorm.io/gorm v1.26.1/go.mod h1:8Z33v652h4//uMA76KjeDH8mJXPm1QNCYrMeatR0DOE= +gorm.io/gorm v1.30.0 h1:qbT5aPv1UH8gI99OsRlvDToLxW5zR7FzS9acZDOZcgs= +gorm.io/gorm v1.30.0/go.mod h1:8Z33v652h4//uMA76KjeDH8mJXPm1QNCYrMeatR0DOE= gorm.io/hints v1.1.0 h1:Lp4z3rxREufSdxn4qmkK3TLDltrM10FLTHiuqwDPvXw= gorm.io/hints v1.1.0/go.mod h1:lKQ0JjySsPBj3uslFzY3JhYDtqEwzm+G1hv8rWujB6Y= gorm.io/plugin/dbresolver v1.6.0 h1:XvKDeOtTn1EIX6s4SrKpEH82q0gXVemhYjbYZFGFVcw= From 5a6aebb05e67148ee7357efcff5a6b92b7d077d4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 27 May 2025 16:23:34 +0000 Subject: [PATCH 108/125] build(deps): bump github.com/expr-lang/expr from 1.17.3 to 1.17.4 Bumps [github.com/expr-lang/expr](https://github.com/expr-lang/expr) from 1.17.3 to 1.17.4. - [Release notes](https://github.com/expr-lang/expr/releases) - [Commits](https://github.com/expr-lang/expr/compare/v1.17.3...v1.17.4) --- updated-dependencies: - dependency-name: github.com/expr-lang/expr dependency-version: 1.17.4 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 729782c8..7de79236 100644 --- a/go.mod +++ b/go.mod @@ -25,7 +25,7 @@ require ( github.com/docker/go-units v0.5.0 github.com/dustin/go-humanize v1.0.1 github.com/emicklei/go-restful/v3 v3.12.2 - github.com/expr-lang/expr v1.17.3 + github.com/expr-lang/expr v1.17.4 github.com/fsnotify/fsnotify v1.9.0 github.com/gen2brain/beeep v0.0.0-20240516210008-9c006672e7f4 github.com/go-echarts/go-echarts/v2 v2.5.4 diff --git a/go.sum b/go.sum index 3f345412..d43ac8ec 100644 --- a/go.sum +++ b/go.sum @@ -118,8 +118,8 @@ github.com/emicklei/go-restful/v3 v3.12.2 h1:DhwDP0vY3k8ZzE0RunuJy8GhNpPL6zqLkDf github.com/emicklei/go-restful/v3 v3.12.2/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= -github.com/expr-lang/expr v1.17.3 h1:myeTTuDFz7k6eFe/JPlep/UsiIjVhG61FMHFu63U7j0= -github.com/expr-lang/expr v1.17.3/go.mod h1:8/vRC7+7HBzESEqt5kKpYXxrxkr31SaO8r40VO/1IT4= +github.com/expr-lang/expr v1.17.4 h1:qhTVftZ2Z3WpOEXRHWErEl2xf1Kq011MnQmWgLq06CY= +github.com/expr-lang/expr v1.17.4/go.mod h1:8/vRC7+7HBzESEqt5kKpYXxrxkr31SaO8r40VO/1IT4= github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw= From 30d17b1d1317b5fbc702e801686f779a09c04e82 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 27 May 2025 16:23:41 +0000 Subject: [PATCH 109/125] build(deps): bump github.com/redis/go-redis/v9 from 9.8.0 to 9.9.0 Bumps [github.com/redis/go-redis/v9](https://github.com/redis/go-redis) from 9.8.0 to 9.9.0. - [Release notes](https://github.com/redis/go-redis/releases) - [Changelog](https://github.com/redis/go-redis/blob/master/CHANGELOG.md) - [Commits](https://github.com/redis/go-redis/compare/v9.8.0...v9.9.0) --- updated-dependencies: - dependency-name: github.com/redis/go-redis/v9 dependency-version: 9.9.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 729782c8..23f8532d 100644 --- a/go.mod +++ b/go.mod @@ -57,7 +57,7 @@ require ( github.com/pkoukk/tiktoken-go v0.1.7 github.com/prometheus/client_model v0.6.2 github.com/prometheus/common v0.64.0 - github.com/redis/go-redis/v9 v9.8.0 + github.com/redis/go-redis/v9 v9.9.0 github.com/robfig/cron/v3 v3.0.1 github.com/rs/zerolog v1.34.0 github.com/samber/lo v1.50.0 diff --git a/go.sum b/go.sum index 3f345412..44f6622a 100644 --- a/go.sum +++ b/go.sum @@ -419,8 +419,8 @@ github.com/prometheus/client_model v0.6.2 h1:oBsgwpGs7iVziMvrGhE53c/GrLUsZdHnqNw github.com/prometheus/client_model v0.6.2/go.mod h1:y3m2F6Gdpfy6Ut/GBsUqTWZqCUvMVzSfMLjcu6wAwpE= github.com/prometheus/common v0.64.0 h1:pdZeA+g617P7oGv1CzdTzyeShxAGrTBsolKNOLQPGO4= github.com/prometheus/common v0.64.0/go.mod h1:0gZns+BLRQ3V6NdaerOhMbwwRbNh9hkGINtQAsP5GS8= -github.com/redis/go-redis/v9 v9.8.0 h1:q3nRvjrlge/6UD7eTu/DSg2uYiU2mCL0G/uzBWqhicI= -github.com/redis/go-redis/v9 v9.8.0/go.mod h1:huWgSWd8mW6+m0VPhJjSSQ+d6Nh1VICQ6Q5lHuCH/Iw= +github.com/redis/go-redis/v9 v9.9.0 h1:URbPQ4xVQSQhZ27WMQVmZSo3uT3pL+4IdHVcYq2nVfM= +github.com/redis/go-redis/v9 v9.9.0/go.mod h1:huWgSWd8mW6+m0VPhJjSSQ+d6Nh1VICQ6Q5lHuCH/Iw= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= From cf6652247b99c11b42751133ba9fde58f366ec38 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 28 May 2025 06:43:11 +0000 Subject: [PATCH 110/125] build(deps): bump github.com/samber/oops from 1.18.0 to 1.18.1 Bumps [github.com/samber/oops](https://github.com/samber/oops) from 1.18.0 to 1.18.1. - [Release notes](https://github.com/samber/oops/releases) - [Commits](https://github.com/samber/oops/compare/v1.18.0...v1.18.1) --- updated-dependencies: - dependency-name: github.com/samber/oops dependency-version: 1.18.1 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 4 ++-- go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 919c69eb..7dd1cc3a 100644 --- a/go.mod +++ b/go.mod @@ -61,7 +61,7 @@ require ( github.com/robfig/cron/v3 v3.0.1 github.com/rs/zerolog v1.34.0 github.com/samber/lo v1.50.0 - github.com/samber/oops v1.18.0 + github.com/samber/oops v1.18.1 github.com/schollz/progressbar/v3 v3.18.0 github.com/shirou/gopsutil/v4 v4.25.4 github.com/slack-go/slack v0.17.0 @@ -169,7 +169,7 @@ require ( github.com/nikolalohinski/gonja v1.5.3 // indirect github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d // indirect github.com/oklog/ulid v1.3.1 // indirect - github.com/oklog/ulid/v2 v2.1.0 // indirect + github.com/oklog/ulid/v2 v2.1.1 // indirect github.com/ollama/ollama v0.5.12 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect github.com/opencontainers/image-spec v1.1.0 // indirect diff --git a/go.sum b/go.sum index 424b944d..d3699117 100644 --- a/go.sum +++ b/go.sum @@ -384,8 +384,8 @@ github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d h1:VhgPp6v9qf9Agr/ github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d/go.mod h1:YUTz3bUH2ZwIWBy3CJBeOBEugqcmXREj14T+iG/4k4U= github.com/oklog/ulid v1.3.1 h1:EGfNDEx6MqHz8B3uNV6QAib1UR2Lm97sHi3ocA6ESJ4= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= -github.com/oklog/ulid/v2 v2.1.0 h1:+9lhoxAP56we25tyYETBBY1YLA2SaoLvUFgrP2miPJU= -github.com/oklog/ulid/v2 v2.1.0/go.mod h1:rcEKHmBBKfef9DhnvX7y1HZBYxjXb0cP5ExxNsTT1QQ= +github.com/oklog/ulid/v2 v2.1.1 h1:suPZ4ARWLOJLegGFiZZ1dFAkqzhMjL3J1TzI+5wHz8s= +github.com/oklog/ulid/v2 v2.1.1/go.mod h1:rcEKHmBBKfef9DhnvX7y1HZBYxjXb0cP5ExxNsTT1QQ= github.com/ollama/ollama v0.5.12 h1:qM+k/ozyHLJzEQoAEPrUQ0qXqsgDEEdpIVwuwScrd2U= github.com/ollama/ollama v0.5.12/go.mod h1:ibdmDvb/TjKY1OArBWIazL3pd1DHTk8eG2MMjEkWhiI= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= @@ -439,8 +439,8 @@ github.com/sagikazarmark/locafero v0.7.0 h1:5MqpDsTGNDhY8sGp0Aowyf0qKsPrhewaLSsF github.com/sagikazarmark/locafero v0.7.0/go.mod h1:2za3Cg5rMaTMoG/2Ulr9AwtFaIppKXTRYnozin4aB5k= github.com/samber/lo v1.50.0 h1:XrG0xOeHs+4FQ8gJR97zDz5uOFMW7OwFWiFVzqopKgY= github.com/samber/lo v1.50.0/go.mod h1:RjZyNk6WSnUFRKK6EyOhsRJMqft3G+pg7dCWHQCWvsc= -github.com/samber/oops v1.18.0 h1:NnoCdxlOg/ajFos8HIC0+dV8S6cZRcrjW1WrfZe+GOc= -github.com/samber/oops v1.18.0/go.mod h1:DcZbba2s+PzSx14vY6HjvhV1FDsGOZ1TJg7T/ZZARBQ= +github.com/samber/oops v1.18.1 h1:qjhZbqbdyhWBKntkY8sxrDNKA8b4c5VHlmI1rli7X7M= +github.com/samber/oops v1.18.1/go.mod h1:xYqvimigkKV70HyLXiBZJFpIWi2CGcc6Xx7eV+2HycI= github.com/schollz/progressbar/v3 v3.18.0 h1:uXdoHABRFmNIjUfte/Ex7WtuyVslrw2wVPQmCN62HpA= github.com/schollz/progressbar/v3 v3.18.0/go.mod h1:IsO3lpbaGuzh8zIMzgY3+J8l4C8GjO0Y9S69eFvNsec= github.com/shirou/gopsutil/v4 v4.25.4 h1:cdtFO363VEOOFrUCjZRh4XVJkb548lyF0q0uTeMqYPw= From 722fa0c60f80a1ce88db4ef322e707ada7ffe933 Mon Sep 17 00:00:00 2001 From: sysatom Date: Wed, 28 May 2025 16:37:58 +0800 Subject: [PATCH 111/125] feat: go-github upgrade v72 --- cmd/agent/updater/updater.go | 4 ++-- go.mod | 2 +- go.sum | 4 ++-- pkg/config/config.go | 5 ----- 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/cmd/agent/updater/updater.go b/cmd/agent/updater/updater.go index 3095daa1..69162ce3 100644 --- a/cmd/agent/updater/updater.go +++ b/cmd/agent/updater/updater.go @@ -4,7 +4,6 @@ import ( "context" "crypto/sha256" "fmt" - "github.com/samber/lo" "io" "net/http" "os" @@ -14,8 +13,9 @@ import ( "github.com/Masterminds/semver/v3" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/version" - "github.com/google/go-github/v66/github" + "github.com/google/go-github/v72/github" "github.com/minio/selfupdate" + "github.com/samber/lo" "github.com/schollz/progressbar/v3" ) diff --git a/go.mod b/go.mod index 7dd1cc3a..3ebba7b2 100644 --- a/go.mod +++ b/go.mod @@ -37,7 +37,7 @@ require ( github.com/gofiber/fiber/v2 v2.52.8 github.com/gofiber/swagger v1.1.1 github.com/golang-migrate/migrate/v4 v4.18.3 - github.com/google/go-github/v66 v66.0.0 + github.com/google/go-github/v72 v72.0.0 github.com/google/uuid v1.6.0 github.com/heimdalr/dag v1.5.0 github.com/hekmon/transmissionrpc/v3 v3.0.0 diff --git a/go.sum b/go.sum index d3699117..551bd289 100644 --- a/go.sum +++ b/go.sum @@ -219,8 +219,8 @@ github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= -github.com/google/go-github/v66 v66.0.0 h1:ADJsaXj9UotwdgK8/iFZtv7MLc8E8WBl62WLd/D/9+M= -github.com/google/go-github/v66 v66.0.0/go.mod h1:+4SO9Zkuyf8ytMj0csN1NR/5OTR+MfqPp8P8dVlcvY4= +github.com/google/go-github/v72 v72.0.0 h1:FcIO37BLoVPBO9igQQ6tStsv2asG4IPcYFi655PPvBM= +github.com/google/go-github/v72 v72.0.0/go.mod h1:WWtw8GMRiL62mvIquf1kO3onRHeWWKmK01qdCY8c5fg= github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8= github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= diff --git a/pkg/config/config.go b/pkg/config/config.go index b1a7077e..f619e594 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -319,11 +319,6 @@ func NewConfig(lc fx.Lifecycle) Type { } log.Printf("API served from root URL path '%s'\n", App.ApiPath) - // // Debug - // if App.IsDevelopmentMode() { - // viper.Debug() - // } - // fx hooks lc.Append(fx.Hook{ OnStart: func(ctx context.Context) error { From d22d8bf18a9ca8ad53b6e38e225abb6bfdbe01d7 Mon Sep 17 00:00:00 2001 From: sysatom Date: Wed, 28 May 2025 16:43:58 +0800 Subject: [PATCH 112/125] fix: reader_daily_summary scope --- internal/bots/reader/cron.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/bots/reader/cron.go b/internal/bots/reader/cron.go index e028837e..cc9dc409 100644 --- a/internal/bots/reader/cron.go +++ b/internal/bots/reader/cron.go @@ -46,7 +46,7 @@ var cronRules = []cron.Rule{ }, { Name: "reader_daily_summary", - Scope: cron.CronScopeUser, + Scope: cron.CronScopeSystem, When: "0 9 * * *", Action: func(ctx types.Context) []types.MsgPayload { if !agents.AgentEnabled(agents.AgentNewsSummary) { From 84899064d36860784c900ad0bf1ee91ad9a42e60 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 28 May 2025 16:18:06 +0000 Subject: [PATCH 113/125] build(deps): bump github.com/mark3labs/mcp-go from 0.30.0 to 0.30.1 Bumps [github.com/mark3labs/mcp-go](https://github.com/mark3labs/mcp-go) from 0.30.0 to 0.30.1. - [Release notes](https://github.com/mark3labs/mcp-go/releases) - [Commits](https://github.com/mark3labs/mcp-go/compare/v0.30.0...v0.30.1) --- updated-dependencies: - dependency-name: github.com/mark3labs/mcp-go dependency-version: 0.30.1 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 3ebba7b2..ffa53291 100644 --- a/go.mod +++ b/go.mod @@ -47,7 +47,7 @@ require ( github.com/json-iterator/go v1.1.12 github.com/lithammer/shortuuid/v4 v4.2.0 github.com/looplab/fsm v1.0.3 - github.com/mark3labs/mcp-go v0.30.0 + github.com/mark3labs/mcp-go v0.30.1 github.com/maxence-charriere/go-app/v10 v10.1.3 github.com/meilisearch/meilisearch-go v0.32.0 github.com/minio/minio-go/v7 v7.0.92 diff --git a/go.sum b/go.sum index 551bd289..8e9b8c26 100644 --- a/go.sum +++ b/go.sum @@ -318,8 +318,8 @@ github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJ github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= github.com/mailru/easyjson v0.9.0 h1:PrnmzHw7262yW8sTBwxi1PdJA3Iw/EKBa8psRf7d9a4= github.com/mailru/easyjson v0.9.0/go.mod h1:1+xMtQp2MRNVL/V1bOzuP3aP8VNwRW55fQUto+XFtTU= -github.com/mark3labs/mcp-go v0.30.0 h1:Taz7fiefkxY/l8jz1nA90V+WdM2eoMtlvwfWforVYbo= -github.com/mark3labs/mcp-go v0.30.0/go.mod h1:rXqOudj/djTORU/ThxYx8fqEVj/5pvTuuebQ2RC7uk4= +github.com/mark3labs/mcp-go v0.30.1 h1:3R1BPvNT/rC1iPpLx+EMXFy+gvux/Mz/Nio3c6XEU9E= +github.com/mark3labs/mcp-go v0.30.1/go.mod h1:rXqOudj/djTORU/ThxYx8fqEVj/5pvTuuebQ2RC7uk4= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= From ebac37cf3442c5719ae557b5c37914292f8608b3 Mon Sep 17 00:00:00 2001 From: sysatom Date: Thu, 29 May 2025 10:44:47 +0800 Subject: [PATCH 114/125] feat: urfave/cli upgrade v3 --- cmd/composer/action/dao/dao.go | 5 +++-- cmd/composer/action/doc/schema.go | 5 +++-- cmd/composer/action/generator/bot.go | 5 +++-- cmd/composer/action/generator/vendor.go | 5 +++-- cmd/composer/action/migrate/migration.go | 5 +++-- cmd/composer/action/workflow/import.go | 5 +++-- cmd/composer/main.go | 27 ++++++++++++------------ go.mod | 5 +---- go.sum | 10 ++------- 9 files changed, 35 insertions(+), 37 deletions(-) diff --git a/cmd/composer/action/dao/dao.go b/cmd/composer/action/dao/dao.go index 06fd3974..4ac5cadd 100644 --- a/cmd/composer/action/dao/dao.go +++ b/cmd/composer/action/dao/dao.go @@ -1,11 +1,12 @@ package dao import ( + "context" "io" "os" "github.com/flowline-io/flowbot/pkg/flog" - "github.com/urfave/cli/v2" + "github.com/urfave/cli/v3" "gopkg.in/yaml.v3" "gorm.io/driver/mysql" "gorm.io/gen" @@ -30,7 +31,7 @@ type Querier interface { FindByUidAndTopic(uid, topic string) ([]*gen.T, error) } -func GenerationAction(c *cli.Context) error { +func GenerationAction(ctx context.Context, c *cli.Command) error { conffile := c.String("config") file, err := os.Open(conffile) diff --git a/cmd/composer/action/doc/schema.go b/cmd/composer/action/doc/schema.go index 4e0e46de..4c1cd2f5 100644 --- a/cmd/composer/action/doc/schema.go +++ b/cmd/composer/action/doc/schema.go @@ -1,6 +1,7 @@ package doc import ( + "context" "database/sql" "fmt" "io" @@ -12,7 +13,7 @@ import ( "github.com/flowline-io/flowbot/pkg/flog" _ "github.com/go-sql-driver/mysql" //revive:disable "github.com/jmoiron/sqlx" - "github.com/urfave/cli/v2" + "github.com/urfave/cli/v3" "gopkg.in/yaml.v3" ) @@ -73,7 +74,7 @@ func NullString2String(s sql.NullString) string { } } -func SchemaAction(c *cli.Context) error { +func SchemaAction(ctx context.Context, c *cli.Command) error { conffile := c.String("config") database := c.String("database") diff --git a/cmd/composer/action/generator/bot.go b/cmd/composer/action/generator/bot.go index dffffea1..4d0a44c4 100644 --- a/cmd/composer/action/generator/bot.go +++ b/cmd/composer/action/generator/bot.go @@ -2,6 +2,7 @@ package generator import ( "bytes" + "context" _ "embed" "errors" "fmt" @@ -9,7 +10,7 @@ import ( "text/template" "github.com/flowline-io/flowbot/pkg/flog" - "github.com/urfave/cli/v2" + "github.com/urfave/cli/v3" ) //go:embed tmpl/main.tmpl @@ -47,7 +48,7 @@ var inputFuncTemple string const BasePath = "./internal/bots" -func BotAction(c *cli.Context) error { +func BotAction(ctx context.Context, c *cli.Command) error { // args bot := c.String("name") rule := c.StringSlice("rule") // input,group,collect,command,condition,cron,form diff --git a/cmd/composer/action/generator/vendor.go b/cmd/composer/action/generator/vendor.go index 6b6813bb..1480f3cc 100644 --- a/cmd/composer/action/generator/vendor.go +++ b/cmd/composer/action/generator/vendor.go @@ -1,13 +1,14 @@ package generator import ( + "context" _ "embed" "errors" "fmt" "os" "github.com/flowline-io/flowbot/pkg/utils" - "github.com/urfave/cli/v2" + "github.com/urfave/cli/v3" ) //go:embed tmpl/vendor.tmpl @@ -15,7 +16,7 @@ var vendorTemple string const VendorsPath = "./pkg/providers" -func VendorAction(c *cli.Context) error { +func VendorAction(ctx context.Context, c *cli.Command) error { vendor := c.String("name") if vendor == "" { return errors.New("vendor name args error") diff --git a/cmd/composer/action/migrate/migration.go b/cmd/composer/action/migrate/migration.go index 820dd77c..1faaeae3 100644 --- a/cmd/composer/action/migrate/migration.go +++ b/cmd/composer/action/migrate/migration.go @@ -1,6 +1,7 @@ package migrate import ( + "context" "errors" "fmt" "log" @@ -9,12 +10,12 @@ import ( "strconv" "github.com/flowline-io/flowbot/pkg/flog" - "github.com/urfave/cli/v2" + "github.com/urfave/cli/v3" ) const path = "./internal/store/migrate/migrations" -func MigrationAction(c *cli.Context) error { +func MigrationAction(ctx context.Context, c *cli.Command) error { name := c.String("name") if name == "" { return errors.New("error name") diff --git a/cmd/composer/action/workflow/import.go b/cmd/composer/action/workflow/import.go index 163adf05..c3b03952 100644 --- a/cmd/composer/action/workflow/import.go +++ b/cmd/composer/action/workflow/import.go @@ -1,6 +1,7 @@ package workflow import ( + "context" "errors" "fmt" "io" @@ -11,11 +12,11 @@ import ( "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/types/protocol" "github.com/go-resty/resty/v2" - "github.com/urfave/cli/v2" + "github.com/urfave/cli/v3" "gopkg.in/yaml.v3" ) -func ImportAction(c *cli.Context) error { +func ImportAction(ctx context.Context, c *cli.Command) error { // api url conffile := c.String("config") diff --git a/cmd/composer/main.go b/cmd/composer/main.go index 50c579a8..3bd772c0 100644 --- a/cmd/composer/main.go +++ b/cmd/composer/main.go @@ -1,6 +1,7 @@ package main import ( + "context" "fmt" "os" @@ -11,30 +12,30 @@ import ( "github.com/flowline-io/flowbot/cmd/composer/action/workflow" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/version" - "github.com/urfave/cli/v2" + "github.com/urfave/cli/v3" ) func main() { command := NewCommand() - if err := command.Run(os.Args); err != nil { + if err := command.Run(context.Background(), os.Args); err != nil { flog.Panic(err.Error()) } } -func NewCommand() *cli.App { - cli.VersionPrinter = func(_ *cli.Context) { +func NewCommand() *cli.Command { + cli.VersionPrinter = func(_ *cli.Command) { _, _ = fmt.Printf("version=%s\n", version.Buildtags) } - return &cli.App{ - Name: "composer", - Usage: "chatbot tool cli", - EnableBashCompletion: true, - Version: version.Buildtags, + return &cli.Command{ + Name: "composer", + Usage: "chatbot tool cli", + EnableShellCompletion: true, + Version: version.Buildtags, Commands: []*cli.Command{ { Name: "migrate", Usage: "migrate tool", - Subcommands: []*cli.Command{ + Commands: []*cli.Command{ { Name: "migration", Usage: "generate migration files", @@ -52,7 +53,7 @@ func NewCommand() *cli.App { { Name: "generator", Usage: "code generator", - Subcommands: []*cli.Command{ + Commands: []*cli.Command{ { Name: "bot", Usage: "generate bot code files", @@ -64,7 +65,7 @@ func NewCommand() *cli.App { }, &cli.StringSliceFlag{ Name: "rule", - Value: cli.NewStringSlice("command"), + Value: []string{"command"}, Usage: "rule type", }, }, @@ -116,7 +117,7 @@ func NewCommand() *cli.App { { Name: "workflow", Usage: "workflow", - Subcommands: []*cli.Command{ + Commands: []*cli.Command{ { Name: "import", Usage: "import workflow yaml", diff --git a/go.mod b/go.mod index ffa53291..d8894ae4 100644 --- a/go.mod +++ b/go.mod @@ -70,7 +70,7 @@ require ( github.com/stretchr/testify v1.10.0 github.com/swaggo/swag v1.16.4 github.com/tidwall/gjson v1.18.0 - github.com/urfave/cli/v2 v2.27.6 + github.com/urfave/cli/v3 v3.3.3 github.com/valyala/fasthttp v1.62.0 go.uber.org/automaxprocs v1.6.0 go.uber.org/fx v1.24.0 @@ -103,7 +103,6 @@ require ( github.com/cloudwego/base64x v0.1.5 // indirect github.com/cloudwego/eino-ext/libs/acl/openai v0.0.0-20250519084852-38fafa73d9ea // indirect github.com/containerd/log v0.1.0 // indirect - github.com/cpuguy83/go-md2man/v2 v2.0.5 // indirect github.com/creachadair/mds v0.23.0 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/davidmz/go-pageant v1.0.2 // indirect @@ -181,7 +180,6 @@ require ( github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect github.com/rivo/uniseg v0.4.7 // indirect github.com/rs/xid v1.6.0 // indirect - github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/sagikazarmark/locafero v0.7.0 // indirect github.com/sirupsen/logrus v1.9.3 // indirect github.com/slongfield/pyfmt v0.0.0-20220222012616-ea85ff4c361f // indirect @@ -202,7 +200,6 @@ require ( github.com/valyala/fastrand v1.1.0 // indirect github.com/valyala/histogram v1.2.0 // indirect github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect - github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect github.com/yargevad/filepathx v1.0.0 // indirect github.com/yosida95/uritemplate/v3 v3.0.2 // indirect github.com/yusufpapurcu/wmi v1.2.4 // indirect diff --git a/go.sum b/go.sum index 8e9b8c26..d54b0435 100644 --- a/go.sum +++ b/go.sum @@ -77,8 +77,6 @@ github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQ github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I= github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo= github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= -github.com/cpuguy83/go-md2man/v2 v2.0.5 h1:ZtcqGrnekaHpVLArFSe4HK5DoKx1T0rq2DwVB0alcyc= -github.com/cpuguy83/go-md2man/v2 v2.0.5/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/creachadair/jrpc2 v1.3.1 h1:4B2R9050CYdhCKepbFVWQVG0/EFqRa9MuuM1Thd7tZo= github.com/creachadair/jrpc2 v1.3.1/go.mod h1:GtMp2RXHMnrdOY8hWWlbBpjWXSVDXhuO/LMRJAtRFno= github.com/creachadair/mds v0.23.0 h1:cANHIuKZwbfIoo/zEWA2sn+uGYjqYHuWvpoApkdjGpg= @@ -433,8 +431,6 @@ github.com/rs/xid v1.6.0 h1:fV591PaemRlL6JfRxGDEPl69wICngIQ3shQtzfy2gxU= github.com/rs/xid v1.6.0/go.mod h1:7XoLgs4eV+QndskICGsho+ADou8ySMSjJKDIan90Nz0= github.com/rs/zerolog v1.34.0 h1:k43nTLIwcTVQAncfCw4KZ2VY6ukYoZaBPNOE8txlOeY= github.com/rs/zerolog v1.34.0/go.mod h1:bJsvje4Z08ROH4Nhs5iH600c3IkWhwp44iRc54W6wYQ= -github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= -github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/sagikazarmark/locafero v0.7.0 h1:5MqpDsTGNDhY8sGp0Aowyf0qKsPrhewaLSsFaodPcyo= github.com/sagikazarmark/locafero v0.7.0/go.mod h1:2za3Cg5rMaTMoG/2Ulr9AwtFaIppKXTRYnozin4aB5k= github.com/samber/lo v1.50.0 h1:XrG0xOeHs+4FQ8gJR97zDz5uOFMW7OwFWiFVzqopKgY= @@ -509,8 +505,8 @@ github.com/ugorji/go v1.2.7/go.mod h1:nF9osbDWLy6bDVv/Rtoh6QgnvNDpmCalQV5urGCCS6 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/urfave/cli/v2 v2.27.6 h1:VdRdS98FNhKZ8/Az8B7MTyGQmpIr36O1EHybx/LaZ4g= -github.com/urfave/cli/v2 v2.27.6/go.mod h1:3Sevf16NykTbInEnD0yKkjDAeZDS0A6bzhBH5hrMvTQ= +github.com/urfave/cli/v3 v3.3.3 h1:byCBaVdIXuLPIDm5CYZRVG6NvT7tv1ECqdU4YzlEa3I= +github.com/urfave/cli/v3 v3.3.3/go.mod h1:FJSKtM/9AiiTOJL4fJ6TbMUkxBXn7GO9guZqoZtpYpo= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= github.com/valyala/fasthttp v1.62.0 h1:8dKRBX/y2rCzyc6903Zu1+3qN0H/d2MsxPPmVNamiH0= @@ -523,8 +519,6 @@ github.com/vmihailenco/msgpack v4.0.4+incompatible h1:dSLoQfGFAo3F6OoNhwUmLwVgaU github.com/vmihailenco/msgpack v4.0.4+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= github.com/x-cray/logrus-prefixed-formatter v0.5.2 h1:00txxvfBM9muc0jiLIEAkAcIMJzfthRT6usrui8uGmg= github.com/x-cray/logrus-prefixed-formatter v0.5.2/go.mod h1:2duySbKsL6M18s5GU7VPsoEPHyzalCE06qoARUCeBBE= -github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 h1:gEOO8jv9F4OT7lGCjxCBTO/36wtF6j2nSip77qHd4x4= -github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1/go.mod h1:Ohn+xnUBiLI6FVj/9LpzZWtj1/D6lUovWYBkxHVV3aM= github.com/xyproto/randomstring v1.0.5 h1:YtlWPoRdgMu3NZtP45drfy1GKoojuR7hmRcnhZqKjWU= github.com/xyproto/randomstring v1.0.5/go.mod h1:rgmS5DeNXLivK7YprL0pY+lTuhNQW3iGxZ18UQApw/E= github.com/yargevad/filepathx v1.0.0 h1:SYcT+N3tYGi+NvazubCNlvgIPbzAk7i7y2dwg3I5FYc= From 988951d8bb19e46e192336cc1ac46eac735b8fb6 Mon Sep 17 00:00:00 2001 From: sysatom Date: Thu, 29 May 2025 10:45:35 +0800 Subject: [PATCH 115/125] build(dao): gen files --- internal/store/dao/jobs.gen.go | 13 +++++++++++++ internal/store/dao/key_results.gen.go | 26 ++++++++++++++++++++++++++ internal/store/dao/messages.gen.go | 8 ++++---- internal/store/dao/objectives.gen.go | 26 ++++++++++++++++++++++++++ internal/store/dao/reviews.gen.go | 13 +++++++++++++ internal/store/dao/todos.gen.go | 13 +++++++++++++ internal/store/dao/workflow.gen.go | 26 ++++++++++++++++++++++++++ internal/store/model/messages.gen.go | 2 +- 8 files changed, 122 insertions(+), 5 deletions(-) diff --git a/internal/store/dao/jobs.gen.go b/internal/store/dao/jobs.gen.go index 54cae094..e9f5f260 100644 --- a/internal/store/dao/jobs.gen.go +++ b/internal/store/dao/jobs.gen.go @@ -130,11 +130,14 @@ func (j *job) fillFieldMap() { func (j job) clone(db *gorm.DB) job { j.jobDo.ReplaceConnPool(db.Statement.ConnPool) + j.Steps.db = db.Session(&gorm.Session{Initialized: true}) + j.Steps.db.Statement.ConnPool = db.Statement.ConnPool return j } func (j job) replaceDB(db *gorm.DB) job { j.jobDo.ReplaceDB(db) + j.Steps.db = db.Session(&gorm.Session{}) return j } @@ -171,6 +174,11 @@ func (a jobHasManySteps) Model(m *model.Job) *jobHasManyStepsTx { return &jobHasManyStepsTx{a.db.Model(m).Association(a.Name())} } +func (a jobHasManySteps) Unscoped() *jobHasManySteps { + a.db = a.db.Unscoped() + return &a +} + type jobHasManyStepsTx struct{ tx *gorm.Association } func (a jobHasManyStepsTx) Find() (result []*model.Step, err error) { @@ -209,6 +217,11 @@ func (a jobHasManyStepsTx) Count() int64 { return a.tx.Count() } +func (a jobHasManyStepsTx) Unscoped() *jobHasManyStepsTx { + a.tx = a.tx.Unscoped() + return &a +} + type jobDo struct{ gen.DO } // GetByID diff --git a/internal/store/dao/key_results.gen.go b/internal/store/dao/key_results.gen.go index 8e0ee1bf..0f58ac76 100644 --- a/internal/store/dao/key_results.gen.go +++ b/internal/store/dao/key_results.gen.go @@ -151,11 +151,17 @@ func (k *keyResult) fillFieldMap() { func (k keyResult) clone(db *gorm.DB) keyResult { k.keyResultDo.ReplaceConnPool(db.Statement.ConnPool) + k.KeyResultValues.db = db.Session(&gorm.Session{Initialized: true}) + k.KeyResultValues.db.Statement.ConnPool = db.Statement.ConnPool + k.Todos.db = db.Session(&gorm.Session{Initialized: true}) + k.Todos.db.Statement.ConnPool = db.Statement.ConnPool return k } func (k keyResult) replaceDB(db *gorm.DB) keyResult { k.keyResultDo.ReplaceDB(db) + k.KeyResultValues.db = db.Session(&gorm.Session{}) + k.Todos.db = db.Session(&gorm.Session{}) return k } @@ -192,6 +198,11 @@ func (a keyResultHasManyKeyResultValues) Model(m *model.KeyResult) *keyResultHas return &keyResultHasManyKeyResultValuesTx{a.db.Model(m).Association(a.Name())} } +func (a keyResultHasManyKeyResultValues) Unscoped() *keyResultHasManyKeyResultValues { + a.db = a.db.Unscoped() + return &a +} + type keyResultHasManyKeyResultValuesTx struct{ tx *gorm.Association } func (a keyResultHasManyKeyResultValuesTx) Find() (result []*model.KeyResultValue, err error) { @@ -230,6 +241,11 @@ func (a keyResultHasManyKeyResultValuesTx) Count() int64 { return a.tx.Count() } +func (a keyResultHasManyKeyResultValuesTx) Unscoped() *keyResultHasManyKeyResultValuesTx { + a.tx = a.tx.Unscoped() + return &a +} + type keyResultHasManyTodos struct { db *gorm.DB @@ -267,6 +283,11 @@ func (a keyResultHasManyTodos) Model(m *model.KeyResult) *keyResultHasManyTodosT return &keyResultHasManyTodosTx{a.db.Model(m).Association(a.Name())} } +func (a keyResultHasManyTodos) Unscoped() *keyResultHasManyTodos { + a.db = a.db.Unscoped() + return &a +} + type keyResultHasManyTodosTx struct{ tx *gorm.Association } func (a keyResultHasManyTodosTx) Find() (result []*model.Todo, err error) { @@ -305,6 +326,11 @@ func (a keyResultHasManyTodosTx) Count() int64 { return a.tx.Count() } +func (a keyResultHasManyTodosTx) Unscoped() *keyResultHasManyTodosTx { + a.tx = a.tx.Unscoped() + return &a +} + type keyResultDo struct{ gen.DO } // GetByID diff --git a/internal/store/dao/messages.gen.go b/internal/store/dao/messages.gen.go index 7a3ffec2..4ee3f8e2 100644 --- a/internal/store/dao/messages.gen.go +++ b/internal/store/dao/messages.gen.go @@ -32,8 +32,8 @@ func newMessage(db *gorm.DB, opts ...gen.DOOption) message { _message.PlatformID = field.NewInt64(tableName, "platform_id") _message.PlatformMsgID = field.NewString(tableName, "platform_msg_id") _message.Topic = field.NewString(tableName, "topic") - _message.Session = field.NewString(tableName, "session") _message.Role = field.NewString(tableName, "role") + _message.Session = field.NewString(tableName, "session") _message.Content = field.NewField(tableName, "content") _message.State = field.NewField(tableName, "state") _message.CreatedAt = field.NewTime(tableName, "created_at") @@ -54,8 +54,8 @@ type message struct { PlatformID field.Int64 PlatformMsgID field.String Topic field.String - Session field.String Role field.String + Session field.String Content field.Field State field.Field CreatedAt field.Time @@ -82,8 +82,8 @@ func (m *message) updateTableName(table string) *message { m.PlatformID = field.NewInt64(table, "platform_id") m.PlatformMsgID = field.NewString(table, "platform_msg_id") m.Topic = field.NewString(table, "topic") - m.Session = field.NewString(table, "session") m.Role = field.NewString(table, "role") + m.Session = field.NewString(table, "session") m.Content = field.NewField(table, "content") m.State = field.NewField(table, "state") m.CreatedAt = field.NewTime(table, "created_at") @@ -111,8 +111,8 @@ func (m *message) fillFieldMap() { m.fieldMap["platform_id"] = m.PlatformID m.fieldMap["platform_msg_id"] = m.PlatformMsgID m.fieldMap["topic"] = m.Topic - m.fieldMap["session"] = m.Session m.fieldMap["role"] = m.Role + m.fieldMap["session"] = m.Session m.fieldMap["content"] = m.Content m.fieldMap["state"] = m.State m.fieldMap["created_at"] = m.CreatedAt diff --git a/internal/store/dao/objectives.gen.go b/internal/store/dao/objectives.gen.go index 5dc6ab62..a25f6e80 100644 --- a/internal/store/dao/objectives.gen.go +++ b/internal/store/dao/objectives.gen.go @@ -181,11 +181,17 @@ func (o *objective) fillFieldMap() { func (o objective) clone(db *gorm.DB) objective { o.objectiveDo.ReplaceConnPool(db.Statement.ConnPool) + o.KeyResults.db = db.Session(&gorm.Session{Initialized: true}) + o.KeyResults.db.Statement.ConnPool = db.Statement.ConnPool + o.Reviews.db = db.Session(&gorm.Session{Initialized: true}) + o.Reviews.db.Statement.ConnPool = db.Statement.ConnPool return o } func (o objective) replaceDB(db *gorm.DB) objective { o.objectiveDo.ReplaceDB(db) + o.KeyResults.db = db.Session(&gorm.Session{}) + o.Reviews.db = db.Session(&gorm.Session{}) return o } @@ -232,6 +238,11 @@ func (a objectiveHasManyKeyResults) Model(m *model.Objective) *objectiveHasManyK return &objectiveHasManyKeyResultsTx{a.db.Model(m).Association(a.Name())} } +func (a objectiveHasManyKeyResults) Unscoped() *objectiveHasManyKeyResults { + a.db = a.db.Unscoped() + return &a +} + type objectiveHasManyKeyResultsTx struct{ tx *gorm.Association } func (a objectiveHasManyKeyResultsTx) Find() (result []*model.KeyResult, err error) { @@ -270,6 +281,11 @@ func (a objectiveHasManyKeyResultsTx) Count() int64 { return a.tx.Count() } +func (a objectiveHasManyKeyResultsTx) Unscoped() *objectiveHasManyKeyResultsTx { + a.tx = a.tx.Unscoped() + return &a +} + type objectiveHasManyReviews struct { db *gorm.DB @@ -307,6 +323,11 @@ func (a objectiveHasManyReviews) Model(m *model.Objective) *objectiveHasManyRevi return &objectiveHasManyReviewsTx{a.db.Model(m).Association(a.Name())} } +func (a objectiveHasManyReviews) Unscoped() *objectiveHasManyReviews { + a.db = a.db.Unscoped() + return &a +} + type objectiveHasManyReviewsTx struct{ tx *gorm.Association } func (a objectiveHasManyReviewsTx) Find() (result []*model.Review, err error) { @@ -345,6 +366,11 @@ func (a objectiveHasManyReviewsTx) Count() int64 { return a.tx.Count() } +func (a objectiveHasManyReviewsTx) Unscoped() *objectiveHasManyReviewsTx { + a.tx = a.tx.Unscoped() + return &a +} + type objectiveDo struct{ gen.DO } // GetByID diff --git a/internal/store/dao/reviews.gen.go b/internal/store/dao/reviews.gen.go index e4050269..374102d8 100644 --- a/internal/store/dao/reviews.gen.go +++ b/internal/store/dao/reviews.gen.go @@ -114,11 +114,14 @@ func (r *review) fillFieldMap() { func (r review) clone(db *gorm.DB) review { r.reviewDo.ReplaceConnPool(db.Statement.ConnPool) + r.Evaluations.db = db.Session(&gorm.Session{Initialized: true}) + r.Evaluations.db.Statement.ConnPool = db.Statement.ConnPool return r } func (r review) replaceDB(db *gorm.DB) review { r.reviewDo.ReplaceDB(db) + r.Evaluations.db = db.Session(&gorm.Session{}) return r } @@ -155,6 +158,11 @@ func (a reviewHasManyEvaluations) Model(m *model.Review) *reviewHasManyEvaluatio return &reviewHasManyEvaluationsTx{a.db.Model(m).Association(a.Name())} } +func (a reviewHasManyEvaluations) Unscoped() *reviewHasManyEvaluations { + a.db = a.db.Unscoped() + return &a +} + type reviewHasManyEvaluationsTx struct{ tx *gorm.Association } func (a reviewHasManyEvaluationsTx) Find() (result []*model.ReviewEvaluation, err error) { @@ -193,6 +201,11 @@ func (a reviewHasManyEvaluationsTx) Count() int64 { return a.tx.Count() } +func (a reviewHasManyEvaluationsTx) Unscoped() *reviewHasManyEvaluationsTx { + a.tx = a.tx.Unscoped() + return &a +} + type reviewDo struct{ gen.DO } // GetByID diff --git a/internal/store/dao/todos.gen.go b/internal/store/dao/todos.gen.go index 81ec9754..c086aea6 100644 --- a/internal/store/dao/todos.gen.go +++ b/internal/store/dao/todos.gen.go @@ -154,11 +154,14 @@ func (t *todo) fillFieldMap() { func (t todo) clone(db *gorm.DB) todo { t.todoDo.ReplaceConnPool(db.Statement.ConnPool) + t.SubTodos.db = db.Session(&gorm.Session{Initialized: true}) + t.SubTodos.db.Statement.ConnPool = db.Statement.ConnPool return t } func (t todo) replaceDB(db *gorm.DB) todo { t.todoDo.ReplaceDB(db) + t.SubTodos.db = db.Session(&gorm.Session{}) return t } @@ -195,6 +198,11 @@ func (a todoHasManySubTodos) Model(m *model.Todo) *todoHasManySubTodosTx { return &todoHasManySubTodosTx{a.db.Model(m).Association(a.Name())} } +func (a todoHasManySubTodos) Unscoped() *todoHasManySubTodos { + a.db = a.db.Unscoped() + return &a +} + type todoHasManySubTodosTx struct{ tx *gorm.Association } func (a todoHasManySubTodosTx) Find() (result []*model.Todo, err error) { @@ -233,6 +241,11 @@ func (a todoHasManySubTodosTx) Count() int64 { return a.tx.Count() } +func (a todoHasManySubTodosTx) Unscoped() *todoHasManySubTodosTx { + a.tx = a.tx.Unscoped() + return &a +} + type todoDo struct{ gen.DO } // GetByID diff --git a/internal/store/dao/workflow.gen.go b/internal/store/dao/workflow.gen.go index da64fb57..a6f178d2 100644 --- a/internal/store/dao/workflow.gen.go +++ b/internal/store/dao/workflow.gen.go @@ -142,11 +142,17 @@ func (w *workflow) fillFieldMap() { func (w workflow) clone(db *gorm.DB) workflow { w.workflowDo.ReplaceConnPool(db.Statement.ConnPool) + w.Dag.db = db.Session(&gorm.Session{Initialized: true}) + w.Dag.db.Statement.ConnPool = db.Statement.ConnPool + w.Triggers.db = db.Session(&gorm.Session{Initialized: true}) + w.Triggers.db.Statement.ConnPool = db.Statement.ConnPool return w } func (w workflow) replaceDB(db *gorm.DB) workflow { w.workflowDo.ReplaceDB(db) + w.Dag.db = db.Session(&gorm.Session{}) + w.Triggers.db = db.Session(&gorm.Session{}) return w } @@ -183,6 +189,11 @@ func (a workflowHasOneDag) Model(m *model.Workflow) *workflowHasOneDagTx { return &workflowHasOneDagTx{a.db.Model(m).Association(a.Name())} } +func (a workflowHasOneDag) Unscoped() *workflowHasOneDag { + a.db = a.db.Unscoped() + return &a +} + type workflowHasOneDagTx struct{ tx *gorm.Association } func (a workflowHasOneDagTx) Find() (result *model.Dag, err error) { @@ -221,6 +232,11 @@ func (a workflowHasOneDagTx) Count() int64 { return a.tx.Count() } +func (a workflowHasOneDagTx) Unscoped() *workflowHasOneDagTx { + a.tx = a.tx.Unscoped() + return &a +} + type workflowHasManyTriggers struct { db *gorm.DB @@ -254,6 +270,11 @@ func (a workflowHasManyTriggers) Model(m *model.Workflow) *workflowHasManyTrigge return &workflowHasManyTriggersTx{a.db.Model(m).Association(a.Name())} } +func (a workflowHasManyTriggers) Unscoped() *workflowHasManyTriggers { + a.db = a.db.Unscoped() + return &a +} + type workflowHasManyTriggersTx struct{ tx *gorm.Association } func (a workflowHasManyTriggersTx) Find() (result []*model.WorkflowTrigger, err error) { @@ -292,6 +313,11 @@ func (a workflowHasManyTriggersTx) Count() int64 { return a.tx.Count() } +func (a workflowHasManyTriggersTx) Unscoped() *workflowHasManyTriggersTx { + a.tx = a.tx.Unscoped() + return &a +} + type workflowDo struct{ gen.DO } // GetByID diff --git a/internal/store/model/messages.gen.go b/internal/store/model/messages.gen.go index bc4fbc56..574a7f89 100644 --- a/internal/store/model/messages.gen.go +++ b/internal/store/model/messages.gen.go @@ -19,8 +19,8 @@ type Message struct { PlatformID int64 `gorm:"column:platform_id;not null" json:"platform_id"` PlatformMsgID string `gorm:"column:platform_msg_id;not null" json:"platform_msg_id"` Topic string `gorm:"column:topic;not null" json:"topic"` + Role string `gorm:"column:role;not null;default:user" json:"role"` Session string `gorm:"column:session;not null" json:"session"` - Role string `gorm:"column:role;not null" json:"role"` Content JSON `gorm:"column:content" json:"content"` State MessageState `gorm:"column:state;not null" json:"state"` CreatedAt time.Time `gorm:"column:created_at;not null" json:"created_at"` From a702d0be665210372ee3548173c8165dd23db8d1 Mon Sep 17 00:00:00 2001 From: sysatom Date: Thu, 29 May 2025 17:57:07 +0800 Subject: [PATCH 116/125] refactor: use github.com/flc1125/go-cron/v4 --- cmd/agent/ruleset/collect/collect.go | 2 +- cmd/agent/ruleset/collect/job.go | 15 ++++++++++----- cmd/agent/ruleset/instruct/instruct.go | 2 +- cmd/agent/ruleset/instruct/job.go | 9 ++++++--- go.mod | 3 ++- go.sum | 6 ++++-- internal/bots/workflow/utils.go | 2 +- 7 files changed, 25 insertions(+), 14 deletions(-) diff --git a/cmd/agent/ruleset/collect/collect.go b/cmd/agent/ruleset/collect/collect.go index 429ecf06..3bd11371 100644 --- a/cmd/agent/ruleset/collect/collect.go +++ b/cmd/agent/ruleset/collect/collect.go @@ -5,8 +5,8 @@ import ( "time" "github.com/allegro/bigcache/v3" + "github.com/flc1125/go-cron/v4" "github.com/flowline-io/flowbot/pkg/flog" - "github.com/robfig/cron/v3" ) func Cron() { diff --git a/cmd/agent/ruleset/collect/job.go b/cmd/agent/ruleset/collect/job.go index 58dba0f7..52d40b00 100644 --- a/cmd/agent/ruleset/collect/job.go +++ b/cmd/agent/ruleset/collect/job.go @@ -1,10 +1,12 @@ package collect import ( + "context" + "github.com/allegro/bigcache/v3" + "github.com/flc1125/go-cron/v4" "github.com/flowline-io/flowbot/cmd/agent/ruleset/collect/bot" "github.com/flowline-io/flowbot/pkg/flog" - "github.com/robfig/cron/v3" ) type collectJob struct { @@ -12,25 +14,28 @@ type collectJob struct { } func (j *collectJob) RunAnki(c *cron.Cron) { - MustAddFunc(c, "0 * * * * *", func() { + MustAddFunc(c, "0 * * * * *", func(ctx context.Context) error { flog.Info("[anki] stats") bot.AnkiStats() + return nil }) - MustAddFunc(c, "0 * * * * *", func() { + MustAddFunc(c, "0 * * * * *", func(ctx context.Context) error { flog.Info("[anki] review") bot.AnkiReview() + return nil }) } func (j *collectJob) RunDev(c *cron.Cron) { - MustAddFunc(c, "0 * * * * *", func() { + MustAddFunc(c, "0 * * * * *", func(ctx context.Context) error { flog.Info("[dev] import") bot.DevImport() + return nil }) } // MustAddFunc will panic -func MustAddFunc(c *cron.Cron, spec string, cmd func()) { +func MustAddFunc(c *cron.Cron, spec string, cmd func(ctx context.Context) error) { _, err := c.AddFunc(spec, cmd) if err != nil { flog.Panic(err.Error()) diff --git a/cmd/agent/ruleset/instruct/instruct.go b/cmd/agent/ruleset/instruct/instruct.go index a6849a3f..d7031124 100644 --- a/cmd/agent/ruleset/instruct/instruct.go +++ b/cmd/agent/ruleset/instruct/instruct.go @@ -5,8 +5,8 @@ import ( "time" "github.com/allegro/bigcache/v3" + "github.com/flc1125/go-cron/v4" "github.com/flowline-io/flowbot/pkg/flog" - "github.com/robfig/cron/v3" ) func Cron() { diff --git a/cmd/agent/ruleset/instruct/job.go b/cmd/agent/ruleset/instruct/job.go index 1f2e35bc..d860022a 100644 --- a/cmd/agent/ruleset/instruct/job.go +++ b/cmd/agent/ruleset/instruct/job.go @@ -1,6 +1,7 @@ package instruct import ( + "context" "fmt" "time" @@ -15,14 +16,14 @@ type instructJob struct { cache *bigcache.BigCache } -func (j *instructJob) Run() { +func (j *instructJob) Run(ctx context.Context) error { res, err := client.Pull() if err != nil { flog.Error(err) - return + return err } if res == nil { - return + return nil } // instruct loop @@ -45,6 +46,8 @@ func (j *instructJob) Run() { flog.Error(fmt.Errorf("instruct run job failed %s %s %s", item.Bot, item.No, err)) } } + + return nil } func RunInstruct(cache *bigcache.BigCache, item client.Instruct) error { diff --git a/go.mod b/go.mod index d8894ae4..44d8bdf4 100644 --- a/go.mod +++ b/go.mod @@ -26,6 +26,7 @@ require ( github.com/dustin/go-humanize v1.0.1 github.com/emicklei/go-restful/v3 v3.12.2 github.com/expr-lang/expr v1.17.4 + github.com/flc1125/go-cron/v4 v4.5.4 github.com/fsnotify/fsnotify v1.9.0 github.com/gen2brain/beeep v0.0.0-20240516210008-9c006672e7f4 github.com/go-echarts/go-echarts/v2 v2.5.4 @@ -58,7 +59,6 @@ require ( github.com/prometheus/client_model v0.6.2 github.com/prometheus/common v0.64.0 github.com/redis/go-redis/v9 v9.9.0 - github.com/robfig/cron/v3 v3.0.1 github.com/rs/zerolog v1.34.0 github.com/samber/lo v1.50.0 github.com/samber/oops v1.18.1 @@ -179,6 +179,7 @@ require ( github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect github.com/rivo/uniseg v0.4.7 // indirect + github.com/robfig/cron/v3 v3.0.1 // indirect github.com/rs/xid v1.6.0 // indirect github.com/sagikazarmark/locafero v0.7.0 // indirect github.com/sirupsen/logrus v1.9.3 // indirect diff --git a/go.sum b/go.sum index d54b0435..3f16c0b4 100644 --- a/go.sum +++ b/go.sum @@ -120,6 +120,8 @@ github.com/expr-lang/expr v1.17.4 h1:qhTVftZ2Z3WpOEXRHWErEl2xf1Kq011MnQmWgLq06CY github.com/expr-lang/expr v1.17.4/go.mod h1:8/vRC7+7HBzESEqt5kKpYXxrxkr31SaO8r40VO/1IT4= github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= +github.com/flc1125/go-cron/v4 v4.5.4 h1:B/BpLGOUwFQFtocqDxkZVyZvb7uXfZfcJUcE3knRxZg= +github.com/flc1125/go-cron/v4 v4.5.4/go.mod h1:7wGlEw0cBolSHQEyM8Kl46Watl/lXwVkdc8zc5G9WuY= github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw= github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g= github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8= @@ -424,8 +426,8 @@ github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs= github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro= -github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= -github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= +github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ= +github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc= github.com/rollbar/rollbar-go v1.0.2/go.mod h1:AcFs5f0I+c71bpHlXNNDbOWJiKwjFDtISeXco0L5PKQ= github.com/rs/xid v1.6.0 h1:fV591PaemRlL6JfRxGDEPl69wICngIQ3shQtzfy2gxU= github.com/rs/xid v1.6.0/go.mod h1:7XoLgs4eV+QndskICGsho+ADou8ySMSjJKDIan90Nz0= diff --git a/internal/bots/workflow/utils.go b/internal/bots/workflow/utils.go index e9ee4760..e7a8cd0c 100644 --- a/internal/bots/workflow/utils.go +++ b/internal/bots/workflow/utils.go @@ -7,10 +7,10 @@ import ( "regexp" "strings" + "github.com/flc1125/go-cron/v4" "github.com/flowline-io/flowbot/internal/store/model" "github.com/flowline-io/flowbot/pkg/types" "github.com/flowline-io/flowbot/pkg/utils" - "github.com/robfig/cron/v3" "gopkg.in/yaml.v3" ) From ed1dc67126ff99fdc813f22216ba444487c841ed Mon Sep 17 00:00:00 2001 From: sysatom Date: Thu, 29 May 2025 18:01:06 +0800 Subject: [PATCH 117/125] refactor: use github.com/goccy/go-yaml --- cmd/composer/action/dao/dao.go | 2 +- cmd/composer/action/doc/schema.go | 2 +- cmd/composer/action/workflow/import.go | 2 +- go.mod | 3 ++- go.sum | 2 ++ internal/bots/workflow/form.go | 2 +- internal/bots/workflow/utils.go | 2 +- internal/platforms/platforms.go | 2 +- pkg/utils/string.go | 3 +-- 9 files changed, 11 insertions(+), 9 deletions(-) diff --git a/cmd/composer/action/dao/dao.go b/cmd/composer/action/dao/dao.go index 4ac5cadd..c31926c7 100644 --- a/cmd/composer/action/dao/dao.go +++ b/cmd/composer/action/dao/dao.go @@ -6,8 +6,8 @@ import ( "os" "github.com/flowline-io/flowbot/pkg/flog" + "github.com/goccy/go-yaml" "github.com/urfave/cli/v3" - "gopkg.in/yaml.v3" "gorm.io/driver/mysql" "gorm.io/gen" "gorm.io/gen/field" diff --git a/cmd/composer/action/doc/schema.go b/cmd/composer/action/doc/schema.go index 4c1cd2f5..10051337 100644 --- a/cmd/composer/action/doc/schema.go +++ b/cmd/composer/action/doc/schema.go @@ -12,9 +12,9 @@ import ( "github.com/flowline-io/flowbot/pkg/flog" _ "github.com/go-sql-driver/mysql" //revive:disable + "github.com/goccy/go-yaml" "github.com/jmoiron/sqlx" "github.com/urfave/cli/v3" - "gopkg.in/yaml.v3" ) type Column struct { diff --git a/cmd/composer/action/workflow/import.go b/cmd/composer/action/workflow/import.go index c3b03952..c0272bc0 100644 --- a/cmd/composer/action/workflow/import.go +++ b/cmd/composer/action/workflow/import.go @@ -12,8 +12,8 @@ import ( "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/types/protocol" "github.com/go-resty/resty/v2" + "github.com/goccy/go-yaml" "github.com/urfave/cli/v3" - "gopkg.in/yaml.v3" ) func ImportAction(ctx context.Context, c *cli.Command) error { diff --git a/go.mod b/go.mod index 44d8bdf4..3241f4bc 100644 --- a/go.mod +++ b/go.mod @@ -34,6 +34,7 @@ require ( github.com/go-resty/resty/v2 v2.16.5 github.com/go-sql-driver/mysql v1.9.2 github.com/goccy/go-json v0.10.5 + github.com/goccy/go-yaml v1.18.0 github.com/gofiber/contrib/fiberzerolog v1.0.3 github.com/gofiber/fiber/v2 v2.52.8 github.com/gofiber/swagger v1.1.1 @@ -79,7 +80,6 @@ require ( golang.org/x/sys v0.33.0 golang.org/x/time v0.11.0 golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 - gopkg.in/yaml.v3 v3.0.1 gorm.io/driver/mysql v1.5.7 gorm.io/gen v0.3.27 gorm.io/gorm v1.30.0 @@ -222,6 +222,7 @@ require ( golang.org/x/tools v0.30.0 // indirect google.golang.org/appengine v1.6.8 // indirect google.golang.org/protobuf v1.36.6 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect gorm.io/datatypes v1.2.4 // indirect gorm.io/hints v1.1.0 // indirect ) diff --git a/go.sum b/go.sum index 3f16c0b4..ef2343f7 100644 --- a/go.sum +++ b/go.sum @@ -187,6 +187,8 @@ github.com/go-viper/mapstructure/v2 v2.2.1 h1:ZAaOCxANMuZx5RCeg0mBdEZk7DZasvvZIx github.com/go-viper/mapstructure/v2 v2.2.1/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM= github.com/goccy/go-json v0.10.5 h1:Fq85nIqj+gXn/S5ahsiTlK3TmC85qgirsdTP/+DeaC4= github.com/goccy/go-json v0.10.5/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M= +github.com/goccy/go-yaml v1.18.0 h1:8W7wMFS12Pcas7KU+VVkaiCng+kG8QiFeFwzFb+rwuw= +github.com/goccy/go-yaml v1.18.0/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk= github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= diff --git a/internal/bots/workflow/form.go b/internal/bots/workflow/form.go index 23b08670..d3c11c97 100644 --- a/internal/bots/workflow/form.go +++ b/internal/bots/workflow/form.go @@ -11,7 +11,7 @@ import ( "github.com/flowline-io/flowbot/pkg/types" "github.com/flowline-io/flowbot/pkg/types/ruleset/form" "github.com/flowline-io/flowbot/pkg/types/ruleset/workflow" - "gopkg.in/yaml.v3" + "github.com/goccy/go-yaml" ) const ( diff --git a/internal/bots/workflow/utils.go b/internal/bots/workflow/utils.go index e7a8cd0c..b0f8f7b9 100644 --- a/internal/bots/workflow/utils.go +++ b/internal/bots/workflow/utils.go @@ -11,7 +11,7 @@ import ( "github.com/flowline-io/flowbot/internal/store/model" "github.com/flowline-io/flowbot/pkg/types" "github.com/flowline-io/flowbot/pkg/utils" - "gopkg.in/yaml.v3" + "github.com/goccy/go-yaml" ) const arrowSymbol = "->" diff --git a/internal/platforms/platforms.go b/internal/platforms/platforms.go index d169311f..cf292fc1 100644 --- a/internal/platforms/platforms.go +++ b/internal/platforms/platforms.go @@ -10,7 +10,7 @@ import ( "github.com/flowline-io/flowbot/pkg/types" "github.com/flowline-io/flowbot/pkg/types/protocol" "github.com/flowline-io/flowbot/pkg/utils" - "gopkg.in/yaml.v3" + "github.com/goccy/go-yaml" "gorm.io/gorm" ) diff --git a/pkg/utils/string.go b/pkg/utils/string.go index 688adb61..1ddb572d 100644 --- a/pkg/utils/string.go +++ b/pkg/utils/string.go @@ -13,8 +13,7 @@ import ( "unicode" "github.com/bytedance/sonic" - "gopkg.in/yaml.v3" - + "github.com/goccy/go-yaml" "github.com/google/uuid" ) From 77ecea59c818bf170fac358a6aa7b00a6b65a3ae Mon Sep 17 00:00:00 2001 From: sysatom Date: Thu, 29 May 2025 18:29:24 +0800 Subject: [PATCH 118/125] refactor: remove bigcache --- cmd/agent/ruleset/collect/collect.go | 11 +---------- cmd/agent/ruleset/collect/job.go | 5 +---- cmd/agent/ruleset/instruct/instruct.go | 10 ++++------ cmd/agent/ruleset/instruct/job.go | 17 +++++++++-------- go.mod | 1 - go.sum | 2 -- 6 files changed, 15 insertions(+), 31 deletions(-) diff --git a/cmd/agent/ruleset/collect/collect.go b/cmd/agent/ruleset/collect/collect.go index 3bd11371..40eaca96 100644 --- a/cmd/agent/ruleset/collect/collect.go +++ b/cmd/agent/ruleset/collect/collect.go @@ -1,23 +1,14 @@ package collect import ( - "context" - "time" - - "github.com/allegro/bigcache/v3" "github.com/flc1125/go-cron/v4" - "github.com/flowline-io/flowbot/pkg/flog" ) func Cron() { // collect job c := cron.New(cron.WithSeconds()) - cache, err := bigcache.New(context.Background(), bigcache.DefaultConfig(24*time.Hour)) - if err != nil { - flog.Panic(err.Error()) - } - job := &collectJob{cache: cache} + job := &collectJob{} job.RunAnki(c) job.RunDev(c) c.Start() diff --git a/cmd/agent/ruleset/collect/job.go b/cmd/agent/ruleset/collect/job.go index 52d40b00..f2ce359b 100644 --- a/cmd/agent/ruleset/collect/job.go +++ b/cmd/agent/ruleset/collect/job.go @@ -3,15 +3,12 @@ package collect import ( "context" - "github.com/allegro/bigcache/v3" "github.com/flc1125/go-cron/v4" "github.com/flowline-io/flowbot/cmd/agent/ruleset/collect/bot" "github.com/flowline-io/flowbot/pkg/flog" ) -type collectJob struct { - cache *bigcache.BigCache -} +type collectJob struct{} func (j *collectJob) RunAnki(c *cron.Cron) { MustAddFunc(c, "0 * * * * *", func(ctx context.Context) error { diff --git a/cmd/agent/ruleset/instruct/instruct.go b/cmd/agent/ruleset/instruct/instruct.go index d7031124..90346759 100644 --- a/cmd/agent/ruleset/instruct/instruct.go +++ b/cmd/agent/ruleset/instruct/instruct.go @@ -1,23 +1,21 @@ package instruct import ( - "context" - "time" - - "github.com/allegro/bigcache/v3" "github.com/flc1125/go-cron/v4" + "github.com/flowline-io/flowbot/pkg/cache" + "github.com/flowline-io/flowbot/pkg/config" "github.com/flowline-io/flowbot/pkg/flog" ) func Cron() { // instruct job c := cron.New(cron.WithSeconds()) - cache, err := bigcache.New(context.Background(), bigcache.DefaultConfig(time.Hour)) + ac, err := cache.NewCache(config.Type{}) if err != nil { flog.Panic(err.Error()) } - job := &instructJob{cache: cache} + job := &instructJob{cache: ac} _, err = c.AddJob("*/10 * * * * *", job) if err != nil { flog.Panic(err.Error()) diff --git a/cmd/agent/ruleset/instruct/job.go b/cmd/agent/ruleset/instruct/job.go index d860022a..2b5247c2 100644 --- a/cmd/agent/ruleset/instruct/job.go +++ b/cmd/agent/ruleset/instruct/job.go @@ -2,18 +2,19 @@ package instruct import ( "context" + "errors" "fmt" "time" - "github.com/allegro/bigcache/v3" "github.com/flowline-io/flowbot/cmd/agent/client" "github.com/flowline-io/flowbot/cmd/agent/ruleset/instruct/bot" + "github.com/flowline-io/flowbot/pkg/cache" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/types" ) type instructJob struct { - cache *bigcache.BigCache + cache *cache.Cache } func (j *instructJob) Run(ctx context.Context) error { @@ -29,8 +30,8 @@ func (j *instructJob) Run(ctx context.Context) error { // instruct loop for _, item := range res.Instruct { // check has been run - has, _ := j.cache.Get(item.No) - if len(has) > 0 { + _, has := j.cache.Get(item.No) + if has { continue } // check expired @@ -50,7 +51,7 @@ func (j *instructJob) Run(ctx context.Context) error { return nil } -func RunInstruct(cache *bigcache.BigCache, item client.Instruct) error { +func RunInstruct(c *cache.Cache, item client.Instruct) error { for id, dos := range bot.DoInstruct { if item.Bot != id { continue @@ -73,9 +74,9 @@ func RunInstruct(cache *bigcache.BigCache, item client.Instruct) error { return err } flog.Info("[instruct] %s %s ack", item.Bot, item.No) - err = cache.Set(item.No, []byte("1")) - if err != nil { - return err + ok := c.Set(item.No, "1", 1) + if !ok { + return errors.New("set cache failed") } } } diff --git a/go.mod b/go.mod index 3241f4bc..8ac3e626 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,6 @@ require ( github.com/ThreeDotsLabs/watermill v1.4.6 github.com/ThreeDotsLabs/watermill-redisstream v1.4.3 github.com/VictoriaMetrics/metrics v1.37.0 - github.com/allegro/bigcache/v3 v3.1.0 github.com/bsm/redislock v0.9.4 github.com/bwmarrin/discordgo v0.29.0 github.com/bytedance/sonic v1.13.2 diff --git a/go.sum b/go.sum index ef2343f7..31ab1680 100644 --- a/go.sum +++ b/go.sum @@ -27,8 +27,6 @@ github.com/ThreeDotsLabs/watermill-redisstream v1.4.3/go.mod h1:69++855LyB+ckYDe github.com/VictoriaMetrics/metrics v1.37.0 h1:u5Yr+HFofQyn7kgmmkufgkX0nEA6G1oEyK2eaKsVaUM= github.com/VictoriaMetrics/metrics v1.37.0/go.mod h1:r7hveu6xMdUACXvB8TYdAj8WEsKzWB0EkpJN+RDtOf8= github.com/airbrake/gobrake v3.6.1+incompatible/go.mod h1:wM4gu3Cn0W0K7GUuVWnlXZU11AGBXMILnrdOU8Kn00o= -github.com/allegro/bigcache/v3 v3.1.0 h1:H2Vp8VOvxcrB91o86fUSVJFqeuz8kpyyB02eH3bSzwk= -github.com/allegro/bigcache/v3 v3.1.0/go.mod h1:aPyh7jEvrog9zAwx5N7+JUQX5dZTSGpxF1LAR4dr35I= github.com/andybalholm/brotli v1.1.1 h1:PR2pgnyFznKEugtsUo0xLdDop5SKXd5Qf5ysW+7XdTA= github.com/andybalholm/brotli v1.1.1/go.mod h1:05ib4cKhjx3OQYUY22hTVd34Bc8upXjOLL2rKwwZBoA= github.com/andybalholm/cascadia v1.3.3 h1:AG2YHrzJIm4BZ19iwJ/DAua6Btl3IwJX+VI4kktS1LM= From 67f8e2789f08631f918a6c1c6e678f504687beb1 Mon Sep 17 00:00:00 2001 From: sysatom Date: Fri, 30 May 2025 00:49:32 +0800 Subject: [PATCH 119/125] update: upgrade fiber v3 --- go.mod | 11 ++++--- go.sum | 21 ++++++++----- internal/bots/dev/bot.go | 2 +- internal/bots/dev/webservice.go | 4 +-- internal/bots/okr/bot.go | 2 +- internal/bots/okr/webservice.go | 36 +++++++++++----------- internal/bots/search/bot.go | 2 +- internal/bots/search/webservice.go | 6 ++-- internal/bots/server/bot.go | 2 +- internal/bots/server/webservice.go | 4 +-- internal/bots/user/bot.go | 2 +- internal/bots/user/webservice.go | 10 +++--- internal/bots/workflow/bot.go | 2 +- internal/bots/workflow/webservice.go | 28 ++++++++--------- internal/platforms/slack/driver.go | 4 +-- internal/platforms/tailchat/driver.go | 7 ++--- internal/server/http.go | 36 ++++++++-------------- internal/server/init.go | 2 +- internal/server/router.go | 26 +++++++++------- internal/server/server.go | 7 +++-- internal/server/swagger.go | 2 +- pkg/chatbot/bot.go | 2 +- pkg/chatbot/interface.go | 2 +- pkg/providers/dropbox/dropbox.go | 4 +-- pkg/providers/github/github.go | 4 +-- pkg/providers/pocket/pocket.go | 4 +-- pkg/providers/providers.go | 4 +-- pkg/route/route.go | 14 ++++----- pkg/types/protocol/platform.go | 4 +-- pkg/types/ruleset/webservice/webservice.go | 2 +- pkg/utils/singleton.go | 14 ++++----- 31 files changed, 137 insertions(+), 133 deletions(-) diff --git a/go.mod b/go.mod index 8ac3e626..e371cfc8 100644 --- a/go.mod +++ b/go.mod @@ -26,6 +26,8 @@ require ( github.com/emicklei/go-restful/v3 v3.12.2 github.com/expr-lang/expr v1.17.4 github.com/flc1125/go-cron/v4 v4.5.4 + github.com/flowline-io/contrib/fiberzerolog v0.0.0-20250529160935-d348985506ed + github.com/flowline-io/fiberswagger v0.0.0-20250529155353-3b5b94dbd01c github.com/fsnotify/fsnotify v1.9.0 github.com/gen2brain/beeep v0.0.0-20240516210008-9c006672e7f4 github.com/go-echarts/go-echarts/v2 v2.5.4 @@ -34,9 +36,7 @@ require ( github.com/go-sql-driver/mysql v1.9.2 github.com/goccy/go-json v0.10.5 github.com/goccy/go-yaml v1.18.0 - github.com/gofiber/contrib/fiberzerolog v1.0.3 - github.com/gofiber/fiber/v2 v2.52.8 - github.com/gofiber/swagger v1.1.1 + github.com/gofiber/fiber/v3 v3.0.0-beta.4 github.com/golang-migrate/migrate/v4 v4.18.3 github.com/google/go-github/v72 v72.0.0 github.com/google/uuid v1.6.0 @@ -112,6 +112,7 @@ require ( github.com/ebitengine/purego v0.8.2 // indirect github.com/emirpasic/gods v1.18.1 // indirect github.com/felixge/httpsnoop v1.0.4 // indirect + github.com/fxamacker/cbor/v2 v2.8.0 // indirect github.com/gabriel-vasile/mimetype v1.4.8 // indirect github.com/getkin/kin-openapi v0.118.0 // indirect github.com/go-fed/httpsig v1.1.0 // indirect @@ -128,6 +129,8 @@ require ( github.com/go-toast/toast v0.0.0-20190211030409-01e6764cf0a4 // indirect github.com/go-viper/mapstructure/v2 v2.2.1 // indirect github.com/godbus/dbus/v5 v5.1.0 // indirect + github.com/gofiber/schema v1.2.0 // indirect + github.com/gofiber/utils/v2 v2.0.0-beta.8 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang-jwt/jwt/v4 v4.5.2 // indirect github.com/golang/protobuf v1.5.4 // indirect @@ -152,7 +155,6 @@ require ( github.com/mailru/easyjson v0.9.0 // 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.16 // indirect github.com/meguminnnnnnnnn/go-openai v0.0.0-20250408071642-761325becfd6 // indirect github.com/minio/crc64nvme v1.0.1 // indirect github.com/minio/md5-simd v1.1.2 // indirect @@ -200,6 +202,7 @@ require ( github.com/valyala/fastrand v1.1.0 // indirect github.com/valyala/histogram v1.2.0 // indirect github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect + github.com/x448/float16 v0.8.4 // indirect github.com/yargevad/filepathx v1.0.0 // indirect github.com/yosida95/uritemplate/v3 v3.0.2 // indirect github.com/yusufpapurcu/wmi v1.2.4 // indirect diff --git a/go.sum b/go.sum index 31ab1680..3cc0d0aa 100644 --- a/go.sum +++ b/go.sum @@ -120,6 +120,10 @@ github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2 github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= github.com/flc1125/go-cron/v4 v4.5.4 h1:B/BpLGOUwFQFtocqDxkZVyZvb7uXfZfcJUcE3knRxZg= github.com/flc1125/go-cron/v4 v4.5.4/go.mod h1:7wGlEw0cBolSHQEyM8Kl46Watl/lXwVkdc8zc5G9WuY= +github.com/flowline-io/contrib/fiberzerolog v0.0.0-20250529160935-d348985506ed h1:45TJa+yWA875amR12FImFaDJGa6NBvCX2dBphOTAUU8= +github.com/flowline-io/contrib/fiberzerolog v0.0.0-20250529160935-d348985506ed/go.mod h1:Pgz+8dD5p/Mj7XZQJ4HJWqB0XiX2+Ghtkg3HuxD4pFQ= +github.com/flowline-io/fiberswagger v0.0.0-20250529155353-3b5b94dbd01c h1:BnsSRINEkyL9MLa3NvJH1blJu4Dd2asmjr5j7b/LeI4= +github.com/flowline-io/fiberswagger v0.0.0-20250529155353-3b5b94dbd01c/go.mod h1:PciAU8mP0jIPPIo8S9Q9VYswlzq/J4YMNwUGZ0mnbt0= github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw= github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g= github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8= @@ -127,6 +131,8 @@ github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7z github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k= github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0= +github.com/fxamacker/cbor/v2 v2.8.0 h1:fFtUGXUzXPHTIUdne5+zzMPTfffl3RD5qYnkY40vtxU= +github.com/fxamacker/cbor/v2 v2.8.0/go.mod h1:vM4b+DJCtHn+zz7h3FFp/hDAI9WNWCsZj23V5ytsSxQ= github.com/gabriel-vasile/mimetype v1.4.8 h1:FfZ3gj38NjllZIeJAmMhr+qKL8Wu+nOoI3GqacKw1NM= github.com/gabriel-vasile/mimetype v1.4.8/go.mod h1:ByKUIKGjh1ODkGM1asKUbQZOLGrPjydw3hYPU2YU9t8= github.com/gen2brain/beeep v0.0.0-20240516210008-9c006672e7f4 h1:ygs9POGDQpQGLJPlq4+0LBUmMBNox1N4JSpw+OETcvI= @@ -190,12 +196,12 @@ github.com/goccy/go-yaml v1.18.0/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7Lk github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk= github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= -github.com/gofiber/contrib/fiberzerolog v1.0.3 h1:Z97hA5bNfThtZjEYG12g9YcT8I/cmCikNgmE4uzFk0U= -github.com/gofiber/contrib/fiberzerolog v1.0.3/go.mod h1:0MD+NNFy0nZwiSo4dSVW7WwWVzOyuATNXwhJwgOP8uM= -github.com/gofiber/fiber/v2 v2.52.8 h1:xl4jJQ0BV5EJTA2aWiKw/VddRpHrKeZLF0QPUxqn0x4= -github.com/gofiber/fiber/v2 v2.52.8/go.mod h1:YEcBbO/FB+5M1IZNBP9FO3J9281zgPAreiI1oqg8nDw= -github.com/gofiber/swagger v1.1.1 h1:FZVhVQQ9s1ZKLHL/O0loLh49bYB5l1HEAgxDlcTtkRA= -github.com/gofiber/swagger v1.1.1/go.mod h1:vtvY/sQAMc/lGTUCg0lqmBL7Ht9O7uzChpbvJeJQINw= +github.com/gofiber/fiber/v3 v3.0.0-beta.4 h1:KzDSavvhG7m81NIsmnu5l3ZDbVS4feCidl4xlIfu6V0= +github.com/gofiber/fiber/v3 v3.0.0-beta.4/go.mod h1:/WFUoHRkZEsGHyy2+fYcdqi109IVOFbVwxv1n1RU+kk= +github.com/gofiber/schema v1.2.0 h1:j+ZRrNnUa/0ZuWrn/6kAtAufEr4jCJ+JuTURAMxNSZg= +github.com/gofiber/schema v1.2.0/go.mod h1:YYwj01w3hVfaNjhtJzaqetymL56VW642YS3qZPhuE6c= +github.com/gofiber/utils/v2 v2.0.0-beta.8 h1:ZifwbHZqZO3YJsx1ZhDsWnPjaQ7C0YD20LHt+DQeXOU= +github.com/gofiber/utils/v2 v2.0.0-beta.8/go.mod h1:1lCBo9vEF4RFEtTgWntipnaScJZQiM8rrsYycLZ4n9c= github.com/gofrs/uuid v3.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= @@ -421,7 +427,6 @@ github.com/prometheus/common v0.64.0 h1:pdZeA+g617P7oGv1CzdTzyeShxAGrTBsolKNOLQP github.com/prometheus/common v0.64.0/go.mod h1:0gZns+BLRQ3V6NdaerOhMbwwRbNh9hkGINtQAsP5GS8= github.com/redis/go-redis/v9 v9.9.0 h1:URbPQ4xVQSQhZ27WMQVmZSo3uT3pL+4IdHVcYq2nVfM= github.com/redis/go-redis/v9 v9.9.0/go.mod h1:huWgSWd8mW6+m0VPhJjSSQ+d6Nh1VICQ6Q5lHuCH/Iw= -github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs= @@ -521,6 +526,8 @@ github.com/vmihailenco/msgpack v4.0.4+incompatible h1:dSLoQfGFAo3F6OoNhwUmLwVgaU github.com/vmihailenco/msgpack v4.0.4+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= github.com/x-cray/logrus-prefixed-formatter v0.5.2 h1:00txxvfBM9muc0jiLIEAkAcIMJzfthRT6usrui8uGmg= github.com/x-cray/logrus-prefixed-formatter v0.5.2/go.mod h1:2duySbKsL6M18s5GU7VPsoEPHyzalCE06qoARUCeBBE= +github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM= +github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg= github.com/xyproto/randomstring v1.0.5 h1:YtlWPoRdgMu3NZtP45drfy1GKoojuR7hmRcnhZqKjWU= github.com/xyproto/randomstring v1.0.5/go.mod h1:rgmS5DeNXLivK7YprL0pY+lTuhNQW3iGxZ18UQApw/E= github.com/yargevad/filepathx v1.0.0 h1:SYcT+N3tYGi+NvazubCNlvgIPbzAk7i7y2dwg3I5FYc= diff --git a/internal/bots/dev/bot.go b/internal/bots/dev/bot.go index ef7f6a56..f03b735a 100644 --- a/internal/bots/dev/bot.go +++ b/internal/bots/dev/bot.go @@ -10,7 +10,7 @@ import ( "github.com/flowline-io/flowbot/pkg/types" "github.com/flowline-io/flowbot/pkg/types/ruleset/cron" "github.com/flowline-io/flowbot/pkg/types/ruleset/instruct" - "github.com/gofiber/fiber/v2" + "github.com/gofiber/fiber/v3" ) const Name = "dev" diff --git a/internal/bots/dev/webservice.go b/internal/bots/dev/webservice.go index 5d875ca4..6aac1e21 100644 --- a/internal/bots/dev/webservice.go +++ b/internal/bots/dev/webservice.go @@ -5,7 +5,7 @@ import ( "github.com/flowline-io/flowbot/pkg/types" "github.com/flowline-io/flowbot/pkg/types/protocol" "github.com/flowline-io/flowbot/pkg/types/ruleset/webservice" - "github.com/gofiber/fiber/v2" + "github.com/gofiber/fiber/v3" ) var webserviceRules = []webservice.Rule{ @@ -20,7 +20,7 @@ var webserviceRules = []webservice.Rule{ // @Produce json // @Success 200 {object} protocol.Response{data=types.KV} // @Router /dev/example [get] -func example(ctx *fiber.Ctx) error { +func example(ctx fiber.Ctx) error { return ctx.JSON(protocol.NewSuccessResponse(types.KV{ "title": "example", "cpu": "20%", diff --git a/internal/bots/okr/bot.go b/internal/bots/okr/bot.go index 1bae2a38..69358850 100644 --- a/internal/bots/okr/bot.go +++ b/internal/bots/okr/bot.go @@ -8,7 +8,7 @@ import ( "github.com/flowline-io/flowbot/pkg/chatbot" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/types" - "github.com/gofiber/fiber/v2" + "github.com/gofiber/fiber/v3" ) const Name = "okr" diff --git a/internal/bots/okr/webservice.go b/internal/bots/okr/webservice.go index 07749e64..080b8780 100644 --- a/internal/bots/okr/webservice.go +++ b/internal/bots/okr/webservice.go @@ -6,7 +6,7 @@ import ( "github.com/flowline-io/flowbot/pkg/route" "github.com/flowline-io/flowbot/pkg/types/protocol" "github.com/flowline-io/flowbot/pkg/types/ruleset/webservice" - "github.com/gofiber/fiber/v2" + "github.com/gofiber/fiber/v3" ) var webserviceRules = []webservice.Rule{ @@ -33,7 +33,7 @@ var webserviceRules = []webservice.Rule{ // @Success 200 {object} protocol.Response{data=[]model.Objective} // @Security ApiKeyAuth // @Router /okr/objectives [get] -func objectiveList(ctx *fiber.Ctx) error { +func objectiveList(ctx fiber.Ctx) error { uid := route.GetUid(ctx) topic := route.GetTopic(ctx) @@ -54,7 +54,7 @@ func objectiveList(ctx *fiber.Ctx) error { // @Success 200 {object} protocol.Response{data=model.Objective} // @Security ApiKeyAuth // @Router /okr/objective/{sequence} [get] -func objectiveDetail(ctx *fiber.Ctx) error { +func objectiveDetail(ctx fiber.Ctx) error { uid := route.GetUid(ctx) topic := route.GetTopic(ctx) sequence := route.GetIntParam(ctx, "sequence") @@ -76,12 +76,12 @@ func objectiveDetail(ctx *fiber.Ctx) error { // @Success 200 {object} protocol.Response // @Security ApiKeyAuth // @Router /okr/objective [post] -func objectiveCreate(ctx *fiber.Ctx) error { +func objectiveCreate(ctx fiber.Ctx) error { uid := route.GetUid(ctx) topic := route.GetTopic(ctx) item := new(model.Objective) - err := ctx.BodyParser(&item) + err := ctx.Bind().Body(&item) if err != nil { return protocol.ErrBadParam.Wrap(err) } @@ -113,13 +113,13 @@ func objectiveCreate(ctx *fiber.Ctx) error { // @Success 200 {object} protocol.Response // @Security ApiKeyAuth // @Router /okr/objective/{sequence} [put] -func objectiveUpdate(ctx *fiber.Ctx) error { +func objectiveUpdate(ctx fiber.Ctx) error { uid := route.GetUid(ctx) topic := route.GetTopic(ctx) sequence := route.GetIntParam(ctx, "sequence") item := new(model.Objective) - err := ctx.BodyParser(&item) + err := ctx.Bind().Body(&item) if err != nil { return protocol.ErrBadParam.Wrap(err) } @@ -143,7 +143,7 @@ func objectiveUpdate(ctx *fiber.Ctx) error { // @Success 200 {object} protocol.Response // @Security ApiKeyAuth // @Router /okr/objective/{sequence} [delete] -func objectiveDelete(ctx *fiber.Ctx) error { +func objectiveDelete(ctx fiber.Ctx) error { uid := route.GetUid(ctx) topic := route.GetTopic(ctx) sequence := route.GetIntParam(ctx, "sequence") @@ -165,12 +165,12 @@ func objectiveDelete(ctx *fiber.Ctx) error { // @Success 200 {object} protocol.Response // @Security ApiKeyAuth // @Router /okr/key_result [post] -func keyResultCreate(ctx *fiber.Ctx) error { +func keyResultCreate(ctx fiber.Ctx) error { uid := route.GetUid(ctx) topic := route.GetTopic(ctx) item := new(model.KeyResult) - err := ctx.BodyParser(&item) + err := ctx.Bind().Body(&item) if err != nil { return protocol.ErrBadParam.Wrap(err) } @@ -194,13 +194,13 @@ func keyResultCreate(ctx *fiber.Ctx) error { // @Success 200 {object} protocol.Response // @Security ApiKeyAuth // @Router /okr/key_result/{sequence} [put] -func keyResultUpdate(ctx *fiber.Ctx) error { +func keyResultUpdate(ctx fiber.Ctx) error { uid := route.GetUid(ctx) topic := route.GetTopic(ctx) sequence := route.GetIntParam(ctx, "sequence") item := new(model.KeyResult) - err := ctx.BodyParser(&item) + err := ctx.Bind().Body(&item) if err != nil { return protocol.ErrBadParam.Wrap(err) } @@ -224,7 +224,7 @@ func keyResultUpdate(ctx *fiber.Ctx) error { // @Success 200 {object} protocol.Response // @Security ApiKeyAuth // @Router /okr/key_result/{sequence} [delete] -func keyResultDelete(ctx *fiber.Ctx) error { +func keyResultDelete(ctx fiber.Ctx) error { uid := route.GetUid(ctx) topic := route.GetTopic(ctx) sequence := route.GetIntParam(ctx, "sequence") @@ -246,7 +246,7 @@ func keyResultDelete(ctx *fiber.Ctx) error { // @Success 200 {object} protocol.Response{data=[]model.KeyResultValue} // @Security ApiKeyAuth // @Router /okr/key_result/{id}/values [get] -func keyResultValueList(ctx *fiber.Ctx) error { +func keyResultValueList(ctx fiber.Ctx) error { keyResultId := route.GetIntParam(ctx, "id") if keyResultId == 0 { return protocol.ErrBadParam.New("id empty") @@ -270,14 +270,14 @@ func keyResultValueList(ctx *fiber.Ctx) error { // @Success 200 {object} protocol.Response // @Security ApiKeyAuth // @Router /okr/key_result/{id}/value [post] -func keyResultValueCreate(ctx *fiber.Ctx) error { +func keyResultValueCreate(ctx fiber.Ctx) error { keyResultId := route.GetIntParam(ctx, "id") if keyResultId == 0 { return protocol.ErrBadParam.New("id empty") } item := new(model.KeyResultValue) - err := ctx.BodyParser(&item) + err := ctx.Bind().Body(&item) if err != nil { return protocol.ErrBadParam.Wrap(err) } @@ -299,7 +299,7 @@ func keyResultValueCreate(ctx *fiber.Ctx) error { // @Success 200 {object} protocol.Response // @Security ApiKeyAuth // @Router /okr/key_result_value/{id} [delete] -func keyResultValueDelete(ctx *fiber.Ctx) error { +func keyResultValueDelete(ctx fiber.Ctx) error { keyResultValueId := route.GetIntParam(ctx, "id") if keyResultValueId == 0 { return protocol.ErrBadParam.New("id emtpy") @@ -322,7 +322,7 @@ func keyResultValueDelete(ctx *fiber.Ctx) error { // @Success 200 {object} protocol.Response{data=model.KeyResultValue} // @Security ApiKeyAuth // @Router /okr/key_result_value/{id} [get] -func keyResultValue(ctx *fiber.Ctx) error { +func keyResultValue(ctx fiber.Ctx) error { keyResultValueId := route.GetIntParam(ctx, "id") if keyResultValueId == 0 { return protocol.ErrBadParam.New("id emtpy") diff --git a/internal/bots/search/bot.go b/internal/bots/search/bot.go index cd09e1c8..031523cb 100755 --- a/internal/bots/search/bot.go +++ b/internal/bots/search/bot.go @@ -9,7 +9,7 @@ import ( "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/types" "github.com/flowline-io/flowbot/pkg/types/ruleset/cron" - "github.com/gofiber/fiber/v2" + "github.com/gofiber/fiber/v3" ) const Name = "search" diff --git a/internal/bots/search/webservice.go b/internal/bots/search/webservice.go index 930d1332..98bdec4d 100644 --- a/internal/bots/search/webservice.go +++ b/internal/bots/search/webservice.go @@ -5,7 +5,7 @@ import ( "github.com/flowline-io/flowbot/pkg/search" "github.com/flowline-io/flowbot/pkg/types/protocol" "github.com/flowline-io/flowbot/pkg/types/ruleset/webservice" - "github.com/gofiber/fiber/v2" + "github.com/gofiber/fiber/v3" ) var webserviceRules = []webservice.Rule{ @@ -22,7 +22,7 @@ var webserviceRules = []webservice.Rule{ // @Success 200 {object} protocol.Response{data=types.KV} // @Security ApiKeyAuth // @Router /search/query [get] -func query(ctx *fiber.Ctx) error { +func query(ctx fiber.Ctx) error { q := ctx.Query("q") source := ctx.Query("source") if q == "" { @@ -47,7 +47,7 @@ func query(ctx *fiber.Ctx) error { // @Success 200 {object} protocol.Response{data=types.KV} // @Security ApiKeyAuth // @Router /search/autocomplete [get] -func autocomplete(ctx *fiber.Ctx) error { +func autocomplete(ctx fiber.Ctx) error { q := ctx.Query("q") source := ctx.Query("source") if q == "" { diff --git a/internal/bots/server/bot.go b/internal/bots/server/bot.go index ce36eeab..22017315 100644 --- a/internal/bots/server/bot.go +++ b/internal/bots/server/bot.go @@ -4,7 +4,7 @@ import ( "encoding/json" "errors" - "github.com/gofiber/fiber/v2" + "github.com/gofiber/fiber/v3" "github.com/bytedance/sonic" "github.com/flowline-io/flowbot/pkg/chatbot" diff --git a/internal/bots/server/webservice.go b/internal/bots/server/webservice.go index 9ab2beb4..30a2ebb1 100644 --- a/internal/bots/server/webservice.go +++ b/internal/bots/server/webservice.go @@ -7,7 +7,7 @@ import ( "github.com/flowline-io/flowbot/pkg/types" "github.com/flowline-io/flowbot/pkg/types/ruleset/webservice" "github.com/flowline-io/flowbot/pkg/utils" - "github.com/gofiber/fiber/v2" + "github.com/gofiber/fiber/v3" ) var webserviceRules = []webservice.Rule{ @@ -23,7 +23,7 @@ var webserviceRules = []webservice.Rule{ // @Success 200 {object} protocol.Response{data=types.KV} // @Security ApiKeyAuth // @Router /server/upload [post] -func upload(ctx *fiber.Ctx) error { +func upload(ctx fiber.Ctx) error { result := make([]string, 0) if form, err := ctx.MultipartForm(); err == nil { for _, file := range form.File { diff --git a/internal/bots/user/bot.go b/internal/bots/user/bot.go index 972adc10..6c6f074b 100644 --- a/internal/bots/user/bot.go +++ b/internal/bots/user/bot.go @@ -8,7 +8,7 @@ import ( "github.com/flowline-io/flowbot/pkg/chatbot" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/types" - "github.com/gofiber/fiber/v2" + "github.com/gofiber/fiber/v3" ) const Name = "user" diff --git a/internal/bots/user/webservice.go b/internal/bots/user/webservice.go index c3f0087d..8656e671 100644 --- a/internal/bots/user/webservice.go +++ b/internal/bots/user/webservice.go @@ -10,7 +10,7 @@ import ( "github.com/flowline-io/flowbot/pkg/types" "github.com/flowline-io/flowbot/pkg/types/protocol" "github.com/flowline-io/flowbot/pkg/types/ruleset/webservice" - "github.com/gofiber/fiber/v2" + "github.com/gofiber/fiber/v3" ) var webserviceRules = []webservice.Rule{ @@ -29,7 +29,7 @@ var webserviceRules = []webservice.Rule{ // @Success 200 {object} protocol.Response{data=types.KV} // @Security ApiKeyAuth // @Router /user/dashboard [get] -func dashboard(ctx *fiber.Ctx) error { +func dashboard(ctx fiber.Ctx) error { return ctx.JSON(protocol.NewSuccessResponse(types.KV{ "title": "dashboard", })) @@ -44,7 +44,7 @@ func dashboard(ctx *fiber.Ctx) error { // @Success 200 {object} protocol.Response{data=types.KV} // @Security ApiKeyAuth // @Router /user/metrics [get] -func metrics(ctx *fiber.Ctx) error { +func metrics(ctx fiber.Ctx) error { return ctx.JSON(protocol.NewSuccessResponse(types.KV{ stats.BotTotalStatsName: rdb.GetMetricsInt64(stats.BotTotalStatsName), stats.BookmarkTotalStatsName: rdb.GetMetricsInt64(stats.BookmarkTotalStatsName), @@ -67,7 +67,7 @@ func metrics(ctx *fiber.Ctx) error { // @Success 200 {object} protocol.Response{data=types.KV} // @Security ApiKeyAuth // @Router /user/kanban [get] -func getKanban(ctx *fiber.Ctx) error { +func getKanban(ctx fiber.Ctx) error { client, err := kanboard.GetClient() if err != nil { return fmt.Errorf("failed to new client %w", err) @@ -90,7 +90,7 @@ func getKanban(ctx *fiber.Ctx) error { // @Success 200 {object} protocol.Response{data=types.KV} // @Security ApiKeyAuth // @Router /user/bookmark [get] -func getBookmark(ctx *fiber.Ctx) error { +func getBookmark(ctx fiber.Ctx) error { client := hoarder.GetClient() resp, err := client.GetAllBookmarks(&hoarder.BookmarksQuery{Limit: hoarder.MaxPageSize}) diff --git a/internal/bots/workflow/bot.go b/internal/bots/workflow/bot.go index cafd2918..f4678f60 100644 --- a/internal/bots/workflow/bot.go +++ b/internal/bots/workflow/bot.go @@ -9,7 +9,7 @@ import ( "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/types" "github.com/flowline-io/flowbot/pkg/types/ruleset/cron" - "github.com/gofiber/fiber/v2" + "github.com/gofiber/fiber/v3" ) const Name = "workflow" diff --git a/internal/bots/workflow/webservice.go b/internal/bots/workflow/webservice.go index 8775c955..a3bff4b4 100644 --- a/internal/bots/workflow/webservice.go +++ b/internal/bots/workflow/webservice.go @@ -9,7 +9,7 @@ import ( "github.com/flowline-io/flowbot/pkg/types/protocol" "github.com/flowline-io/flowbot/pkg/types/ruleset/webservice" "github.com/flowline-io/flowbot/pkg/types/ruleset/workflow" - "github.com/gofiber/fiber/v2" + "github.com/gofiber/fiber/v3" ) var webserviceRules = []webservice.Rule{ @@ -39,7 +39,7 @@ var webserviceRules = []webservice.Rule{ // @Success 200 {object} protocol.Response{data=map[string][]rule} // @Security ApiKeyAuth // @Router /workflow/actions [get] -func actions(ctx *fiber.Ctx) error { +func actions(ctx fiber.Ctx) error { result := make(map[string][]rule, len(chatbot.List())) for name, botHandler := range chatbot.List() { var list []rule @@ -75,7 +75,7 @@ func actions(ctx *fiber.Ctx) error { // @Success 200 {object} protocol.Response{data=[]model.Workflow} // @Security ApiKeyAuth // @Router /workflow/workflows [get] -func workflowList(ctx *fiber.Ctx) error { +func workflowList(ctx fiber.Ctx) error { uid := route.GetUid(ctx) topic := route.GetTopic(ctx) @@ -96,7 +96,7 @@ func workflowList(ctx *fiber.Ctx) error { // @Success 200 {object} protocol.Response{data=model.Workflow} // @Security ApiKeyAuth // @Router /workflow/workflow/{id} [get] -func workflowDetail(ctx *fiber.Ctx) error { +func workflowDetail(ctx fiber.Ctx) error { id := route.GetIntParam(ctx, "id") item, err := store.Database.GetWorkflow(id) @@ -116,12 +116,12 @@ func workflowDetail(ctx *fiber.Ctx) error { // @Success 200 {object} protocol.Response // @Security ApiKeyAuth // @Router /workflow/workflow [post] -func workflowCreate(ctx *fiber.Ctx) error { +func workflowCreate(ctx fiber.Ctx) error { uid := route.GetUid(ctx) topic := route.GetTopic(ctx) script := new(model.WorkflowScript) - err := ctx.BodyParser(&script) + err := ctx.Bind().Body(&script) if err != nil { return protocol.ErrBadParam.Wrap(err) } @@ -155,13 +155,13 @@ func workflowCreate(ctx *fiber.Ctx) error { // @Success 200 {object} protocol.Response // @Security ApiKeyAuth // @Router /workflow/workflow/{id} [put] -func workflowUpdate(ctx *fiber.Ctx) error { +func workflowUpdate(ctx fiber.Ctx) error { // uid := route.GetUid(ctx) // topic := route.GetTopic(ctx) // id := route.GetIntParam(ctx, "id") script := new(model.WorkflowScript) - err := ctx.BodyParser(&script) + err := ctx.Bind().Body(&script) if err != nil { return protocol.ErrBadParam.Wrap(err) } @@ -199,7 +199,7 @@ func workflowUpdate(ctx *fiber.Ctx) error { // @Success 200 {object} protocol.Response // @Security ApiKeyAuth // @Router /workflow/workflow/{id} [delete] -func workflowDelete(ctx *fiber.Ctx) error { +func workflowDelete(ctx fiber.Ctx) error { id := route.GetIntParam(ctx, "id") err := store.Database.DeleteWorkflow(id) @@ -219,7 +219,7 @@ func workflowDelete(ctx *fiber.Ctx) error { // @Success 200 {object} protocol.Response{data=[]model.WorkflowTrigger} // @Security ApiKeyAuth // @Router /workflow/workflow/{id}/triggers [get] -func workflowTriggerList(ctx *fiber.Ctx) error { +func workflowTriggerList(ctx fiber.Ctx) error { id := route.GetIntParam(ctx, "id") item, err := store.Database.GetWorkflow(id) @@ -239,7 +239,7 @@ func workflowTriggerList(ctx *fiber.Ctx) error { // @Success 200 {object} protocol.Response{data=[]model.Job} // @Security ApiKeyAuth // @Router /workflow/workflow/{id}/jobs [get] -func workflowJobList(ctx *fiber.Ctx) error { +func workflowJobList(ctx fiber.Ctx) error { id := route.GetIntParam(ctx, "id") list, err := store.Database.GetJobsByWorkflowId(id) @@ -259,7 +259,7 @@ func workflowJobList(ctx *fiber.Ctx) error { // @Success 200 {object} protocol.Response{data=model.Job} // @Security ApiKeyAuth // @Router /workflow/job/{id} [get] -func workflowJobDetail(ctx *fiber.Ctx) error { +func workflowJobDetail(ctx fiber.Ctx) error { id := route.GetIntParam(ctx, "id") item, err := store.Database.GetJob(id) @@ -279,7 +279,7 @@ func workflowJobDetail(ctx *fiber.Ctx) error { // @Success 200 {object} protocol.Response // @Security ApiKeyAuth // @Router /workflow/job/{id}/rerun [post] -func workflowJobRerun(ctx *fiber.Ctx) error { +func workflowJobRerun(ctx fiber.Ctx) error { return nil } @@ -293,7 +293,7 @@ func workflowJobRerun(ctx *fiber.Ctx) error { // @Success 200 {object} protocol.Response{data=model.WorkflowScript} // @Security ApiKeyAuth // @Router /workflow/workflow/{id}/script [get] -func workflowScriptDetail(ctx *fiber.Ctx) error { +func workflowScriptDetail(ctx fiber.Ctx) error { id := route.GetIntParam(ctx, "id") item, err := store.Database.GetWorkflowScriptByWorkflowId(id) diff --git a/internal/platforms/slack/driver.go b/internal/platforms/slack/driver.go index cdf8bac8..73708192 100644 --- a/internal/platforms/slack/driver.go +++ b/internal/platforms/slack/driver.go @@ -9,7 +9,7 @@ import ( "github.com/flowline-io/flowbot/pkg/event" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/types/protocol" - "github.com/gofiber/fiber/v2" + "github.com/gofiber/fiber/v3" "github.com/slack-go/slack" "github.com/slack-go/slack/socketmode" "time" @@ -47,7 +47,7 @@ func NewDriver(_ config.Type, _ store.Adapter) protocol.Driver { } } -func (d *Driver) HttpServer(_ *fiber.Ctx) error { +func (d *Driver) HttpServer(_ fiber.Ctx) error { return nil } diff --git a/internal/platforms/tailchat/driver.go b/internal/platforms/tailchat/driver.go index 2042853b..091f3536 100644 --- a/internal/platforms/tailchat/driver.go +++ b/internal/platforms/tailchat/driver.go @@ -2,8 +2,7 @@ package tailchat import ( "fmt" - - "github.com/gofiber/fiber/v2" + "github.com/gofiber/fiber/v3" ) const ID = "tailchat" @@ -11,9 +10,9 @@ const ID = "tailchat" func HandleWebsocket(stop <-chan bool) { } -func HandleHttp(c *fiber.Ctx) error { +func HandleHttp(c fiber.Ctx) error { var payload Payload - err := c.BodyParser(&payload) + err := c.Bind().Body(&payload) if err != nil { return err } diff --git a/internal/server/http.go b/internal/server/http.go index db575fc4..8b3408b9 100644 --- a/internal/server/http.go +++ b/internal/server/http.go @@ -3,33 +3,30 @@ package server import ( "errors" "github.com/bytedance/sonic" + "github.com/flowline-io/contrib/fiberzerolog" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/types/protocol" - "github.com/gofiber/contrib/fiberzerolog" - "github.com/gofiber/fiber/v2" - "github.com/gofiber/fiber/v2/middleware/compress" - "github.com/gofiber/fiber/v2/middleware/cors" - "github.com/gofiber/fiber/v2/middleware/healthcheck" - "github.com/gofiber/fiber/v2/middleware/limiter" - "github.com/gofiber/fiber/v2/middleware/recover" - "github.com/gofiber/fiber/v2/middleware/requestid" + "github.com/gofiber/fiber/v3" + "github.com/gofiber/fiber/v3/middleware/compress" + "github.com/gofiber/fiber/v3/middleware/cors" + "github.com/gofiber/fiber/v3/middleware/healthcheck" + "github.com/gofiber/fiber/v3/middleware/limiter" + "github.com/gofiber/fiber/v3/middleware/recover" + "github.com/gofiber/fiber/v3/middleware/requestid" "github.com/samber/oops" - "net/http" "time" ) func newHTTPServer() *fiber.App { // Set up HTTP server. app := fiber.New(fiber.Config{ - DisableStartupMessage: true, - JSONDecoder: sonic.Unmarshal, JSONEncoder: sonic.Marshal, ReadTimeout: 10 * time.Second, IdleTimeout: 30 * time.Second, WriteTimeout: 90 * time.Second, - ErrorHandler: func(ctx *fiber.Ctx, err error) error { + ErrorHandler: func(ctx fiber.Ctx, err error) error { // custom error var e oops.OopsError if errors.As(err, &e) { @@ -53,7 +50,6 @@ func newHTTPServer() *fiber.App { }) app.Use(recover.New(recover.Config{EnableStackTrace: true})) app.Use(requestid.New()) - app.Use(healthcheck.New()) app.Use(cors.New(cors.Config{ AllowOriginsFunc: func(origin string) bool { return true @@ -71,22 +67,14 @@ func newHTTPServer() *fiber.App { app.Use(fiberzerolog.New(fiberzerolog.Config{ Logger: &logger, SkipURIs: []string{ + healthcheck.DefaultLivenessEndpoint, + healthcheck.DefaultReadinessEndpoint, + healthcheck.DefaultStartupEndpoint, "/", - "/livez", - "/readyz", "/service/user/metrics", }, })) - // hook - app.Hooks().OnRoute(func(r fiber.Route) error { - if r.Method == http.MethodHead { - return nil - } - flog.Info("[route] %+7s %s", r.Method, r.Path) - return nil - }) - // swagger if swagHandler != nil { app.Get("/swagger/*", swagHandler) diff --git a/internal/server/init.go b/internal/server/init.go index c5fb09a3..0d29d0ce 100644 --- a/internal/server/init.go +++ b/internal/server/init.go @@ -11,7 +11,7 @@ import ( "github.com/flowline-io/flowbot/pkg/config" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/version" - "github.com/gofiber/fiber/v2" + "github.com/gofiber/fiber/v3" ) var ( diff --git a/internal/server/router.go b/internal/server/router.go index 4c405f52..e54b5ff3 100644 --- a/internal/server/router.go +++ b/internal/server/router.go @@ -3,6 +3,7 @@ package server import ( "bytes" "errors" + "github.com/gofiber/fiber/v3/middleware/healthcheck" "net/http" "strconv" "strings" @@ -25,8 +26,8 @@ import ( "github.com/flowline-io/flowbot/pkg/types/ruleset/webhook" "github.com/go-echarts/go-echarts/v2/charts" "github.com/go-echarts/go-echarts/v2/opts" - "github.com/gofiber/fiber/v2" - "github.com/gofiber/fiber/v2/middleware/adaptor" + "github.com/gofiber/fiber/v3" + "github.com/gofiber/fiber/v3/middleware/adaptor" "github.com/mark3labs/mcp-go/server" "github.com/maxence-charriere/go-app/v10/pkg/app" "github.com/samber/oops" @@ -41,7 +42,10 @@ func handleRoutes(a *fiber.App, mcpSSE *server.SSEServer, ctl *Controller) { } // common - a.Get("/", func(c *fiber.Ctx) error { return nil }) + a.Get("/", func(c fiber.Ctx) error { return nil }) + a.Get(healthcheck.DefaultLivenessEndpoint, healthcheck.NewHealthChecker()) + a.Get(healthcheck.DefaultReadinessEndpoint, healthcheck.NewHealthChecker()) + a.Get(healthcheck.DefaultStartupEndpoint, healthcheck.NewHealthChecker()) a.All("/oauth/:provider/:flag", ctl.storeOAuth) a.Get("/p/:id", ctl.getPage) // form @@ -71,7 +75,7 @@ func newController(driver protocol.Driver) *Controller { } } -func (c *Controller) storeOAuth(ctx *fiber.Ctx) error { +func (c *Controller) storeOAuth(ctx fiber.Ctx) error { name := ctx.Params("provider") flag := ctx.Params("flag") @@ -114,7 +118,7 @@ func (c *Controller) storeOAuth(ctx *fiber.Ctx) error { return ctx.SendString("ok") } -func (c *Controller) getPage(ctx *fiber.Ctx) error { +func (c *Controller) getPage(ctx fiber.Ctx) error { id := ctx.Params("id") p, err := store.Database.PageGet(id) @@ -170,7 +174,7 @@ func (c *Controller) getPage(ctx *fiber.Ctx) error { return ctx.SendString(page.RenderComponent(title, comp)) } -func (c *Controller) renderPage(ctx *fiber.Ctx) error { +func (c *Controller) renderPage(ctx fiber.Ctx) error { pageRuleId := ctx.Params("id") flag := ctx.Params("flag") @@ -220,7 +224,7 @@ func (c *Controller) renderPage(ctx *fiber.Ctx) error { return ctx.SendString(html) } -func (c *Controller) postForm(ctx *fiber.Ctx) error { +func (c *Controller) postForm(ctx fiber.Ctx) error { formId := ctx.FormValue("x-form_id") uid := ctx.FormValue("x-uid") topic := ctx.FormValue("x-topic") @@ -338,9 +342,9 @@ func (c *Controller) postForm(ctx *fiber.Ctx) error { return ctx.JSON(protocol.NewSuccessResponse("ok")) } -func (c *Controller) agentData(ctx *fiber.Ctx) error { +func (c *Controller) agentData(ctx fiber.Ctx) error { var r http.Request - if err := fasthttpadaptor.ConvertRequest(ctx.Context(), &r, true); err != nil { + if err := fasthttpadaptor.ConvertRequest(ctx.RequestCtx(), &r, true); err != nil { return protocol.ErrInternalServerError.Wrap(err) } // authorization @@ -364,7 +368,7 @@ func (c *Controller) agentData(ctx *fiber.Ctx) error { return ctx.JSON(protocol.NewSuccessResponse(result)) } -func (c *Controller) platformCallback(ctx *fiber.Ctx) error { +func (c *Controller) platformCallback(ctx fiber.Ctx) error { platform := ctx.Params("platform") var err error @@ -385,7 +389,7 @@ func (c *Controller) platformCallback(ctx *fiber.Ctx) error { return ctx.JSON(protocol.NewSuccessResponse(nil)) } -func (c *Controller) doWebhook(ctx *fiber.Ctx) error { +func (c *Controller) doWebhook(ctx fiber.Ctx) error { flag := ctx.Params("flag") method := ctx.Method() diff --git a/internal/server/server.go b/internal/server/server.go index de8c802c..651079ce 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -11,7 +11,7 @@ import ( "github.com/flowline-io/flowbot/pkg/config" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/search" - "github.com/gofiber/fiber/v2" + "github.com/gofiber/fiber/v3" "github.com/redis/go-redis/v9" "go.uber.org/fx" ) @@ -48,7 +48,10 @@ func RunServer(lc fx.Lifecycle, app *fiber.App, _ store.Adapter, _ *cache.Cache, // http server go func() { - err := app.Listen(config.App.Listen) + err := app.Listen(config.App.Listen, fiber.ListenConfig{ + DisableStartupMessage: true, + EnablePrintRoutes: true, + }) if err != nil { flog.Error(err) } diff --git a/internal/server/swagger.go b/internal/server/swagger.go index 83c0c791..92b2569a 100644 --- a/internal/server/swagger.go +++ b/internal/server/swagger.go @@ -3,8 +3,8 @@ package server import ( + "github.com/flowline-io/fiberswagger" _ "github.com/flowline-io/flowbot/docs" - "github.com/gofiber/swagger" ) func init() { diff --git a/pkg/chatbot/bot.go b/pkg/chatbot/bot.go index a2acde89..4d6c6224 100644 --- a/pkg/chatbot/bot.go +++ b/pkg/chatbot/bot.go @@ -28,7 +28,7 @@ import ( "github.com/flowline-io/flowbot/pkg/types/ruleset/webservice" "github.com/flowline-io/flowbot/pkg/types/ruleset/workflow" "github.com/flowline-io/flowbot/pkg/utils" - "github.com/gofiber/fiber/v2" + "github.com/gofiber/fiber/v3" "gorm.io/gorm" ) diff --git a/pkg/chatbot/interface.go b/pkg/chatbot/interface.go index 58af71f6..54cb0171 100644 --- a/pkg/chatbot/interface.go +++ b/pkg/chatbot/interface.go @@ -6,7 +6,7 @@ import ( "github.com/flowline-io/flowbot/pkg/types" "github.com/flowline-io/flowbot/pkg/types/ruleset/cron" "github.com/flowline-io/flowbot/pkg/types/ruleset/instruct" - "github.com/gofiber/fiber/v2" + "github.com/gofiber/fiber/v3" ) type Handler interface { diff --git a/pkg/providers/dropbox/dropbox.go b/pkg/providers/dropbox/dropbox.go index eddaf907..c39906db 100644 --- a/pkg/providers/dropbox/dropbox.go +++ b/pkg/providers/dropbox/dropbox.go @@ -10,7 +10,7 @@ import ( "github.com/flowline-io/flowbot/pkg/providers" "github.com/flowline-io/flowbot/pkg/types" "github.com/go-resty/resty/v2" - "github.com/gofiber/fiber/v2" + "github.com/gofiber/fiber/v3" ) const ( @@ -72,7 +72,7 @@ func (v *Dropbox) Redirect(req *http.Request) (string, error) { return appRedirectURI, nil } -func (v *Dropbox) GetAccessToken(ctx *fiber.Ctx) (types.KV, error) { +func (v *Dropbox) GetAccessToken(ctx fiber.Ctx) (types.KV, error) { code := ctx.Query("code") clientId, _ := providers.GetConfig(ID, ClientIdKey) clientSecret, _ := providers.GetConfig(ID, ClientSecretKey) diff --git a/pkg/providers/github/github.go b/pkg/providers/github/github.go index 70b604d5..748e4252 100644 --- a/pkg/providers/github/github.go +++ b/pkg/providers/github/github.go @@ -8,7 +8,7 @@ import ( "github.com/bytedance/sonic" "github.com/flowline-io/flowbot/pkg/types" "github.com/go-resty/resty/v2" - "github.com/gofiber/fiber/v2" + "github.com/gofiber/fiber/v3" ) const ( @@ -67,7 +67,7 @@ func (v *Github) Redirect(_ *http.Request) (string, error) { return appRedirectURI, nil } -func (v *Github) GetAccessToken(ctx *fiber.Ctx) (types.KV, error) { +func (v *Github) GetAccessToken(ctx fiber.Ctx) (types.KV, error) { code := ctx.Query("code") tokenResp, err := v.completeAuth(code) if err != nil { diff --git a/pkg/providers/pocket/pocket.go b/pkg/providers/pocket/pocket.go index 3696431c..7b092361 100644 --- a/pkg/providers/pocket/pocket.go +++ b/pkg/providers/pocket/pocket.go @@ -11,7 +11,7 @@ import ( "github.com/flowline-io/flowbot/pkg/rdb" "github.com/flowline-io/flowbot/pkg/types" "github.com/go-resty/resty/v2" - "github.com/gofiber/fiber/v2" + "github.com/gofiber/fiber/v3" "github.com/redis/go-redis/v9" ) @@ -93,7 +93,7 @@ func (v *Pocket) Redirect(_ *http.Request) (string, error) { return appRedirectURI, nil } -func (v *Pocket) GetAccessToken(_ *fiber.Ctx) (types.KV, error) { +func (v *Pocket) GetAccessToken(_ fiber.Ctx) (types.KV, error) { ctx := context.Background() code, err := rdb.Client.Get(ctx, "pocket:code").Result() // fixme uid key if err != nil && !errors.Is(err, redis.Nil) { diff --git a/pkg/providers/providers.go b/pkg/providers/providers.go index 746d7a94..bd91c8c2 100644 --- a/pkg/providers/providers.go +++ b/pkg/providers/providers.go @@ -6,13 +6,13 @@ import ( "fmt" "github.com/flowline-io/flowbot/pkg/types" - "github.com/gofiber/fiber/v2" + "github.com/gofiber/fiber/v3" "github.com/tidwall/gjson" ) type OAuthProvider interface { GetAuthorizeURL() string - GetAccessToken(ctx *fiber.Ctx) (types.KV, error) + GetAccessToken(ctx fiber.Ctx) (types.KV, error) } func RedirectURI(name string, flag string) string { diff --git a/pkg/route/route.go b/pkg/route/route.go index 0f121f1a..56e469b3 100644 --- a/pkg/route/route.go +++ b/pkg/route/route.go @@ -8,7 +8,7 @@ import ( "github.com/flowline-io/flowbot/internal/store" "github.com/flowline-io/flowbot/pkg/types" "github.com/flowline-io/flowbot/pkg/types/protocol" - "github.com/gofiber/fiber/v2" + "github.com/gofiber/fiber/v3" "github.com/valyala/fasthttp/fasthttpadaptor" ) @@ -71,7 +71,7 @@ func WithNotAuth() Option { } } -func ErrorResponse(ctx *fiber.Ctx, text string) error { +func ErrorResponse(ctx fiber.Ctx, text string) error { ctx = ctx.Status(http.StatusBadRequest) return ctx.SendString(text) } @@ -84,7 +84,7 @@ const ( ) func Authorize(authLevel AuthLevel, handler fiber.Handler) fiber.Handler { - return func(ctx *fiber.Ctx) error { + return func(ctx fiber.Ctx) error { // Check if authentication can be skipped if authLevel == NoAuth { return handler(ctx) @@ -92,7 +92,7 @@ func Authorize(authLevel AuthLevel, handler fiber.Handler) fiber.Handler { // Check API flag var r http.Request - if err := fasthttpadaptor.ConvertRequest(ctx.Context(), &r, true); err != nil { + if err := fasthttpadaptor.ConvertRequest(ctx.RequestCtx(), &r, true); err != nil { return protocol.ErrNotAuthorized.Wrap(err) } @@ -176,17 +176,17 @@ func CheckAccessToken(accessToken string) (uid types.Uid, isValid bool) { return } -func GetUid(ctx *fiber.Ctx) types.Uid { +func GetUid(ctx fiber.Ctx) types.Uid { uid, _ := ctx.Locals(uidKey).(types.Uid) return uid } -func GetTopic(ctx *fiber.Ctx) string { +func GetTopic(ctx fiber.Ctx) string { topic, _ := ctx.Locals(topicKey).(string) return topic } -func GetIntParam(ctx *fiber.Ctx, name string) int64 { +func GetIntParam(ctx fiber.Ctx, name string) int64 { s := ctx.Params(name) i, _ := strconv.ParseInt(s, 10, 64) return i diff --git a/pkg/types/protocol/platform.go b/pkg/types/protocol/platform.go index 06d63997..6eeda1a9 100644 --- a/pkg/types/protocol/platform.go +++ b/pkg/types/protocol/platform.go @@ -1,14 +1,14 @@ package protocol import ( - "github.com/gofiber/fiber/v2" + "github.com/gofiber/fiber/v3" ) // Driver Functional implementation of the client/server responsible for receiving // and sending messages (usually HTTP communication) type Driver interface { // HttpServer The application can actively access the Chatbot implementation. - HttpServer(ctx *fiber.Ctx) error + HttpServer(ctx fiber.Ctx) error // HttpWebhookClient Chatbot implements active access to applications HttpWebhookClient(message Message) error // WebSocketClient The application can actively access the Chatbot implementation. diff --git a/pkg/types/ruleset/webservice/webservice.go b/pkg/types/ruleset/webservice/webservice.go index a6c230ab..7b4378f5 100644 --- a/pkg/types/ruleset/webservice/webservice.go +++ b/pkg/types/ruleset/webservice/webservice.go @@ -5,7 +5,7 @@ import ( "github.com/flowline-io/flowbot/pkg/route" "github.com/flowline-io/flowbot/pkg/types" - "github.com/gofiber/fiber/v2" + "github.com/gofiber/fiber/v3" ) type Rule struct { diff --git a/pkg/utils/singleton.go b/pkg/utils/singleton.go index b54164e5..097b7dd7 100644 --- a/pkg/utils/singleton.go +++ b/pkg/utils/singleton.go @@ -7,10 +7,10 @@ import ( "time" "github.com/go-resty/resty/v2" - "github.com/gofiber/fiber/v2" - "github.com/gofiber/fiber/v2/middleware/cors" - "github.com/gofiber/fiber/v2/middleware/recover" - "github.com/gofiber/fiber/v2/middleware/requestid" + "github.com/gofiber/fiber/v3" + "github.com/gofiber/fiber/v3/middleware/cors" + "github.com/gofiber/fiber/v3/middleware/recover" + "github.com/gofiber/fiber/v3/middleware/requestid" ) const EmbedServerPort = "5678" @@ -33,13 +33,13 @@ func EmbedServer() { go func() { log.Printf("embed server http://127.0.0.1:%v", EmbedServerPort) - app := fiber.New(fiber.Config{DisableStartupMessage: true}) + app := fiber.New(fiber.Config{}) app.Use(cors.New()) app.Use(recover.New()) app.Use(requestid.New()) - app.Get("/", func(c *fiber.Ctx) error { return nil }) - app.Get("/health", func(c *fiber.Ctx) error { return c.SendString("ok") }) + app.Get("/", func(c fiber.Ctx) error { return nil }) + app.Get("/health", func(c fiber.Ctx) error { return c.SendString("ok") }) err := app.Listen(net.JoinHostPort("127.0.0.1", EmbedServerPort)) if err != nil { From 0045b4b63803c6e7aefccd26080bc7659442bb65 Mon Sep 17 00:00:00 2001 From: sysatom Date: Fri, 30 May 2025 01:03:06 +0800 Subject: [PATCH 120/125] update: upgrade resty v3 --- cmd/agent/client/client.go | 2 +- cmd/agent/ruleset/collect/bot/anki.go | 2 +- cmd/composer/action/generator/tmpl/vendor.tmpl | 2 +- cmd/composer/action/workflow/import.go | 2 +- go.mod | 2 +- go.sum | 4 ++-- internal/platforms/tailchat/types.go | 4 ++-- pkg/notify/message-pusher/message_pusher.go | 2 +- pkg/notify/ntfy/notify.go | 2 +- pkg/notify/slack/slack.go | 2 +- pkg/providers/adguard/adguard_home.go | 2 +- pkg/providers/archivebox/archivebox.go | 2 +- pkg/providers/cloudflare/cloudflare.go | 4 ++-- pkg/providers/crates/crates.go | 2 +- pkg/providers/doctorxiong/doctorxiong.go | 2 +- pkg/providers/drone/drone.go | 2 +- pkg/providers/dropbox/dropbox.go | 16 ++++++++-------- pkg/providers/fireflyiii/fireflyiii.go | 2 +- pkg/providers/github/github.go | 2 +- pkg/providers/hoarder/hoarder.go | 2 +- pkg/providers/lobehub/lobehub.go | 4 ++-- pkg/providers/pocket/pocket.go | 2 +- pkg/providers/safeline/safeline.go | 2 +- pkg/providers/shiori/shiori.go | 9 +++++---- pkg/providers/slash/slash.go | 2 +- pkg/providers/uptimekuma/uptimekuma.go | 5 ++--- pkg/providers/victoriametrics/victoriametrics.go | 4 ++-- pkg/providers/wallos/wallos.go | 2 +- pkg/utils/singleton.go | 2 +- 29 files changed, 46 insertions(+), 46 deletions(-) diff --git a/cmd/agent/client/client.go b/cmd/agent/client/client.go index cb412a17..f7eceeab 100644 --- a/cmd/agent/client/client.go +++ b/cmd/agent/client/client.go @@ -9,7 +9,7 @@ import ( "github.com/flowline-io/flowbot/cmd/agent/config" "github.com/flowline-io/flowbot/pkg/types" "github.com/flowline-io/flowbot/pkg/types/protocol" - "github.com/go-resty/resty/v2" + "resty.dev/v3" ) type flowbot struct { diff --git a/cmd/agent/ruleset/collect/bot/anki.go b/cmd/agent/ruleset/collect/bot/anki.go index bb6839e5..1231e09f 100644 --- a/cmd/agent/ruleset/collect/bot/anki.go +++ b/cmd/agent/ruleset/collect/bot/anki.go @@ -10,7 +10,7 @@ import ( "github.com/flowline-io/flowbot/cmd/agent/client" "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/types" - "github.com/go-resty/resty/v2" + "resty.dev/v3" ) const ( diff --git a/cmd/composer/action/generator/tmpl/vendor.tmpl b/cmd/composer/action/generator/tmpl/vendor.tmpl index b513bb59..2ddab945 100644 --- a/cmd/composer/action/generator/tmpl/vendor.tmpl +++ b/cmd/composer/action/generator/tmpl/vendor.tmpl @@ -2,7 +2,7 @@ package {{ .VendorName }} import ( "fmt" - "github.com/go-resty/resty/v2" + "resty.dev/v3" "net/http" "time" ) diff --git a/cmd/composer/action/workflow/import.go b/cmd/composer/action/workflow/import.go index c0272bc0..f38cd81d 100644 --- a/cmd/composer/action/workflow/import.go +++ b/cmd/composer/action/workflow/import.go @@ -11,9 +11,9 @@ import ( "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/types/protocol" - "github.com/go-resty/resty/v2" "github.com/goccy/go-yaml" "github.com/urfave/cli/v3" + "resty.dev/v3" ) func ImportAction(ctx context.Context, c *cli.Command) error { diff --git a/go.mod b/go.mod index e371cfc8..227845c0 100644 --- a/go.mod +++ b/go.mod @@ -32,7 +32,6 @@ require ( github.com/gen2brain/beeep v0.0.0-20240516210008-9c006672e7f4 github.com/go-echarts/go-echarts/v2 v2.5.4 github.com/go-playground/validator/v10 v10.26.0 - github.com/go-resty/resty/v2 v2.16.5 github.com/go-sql-driver/mysql v1.9.2 github.com/goccy/go-json v0.10.5 github.com/goccy/go-yaml v1.18.0 @@ -85,6 +84,7 @@ require ( gorm.io/plugin/dbresolver v1.6.0 gotest.tools/v3 v3.5.2 miniflux.app/v2 v2.2.8 + resty.dev/v3 v3.0.0-beta.3 ) require ( diff --git a/go.sum b/go.sum index 3cc0d0aa..6d33b627 100644 --- a/go.sum +++ b/go.sum @@ -175,8 +175,6 @@ github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJn github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= github.com/go-playground/validator/v10 v10.26.0 h1:SP05Nqhjcvz81uJaRfEV0YBSSSGMc/iMaVtFbr3Sw2k= github.com/go-playground/validator/v10 v10.26.0/go.mod h1:I5QpIEbmr8On7W0TktmJAumgzX4CA1XNl4ZmDuVHKKo= -github.com/go-resty/resty/v2 v2.16.5 h1:hBKqmWrr7uRc3euHVqmh1HTHcKn99Smr7o5spptdhTM= -github.com/go-resty/resty/v2 v2.16.5/go.mod h1:hkJtXbA2iKHzJheXYvQ8snQES5ZLGKMwQ07xAwp/fiA= github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI= github.com/go-sql-driver/mysql v1.8.1/go.mod h1:wEBSXgmK//2ZFJyE+qWnIsVGmvmEKlqwuVSjsCm7DZg= github.com/go-sql-driver/mysql v1.9.2 h1:4cNKDYQ1I84SXslGddlsrMhc8k4LeDVj6Ad6WRjiHuU= @@ -752,3 +750,5 @@ gotest.tools/v3 v3.5.2/go.mod h1:LtdLGcnqToBH83WByAAi/wiwSFCArdFIUV/xxN4pcjA= miniflux.app/v2 v2.2.8 h1:SsWBlyK7hiBJ5fkNeOgK1p872a4/qDJMOyTH2iSWIsA= miniflux.app/v2 v2.2.8/go.mod h1:30vy970xFSfHePD/W+SKFz1vnzQx9rqo9/xeFP/GDlE= nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50= +resty.dev/v3 v3.0.0-beta.3 h1:3kEwzEgCnnS6Ob4Emlk94t+I/gClyoah7SnNi67lt+E= +resty.dev/v3 v3.0.0-beta.3/go.mod h1:OgkqiPvTDtOuV4MGZuUDhwOpkY8enjOsjjMzeOHefy4= diff --git a/internal/platforms/tailchat/types.go b/internal/platforms/tailchat/types.go index 6bd3c300..d453f425 100644 --- a/internal/platforms/tailchat/types.go +++ b/internal/platforms/tailchat/types.go @@ -8,7 +8,7 @@ import ( "github.com/flowline-io/flowbot/pkg/config" "github.com/flowline-io/flowbot/pkg/types" "github.com/flowline-io/flowbot/pkg/utils" - "github.com/go-resty/resty/v2" + "resty.dev/v3" ) type Payload struct { @@ -80,7 +80,7 @@ func (v *client) sendMessage(data SendMessageData) error { } if resp.StatusCode() == http.StatusOK { - _, _ = fmt.Println(string(resp.Body())) + _, _ = fmt.Println(utils.BytesToString(resp.Bytes())) return nil } else { return fmt.Errorf("%d, %s (%s)", resp.StatusCode(), resp.Header().Get("X-Error-Code"), resp.Header().Get("X-Error")) diff --git a/pkg/notify/message-pusher/message_pusher.go b/pkg/notify/message-pusher/message_pusher.go index 559d3ec5..9242cfb6 100644 --- a/pkg/notify/message-pusher/message_pusher.go +++ b/pkg/notify/message-pusher/message_pusher.go @@ -4,8 +4,8 @@ import ( "fmt" "github.com/flowline-io/flowbot/pkg/notify" "github.com/flowline-io/flowbot/pkg/types" - "github.com/go-resty/resty/v2" "net/http" + "resty.dev/v3" "time" ) diff --git a/pkg/notify/ntfy/notify.go b/pkg/notify/ntfy/notify.go index 7f85d5ca..380c6578 100644 --- a/pkg/notify/ntfy/notify.go +++ b/pkg/notify/ntfy/notify.go @@ -7,7 +7,7 @@ import ( "github.com/flowline-io/flowbot/pkg/notify" "github.com/flowline-io/flowbot/pkg/types" - "github.com/go-resty/resty/v2" + "resty.dev/v3" ) const ID = "ntfy" diff --git a/pkg/notify/slack/slack.go b/pkg/notify/slack/slack.go index 81958879..ea1a7cd1 100644 --- a/pkg/notify/slack/slack.go +++ b/pkg/notify/slack/slack.go @@ -8,7 +8,7 @@ import ( "github.com/flowline-io/flowbot/pkg/flog" "github.com/flowline-io/flowbot/pkg/notify" "github.com/flowline-io/flowbot/pkg/types" - "github.com/go-resty/resty/v2" + "resty.dev/v3" ) const ID = "slack" diff --git a/pkg/providers/adguard/adguard_home.go b/pkg/providers/adguard/adguard_home.go index 988a51f4..7502c257 100644 --- a/pkg/providers/adguard/adguard_home.go +++ b/pkg/providers/adguard/adguard_home.go @@ -5,7 +5,7 @@ import ( "time" "github.com/flowline-io/flowbot/pkg/providers" - "github.com/go-resty/resty/v2" + "resty.dev/v3" ) const ( diff --git a/pkg/providers/archivebox/archivebox.go b/pkg/providers/archivebox/archivebox.go index 0a2b2160..dea75583 100644 --- a/pkg/providers/archivebox/archivebox.go +++ b/pkg/providers/archivebox/archivebox.go @@ -5,7 +5,7 @@ import ( "time" "github.com/flowline-io/flowbot/pkg/providers" - "github.com/go-resty/resty/v2" + "resty.dev/v3" ) const ( diff --git a/pkg/providers/cloudflare/cloudflare.go b/pkg/providers/cloudflare/cloudflare.go index 86051cb6..30b340fc 100644 --- a/pkg/providers/cloudflare/cloudflare.go +++ b/pkg/providers/cloudflare/cloudflare.go @@ -6,7 +6,7 @@ import ( "time" "github.com/flowline-io/flowbot/pkg/providers" - "github.com/go-resty/resty/v2" + "resty.dev/v3" ) const ( @@ -54,7 +54,7 @@ query firewallEventsAdaptive( filter: { datetime_gt: "%s", - datetime_lt: "%s" + datetime_lt: "%s" }, limit: 2, orderBy: [datetime_DESC, rayName_DESC]) diff --git a/pkg/providers/crates/crates.go b/pkg/providers/crates/crates.go index 72407572..348960a2 100644 --- a/pkg/providers/crates/crates.go +++ b/pkg/providers/crates/crates.go @@ -5,7 +5,7 @@ import ( "net/http" "time" - "github.com/go-resty/resty/v2" + "resty.dev/v3" ) const ( diff --git a/pkg/providers/doctorxiong/doctorxiong.go b/pkg/providers/doctorxiong/doctorxiong.go index 7984ae8c..46a2465a 100644 --- a/pkg/providers/doctorxiong/doctorxiong.go +++ b/pkg/providers/doctorxiong/doctorxiong.go @@ -7,7 +7,7 @@ import ( "strconv" "time" - "github.com/go-resty/resty/v2" + "resty.dev/v3" ) const ( diff --git a/pkg/providers/drone/drone.go b/pkg/providers/drone/drone.go index 9302ca9d..a37f926f 100644 --- a/pkg/providers/drone/drone.go +++ b/pkg/providers/drone/drone.go @@ -5,7 +5,7 @@ import ( "time" "github.com/flowline-io/flowbot/pkg/providers" - "github.com/go-resty/resty/v2" + "resty.dev/v3" ) const ( diff --git a/pkg/providers/dropbox/dropbox.go b/pkg/providers/dropbox/dropbox.go index c39906db..a939d81a 100644 --- a/pkg/providers/dropbox/dropbox.go +++ b/pkg/providers/dropbox/dropbox.go @@ -2,15 +2,15 @@ package dropbox import ( "fmt" - "io" - "net/http" - "time" - "github.com/bytedance/sonic" "github.com/flowline-io/flowbot/pkg/providers" "github.com/flowline-io/flowbot/pkg/types" - "github.com/go-resty/resty/v2" + "github.com/flowline-io/flowbot/pkg/utils" "github.com/gofiber/fiber/v3" + "io" + "net/http" + "resty.dev/v3" + "time" ) const ( @@ -56,14 +56,14 @@ func (v *Dropbox) completeAuth(code string) (interface{}, error) { if resp.StatusCode() == http.StatusOK { var result TokenResponse - err = sonic.Unmarshal(resp.Body(), &result) + err = sonic.Unmarshal(resp.Bytes(), &result) if err != nil { return nil, err } v.accessToken = result.AccessToken return &result, nil } else { - return nil, fmt.Errorf("%d, %s", resp.StatusCode(), string(resp.Body())) + return nil, fmt.Errorf("%d, %s", resp.StatusCode(), utils.BytesToString(resp.Bytes())) } } @@ -121,6 +121,6 @@ func (v *Dropbox) Upload(path string, content io.Reader) error { if resp.StatusCode() == http.StatusOK { return nil } else { - return fmt.Errorf("%d, %s", resp.StatusCode(), string(resp.Body())) + return fmt.Errorf("%d, %s", resp.StatusCode(), utils.BytesToString(resp.Bytes())) } } diff --git a/pkg/providers/fireflyiii/fireflyiii.go b/pkg/providers/fireflyiii/fireflyiii.go index 05acf065..358ca0a1 100644 --- a/pkg/providers/fireflyiii/fireflyiii.go +++ b/pkg/providers/fireflyiii/fireflyiii.go @@ -7,7 +7,7 @@ import ( "time" "github.com/flowline-io/flowbot/pkg/providers" - "github.com/go-resty/resty/v2" + "resty.dev/v3" ) const ( diff --git a/pkg/providers/github/github.go b/pkg/providers/github/github.go index 748e4252..f10ebb52 100644 --- a/pkg/providers/github/github.go +++ b/pkg/providers/github/github.go @@ -7,8 +7,8 @@ import ( "github.com/bytedance/sonic" "github.com/flowline-io/flowbot/pkg/types" - "github.com/go-resty/resty/v2" "github.com/gofiber/fiber/v3" + "resty.dev/v3" ) const ( diff --git a/pkg/providers/hoarder/hoarder.go b/pkg/providers/hoarder/hoarder.go index 31d2d9ff..b85e0d3d 100644 --- a/pkg/providers/hoarder/hoarder.go +++ b/pkg/providers/hoarder/hoarder.go @@ -5,7 +5,7 @@ import ( "time" "github.com/flowline-io/flowbot/pkg/providers" - "github.com/go-resty/resty/v2" + "resty.dev/v3" ) const ( diff --git a/pkg/providers/lobehub/lobehub.go b/pkg/providers/lobehub/lobehub.go index a9ef5dac..3f36e5c9 100644 --- a/pkg/providers/lobehub/lobehub.go +++ b/pkg/providers/lobehub/lobehub.go @@ -6,7 +6,7 @@ import ( "time" "github.com/flowline-io/flowbot/pkg/utils" - "github.com/go-resty/resty/v2" + "resty.dev/v3" ) const ( @@ -40,6 +40,6 @@ func (i *Lobehub) WebCrawler(url string) (*WebCrawlerResponse, error) { result := resp.Result().(*WebCrawlerResponse) return result, nil } else { - return nil, fmt.Errorf("%d, %s", resp.StatusCode(), utils.BytesToString(resp.Body())) + return nil, fmt.Errorf("%d, %s", resp.StatusCode(), utils.BytesToString(resp.Bytes())) } } diff --git a/pkg/providers/pocket/pocket.go b/pkg/providers/pocket/pocket.go index 7b092361..85e5802d 100644 --- a/pkg/providers/pocket/pocket.go +++ b/pkg/providers/pocket/pocket.go @@ -10,9 +10,9 @@ import ( "github.com/bytedance/sonic" "github.com/flowline-io/flowbot/pkg/rdb" "github.com/flowline-io/flowbot/pkg/types" - "github.com/go-resty/resty/v2" "github.com/gofiber/fiber/v3" "github.com/redis/go-redis/v9" + "resty.dev/v3" ) const ( diff --git a/pkg/providers/safeline/safeline.go b/pkg/providers/safeline/safeline.go index fa757a93..cc85c692 100644 --- a/pkg/providers/safeline/safeline.go +++ b/pkg/providers/safeline/safeline.go @@ -6,7 +6,7 @@ import ( "time" "github.com/flowline-io/flowbot/pkg/providers" - "github.com/go-resty/resty/v2" + "resty.dev/v3" ) const ( diff --git a/pkg/providers/shiori/shiori.go b/pkg/providers/shiori/shiori.go index 083f3a7a..3f104739 100644 --- a/pkg/providers/shiori/shiori.go +++ b/pkg/providers/shiori/shiori.go @@ -2,10 +2,11 @@ package shiori import ( "fmt" + "github.com/flowline-io/flowbot/pkg/utils" "time" "github.com/flowline-io/flowbot/pkg/providers" - "github.com/go-resty/resty/v2" + "resty.dev/v3" ) const ( @@ -51,7 +52,7 @@ func (v *Shiori) Login(username string, password string) (*LoginResponse, error) } if resp.StatusCode() != 200 { - return nil, fmt.Errorf("unexpected status code: %d, %s", resp.StatusCode(), string(resp.Body())) + return nil, fmt.Errorf("unexpected status code: %d, %s", resp.StatusCode(), utils.BytesToString(resp.Bytes())) } r := resp.Result().(*LoginResponse) @@ -70,7 +71,7 @@ func (v *Shiori) Logout(sessionId string) error { } if resp.StatusCode() != 200 { - return fmt.Errorf("unexpected status code: %d, %s", resp.StatusCode(), string(resp.Body())) + return fmt.Errorf("unexpected status code: %d, %s", resp.StatusCode(), utils.BytesToString(resp.Bytes())) } return nil } @@ -102,7 +103,7 @@ func (v *Shiori) AddBookmark(url, title string) (*BookmarkResponse, error) { } if resp.StatusCode() != 200 { - return nil, fmt.Errorf("unexpected status code: %d, %s", resp.StatusCode(), string(resp.Body())) + return nil, fmt.Errorf("unexpected status code: %d, %s", resp.StatusCode(), utils.BytesToString(resp.Bytes())) } return resp.Result().(*BookmarkResponse), nil diff --git a/pkg/providers/slash/slash.go b/pkg/providers/slash/slash.go index 87baac50..a61e3c39 100644 --- a/pkg/providers/slash/slash.go +++ b/pkg/providers/slash/slash.go @@ -5,7 +5,7 @@ import ( "time" "github.com/flowline-io/flowbot/pkg/providers" - "github.com/go-resty/resty/v2" + "resty.dev/v3" ) const ( diff --git a/pkg/providers/uptimekuma/uptimekuma.go b/pkg/providers/uptimekuma/uptimekuma.go index 131258fd..878db9e5 100644 --- a/pkg/providers/uptimekuma/uptimekuma.go +++ b/pkg/providers/uptimekuma/uptimekuma.go @@ -1,14 +1,13 @@ package uptimekuma import ( - "bytes" "fmt" "time" "github.com/flowline-io/flowbot/pkg/providers" - "github.com/go-resty/resty/v2" dto "github.com/prometheus/client_model/go" "github.com/prometheus/common/expfmt" + "resty.dev/v3" ) const ( @@ -48,7 +47,7 @@ func (i *UptimeKuma) Metrics() (map[string]*dto.MetricFamily, error) { } parser := expfmt.TextParser{} - metricFamilies, err := parser.TextToMetricFamilies(bytes.NewBuffer(resp.Body())) + metricFamilies, err := parser.TextToMetricFamilies(resp.Body) if err != nil { return nil, fmt.Errorf("failed to parse metrics: %w", err) } diff --git a/pkg/providers/victoriametrics/victoriametrics.go b/pkg/providers/victoriametrics/victoriametrics.go index c6000e55..95bbbd4a 100644 --- a/pkg/providers/victoriametrics/victoriametrics.go +++ b/pkg/providers/victoriametrics/victoriametrics.go @@ -7,7 +7,7 @@ import ( "github.com/flowline-io/flowbot/pkg/config" "github.com/flowline-io/flowbot/pkg/utils" - "github.com/go-resty/resty/v2" + "resty.dev/v3" ) const ( @@ -40,6 +40,6 @@ func (i *VictoriaMetrics) Query(expression string) (*MetricsResponse, error) { result := resp.Result().(*MetricsResponse) return result, nil } else { - return nil, fmt.Errorf("%d, %s", resp.StatusCode(), utils.BytesToString(resp.Body())) + return nil, fmt.Errorf("%d, %s", resp.StatusCode(), utils.BytesToString(resp.Bytes())) } } diff --git a/pkg/providers/wallos/wallos.go b/pkg/providers/wallos/wallos.go index 368bb2bf..209e2bba 100644 --- a/pkg/providers/wallos/wallos.go +++ b/pkg/providers/wallos/wallos.go @@ -6,7 +6,7 @@ import ( "time" "github.com/flowline-io/flowbot/pkg/providers" - "github.com/go-resty/resty/v2" + "resty.dev/v3" ) const ( diff --git a/pkg/utils/singleton.go b/pkg/utils/singleton.go index 097b7dd7..a1e6486d 100644 --- a/pkg/utils/singleton.go +++ b/pkg/utils/singleton.go @@ -6,11 +6,11 @@ import ( "net" "time" - "github.com/go-resty/resty/v2" "github.com/gofiber/fiber/v3" "github.com/gofiber/fiber/v3/middleware/cors" "github.com/gofiber/fiber/v3/middleware/recover" "github.com/gofiber/fiber/v3/middleware/requestid" + "resty.dev/v3" ) const EmbedServerPort = "5678" From 41f33c73c9eef06c9ef59f62641378c1697d921b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 30 May 2025 16:23:43 +0000 Subject: [PATCH 121/125] build(deps): bump github.com/flc1125/go-cron/v4 from 4.5.4 to 4.5.5 Bumps [github.com/flc1125/go-cron/v4](https://github.com/flc1125/go-cron) from 4.5.4 to 4.5.5. - [Release notes](https://github.com/flc1125/go-cron/releases) - [Commits](https://github.com/flc1125/go-cron/compare/v4.5.4...v4.5.5) --- updated-dependencies: - dependency-name: github.com/flc1125/go-cron/v4 dependency-version: 4.5.5 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 227845c0..8537eaa0 100644 --- a/go.mod +++ b/go.mod @@ -25,7 +25,7 @@ require ( github.com/dustin/go-humanize v1.0.1 github.com/emicklei/go-restful/v3 v3.12.2 github.com/expr-lang/expr v1.17.4 - github.com/flc1125/go-cron/v4 v4.5.4 + github.com/flc1125/go-cron/v4 v4.5.5 github.com/flowline-io/contrib/fiberzerolog v0.0.0-20250529160935-d348985506ed github.com/flowline-io/fiberswagger v0.0.0-20250529155353-3b5b94dbd01c github.com/fsnotify/fsnotify v1.9.0 diff --git a/go.sum b/go.sum index 6d33b627..207e95d1 100644 --- a/go.sum +++ b/go.sum @@ -118,8 +118,8 @@ github.com/expr-lang/expr v1.17.4 h1:qhTVftZ2Z3WpOEXRHWErEl2xf1Kq011MnQmWgLq06CY github.com/expr-lang/expr v1.17.4/go.mod h1:8/vRC7+7HBzESEqt5kKpYXxrxkr31SaO8r40VO/1IT4= github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= -github.com/flc1125/go-cron/v4 v4.5.4 h1:B/BpLGOUwFQFtocqDxkZVyZvb7uXfZfcJUcE3knRxZg= -github.com/flc1125/go-cron/v4 v4.5.4/go.mod h1:7wGlEw0cBolSHQEyM8Kl46Watl/lXwVkdc8zc5G9WuY= +github.com/flc1125/go-cron/v4 v4.5.5 h1:sej00JBY0PxIq12Dt/BFPAEuj56yoG/3uYCFzTp8kw0= +github.com/flc1125/go-cron/v4 v4.5.5/go.mod h1:7wGlEw0cBolSHQEyM8Kl46Watl/lXwVkdc8zc5G9WuY= github.com/flowline-io/contrib/fiberzerolog v0.0.0-20250529160935-d348985506ed h1:45TJa+yWA875amR12FImFaDJGa6NBvCX2dBphOTAUU8= github.com/flowline-io/contrib/fiberzerolog v0.0.0-20250529160935-d348985506ed/go.mod h1:Pgz+8dD5p/Mj7XZQJ4HJWqB0XiX2+Ghtkg3HuxD4pFQ= github.com/flowline-io/fiberswagger v0.0.0-20250529155353-3b5b94dbd01c h1:BnsSRINEkyL9MLa3NvJH1blJu4Dd2asmjr5j7b/LeI4= From 03daa515c61b0b043755ab369d5451b6512263ca Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 30 May 2025 16:23:49 +0000 Subject: [PATCH 122/125] build(deps): bump github.com/cloudwego/eino from 0.3.37 to 0.3.38 Bumps [github.com/cloudwego/eino](https://github.com/cloudwego/eino) from 0.3.37 to 0.3.38. - [Release notes](https://github.com/cloudwego/eino/releases) - [Commits](https://github.com/cloudwego/eino/compare/v0.3.37...v0.3.38) --- updated-dependencies: - dependency-name: github.com/cloudwego/eino dependency-version: 0.3.38 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 227845c0..c434c394 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/bwmarrin/discordgo v0.29.0 github.com/bytedance/sonic v1.13.2 github.com/cenkalti/backoff v2.2.1+incompatible - github.com/cloudwego/eino v0.3.37 + github.com/cloudwego/eino v0.3.38 github.com/cloudwego/eino-ext/components/model/ollama v0.0.0-20250520101807-b2008771903a github.com/cloudwego/eino-ext/components/model/openai v0.0.0-20250520101807-b2008771903a github.com/creachadair/jrpc2 v1.3.1 diff --git a/go.sum b/go.sum index 6d33b627..879582fb 100644 --- a/go.sum +++ b/go.sum @@ -63,8 +63,8 @@ github.com/chengxilo/virtualterm v1.0.4 h1:Z6IpERbRVlfB8WkOmtbHiDbBANU7cimRIof7m github.com/chengxilo/virtualterm v1.0.4/go.mod h1:DyxxBZz/x1iqJjFxTFcr6/x+jSpqN0iwWCOK1q10rlY= github.com/cloudwego/base64x v0.1.5 h1:XPciSp1xaq2VCSt6lF0phncD4koWyULpl5bUxbfCyP4= github.com/cloudwego/base64x v0.1.5/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w= -github.com/cloudwego/eino v0.3.37 h1:UliGEzM88vVMmG9g2kZCyosaVbg7Rz0dNARs1c0HVs8= -github.com/cloudwego/eino v0.3.37/go.mod h1:wUjz990apdsaOraOXdh6CdhVXq8DJsOvLsVlxNTcNfY= +github.com/cloudwego/eino v0.3.38 h1:X6e+rL/RReZEtqgslTnoc0n7M2RFDt0e0mI/R+m2tkc= +github.com/cloudwego/eino v0.3.38/go.mod h1:wUjz990apdsaOraOXdh6CdhVXq8DJsOvLsVlxNTcNfY= github.com/cloudwego/eino-ext/components/model/ollama v0.0.0-20250520101807-b2008771903a h1:+/VYbeXv7bCdm0Wk183zIj9MjtF8yVaO1aDQyjfhf6c= github.com/cloudwego/eino-ext/components/model/ollama v0.0.0-20250520101807-b2008771903a/go.mod h1:giNUFqA+V7xrm/EDvH7JFnDqoWI+e2m1SVAnReU+Fd8= github.com/cloudwego/eino-ext/components/model/openai v0.0.0-20250520101807-b2008771903a h1:mpUCTgxWY34WyXopxMZcZPMJtg05tOCswxoRRXqT+lQ= From 34d34f848f40415d171b65eecce3e0c31c6c4218 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 30 May 2025 16:23:58 +0000 Subject: [PATCH 123/125] build(deps): bump github.com/docker/cli Bumps [github.com/docker/cli](https://github.com/docker/cli) from 28.1.1+incompatible to 28.2.2+incompatible. - [Commits](https://github.com/docker/cli/compare/v28.1.1...v28.2.2) --- updated-dependencies: - dependency-name: github.com/docker/cli dependency-version: 28.2.2+incompatible dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 227845c0..c4d2aa80 100644 --- a/go.mod +++ b/go.mod @@ -19,7 +19,7 @@ require ( github.com/cloudwego/eino-ext/components/model/openai v0.0.0-20250520101807-b2008771903a github.com/creachadair/jrpc2 v1.3.1 github.com/dgraph-io/ristretto/v2 v2.2.0 - github.com/docker/cli v28.1.1+incompatible + github.com/docker/cli v28.2.2+incompatible github.com/docker/docker v28.1.1+incompatible github.com/docker/go-units v0.5.0 github.com/dustin/go-humanize v1.0.1 diff --git a/go.sum b/go.sum index 6d33b627..ddc27f62 100644 --- a/go.sum +++ b/go.sum @@ -98,8 +98,8 @@ github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5Qvfr github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E= github.com/dlclark/regexp2 v1.11.4 h1:rPYF9/LECdNymJufQKmri9gV604RvvABwgOA8un7yAo= github.com/dlclark/regexp2 v1.11.4/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= -github.com/docker/cli v28.1.1+incompatible h1:eyUemzeI45DY7eDPuwUcmDyDj1pM98oD5MdSpiItp8k= -github.com/docker/cli v28.1.1+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= +github.com/docker/cli v28.2.2+incompatible h1:qzx5BNUDFqlvyq4AHzdNB7gSyVTmU4cgsyN9SdInc1A= +github.com/docker/cli v28.2.2+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= github.com/docker/docker v28.1.1+incompatible h1:49M11BFLsVO1gxY9UX9p/zwkE/rswggs8AdFmXQw51I= github.com/docker/docker v28.1.1+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/go-connections v0.5.0 h1:USnMq7hx7gwdVZq1L49hLXaFtUdTADjXGp+uj1Br63c= From 354a896da59d55c8ac45086cbc9f72f7e9d8834e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 30 May 2025 16:24:16 +0000 Subject: [PATCH 124/125] build(deps): bump github.com/mark3labs/mcp-go from 0.30.1 to 0.31.0 Bumps [github.com/mark3labs/mcp-go](https://github.com/mark3labs/mcp-go) from 0.30.1 to 0.31.0. - [Release notes](https://github.com/mark3labs/mcp-go/releases) - [Commits](https://github.com/mark3labs/mcp-go/compare/v0.30.1...v0.31.0) --- updated-dependencies: - dependency-name: github.com/mark3labs/mcp-go dependency-version: 0.31.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 227845c0..8cc01324 100644 --- a/go.mod +++ b/go.mod @@ -47,7 +47,7 @@ require ( github.com/json-iterator/go v1.1.12 github.com/lithammer/shortuuid/v4 v4.2.0 github.com/looplab/fsm v1.0.3 - github.com/mark3labs/mcp-go v0.30.1 + github.com/mark3labs/mcp-go v0.31.0 github.com/maxence-charriere/go-app/v10 v10.1.3 github.com/meilisearch/meilisearch-go v0.32.0 github.com/minio/minio-go/v7 v7.0.92 diff --git a/go.sum b/go.sum index 6d33b627..809367d4 100644 --- a/go.sum +++ b/go.sum @@ -322,8 +322,8 @@ github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJ github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= github.com/mailru/easyjson v0.9.0 h1:PrnmzHw7262yW8sTBwxi1PdJA3Iw/EKBa8psRf7d9a4= github.com/mailru/easyjson v0.9.0/go.mod h1:1+xMtQp2MRNVL/V1bOzuP3aP8VNwRW55fQUto+XFtTU= -github.com/mark3labs/mcp-go v0.30.1 h1:3R1BPvNT/rC1iPpLx+EMXFy+gvux/Mz/Nio3c6XEU9E= -github.com/mark3labs/mcp-go v0.30.1/go.mod h1:rXqOudj/djTORU/ThxYx8fqEVj/5pvTuuebQ2RC7uk4= +github.com/mark3labs/mcp-go v0.31.0 h1:4UxSV8aM770OPmTvaVe/b1rA2oZAjBMhGBfUgOGut+4= +github.com/mark3labs/mcp-go v0.31.0/go.mod h1:rXqOudj/djTORU/ThxYx8fqEVj/5pvTuuebQ2RC7uk4= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= From 4200c06e3238e73a68aabdc25ddb7ab06d35eaa2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 31 May 2025 02:27:53 +0000 Subject: [PATCH 125/125] build(deps): bump github.com/docker/docker Bumps [github.com/docker/docker](https://github.com/docker/docker) from 28.1.1+incompatible to 28.2.2+incompatible. - [Release notes](https://github.com/docker/docker/releases) - [Commits](https://github.com/docker/docker/compare/v28.1.1...v28.2.2) --- updated-dependencies: - dependency-name: github.com/docker/docker dependency-version: 28.2.2+incompatible dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 4 +++- go.sum | 8 ++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index b65cc34e..a9cd2ccc 100644 --- a/go.mod +++ b/go.mod @@ -20,7 +20,7 @@ require ( github.com/creachadair/jrpc2 v1.3.1 github.com/dgraph-io/ristretto/v2 v2.2.0 github.com/docker/cli v28.2.2+incompatible - github.com/docker/docker v28.1.1+incompatible + github.com/docker/docker v28.2.2+incompatible github.com/docker/go-units v0.5.0 github.com/dustin/go-humanize v1.0.1 github.com/emicklei/go-restful/v3 v3.12.2 @@ -101,6 +101,8 @@ require ( github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/cloudwego/base64x v0.1.5 // indirect github.com/cloudwego/eino-ext/libs/acl/openai v0.0.0-20250519084852-38fafa73d9ea // indirect + github.com/containerd/errdefs v1.0.0 // indirect + github.com/containerd/errdefs/pkg v0.3.0 // indirect github.com/containerd/log v0.1.0 // indirect github.com/creachadair/mds v0.23.0 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect diff --git a/go.sum b/go.sum index 09c2ba1d..7d32ace0 100644 --- a/go.sum +++ b/go.sum @@ -72,6 +72,10 @@ github.com/cloudwego/eino-ext/components/model/openai v0.0.0-20250520101807-b200 github.com/cloudwego/eino-ext/libs/acl/openai v0.0.0-20250519084852-38fafa73d9ea h1:FojwJhddzbKAshizfGOYwCR9HPvaCSCM1P6Vlfr4fKo= github.com/cloudwego/eino-ext/libs/acl/openai v0.0.0-20250519084852-38fafa73d9ea/go.mod h1:21bzzKhB1SSBr2jUaEBvNs75ZxSWSfIyM3oF2RB1ELs= github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY= +github.com/containerd/errdefs v1.0.0 h1:tg5yIfIlQIrxYtu9ajqY42W3lpS19XqdxRQeEwYG8PI= +github.com/containerd/errdefs v1.0.0/go.mod h1:+YBYIdtsnF4Iw6nWZhJcqGSg/dwvV7tyJ/kCkyJ2k+M= +github.com/containerd/errdefs/pkg v0.3.0 h1:9IKJ06FvyNlexW690DXuQNx2KA2cUJXx151Xdx3ZPPE= +github.com/containerd/errdefs/pkg v0.3.0/go.mod h1:NJw6s9HwNuRhnjJhM7pylWwMyAkmCQvQ4GpJHEqRLVk= github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I= github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo= github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= @@ -100,8 +104,8 @@ github.com/dlclark/regexp2 v1.11.4 h1:rPYF9/LECdNymJufQKmri9gV604RvvABwgOA8un7yA github.com/dlclark/regexp2 v1.11.4/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= github.com/docker/cli v28.2.2+incompatible h1:qzx5BNUDFqlvyq4AHzdNB7gSyVTmU4cgsyN9SdInc1A= github.com/docker/cli v28.2.2+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= -github.com/docker/docker v28.1.1+incompatible h1:49M11BFLsVO1gxY9UX9p/zwkE/rswggs8AdFmXQw51I= -github.com/docker/docker v28.1.1+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= +github.com/docker/docker v28.2.2+incompatible h1:CjwRSksz8Yo4+RmQ339Dp/D2tGO5JxwYeqtMOEe0LDw= +github.com/docker/docker v28.2.2+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/go-connections v0.5.0 h1:USnMq7hx7gwdVZq1L49hLXaFtUdTADjXGp+uj1Br63c= github.com/docker/go-connections v0.5.0/go.mod h1:ov60Kzw0kKElRwhNs9UlUHAE/F9Fe6GLaXnqyDdmEXc= github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4=