feat: 添加数据库实例到上下文,更新相关逻辑以支持新的数据库操作
This commit is contained in:
parent
6e910d09e4
commit
d2168377a7
134
bun.lock
134
bun.lock
@ -7,38 +7,38 @@
|
||||
"@egg/hooks": "^1.2.0",
|
||||
"@egg/lark-msg-tool": "^1.21.0",
|
||||
"@egg/logger": "^1.6.0",
|
||||
"@egg/net-tool": "^1.31.2",
|
||||
"@egg/net-tool": "^1.32.2",
|
||||
"@egg/path-tool": "^1.4.1",
|
||||
"@langchain/core": "^0.3.42",
|
||||
"@langchain/langgraph": "^0.2.53",
|
||||
"@langchain/langgraph": "^0.2.56",
|
||||
"@langchain/openai": "^0.3.17",
|
||||
"joi": "^17.13.3",
|
||||
"jsdom": "^26.0.0",
|
||||
"langfuse-langchain": "^3.36.0",
|
||||
"langfuse-langchain": "^3.37.0",
|
||||
"node-schedule": "^2.1.1",
|
||||
"p-limit": "^6.2.0",
|
||||
"pocketbase": "^0.23.0",
|
||||
"uuid": "^10.0.0",
|
||||
},
|
||||
"devDependencies": {
|
||||
"@commitlint/cli": "^19.7.1",
|
||||
"@commitlint/config-conventional": "^19.7.1",
|
||||
"@eslint/js": "^9.21.0",
|
||||
"@commitlint/cli": "^19.8.0",
|
||||
"@commitlint/config-conventional": "^19.8.0",
|
||||
"@eslint/js": "^9.22.0",
|
||||
"@types/jsdom": "^21.1.7",
|
||||
"@types/node-schedule": "^2.1.7",
|
||||
"@types/uuid": "^10.0.0",
|
||||
"bun-types": "^1.2.4",
|
||||
"eslint": "^9.21.0",
|
||||
"bun-types": "^1.2.5",
|
||||
"eslint": "^9.22.0",
|
||||
"eslint-plugin-simple-import-sort": "^12.1.1",
|
||||
"eslint-plugin-unused-imports": "^4.1.4",
|
||||
"husky": "^9.1.7",
|
||||
"lint-staged": "^15.4.3",
|
||||
"lint-staged": "^15.5.0",
|
||||
"oxlint": "^0.13.2",
|
||||
"prettier": "^3.5.3",
|
||||
"typescript-eslint": "^8.26.0",
|
||||
"typescript-eslint": "^8.26.1",
|
||||
},
|
||||
"peerDependencies": {
|
||||
"typescript": "^5.5.4",
|
||||
"typescript": "^5.8.2",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -53,39 +53,39 @@
|
||||
|
||||
"@colors/colors": ["@colors/colors@1.6.0", "", {}, "sha512-Ir+AOibqzrIsL6ajt3Rz3LskB7OiMVHqltZmspbW/TJuTVuyOMirVqAkjfY6JISiLHgyNqicAC8AyHHGzNd/dA=="],
|
||||
|
||||
"@commitlint/cli": ["@commitlint/cli@19.7.1", "", { "dependencies": { "@commitlint/format": "^19.5.0", "@commitlint/lint": "^19.7.1", "@commitlint/load": "^19.6.1", "@commitlint/read": "^19.5.0", "@commitlint/types": "^19.5.0", "tinyexec": "^0.3.0", "yargs": "^17.0.0" }, "bin": { "commitlint": "cli.js" } }, "sha512-iObGjR1tE/PfDtDTEfd+tnRkB3/HJzpQqRTyofS2MPPkDn1mp3DBC8SoPDayokfAy+xKhF8+bwRCJO25Nea0YQ=="],
|
||||
"@commitlint/cli": ["@commitlint/cli@19.8.0", "", { "dependencies": { "@commitlint/format": "^19.8.0", "@commitlint/lint": "^19.8.0", "@commitlint/load": "^19.8.0", "@commitlint/read": "^19.8.0", "@commitlint/types": "^19.8.0", "tinyexec": "^0.3.0", "yargs": "^17.0.0" }, "bin": { "commitlint": "./cli.js" } }, "sha512-t/fCrLVu+Ru01h0DtlgHZXbHV2Y8gKocTR5elDOqIRUzQd0/6hpt2VIWOj9b3NDo7y4/gfxeR2zRtXq/qO6iUg=="],
|
||||
|
||||
"@commitlint/config-conventional": ["@commitlint/config-conventional@19.7.1", "", { "dependencies": { "@commitlint/types": "^19.5.0", "conventional-changelog-conventionalcommits": "^7.0.2" } }, "sha512-fsEIF8zgiI/FIWSnykdQNj/0JE4av08MudLTyYHm4FlLWemKoQvPNUYU2M/3tktWcCEyq7aOkDDgtjrmgWFbvg=="],
|
||||
"@commitlint/config-conventional": ["@commitlint/config-conventional@19.8.0", "", { "dependencies": { "@commitlint/types": "^19.8.0", "conventional-changelog-conventionalcommits": "^7.0.2" } }, "sha512-9I2kKJwcAPwMoAj38hwqFXG0CzS2Kj+SAByPUQ0SlHTfb7VUhYVmo7G2w2tBrqmOf7PFd6MpZ/a1GQJo8na8kw=="],
|
||||
|
||||
"@commitlint/config-validator": ["@commitlint/config-validator@19.5.0", "", { "dependencies": { "@commitlint/types": "^19.5.0", "ajv": "^8.11.0" } }, "sha512-CHtj92H5rdhKt17RmgALhfQt95VayrUo2tSqY9g2w+laAXyk7K/Ef6uPm9tn5qSIwSmrLjKaXK9eiNuxmQrDBw=="],
|
||||
"@commitlint/config-validator": ["@commitlint/config-validator@19.8.0", "", { "dependencies": { "@commitlint/types": "^19.8.0", "ajv": "^8.11.0" } }, "sha512-+r5ZvD/0hQC3w5VOHJhGcCooiAVdynFlCe2d6I9dU+PvXdV3O+fU4vipVg+6hyLbQUuCH82mz3HnT/cBQTYYuA=="],
|
||||
|
||||
"@commitlint/ensure": ["@commitlint/ensure@19.5.0", "", { "dependencies": { "@commitlint/types": "^19.5.0", "lodash.camelcase": "^4.3.0", "lodash.kebabcase": "^4.1.1", "lodash.snakecase": "^4.1.1", "lodash.startcase": "^4.4.0", "lodash.upperfirst": "^4.3.1" } }, "sha512-Kv0pYZeMrdg48bHFEU5KKcccRfKmISSm9MvgIgkpI6m+ohFTB55qZlBW6eYqh/XDfRuIO0x4zSmvBjmOwWTwkg=="],
|
||||
"@commitlint/ensure": ["@commitlint/ensure@19.8.0", "", { "dependencies": { "@commitlint/types": "^19.8.0", "lodash.camelcase": "^4.3.0", "lodash.kebabcase": "^4.1.1", "lodash.snakecase": "^4.1.1", "lodash.startcase": "^4.4.0", "lodash.upperfirst": "^4.3.1" } }, "sha512-kNiNU4/bhEQ/wutI1tp1pVW1mQ0QbAjfPRo5v8SaxoVV+ARhkB8Wjg3BSseNYECPzWWfg/WDqQGIfV1RaBFQZg=="],
|
||||
|
||||
"@commitlint/execute-rule": ["@commitlint/execute-rule@19.5.0", "", {}, "sha512-aqyGgytXhl2ejlk+/rfgtwpPexYyri4t8/n4ku6rRJoRhGZpLFMqrZ+YaubeGysCP6oz4mMA34YSTaSOKEeNrg=="],
|
||||
"@commitlint/execute-rule": ["@commitlint/execute-rule@19.8.0", "", {}, "sha512-fuLeI+EZ9x2v/+TXKAjplBJWI9CNrHnyi5nvUQGQt4WRkww/d95oVRsc9ajpt4xFrFmqMZkd/xBQHZDvALIY7A=="],
|
||||
|
||||
"@commitlint/format": ["@commitlint/format@19.5.0", "", { "dependencies": { "@commitlint/types": "^19.5.0", "chalk": "^5.3.0" } }, "sha512-yNy088miE52stCI3dhG/vvxFo9e4jFkU1Mj3xECfzp/bIS/JUay4491huAlVcffOoMK1cd296q0W92NlER6r3A=="],
|
||||
"@commitlint/format": ["@commitlint/format@19.8.0", "", { "dependencies": { "@commitlint/types": "^19.8.0", "chalk": "^5.3.0" } }, "sha512-EOpA8IERpQstxwp/WGnDArA7S+wlZDeTeKi98WMOvaDLKbjptuHWdOYYr790iO7kTCif/z971PKPI2PkWMfOxg=="],
|
||||
|
||||
"@commitlint/is-ignored": ["@commitlint/is-ignored@19.7.1", "", { "dependencies": { "@commitlint/types": "^19.5.0", "semver": "^7.6.0" } }, "sha512-3IaOc6HVg2hAoGleRK3r9vL9zZ3XY0rf1RsUf6jdQLuaD46ZHnXBiOPTyQ004C4IvYjSWqJwlh0/u2P73aIE3g=="],
|
||||
"@commitlint/is-ignored": ["@commitlint/is-ignored@19.8.0", "", { "dependencies": { "@commitlint/types": "^19.8.0", "semver": "^7.6.0" } }, "sha512-L2Jv9yUg/I+jF3zikOV0rdiHUul9X3a/oU5HIXhAJLE2+TXTnEBfqYP9G5yMw/Yb40SnR764g4fyDK6WR2xtpw=="],
|
||||
|
||||
"@commitlint/lint": ["@commitlint/lint@19.7.1", "", { "dependencies": { "@commitlint/is-ignored": "^19.7.1", "@commitlint/parse": "^19.5.0", "@commitlint/rules": "^19.6.0", "@commitlint/types": "^19.5.0" } }, "sha512-LhcPfVjcOcOZA7LEuBBeO00o3MeZa+tWrX9Xyl1r9PMd5FWsEoZI9IgnGqTKZ0lZt5pO3ZlstgnRyY1CJJc9Xg=="],
|
||||
"@commitlint/lint": ["@commitlint/lint@19.8.0", "", { "dependencies": { "@commitlint/is-ignored": "^19.8.0", "@commitlint/parse": "^19.8.0", "@commitlint/rules": "^19.8.0", "@commitlint/types": "^19.8.0" } }, "sha512-+/NZKyWKSf39FeNpqhfMebmaLa1P90i1Nrb1SrA7oSU5GNN/lksA4z6+ZTnsft01YfhRZSYMbgGsARXvkr/VLQ=="],
|
||||
|
||||
"@commitlint/load": ["@commitlint/load@19.6.1", "", { "dependencies": { "@commitlint/config-validator": "^19.5.0", "@commitlint/execute-rule": "^19.5.0", "@commitlint/resolve-extends": "^19.5.0", "@commitlint/types": "^19.5.0", "chalk": "^5.3.0", "cosmiconfig": "^9.0.0", "cosmiconfig-typescript-loader": "^6.1.0", "lodash.isplainobject": "^4.0.6", "lodash.merge": "^4.6.2", "lodash.uniq": "^4.5.0" } }, "sha512-kE4mRKWWNju2QpsCWt428XBvUH55OET2N4QKQ0bF85qS/XbsRGG1MiTByDNlEVpEPceMkDr46LNH95DtRwcsfA=="],
|
||||
"@commitlint/load": ["@commitlint/load@19.8.0", "", { "dependencies": { "@commitlint/config-validator": "^19.8.0", "@commitlint/execute-rule": "^19.8.0", "@commitlint/resolve-extends": "^19.8.0", "@commitlint/types": "^19.8.0", "chalk": "^5.3.0", "cosmiconfig": "^9.0.0", "cosmiconfig-typescript-loader": "^6.1.0", "lodash.isplainobject": "^4.0.6", "lodash.merge": "^4.6.2", "lodash.uniq": "^4.5.0" } }, "sha512-4rvmm3ff81Sfb+mcWT5WKlyOa+Hd33WSbirTVUer0wjS1Hv/Hzr07Uv1ULIV9DkimZKNyOwXn593c+h8lsDQPQ=="],
|
||||
|
||||
"@commitlint/message": ["@commitlint/message@19.5.0", "", {}, "sha512-R7AM4YnbxN1Joj1tMfCyBryOC5aNJBdxadTZkuqtWi3Xj0kMdutq16XQwuoGbIzL2Pk62TALV1fZDCv36+JhTQ=="],
|
||||
"@commitlint/message": ["@commitlint/message@19.8.0", "", {}, "sha512-qs/5Vi9bYjf+ZV40bvdCyBn5DvbuelhR6qewLE8Bh476F7KnNyLfdM/ETJ4cp96WgeeHo6tesA2TMXS0sh5X4A=="],
|
||||
|
||||
"@commitlint/parse": ["@commitlint/parse@19.5.0", "", { "dependencies": { "@commitlint/types": "^19.5.0", "conventional-changelog-angular": "^7.0.0", "conventional-commits-parser": "^5.0.0" } }, "sha512-cZ/IxfAlfWYhAQV0TwcbdR1Oc0/r0Ik1GEessDJ3Lbuma/MRO8FRQX76eurcXtmhJC//rj52ZSZuXUg0oIX0Fw=="],
|
||||
"@commitlint/parse": ["@commitlint/parse@19.8.0", "", { "dependencies": { "@commitlint/types": "^19.8.0", "conventional-changelog-angular": "^7.0.0", "conventional-commits-parser": "^5.0.0" } }, "sha512-YNIKAc4EXvNeAvyeEnzgvm1VyAe0/b3Wax7pjJSwXuhqIQ1/t2hD3OYRXb6D5/GffIvaX82RbjD+nWtMZCLL7Q=="],
|
||||
|
||||
"@commitlint/read": ["@commitlint/read@19.5.0", "", { "dependencies": { "@commitlint/top-level": "^19.5.0", "@commitlint/types": "^19.5.0", "git-raw-commits": "^4.0.0", "minimist": "^1.2.8", "tinyexec": "^0.3.0" } }, "sha512-TjS3HLPsLsxFPQj6jou8/CZFAmOP2y+6V4PGYt3ihbQKTY1Jnv0QG28WRKl/d1ha6zLODPZqsxLEov52dhR9BQ=="],
|
||||
"@commitlint/read": ["@commitlint/read@19.8.0", "", { "dependencies": { "@commitlint/top-level": "^19.8.0", "@commitlint/types": "^19.8.0", "git-raw-commits": "^4.0.0", "minimist": "^1.2.8", "tinyexec": "^0.3.0" } }, "sha512-6ywxOGYajcxK1y1MfzrOnwsXO6nnErna88gRWEl3qqOOP8MDu/DTeRkGLXBFIZuRZ7mm5yyxU5BmeUvMpNte5w=="],
|
||||
|
||||
"@commitlint/resolve-extends": ["@commitlint/resolve-extends@19.5.0", "", { "dependencies": { "@commitlint/config-validator": "^19.5.0", "@commitlint/types": "^19.5.0", "global-directory": "^4.0.1", "import-meta-resolve": "^4.0.0", "lodash.mergewith": "^4.6.2", "resolve-from": "^5.0.0" } }, "sha512-CU/GscZhCUsJwcKTJS9Ndh3AKGZTNFIOoQB2n8CmFnizE0VnEuJoum+COW+C1lNABEeqk6ssfc1Kkalm4bDklA=="],
|
||||
"@commitlint/resolve-extends": ["@commitlint/resolve-extends@19.8.0", "", { "dependencies": { "@commitlint/config-validator": "^19.8.0", "@commitlint/types": "^19.8.0", "global-directory": "^4.0.1", "import-meta-resolve": "^4.0.0", "lodash.mergewith": "^4.6.2", "resolve-from": "^5.0.0" } }, "sha512-CLanRQwuG2LPfFVvrkTrBR/L/DMy3+ETsgBqW1OvRxmzp/bbVJW0Xw23LnnExgYcsaFtos967lul1CsbsnJlzQ=="],
|
||||
|
||||
"@commitlint/rules": ["@commitlint/rules@19.6.0", "", { "dependencies": { "@commitlint/ensure": "^19.5.0", "@commitlint/message": "^19.5.0", "@commitlint/to-lines": "^19.5.0", "@commitlint/types": "^19.5.0" } }, "sha512-1f2reW7lbrI0X0ozZMesS/WZxgPa4/wi56vFuJENBmed6mWq5KsheN/nxqnl/C23ioxpPO/PL6tXpiiFy5Bhjw=="],
|
||||
"@commitlint/rules": ["@commitlint/rules@19.8.0", "", { "dependencies": { "@commitlint/ensure": "^19.8.0", "@commitlint/message": "^19.8.0", "@commitlint/to-lines": "^19.8.0", "@commitlint/types": "^19.8.0" } }, "sha512-IZ5IE90h6DSWNuNK/cwjABLAKdy8tP8OgGVGbXe1noBEX5hSsu00uRlLu6JuruiXjWJz2dZc+YSw3H0UZyl/mA=="],
|
||||
|
||||
"@commitlint/to-lines": ["@commitlint/to-lines@19.5.0", "", {}, "sha512-R772oj3NHPkodOSRZ9bBVNq224DOxQtNef5Pl8l2M8ZnkkzQfeSTr4uxawV2Sd3ui05dUVzvLNnzenDBO1KBeQ=="],
|
||||
"@commitlint/to-lines": ["@commitlint/to-lines@19.8.0", "", {}, "sha512-3CKLUw41Cur8VMjh16y8LcsOaKbmQjAKCWlXx6B0vOUREplp6em9uIVhI8Cv934qiwkbi2+uv+mVZPnXJi1o9A=="],
|
||||
|
||||
"@commitlint/top-level": ["@commitlint/top-level@19.5.0", "", { "dependencies": { "find-up": "^7.0.0" } }, "sha512-IP1YLmGAk0yWrImPRRc578I3dDUI5A2UBJx9FbSOjxe9sTlzFiwVJ+zeMLgAtHMtGZsC8LUnzmW1qRemkFU4ng=="],
|
||||
"@commitlint/top-level": ["@commitlint/top-level@19.8.0", "", { "dependencies": { "find-up": "^7.0.0" } }, "sha512-Rphgoc/omYZisoNkcfaBRPQr4myZEHhLPx2/vTXNLjiCw4RgfPR1wEgUpJ9OOmDCiv5ZyIExhprNLhteqH4FuQ=="],
|
||||
|
||||
"@commitlint/types": ["@commitlint/types@19.5.0", "", { "dependencies": { "@types/conventional-commits-parser": "^5.0.0", "chalk": "^5.3.0" } }, "sha512-DSHae2obMSMkAtTBSOulg5X7/z+rGLxcXQIkg3OmWvY6wifojge5uVMydfhUvs7yQj+V7jNmRZ2Xzl8GJyqRgg=="],
|
||||
"@commitlint/types": ["@commitlint/types@19.8.0", "", { "dependencies": { "@types/conventional-commits-parser": "^5.0.0", "chalk": "^5.3.0" } }, "sha512-LRjP623jPyf3Poyfb0ohMj8I3ORyBDOwXAgxxVPbSD0unJuW2mJWeiRfaQinjtccMqC5Wy1HOMfa4btKjbNxbg=="],
|
||||
|
||||
"@csstools/color-helpers": ["@csstools/color-helpers@5.0.2", "", {}, "sha512-JqWH1vsgdGcw2RR6VliXXdA0/59LttzlU8UlRT/iUUsEeWfYq8I+K0yhihEUTTHLRm1EXvpsCx3083EU15ecsA=="],
|
||||
|
||||
@ -105,7 +105,7 @@
|
||||
|
||||
"@egg/logger": ["@egg/logger@1.6.0", "https://git.yingbo.im:333/api/packages/zhaoyingbo/npm/%40egg%2Flogger/-/1.6.0/logger-1.6.0.tgz", { "dependencies": { "winston": "*", "winston-daily-rotate-file": "*" } }, "sha512-BgtK74YK/7q/K3iUs3FGp3B+v4/IJlD9bgrJ/S7iHwgtgMgzl/4avZ5sXNHoZ7xPRhEuOh0ie7Br3MAWFnuuYg=="],
|
||||
|
||||
"@egg/net-tool": ["@egg/net-tool@1.31.2", "https://git.yingbo.im:333/api/packages/zhaoyingbo/npm/%40egg%2Fnet-tool/-/1.31.2/net-tool-1.31.2.tgz", { "dependencies": { "@egg/logger": "^1.6.0", "@gitbeaker/rest": "*", "winston": "*" } }, "sha512-RKc2YOr+6awQzj/n6lbsE0JDV+G3nHCBaOUd78r5umj2Yo7sFkKoqlfMYtBBMr7deD0YULlgBB51g58f09pxOg=="],
|
||||
"@egg/net-tool": ["@egg/net-tool@1.32.2", "https://git.yingbo.im:333/api/packages/zhaoyingbo/npm/%40egg%2Fnet-tool/-/1.32.2/net-tool-1.32.2.tgz", { "dependencies": { "@egg/logger": "^1.6.0", "@gitbeaker/rest": "*", "winston": "*" } }, "sha512-e0iWiVob2DTIKfIDNCgBH9zp7B/MquWvHKmb7DH1lJa6YeyA0Nhp8h3EYZBUTwrUzUyaY83qqMXBJYgjg5zkKA=="],
|
||||
|
||||
"@egg/path-tool": ["@egg/path-tool@1.4.1", "https://git.yingbo.im:333/api/packages/zhaoyingbo/npm/%40egg%2Fpath-tool/-/1.4.1/path-tool-1.4.1.tgz", {}, "sha512-PZE5kMRidZh3ahhmQJQG62wcApbCdmZihKQXYI5eAOhIbwm0hgB1sOUsais94sS9uEBQ+QpH0Om7sZ9w84rumw=="],
|
||||
|
||||
@ -115,11 +115,13 @@
|
||||
|
||||
"@eslint/config-array": ["@eslint/config-array@0.19.2", "", { "dependencies": { "@eslint/object-schema": "^2.1.6", "debug": "^4.3.1", "minimatch": "^3.1.2" } }, "sha512-GNKqxfHG2ySmJOBSHg7LxeUx4xpuCoFjacmlCoYWEbaPXLwvfIjixRI12xCQZeULksQb23uiA8F40w5TojpV7w=="],
|
||||
|
||||
"@eslint/config-helpers": ["@eslint/config-helpers@0.1.0", "", {}, "sha512-kLrdPDJE1ckPo94kmPPf9Hfd0DU0Jw6oKYrhe+pwSC0iTUInmTa+w6fw8sGgcfkFJGNdWOUeOaDM4quW4a7OkA=="],
|
||||
|
||||
"@eslint/core": ["@eslint/core@0.12.0", "", { "dependencies": { "@types/json-schema": "^7.0.15" } }, "sha512-cmrR6pytBuSMTaBweKoGMwu3EiHiEC+DoyupPmlZ0HxBJBtIxwe+j/E4XPIKNx+Q74c8lXKPwYawBf5glsTkHg=="],
|
||||
|
||||
"@eslint/eslintrc": ["@eslint/eslintrc@3.3.0", "", { "dependencies": { "ajv": "^6.12.4", "debug": "^4.3.2", "espree": "^10.0.1", "globals": "^14.0.0", "ignore": "^5.2.0", "import-fresh": "^3.2.1", "js-yaml": "^4.1.0", "minimatch": "^3.1.2", "strip-json-comments": "^3.1.1" } }, "sha512-yaVPAiNAalnCZedKLdR21GOGILMLKPyqSLWaAjQFvYA2i/ciDi8ArYVr69Anohb6cH2Ukhqti4aFnYyPm8wdwQ=="],
|
||||
|
||||
"@eslint/js": ["@eslint/js@9.21.0", "", {}, "sha512-BqStZ3HX8Yz6LvsF5ByXYrtigrV5AXADWLAGc7PH/1SxOb7/FIYYMszZZWiUou/GB9P2lXWk2SV4d+Z8h0nknw=="],
|
||||
"@eslint/js": ["@eslint/js@9.22.0", "", {}, "sha512-vLFajx9o8d1/oL2ZkpMYbkLv8nDB6yaIwFNt7nI4+I80U/z03SxmfOMsLbvWr3p7C+Wnoh//aOu2pQW8cS0HCQ=="],
|
||||
|
||||
"@eslint/object-schema": ["@eslint/object-schema@2.1.6", "", {}, "sha512-RBMg5FRL0I0gs51M/guSAj5/e14VQ4tpZnQNWwuDT66P14I43ItmPfIZRhO9fUVIPOAQXU47atlywZ/czoqFPA=="],
|
||||
|
||||
@ -145,9 +147,9 @@
|
||||
|
||||
"@langchain/core": ["@langchain/core@0.3.42", "", { "dependencies": { "@cfworker/json-schema": "^4.0.2", "ansi-styles": "^5.0.0", "camelcase": "6", "decamelize": "1.2.0", "js-tiktoken": "^1.0.12", "langsmith": ">=0.2.8 <0.4.0", "mustache": "^4.2.0", "p-queue": "^6.6.2", "p-retry": "4", "uuid": "^10.0.0", "zod": "^3.22.4", "zod-to-json-schema": "^3.22.3" } }, "sha512-pT/jC5lqWK3YGDq8dQwgKoa6anqAhMtG1x5JbnrOj9NdaLeBbCKBDQ+/Ykzk3nZ8o+0UMsaXNZo7IVL83VVjHg=="],
|
||||
|
||||
"@langchain/langgraph": ["@langchain/langgraph@0.2.53", "", { "dependencies": { "@langchain/langgraph-checkpoint": "~0.0.15", "@langchain/langgraph-sdk": "~0.0.32", "uuid": "^10.0.0", "zod": "^3.23.8" }, "peerDependencies": { "@langchain/core": ">=0.2.36 <0.3.0 || >=0.3.40 < 0.4.0" } }, "sha512-1LDG9eyO4whN0UuECTRKzfbnr/DjFG+OW57k1N3gXl8u6+f6Fw2W4yY+Jd92pY/mq3OS9FAB9Y5go16AjEn1lA=="],
|
||||
"@langchain/langgraph": ["@langchain/langgraph@0.2.56", "", { "dependencies": { "@langchain/langgraph-checkpoint": "~0.0.16", "@langchain/langgraph-sdk": "~0.0.32", "uuid": "^10.0.0", "zod": "^3.23.8" }, "peerDependencies": { "@langchain/core": ">=0.2.36 <0.3.0 || >=0.3.40 < 0.4.0" } }, "sha512-/uiQL+SeEGNv6QZOilxdwNwDoYQ+t3pFr5tZyG3lvmgmO2Pfojp7SIV2y/yuVYkNlKPvKvpdfE6mmCkCT4G2aA=="],
|
||||
|
||||
"@langchain/langgraph-checkpoint": ["@langchain/langgraph-checkpoint@0.0.15", "", { "dependencies": { "uuid": "^10.0.0" }, "peerDependencies": { "@langchain/core": ">=0.2.31 <0.4.0" } }, "sha512-AiJkvsYHqNbCh1Tx823qs2lf2qRqeB4EAMejirOk8gkpPszAGYua5c3niKYkcKR2tU8Snhrmj7Gm9HKZSFOXyw=="],
|
||||
"@langchain/langgraph-checkpoint": ["@langchain/langgraph-checkpoint@0.0.16", "", { "dependencies": { "uuid": "^10.0.0" }, "peerDependencies": { "@langchain/core": ">=0.2.31 <0.4.0" } }, "sha512-B50l7w9o9353drHsdsD01vhQrCJw0eqvYeXid7oKeoj1Yye+qY90r97xuhiflaYCZHM5VEo2oaizs8oknerZsQ=="],
|
||||
|
||||
"@langchain/langgraph-sdk": ["@langchain/langgraph-sdk@0.0.45", "", { "dependencies": { "@types/json-schema": "^7.0.15", "p-queue": "^6.6.2", "p-retry": "4", "uuid": "^9.0.0" }, "peerDependencies": { "@langchain/core": ">=0.2.31 <0.4.0", "react": "^18 || ^19" }, "optionalPeers": ["@langchain/core", "react"] }, "sha512-y1nKJeP0U3mkj2fTyV3CsWqNgoLN7WidTJxZffLsTrq1DvqFU0ywWSwXyDlw90QIoc96eBOQDrruDyklph/HHg=="],
|
||||
|
||||
@ -209,17 +211,17 @@
|
||||
|
||||
"@typescript-eslint/eslint-plugin": ["@typescript-eslint/eslint-plugin@8.26.0", "", { "dependencies": { "@eslint-community/regexpp": "^4.10.0", "@typescript-eslint/scope-manager": "8.26.0", "@typescript-eslint/type-utils": "8.26.0", "@typescript-eslint/utils": "8.26.0", "@typescript-eslint/visitor-keys": "8.26.0", "graphemer": "^1.4.0", "ignore": "^5.3.1", "natural-compare": "^1.4.0", "ts-api-utils": "^2.0.1" }, "peerDependencies": { "@typescript-eslint/parser": "^8.0.0 || ^8.0.0-alpha.0", "eslint": "^8.57.0 || ^9.0.0", "typescript": ">=4.8.4 <5.9.0" } }, "sha512-cLr1J6pe56zjKYajK6SSSre6nl1Gj6xDp1TY0trpgPzjVbgDwd09v2Ws37LABxzkicmUjhEeg/fAUjPJJB1v5Q=="],
|
||||
|
||||
"@typescript-eslint/parser": ["@typescript-eslint/parser@8.26.0", "", { "dependencies": { "@typescript-eslint/scope-manager": "8.26.0", "@typescript-eslint/types": "8.26.0", "@typescript-eslint/typescript-estree": "8.26.0", "@typescript-eslint/visitor-keys": "8.26.0", "debug": "^4.3.4" }, "peerDependencies": { "eslint": "^8.57.0 || ^9.0.0", "typescript": ">=4.8.4 <5.9.0" } }, "sha512-mNtXP9LTVBy14ZF3o7JG69gRPBK/2QWtQd0j0oH26HcY/foyJJau6pNUez7QrM5UHnSvwlQcJXKsk0I99B9pOA=="],
|
||||
"@typescript-eslint/parser": ["@typescript-eslint/parser@8.26.1", "", { "dependencies": { "@typescript-eslint/scope-manager": "8.26.1", "@typescript-eslint/types": "8.26.1", "@typescript-eslint/typescript-estree": "8.26.1", "@typescript-eslint/visitor-keys": "8.26.1", "debug": "^4.3.4" }, "peerDependencies": { "eslint": "^8.57.0 || ^9.0.0", "typescript": ">=4.8.4 <5.9.0" } }, "sha512-w6HZUV4NWxqd8BdeFf81t07d7/YV9s7TCWrQQbG5uhuvGUAW+fq1usZ1Hmz9UPNLniFnD8GLSsDpjP0hm1S4lQ=="],
|
||||
|
||||
"@typescript-eslint/scope-manager": ["@typescript-eslint/scope-manager@8.26.0", "", { "dependencies": { "@typescript-eslint/types": "8.26.0", "@typescript-eslint/visitor-keys": "8.26.0" } }, "sha512-E0ntLvsfPqnPwng8b8y4OGuzh/iIOm2z8U3S9zic2TeMLW61u5IH2Q1wu0oSTkfrSzwbDJIB/Lm8O3//8BWMPA=="],
|
||||
|
||||
"@typescript-eslint/type-utils": ["@typescript-eslint/type-utils@8.26.0", "", { "dependencies": { "@typescript-eslint/typescript-estree": "8.26.0", "@typescript-eslint/utils": "8.26.0", "debug": "^4.3.4", "ts-api-utils": "^2.0.1" }, "peerDependencies": { "eslint": "^8.57.0 || ^9.0.0", "typescript": ">=4.8.4 <5.9.0" } }, "sha512-ruk0RNChLKz3zKGn2LwXuVoeBcUMh+jaqzN461uMMdxy5H9epZqIBtYj7UiPXRuOpaALXGbmRuZQhmwHhaS04Q=="],
|
||||
|
||||
"@typescript-eslint/types": ["@typescript-eslint/types@8.26.0", "", {}, "sha512-89B1eP3tnpr9A8L6PZlSjBvnJhWXtYfZhECqlBl1D9Lme9mHO6iWlsprBtVenQvY1HMhax1mWOjhtL3fh/u+pA=="],
|
||||
"@typescript-eslint/types": ["@typescript-eslint/types@8.26.1", "", {}, "sha512-n4THUQW27VmQMx+3P+B0Yptl7ydfceUj4ON/AQILAASwgYdZ/2dhfymRMh5egRUrvK5lSmaOm77Ry+lmXPOgBQ=="],
|
||||
|
||||
"@typescript-eslint/typescript-estree": ["@typescript-eslint/typescript-estree@8.26.0", "", { "dependencies": { "@typescript-eslint/types": "8.26.0", "@typescript-eslint/visitor-keys": "8.26.0", "debug": "^4.3.4", "fast-glob": "^3.3.2", "is-glob": "^4.0.3", "minimatch": "^9.0.4", "semver": "^7.6.0", "ts-api-utils": "^2.0.1" }, "peerDependencies": { "typescript": ">=4.8.4 <5.9.0" } }, "sha512-tiJ1Hvy/V/oMVRTbEOIeemA2XoylimlDQ03CgPPNaHYZbpsc78Hmngnt+WXZfJX1pjQ711V7g0H7cSJThGYfPQ=="],
|
||||
"@typescript-eslint/typescript-estree": ["@typescript-eslint/typescript-estree@8.26.1", "", { "dependencies": { "@typescript-eslint/types": "8.26.1", "@typescript-eslint/visitor-keys": "8.26.1", "debug": "^4.3.4", "fast-glob": "^3.3.2", "is-glob": "^4.0.3", "minimatch": "^9.0.4", "semver": "^7.6.0", "ts-api-utils": "^2.0.1" }, "peerDependencies": { "typescript": ">=4.8.4 <5.9.0" } }, "sha512-yUwPpUHDgdrv1QJ7YQal3cMVBGWfnuCdKbXw1yyjArax3353rEJP1ZA+4F8nOlQ3RfS2hUN/wze3nlY+ZOhvoA=="],
|
||||
|
||||
"@typescript-eslint/utils": ["@typescript-eslint/utils@8.26.0", "", { "dependencies": { "@eslint-community/eslint-utils": "^4.4.0", "@typescript-eslint/scope-manager": "8.26.0", "@typescript-eslint/types": "8.26.0", "@typescript-eslint/typescript-estree": "8.26.0" }, "peerDependencies": { "eslint": "^8.57.0 || ^9.0.0", "typescript": ">=4.8.4 <5.9.0" } }, "sha512-2L2tU3FVwhvU14LndnQCA2frYC8JnPDVKyQtWFPf8IYFMt/ykEN1bPolNhNbCVgOmdzTlWdusCTKA/9nKrf8Ig=="],
|
||||
"@typescript-eslint/utils": ["@typescript-eslint/utils@8.26.1", "", { "dependencies": { "@eslint-community/eslint-utils": "^4.4.0", "@typescript-eslint/scope-manager": "8.26.1", "@typescript-eslint/types": "8.26.1", "@typescript-eslint/typescript-estree": "8.26.1" }, "peerDependencies": { "eslint": "^8.57.0 || ^9.0.0", "typescript": ">=4.8.4 <5.9.0" } }, "sha512-V4Urxa/XtSUroUrnI7q6yUTD3hDtfJ2jzVfeT3VK0ciizfK2q/zGC0iDh1lFMUZR8cImRrep6/q0xd/1ZGPQpg=="],
|
||||
|
||||
"@typescript-eslint/visitor-keys": ["@typescript-eslint/visitor-keys@8.26.0", "", { "dependencies": { "@typescript-eslint/types": "8.26.0", "eslint-visitor-keys": "^4.2.0" } }, "sha512-2z8JQJWAzPdDd51dRQ/oqIJxe99/hoLIqmf8RMCAJQtYDc535W/Jt2+RTP4bP0aKeBG1F65yjIZuczOXCmbWwg=="],
|
||||
|
||||
@ -259,7 +261,7 @@
|
||||
|
||||
"braces": ["braces@3.0.3", "", { "dependencies": { "fill-range": "^7.1.1" } }, "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA=="],
|
||||
|
||||
"bun-types": ["bun-types@1.2.4", "", { "dependencies": { "@types/node": "*", "@types/ws": "~8.5.10" } }, "sha512-nDPymR207ZZEoWD4AavvEaa/KZe/qlrbMSchqpQwovPZCKc7pwMoENjEtHgMKaAjJhy+x6vfqSBA1QU3bJgs0Q=="],
|
||||
"bun-types": ["bun-types@1.2.5", "", { "dependencies": { "@types/node": "*", "@types/ws": "~8.5.10" } }, "sha512-3oO6LVGGRRKI4kHINx5PIdIgnLRb7l/SprhzqXapmoYkFl5m4j6EvALvbDVuuBFaamB46Ap6HCUxIXNLCGy+tg=="],
|
||||
|
||||
"call-bind-apply-helpers": ["call-bind-apply-helpers@1.0.2", "", { "dependencies": { "es-errors": "^1.3.0", "function-bind": "^1.1.2" } }, "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ=="],
|
||||
|
||||
@ -357,13 +359,13 @@
|
||||
|
||||
"escape-string-regexp": ["escape-string-regexp@4.0.0", "", {}, "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA=="],
|
||||
|
||||
"eslint": ["eslint@9.21.0", "", { "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/regexpp": "^4.12.1", "@eslint/config-array": "^0.19.2", "@eslint/core": "^0.12.0", "@eslint/eslintrc": "^3.3.0", "@eslint/js": "9.21.0", "@eslint/plugin-kit": "^0.2.7", "@humanfs/node": "^0.16.6", "@humanwhocodes/module-importer": "^1.0.1", "@humanwhocodes/retry": "^0.4.2", "@types/estree": "^1.0.6", "@types/json-schema": "^7.0.15", "ajv": "^6.12.4", "chalk": "^4.0.0", "cross-spawn": "^7.0.6", "debug": "^4.3.2", "escape-string-regexp": "^4.0.0", "eslint-scope": "^8.2.0", "eslint-visitor-keys": "^4.2.0", "espree": "^10.3.0", "esquery": "^1.5.0", "esutils": "^2.0.2", "fast-deep-equal": "^3.1.3", "file-entry-cache": "^8.0.0", "find-up": "^5.0.0", "glob-parent": "^6.0.2", "ignore": "^5.2.0", "imurmurhash": "^0.1.4", "is-glob": "^4.0.0", "json-stable-stringify-without-jsonify": "^1.0.1", "lodash.merge": "^4.6.2", "minimatch": "^3.1.2", "natural-compare": "^1.4.0", "optionator": "^0.9.3" }, "peerDependencies": { "jiti": "*" }, "optionalPeers": ["jiti"], "bin": { "eslint": "bin/eslint.js" } }, "sha512-KjeihdFqTPhOMXTt7StsDxriV4n66ueuF/jfPNC3j/lduHwr/ijDwJMsF+wyMJethgiKi5wniIE243vi07d3pg=="],
|
||||
"eslint": ["eslint@9.22.0", "", { "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/regexpp": "^4.12.1", "@eslint/config-array": "^0.19.2", "@eslint/config-helpers": "^0.1.0", "@eslint/core": "^0.12.0", "@eslint/eslintrc": "^3.3.0", "@eslint/js": "9.22.0", "@eslint/plugin-kit": "^0.2.7", "@humanfs/node": "^0.16.6", "@humanwhocodes/module-importer": "^1.0.1", "@humanwhocodes/retry": "^0.4.2", "@types/estree": "^1.0.6", "@types/json-schema": "^7.0.15", "ajv": "^6.12.4", "chalk": "^4.0.0", "cross-spawn": "^7.0.6", "debug": "^4.3.2", "escape-string-regexp": "^4.0.0", "eslint-scope": "^8.3.0", "eslint-visitor-keys": "^4.2.0", "espree": "^10.3.0", "esquery": "^1.5.0", "esutils": "^2.0.2", "fast-deep-equal": "^3.1.3", "file-entry-cache": "^8.0.0", "find-up": "^5.0.0", "glob-parent": "^6.0.2", "ignore": "^5.2.0", "imurmurhash": "^0.1.4", "is-glob": "^4.0.0", "json-stable-stringify-without-jsonify": "^1.0.1", "lodash.merge": "^4.6.2", "minimatch": "^3.1.2", "natural-compare": "^1.4.0", "optionator": "^0.9.3" }, "peerDependencies": { "jiti": "*" }, "optionalPeers": ["jiti"], "bin": { "eslint": "bin/eslint.js" } }, "sha512-9V/QURhsRN40xuHXWjV64yvrzMjcz7ZyNoF2jJFmy9j/SLk0u1OLSZgXi28MrXjymnjEGSR80WCdab3RGMDveQ=="],
|
||||
|
||||
"eslint-plugin-simple-import-sort": ["eslint-plugin-simple-import-sort@12.1.1", "", { "peerDependencies": { "eslint": ">=5.0.0" } }, "sha512-6nuzu4xwQtE3332Uz0to+TxDQYRLTKRESSc2hefVT48Zc8JthmN23Gx9lnYhu0FtkRSL1oxny3kJ2aveVhmOVA=="],
|
||||
|
||||
"eslint-plugin-unused-imports": ["eslint-plugin-unused-imports@4.1.4", "", { "peerDependencies": { "@typescript-eslint/eslint-plugin": "^8.0.0-0 || ^7.0.0 || ^6.0.0 || ^5.0.0", "eslint": "^9.0.0 || ^8.0.0" }, "optionalPeers": ["@typescript-eslint/eslint-plugin"] }, "sha512-YptD6IzQjDardkl0POxnnRBhU1OEePMV0nd6siHaRBbd+lyh6NAhFEobiznKU7kTsSsDeSD62Pe7kAM1b7dAZQ=="],
|
||||
|
||||
"eslint-scope": ["eslint-scope@8.2.0", "", { "dependencies": { "esrecurse": "^4.3.0", "estraverse": "^5.2.0" } }, "sha512-PHlWUfG6lvPc3yvP5A4PNyBL1W8fkDUccmI21JUu/+GKZBoH/W5u6usENXUrWFRsyoW5ACUjFGgAFQp5gUlb/A=="],
|
||||
"eslint-scope": ["eslint-scope@8.3.0", "", { "dependencies": { "esrecurse": "^4.3.0", "estraverse": "^5.2.0" } }, "sha512-pUNxi75F8MJ/GdeKtVLSbYg4ZI34J6C0C7sbL4YOp2exGwen7ZsuBqKzUhXd0qMQ362yET3z+uPwKeg/0C2XCQ=="],
|
||||
|
||||
"eslint-visitor-keys": ["eslint-visitor-keys@4.2.0", "", {}, "sha512-UyLnSehNt62FFhSwjZlHmeokpRK59rcz29j+F1/aDgbkbRTk7wIc9XzdoasMUbRNKDM0qQt/+BJ4BrpFeABemw=="],
|
||||
|
||||
@ -525,11 +527,11 @@
|
||||
|
||||
"langchain": ["langchain@0.3.19", "", { "dependencies": { "@langchain/openai": ">=0.1.0 <0.5.0", "@langchain/textsplitters": ">=0.0.0 <0.2.0", "js-tiktoken": "^1.0.12", "js-yaml": "^4.1.0", "jsonpointer": "^5.0.1", "langsmith": ">=0.2.8 <0.4.0", "openapi-types": "^12.1.3", "p-retry": "4", "uuid": "^10.0.0", "yaml": "^2.2.1", "zod": "^3.22.4", "zod-to-json-schema": "^3.22.3" }, "peerDependencies": { "@langchain/anthropic": "*", "@langchain/aws": "*", "@langchain/cerebras": "*", "@langchain/cohere": "*", "@langchain/core": ">=0.2.21 <0.4.0", "@langchain/deepseek": "*", "@langchain/google-genai": "*", "@langchain/google-vertexai": "*", "@langchain/google-vertexai-web": "*", "@langchain/groq": "*", "@langchain/mistralai": "*", "@langchain/ollama": "*", "@langchain/xai": "*", "axios": "*", "cheerio": "*", "handlebars": "^4.7.8", "peggy": "^3.0.2", "typeorm": "*" }, "optionalPeers": ["@langchain/anthropic", "@langchain/aws", "@langchain/cerebras", "@langchain/cohere", "@langchain/deepseek", "@langchain/google-genai", "@langchain/google-vertexai", "@langchain/google-vertexai-web", "@langchain/groq", "@langchain/mistralai", "@langchain/ollama", "@langchain/xai", "axios", "cheerio", "handlebars", "peggy", "typeorm"] }, "sha512-aGhoTvTBS5ulatA67RHbJ4bcV5zcYRYdm5IH+hpX99RYSFXG24XF3ghSjhYi6sxW+SUnEQ99fJhA5kroVpKNhw=="],
|
||||
|
||||
"langfuse": ["langfuse@3.36.0", "", { "dependencies": { "langfuse-core": "^3.36.0" } }, "sha512-rHOh1xXlt/iCaw3ZULJZ5OH3jSfxb68ZzCnf6EoZVfT/vv7fIQ75L7sTfH2LdDSBwTVKvZWZYX9vJWAaX9AyHQ=="],
|
||||
"langfuse": ["langfuse@3.37.0", "", { "dependencies": { "langfuse-core": "^3.37.0" } }, "sha512-NpemB+5i6VT9CXmBwQTE4q1DPOY/DH7OMxBJn8Rcirw+z2HYJpTRH8j48cBjzwqmYtqLdqyJMzAALa2ReQ50hQ=="],
|
||||
|
||||
"langfuse-core": ["langfuse-core@3.36.0", "", { "dependencies": { "mustache": "^4.2.0" } }, "sha512-qxaWxy5E4oIyCYPwiRKXNfMP9vwRZnHiHLPDqAssVzcRp8bTG6NGR+9yfP7Yc8bjNxB364FRtm3MtdMhn6I3iQ=="],
|
||||
"langfuse-core": ["langfuse-core@3.37.0", "", { "dependencies": { "mustache": "^4.2.0" } }, "sha512-7ZOFJ51u4dOeCpsQ8otNuNYeMb7xsExVQcOIBOByPFKjjd1mjf/03xF907F44dRzgf7n1U8ZYa0XgMSRgxKNoA=="],
|
||||
|
||||
"langfuse-langchain": ["langfuse-langchain@3.36.0", "", { "dependencies": { "langfuse": "^3.36.0", "langfuse-core": "^3.36.0" }, "peerDependencies": { "langchain": ">=0.0.157 <0.4.0" } }, "sha512-0qK/BVOPjNTSZB0H9Yz5lXztiAbRrGM9YG2H7z/tnjEi3aXHJrbOEXQoi7a7qBoWKjy+Un/4qfUk5s8D2nIK2Q=="],
|
||||
"langfuse-langchain": ["langfuse-langchain@3.37.0", "", { "dependencies": { "langfuse": "^3.37.0", "langfuse-core": "^3.37.0" }, "peerDependencies": { "langchain": ">=0.0.157 <0.4.0" } }, "sha512-IleGRb5Je5/gBd1tUQ+KtvhISyFHuaWbCxKEZyfV0iUIcYAa07YTq3USDVN2TYunEfM7gcioOWDFPtz0UnTy2g=="],
|
||||
|
||||
"langsmith": ["langsmith@0.3.12", "", { "dependencies": { "@types/uuid": "^10.0.0", "chalk": "^4.1.2", "console-table-printer": "^2.12.1", "p-queue": "^6.6.2", "p-retry": "4", "semver": "^7.6.3", "uuid": "^10.0.0" }, "peerDependencies": { "openai": "*" }, "optionalPeers": ["openai"] }, "sha512-e4qWM27hxEr8GfO6dgXrc3W8La+wxkX1zEtMhxhqS/Th2ujTt5OH7x0uXfXFDqCv9WaC3nquo1Y2s4vpYmLLtg=="],
|
||||
|
||||
@ -539,7 +541,7 @@
|
||||
|
||||
"lines-and-columns": ["lines-and-columns@1.2.4", "", {}, "sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg=="],
|
||||
|
||||
"lint-staged": ["lint-staged@15.4.3", "", { "dependencies": { "chalk": "^5.4.1", "commander": "^13.1.0", "debug": "^4.4.0", "execa": "^8.0.1", "lilconfig": "^3.1.3", "listr2": "^8.2.5", "micromatch": "^4.0.8", "pidtree": "^0.6.0", "string-argv": "^0.3.2", "yaml": "^2.7.0" }, "bin": { "lint-staged": "bin/lint-staged.js" } }, "sha512-FoH1vOeouNh1pw+90S+cnuoFwRfUD9ijY2GKy5h7HS3OR7JVir2N2xrsa0+Twc1B7cW72L+88geG5cW4wIhn7g=="],
|
||||
"lint-staged": ["lint-staged@15.5.0", "", { "dependencies": { "chalk": "^5.4.1", "commander": "^13.1.0", "debug": "^4.4.0", "execa": "^8.0.1", "lilconfig": "^3.1.3", "listr2": "^8.2.5", "micromatch": "^4.0.8", "pidtree": "^0.6.0", "string-argv": "^0.3.2", "yaml": "^2.7.0" }, "bin": { "lint-staged": "bin/lint-staged.js" } }, "sha512-WyCzSbfYGhK7cU+UuDDkzUiytbfbi0ZdPy2orwtM75P3WTtQBzmG40cCxIa8Ii2+XjfxzLH6Be46tUfWS85Xfg=="],
|
||||
|
||||
"listr2": ["listr2@8.2.5", "", { "dependencies": { "cli-truncate": "^4.0.0", "colorette": "^2.0.20", "eventemitter3": "^5.0.1", "log-update": "^6.1.0", "rfdc": "^1.4.1", "wrap-ansi": "^9.0.0" } }, "sha512-iyAZCeyD+c1gPyE9qpFu8af0Y+MRtmKOncdGoA2S5EY8iFq99dmmvkNnHiWo+pj0s7yH7l3KPIgee77tKpXPWQ=="],
|
||||
|
||||
@ -773,7 +775,7 @@
|
||||
|
||||
"typescript": ["typescript@5.8.2", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-aJn6wq13/afZp/jT9QZmwEjDqqvSGp1VT5GVg+f/t6/oVyrgXM6BY1h9BRh/O5p3PlUPAe+WuiEZOmb/49RqoQ=="],
|
||||
|
||||
"typescript-eslint": ["typescript-eslint@8.26.0", "", { "dependencies": { "@typescript-eslint/eslint-plugin": "8.26.0", "@typescript-eslint/parser": "8.26.0", "@typescript-eslint/utils": "8.26.0" }, "peerDependencies": { "eslint": "^8.57.0 || ^9.0.0", "typescript": ">=4.8.4 <5.9.0" } }, "sha512-PtVz9nAnuNJuAVeUFvwztjuUgSnJInODAUx47VDwWPXzd5vismPOtPtt83tzNXyOjVQbPRp786D6WFW/M2koIA=="],
|
||||
"typescript-eslint": ["typescript-eslint@8.26.1", "", { "dependencies": { "@typescript-eslint/eslint-plugin": "8.26.1", "@typescript-eslint/parser": "8.26.1", "@typescript-eslint/utils": "8.26.1" }, "peerDependencies": { "eslint": "^8.57.0 || ^9.0.0", "typescript": ">=4.8.4 <5.9.0" } }, "sha512-t/oIs9mYyrwZGRpDv3g+3K6nZ5uhKEMt2oNmAPwaY4/ye0+EH4nXIPYNtkYFS6QHm+1DFg34DbglYBz5P9Xysg=="],
|
||||
|
||||
"undici-types": ["undici-types@6.20.0", "", {}, "sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg=="],
|
||||
|
||||
@ -847,8 +849,26 @@
|
||||
|
||||
"@langchain/langgraph-sdk/uuid": ["uuid@9.0.1", "", { "bin": { "uuid": "dist/bin/uuid" } }, "sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA=="],
|
||||
|
||||
"@typescript-eslint/eslint-plugin/@typescript-eslint/utils": ["@typescript-eslint/utils@8.26.0", "", { "dependencies": { "@eslint-community/eslint-utils": "^4.4.0", "@typescript-eslint/scope-manager": "8.26.0", "@typescript-eslint/types": "8.26.0", "@typescript-eslint/typescript-estree": "8.26.0" }, "peerDependencies": { "eslint": "^8.57.0 || ^9.0.0", "typescript": ">=4.8.4 <5.9.0" } }, "sha512-2L2tU3FVwhvU14LndnQCA2frYC8JnPDVKyQtWFPf8IYFMt/ykEN1bPolNhNbCVgOmdzTlWdusCTKA/9nKrf8Ig=="],
|
||||
|
||||
"@typescript-eslint/parser/@typescript-eslint/scope-manager": ["@typescript-eslint/scope-manager@8.26.1", "", { "dependencies": { "@typescript-eslint/types": "8.26.1", "@typescript-eslint/visitor-keys": "8.26.1" } }, "sha512-6EIvbE5cNER8sqBu6V7+KeMZIC1664d2Yjt+B9EWUXrsyWpxx4lEZrmvxgSKRC6gX+efDL/UY9OpPZ267io3mg=="],
|
||||
|
||||
"@typescript-eslint/parser/@typescript-eslint/visitor-keys": ["@typescript-eslint/visitor-keys@8.26.1", "", { "dependencies": { "@typescript-eslint/types": "8.26.1", "eslint-visitor-keys": "^4.2.0" } }, "sha512-AjOC3zfnxd6S4Eiy3jwktJPclqhFHNyd8L6Gycf9WUPoKZpgM5PjkxY1X7uSy61xVpiJDhhk7XT2NVsN3ALTWg=="],
|
||||
|
||||
"@typescript-eslint/scope-manager/@typescript-eslint/types": ["@typescript-eslint/types@8.26.0", "", {}, "sha512-89B1eP3tnpr9A8L6PZlSjBvnJhWXtYfZhECqlBl1D9Lme9mHO6iWlsprBtVenQvY1HMhax1mWOjhtL3fh/u+pA=="],
|
||||
|
||||
"@typescript-eslint/type-utils/@typescript-eslint/typescript-estree": ["@typescript-eslint/typescript-estree@8.26.0", "", { "dependencies": { "@typescript-eslint/types": "8.26.0", "@typescript-eslint/visitor-keys": "8.26.0", "debug": "^4.3.4", "fast-glob": "^3.3.2", "is-glob": "^4.0.3", "minimatch": "^9.0.4", "semver": "^7.6.0", "ts-api-utils": "^2.0.1" }, "peerDependencies": { "typescript": ">=4.8.4 <5.9.0" } }, "sha512-tiJ1Hvy/V/oMVRTbEOIeemA2XoylimlDQ03CgPPNaHYZbpsc78Hmngnt+WXZfJX1pjQ711V7g0H7cSJThGYfPQ=="],
|
||||
|
||||
"@typescript-eslint/type-utils/@typescript-eslint/utils": ["@typescript-eslint/utils@8.26.0", "", { "dependencies": { "@eslint-community/eslint-utils": "^4.4.0", "@typescript-eslint/scope-manager": "8.26.0", "@typescript-eslint/types": "8.26.0", "@typescript-eslint/typescript-estree": "8.26.0" }, "peerDependencies": { "eslint": "^8.57.0 || ^9.0.0", "typescript": ">=4.8.4 <5.9.0" } }, "sha512-2L2tU3FVwhvU14LndnQCA2frYC8JnPDVKyQtWFPf8IYFMt/ykEN1bPolNhNbCVgOmdzTlWdusCTKA/9nKrf8Ig=="],
|
||||
|
||||
"@typescript-eslint/typescript-estree/@typescript-eslint/visitor-keys": ["@typescript-eslint/visitor-keys@8.26.1", "", { "dependencies": { "@typescript-eslint/types": "8.26.1", "eslint-visitor-keys": "^4.2.0" } }, "sha512-AjOC3zfnxd6S4Eiy3jwktJPclqhFHNyd8L6Gycf9WUPoKZpgM5PjkxY1X7uSy61xVpiJDhhk7XT2NVsN3ALTWg=="],
|
||||
|
||||
"@typescript-eslint/typescript-estree/minimatch": ["minimatch@9.0.5", "", { "dependencies": { "brace-expansion": "^2.0.1" } }, "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow=="],
|
||||
|
||||
"@typescript-eslint/utils/@typescript-eslint/scope-manager": ["@typescript-eslint/scope-manager@8.26.1", "", { "dependencies": { "@typescript-eslint/types": "8.26.1", "@typescript-eslint/visitor-keys": "8.26.1" } }, "sha512-6EIvbE5cNER8sqBu6V7+KeMZIC1664d2Yjt+B9EWUXrsyWpxx4lEZrmvxgSKRC6gX+efDL/UY9OpPZ267io3mg=="],
|
||||
|
||||
"@typescript-eslint/visitor-keys/@typescript-eslint/types": ["@typescript-eslint/types@8.26.0", "", {}, "sha512-89B1eP3tnpr9A8L6PZlSjBvnJhWXtYfZhECqlBl1D9Lme9mHO6iWlsprBtVenQvY1HMhax1mWOjhtL3fh/u+pA=="],
|
||||
|
||||
"chalk/ansi-styles": ["ansi-styles@4.3.0", "", { "dependencies": { "color-convert": "^2.0.1" } }, "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg=="],
|
||||
|
||||
"cli-truncate/string-width": ["string-width@7.2.0", "", { "dependencies": { "emoji-regex": "^10.3.0", "get-east-asian-width": "^1.0.0", "strip-ansi": "^7.1.0" } }, "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ=="],
|
||||
@ -885,6 +905,8 @@
|
||||
|
||||
"slice-ansi/is-fullwidth-code-point": ["is-fullwidth-code-point@4.0.0", "", {}, "sha512-O4L094N2/dZ7xqVdrXhh9r1KODPJpFms8B5sGdJLPy664AgvXsreZUyCQQNItZRDlYug4xStLjNp/sz3HvBowQ=="],
|
||||
|
||||
"typescript-eslint/@typescript-eslint/eslint-plugin": ["@typescript-eslint/eslint-plugin@8.26.1", "", { "dependencies": { "@eslint-community/regexpp": "^4.10.0", "@typescript-eslint/scope-manager": "8.26.1", "@typescript-eslint/type-utils": "8.26.1", "@typescript-eslint/utils": "8.26.1", "@typescript-eslint/visitor-keys": "8.26.1", "graphemer": "^1.4.0", "ignore": "^5.3.1", "natural-compare": "^1.4.0", "ts-api-utils": "^2.0.1" }, "peerDependencies": { "@typescript-eslint/parser": "^8.0.0 || ^8.0.0-alpha.0", "eslint": "^8.57.0 || ^9.0.0", "typescript": ">=4.8.4 <5.9.0" } }, "sha512-2X3mwqsj9Bd3Ciz508ZUtoQQYpOhU/kWoUqIf49H8Z0+Vbh6UF/y0OEYp0Q0axOGzaBGs7QxRwq0knSQ8khQNA=="],
|
||||
|
||||
"winston/is-stream": ["is-stream@2.0.1", "", {}, "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg=="],
|
||||
|
||||
"wrap-ansi/ansi-styles": ["ansi-styles@6.2.1", "", {}, "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug=="],
|
||||
@ -899,8 +921,20 @@
|
||||
|
||||
"@commitlint/top-level/find-up/path-exists": ["path-exists@5.0.0", "", {}, "sha512-RjhtfwJOxzcFmNOi6ltcbcu4Iu+FL3zEj83dk4kAS+fVpTxXLO1b38RvJgT/0QwvV/L3aY9TAnyv0EOqW4GoMQ=="],
|
||||
|
||||
"@typescript-eslint/eslint-plugin/@typescript-eslint/utils/@typescript-eslint/types": ["@typescript-eslint/types@8.26.0", "", {}, "sha512-89B1eP3tnpr9A8L6PZlSjBvnJhWXtYfZhECqlBl1D9Lme9mHO6iWlsprBtVenQvY1HMhax1mWOjhtL3fh/u+pA=="],
|
||||
|
||||
"@typescript-eslint/eslint-plugin/@typescript-eslint/utils/@typescript-eslint/typescript-estree": ["@typescript-eslint/typescript-estree@8.26.0", "", { "dependencies": { "@typescript-eslint/types": "8.26.0", "@typescript-eslint/visitor-keys": "8.26.0", "debug": "^4.3.4", "fast-glob": "^3.3.2", "is-glob": "^4.0.3", "minimatch": "^9.0.4", "semver": "^7.6.0", "ts-api-utils": "^2.0.1" }, "peerDependencies": { "typescript": ">=4.8.4 <5.9.0" } }, "sha512-tiJ1Hvy/V/oMVRTbEOIeemA2XoylimlDQ03CgPPNaHYZbpsc78Hmngnt+WXZfJX1pjQ711V7g0H7cSJThGYfPQ=="],
|
||||
|
||||
"@typescript-eslint/type-utils/@typescript-eslint/typescript-estree/@typescript-eslint/types": ["@typescript-eslint/types@8.26.0", "", {}, "sha512-89B1eP3tnpr9A8L6PZlSjBvnJhWXtYfZhECqlBl1D9Lme9mHO6iWlsprBtVenQvY1HMhax1mWOjhtL3fh/u+pA=="],
|
||||
|
||||
"@typescript-eslint/type-utils/@typescript-eslint/typescript-estree/minimatch": ["minimatch@9.0.5", "", { "dependencies": { "brace-expansion": "^2.0.1" } }, "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow=="],
|
||||
|
||||
"@typescript-eslint/type-utils/@typescript-eslint/utils/@typescript-eslint/types": ["@typescript-eslint/types@8.26.0", "", {}, "sha512-89B1eP3tnpr9A8L6PZlSjBvnJhWXtYfZhECqlBl1D9Lme9mHO6iWlsprBtVenQvY1HMhax1mWOjhtL3fh/u+pA=="],
|
||||
|
||||
"@typescript-eslint/typescript-estree/minimatch/brace-expansion": ["brace-expansion@2.0.1", "", { "dependencies": { "balanced-match": "^1.0.0" } }, "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA=="],
|
||||
|
||||
"@typescript-eslint/utils/@typescript-eslint/scope-manager/@typescript-eslint/visitor-keys": ["@typescript-eslint/visitor-keys@8.26.1", "", { "dependencies": { "@typescript-eslint/types": "8.26.1", "eslint-visitor-keys": "^4.2.0" } }, "sha512-AjOC3zfnxd6S4Eiy3jwktJPclqhFHNyd8L6Gycf9WUPoKZpgM5PjkxY1X7uSy61xVpiJDhhk7XT2NVsN3ALTWg=="],
|
||||
|
||||
"cli-truncate/string-width/emoji-regex": ["emoji-regex@10.4.0", "", {}, "sha512-EC+0oUMY1Rqm4O6LLrgjtYDvcVYTy7chDnM4Q7030tP4Kwj3u/pR6gP9ygnp2CJMK5Gq+9Q2oqmrFJAz01DXjw=="],
|
||||
|
||||
"cli-truncate/string-width/strip-ansi": ["strip-ansi@7.1.0", "", { "dependencies": { "ansi-regex": "^6.0.1" } }, "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ=="],
|
||||
@ -923,14 +957,26 @@
|
||||
|
||||
"p-locate/p-limit/yocto-queue": ["yocto-queue@0.1.0", "", {}, "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q=="],
|
||||
|
||||
"typescript-eslint/@typescript-eslint/eslint-plugin/@typescript-eslint/scope-manager": ["@typescript-eslint/scope-manager@8.26.1", "", { "dependencies": { "@typescript-eslint/types": "8.26.1", "@typescript-eslint/visitor-keys": "8.26.1" } }, "sha512-6EIvbE5cNER8sqBu6V7+KeMZIC1664d2Yjt+B9EWUXrsyWpxx4lEZrmvxgSKRC6gX+efDL/UY9OpPZ267io3mg=="],
|
||||
|
||||
"typescript-eslint/@typescript-eslint/eslint-plugin/@typescript-eslint/type-utils": ["@typescript-eslint/type-utils@8.26.1", "", { "dependencies": { "@typescript-eslint/typescript-estree": "8.26.1", "@typescript-eslint/utils": "8.26.1", "debug": "^4.3.4", "ts-api-utils": "^2.0.1" }, "peerDependencies": { "eslint": "^8.57.0 || ^9.0.0", "typescript": ">=4.8.4 <5.9.0" } }, "sha512-Kcj/TagJLwoY/5w9JGEFV0dclQdyqw9+VMndxOJKtoFSjfZhLXhYjzsQEeyza03rwHx2vFEGvrJWJBXKleRvZg=="],
|
||||
|
||||
"typescript-eslint/@typescript-eslint/eslint-plugin/@typescript-eslint/visitor-keys": ["@typescript-eslint/visitor-keys@8.26.1", "", { "dependencies": { "@typescript-eslint/types": "8.26.1", "eslint-visitor-keys": "^4.2.0" } }, "sha512-AjOC3zfnxd6S4Eiy3jwktJPclqhFHNyd8L6Gycf9WUPoKZpgM5PjkxY1X7uSy61xVpiJDhhk7XT2NVsN3ALTWg=="],
|
||||
|
||||
"wrap-ansi/string-width/emoji-regex": ["emoji-regex@10.4.0", "", {}, "sha512-EC+0oUMY1Rqm4O6LLrgjtYDvcVYTy7chDnM4Q7030tP4Kwj3u/pR6gP9ygnp2CJMK5Gq+9Q2oqmrFJAz01DXjw=="],
|
||||
|
||||
"wrap-ansi/strip-ansi/ansi-regex": ["ansi-regex@6.1.0", "", {}, "sha512-7HSX4QQb4CspciLpVFwyRe79O3xsIZDDLER21kERQ71oaPodF8jL725AgJMFAYbooIqolJoRLuM81SpeUkpkvA=="],
|
||||
|
||||
"@commitlint/top-level/find-up/locate-path/p-locate": ["p-locate@6.0.0", "", { "dependencies": { "p-limit": "^4.0.0" } }, "sha512-wPrq66Llhl7/4AGC6I+cqxT07LhXvWL08LNXz1fENOw0Ap4sRZZ/gZpTTJ5jpurzzzfS2W/Ge9BY3LgLjCShcw=="],
|
||||
|
||||
"@typescript-eslint/eslint-plugin/@typescript-eslint/utils/@typescript-eslint/typescript-estree/minimatch": ["minimatch@9.0.5", "", { "dependencies": { "brace-expansion": "^2.0.1" } }, "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow=="],
|
||||
|
||||
"@typescript-eslint/type-utils/@typescript-eslint/typescript-estree/minimatch/brace-expansion": ["brace-expansion@2.0.1", "", { "dependencies": { "balanced-match": "^1.0.0" } }, "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA=="],
|
||||
|
||||
"cli-truncate/string-width/strip-ansi/ansi-regex": ["ansi-regex@6.1.0", "", {}, "sha512-7HSX4QQb4CspciLpVFwyRe79O3xsIZDDLER21kERQ71oaPodF8jL725AgJMFAYbooIqolJoRLuM81SpeUkpkvA=="],
|
||||
|
||||
"@commitlint/top-level/find-up/locate-path/p-locate/p-limit": ["p-limit@4.0.0", "", { "dependencies": { "yocto-queue": "^1.0.0" } }, "sha512-5b0R4txpzjPWVw/cXXUResoD4hb6U/x9BH08L7nw+GN1sezDzPdxeRvpc9c433fZhBan/wusjbCsqwqm4EIBIQ=="],
|
||||
|
||||
"@typescript-eslint/eslint-plugin/@typescript-eslint/utils/@typescript-eslint/typescript-estree/minimatch/brace-expansion": ["brace-expansion@2.0.1", "", { "dependencies": { "balanced-match": "^1.0.0" } }, "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA=="],
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,3 @@
|
||||
import db from "../../db"
|
||||
import { GitlabProjectModel } from "../../db/gitlabProject/index."
|
||||
import { Context } from "../../types"
|
||||
|
||||
@ -43,7 +42,7 @@ const openFunc = async (
|
||||
projectId: number,
|
||||
func: "openCICDNotify" | "openMRSummary"
|
||||
) => {
|
||||
const { logger, larkBody, larkService, larkCard } = ctx
|
||||
const { logger, larkBody, larkService, larkCard, db } = ctx
|
||||
const cardGender = larkCard.child("gitlabAgent")
|
||||
if (!projectId) {
|
||||
logger.error(`项目ID格式错误,项目ID:${projectId}`)
|
||||
@ -92,7 +91,7 @@ const closeFunc = async (
|
||||
projectId: number,
|
||||
func: "openCICDNotify" | "openMRSummary"
|
||||
) => {
|
||||
const { logger, larkBody, larkService, larkCard } = ctx
|
||||
const { logger, larkBody, larkService, larkCard, db } = ctx
|
||||
const cardGender = larkCard.child("gitlabAgent")
|
||||
if (!projectId) {
|
||||
logger.error(`项目ID格式错误,项目ID:${projectId}`)
|
||||
|
@ -1,5 +1,4 @@
|
||||
import { RespMessage } from "../../constant/message"
|
||||
import db from "../../db"
|
||||
import { Context } from "../../types"
|
||||
import { genContextManually } from "../../utils/genContext"
|
||||
import llm from "../../utils/llm"
|
||||
@ -19,6 +18,7 @@ const genSummary = async (
|
||||
trigger: "auto" | "manual"
|
||||
) => {
|
||||
const {
|
||||
db,
|
||||
logger,
|
||||
requestId,
|
||||
larkCard,
|
||||
@ -35,7 +35,7 @@ const genSummary = async (
|
||||
)
|
||||
}
|
||||
// 获取群聊信息
|
||||
const chat = await db.chat.getAndCreate(ctx)
|
||||
const chat = await db.chat.getByCtx(ctx)
|
||||
if (!chat) {
|
||||
throw new Error("Failed to get chat info")
|
||||
}
|
||||
@ -127,7 +127,7 @@ const genSummary = async (
|
||||
*/
|
||||
const genAllReport = async (timeScope: "daily" | "weekly" = "daily") => {
|
||||
const ctx = await genContextManually()
|
||||
const { logger } = ctx
|
||||
const { logger, db } = ctx
|
||||
logger.info(`genAllReport ${timeScope}`)
|
||||
try {
|
||||
// 获取所有需要自动总结的群组
|
||||
@ -184,6 +184,7 @@ const setSubscription = async (
|
||||
value: boolean
|
||||
) => {
|
||||
const {
|
||||
db,
|
||||
larkService: { message },
|
||||
logger,
|
||||
larkBody,
|
||||
@ -204,7 +205,7 @@ const setSubscription = async (
|
||||
throw new Error("Invalid chatId")
|
||||
}
|
||||
// 获取群组信息
|
||||
const chat = await db.chat.getAndCreate(ctx)
|
||||
const chat = await db.chat.getByCtx(ctx)
|
||||
if (!chat) {
|
||||
throw new Error("Failed to get chat info")
|
||||
}
|
||||
@ -213,7 +214,9 @@ const setSubscription = async (
|
||||
// 更新订阅信息, 如果订阅信息没有变化则不更新
|
||||
if (chat[`${timeScope}Summary`] !== value) {
|
||||
logger.info("value is different, update subscription")
|
||||
const res = await db.chat.updateSummary(chat.id, timeScope, value)
|
||||
const res = await db.chat.update(chat.id, {
|
||||
[`${timeScope}Summary`]: value,
|
||||
})
|
||||
if (!res) {
|
||||
throw new Error("Failed to update subscription")
|
||||
}
|
||||
|
@ -1,4 +1,3 @@
|
||||
import db from "../../db"
|
||||
import { SheetModel } from "../../db/sheet"
|
||||
import { Context } from "../../types"
|
||||
import llm from "../../utils/llm"
|
||||
@ -54,7 +53,8 @@ export const generateSummary = async (
|
||||
* @returns {Promise<{sheetToken: string, range: string, sheetUrl: string}> | null} - 返回表格信息或null
|
||||
*/
|
||||
const getReportSheet = async (ctx: Context) => {
|
||||
const chat = await db.chat.getAndCreate(ctx)
|
||||
const { db } = ctx
|
||||
const chat = await db.chat.getByCtx(ctx)
|
||||
if (!chat || !chat?.sheet || !chat?.expand?.sheet) {
|
||||
return null
|
||||
}
|
||||
@ -272,11 +272,11 @@ const parseSheetInfo = async (
|
||||
* @param {string} sheetUrl - 表格链接
|
||||
*/
|
||||
const setSheet = async (ctx: Context, sheetUrl: string) => {
|
||||
const { larkCard, larkService, logger } = ctx
|
||||
const { larkCard, larkService, logger, db } = ctx
|
||||
const cardGender = larkCard.child("webAgent")
|
||||
try {
|
||||
// 获取chat信息
|
||||
const chat = await db.chat.getAndCreate(ctx)
|
||||
const chat = await db.chat.getByCtx(ctx)
|
||||
if (!chat) throw new Error("获取聊天信息失败")
|
||||
// 获取是否已经有存在的sheet信息
|
||||
const existSheet = await db.sheet.getByUrl(sheetUrl)
|
||||
|
@ -1,5 +1,4 @@
|
||||
import { SoupGameMessage } from "../../constant/message"
|
||||
import db from "../../db"
|
||||
import { SoupGame } from "../../db/soupGame"
|
||||
import { Context } from "../../types"
|
||||
|
||||
@ -14,6 +13,7 @@ const startOrStopGame = async (
|
||||
which: "auto" | "manual" = "manual"
|
||||
) => {
|
||||
const {
|
||||
db,
|
||||
logger,
|
||||
larkBody: { chatId },
|
||||
attachService,
|
||||
@ -128,6 +128,7 @@ const startOrStopGame = async (
|
||||
|
||||
const chat2Soup = async (ctx: Context) => {
|
||||
const {
|
||||
db,
|
||||
larkBody: { msgText, chatId, messageId },
|
||||
logger,
|
||||
attachService,
|
||||
@ -157,7 +158,7 @@ const chat2Soup = async (ctx: Context) => {
|
||||
return
|
||||
}
|
||||
// 继续游戏,更新历史记录
|
||||
await db.soupGame.insertHistory(activeGame.id, [
|
||||
await db.soupGame.overrideHistory(activeGame.id, [
|
||||
...activeGame.history,
|
||||
msgText,
|
||||
])
|
||||
@ -173,6 +174,7 @@ const chat2Soup = async (ctx: Context) => {
|
||||
const agent = async (ctx: Context) => {
|
||||
const {
|
||||
larkBody: { chatId, msgText },
|
||||
db,
|
||||
} = ctx
|
||||
if (!chatId) return
|
||||
const activeGame = await db.soupGame.getActiveOneByChatId(chatId)
|
||||
|
@ -1,48 +1,70 @@
|
||||
import { RecordModel } from "pocketbase"
|
||||
import PocketBase, { RecordModel } from "pocketbase"
|
||||
import { Logger } from "winston"
|
||||
|
||||
import { AppInfoModel } from "../../constant/config"
|
||||
import { managePbError } from "../../utils/pbTools"
|
||||
import pbClient from "../pbClient"
|
||||
import PbToolBase, { WithExpand } from "../base"
|
||||
|
||||
/** API密钥集合的名称常量 */
|
||||
const DB_NAME = "apiKey"
|
||||
|
||||
/**
|
||||
* API密钥基础数据结构接口
|
||||
* 定义了API密钥的基本字段
|
||||
*/
|
||||
export interface ApiKey {
|
||||
/** API密钥名称 */
|
||||
name: string
|
||||
/** API密钥拥有者标识符 */
|
||||
owner: string
|
||||
/** 关联的应用程序标识符 */
|
||||
app: string
|
||||
}
|
||||
|
||||
/**
|
||||
* API密钥模型类型,结合基础接口和PocketBase的记录模型
|
||||
*/
|
||||
export type ApiKeyModel = ApiKey & RecordModel
|
||||
|
||||
export interface ApiKeyModelWithApp extends ApiKeyModel {
|
||||
expand: {
|
||||
app: AppInfoModel
|
||||
/**
|
||||
* 扩展了应用信息的API密钥模型类型
|
||||
* 包含完整的应用程序信息
|
||||
*/
|
||||
export type ApiKeyModelWithApp = ApiKeyModel & WithExpand<{ app: AppInfoModel }>
|
||||
|
||||
/**
|
||||
* API密钥数据库操作类
|
||||
* 提供API密钥相关的特定查询和操作方法
|
||||
*
|
||||
* @extends PbToolBase<ApiKeyModel> 基础PocketBase操作类
|
||||
*/
|
||||
class ApiKeyDB extends PbToolBase<ApiKeyModel> {
|
||||
/**
|
||||
* 创建API密钥数据库操作实例
|
||||
*
|
||||
* @param pbClient - PocketBase客户端实例
|
||||
* @param logger - 日志记录器实例
|
||||
*/
|
||||
constructor(pbClient: PocketBase, logger: Logger) {
|
||||
super(DB_NAME, pbClient, logger)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取带有扩展应用信息的API密钥
|
||||
*
|
||||
* @param id - API密钥记录的ID
|
||||
* @returns 成功时返回包含应用信息的API密钥记录,失败时返回null
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* const apiKeyWithApp = await apiKeyDB.getWithApp("api_key_123");
|
||||
* if (apiKeyWithApp) {
|
||||
* console.log(`应用名称: ${apiKeyWithApp.expand.app.name}`);
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
public getWithApp = (id: string) => {
|
||||
return this.get<ApiKeyModelWithApp>(id, { expand: "app" })
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取单个 API Key 对应的 App 信息
|
||||
* @param id
|
||||
* @returns
|
||||
*/
|
||||
const getOne = (id: string) =>
|
||||
managePbError<ApiKeyModelWithApp>(() =>
|
||||
pbClient.collection(DB_NAME).getOne(id, {
|
||||
expand: "app",
|
||||
})
|
||||
)
|
||||
|
||||
/**
|
||||
* 创建 API Key
|
||||
* @param data
|
||||
* @returns
|
||||
*/
|
||||
const create = (data: ApiKey) =>
|
||||
managePbError<ApiKey>(() => pbClient.collection(DB_NAME).create(data))
|
||||
|
||||
const apiKey = {
|
||||
create,
|
||||
getOne,
|
||||
}
|
||||
|
||||
export default apiKey
|
||||
export default ApiKeyDB
|
||||
|
183
db/base/index.ts
Normal file
183
db/base/index.ts
Normal file
@ -0,0 +1,183 @@
|
||||
import PocketBase, {
|
||||
CommonOptions,
|
||||
RecordFullListOptions,
|
||||
RecordListOptions,
|
||||
RecordModel,
|
||||
RecordOptions,
|
||||
} from "pocketbase"
|
||||
import { Logger } from "winston"
|
||||
|
||||
/**
|
||||
* 用于扩展记录模型的接口,添加展开字段功能
|
||||
* @template T 基础对象类型
|
||||
*/
|
||||
export interface WithExpand<T extends { [key: string]: any } | undefined> {
|
||||
expand: T
|
||||
}
|
||||
|
||||
/**
|
||||
* PocketBase 数据操作基础类
|
||||
* 提供通用的 CRUD 操作方法,自动处理错误和日志
|
||||
*
|
||||
* @template T 继承自 RecordModel 的类型,表示数据库记录模型
|
||||
*/
|
||||
class PbToolBase<T extends RecordModel> {
|
||||
/** PocketBase 集合名称 */
|
||||
protected dbName: string
|
||||
/** PocketBase 客户端实例 */
|
||||
protected pbClient: PocketBase
|
||||
/** 日志记录器实例 */
|
||||
protected logger: Logger
|
||||
|
||||
/**
|
||||
* 创建 PbToolBase 实例
|
||||
*
|
||||
* @param dbName - PocketBase 集合名称
|
||||
* @param pbClient - PocketBase 客户端实例
|
||||
* @param logger - 日志记录器实例
|
||||
*/
|
||||
constructor(dbName: string, pbClient: PocketBase, logger: Logger) {
|
||||
this.dbName = dbName
|
||||
this.pbClient = pbClient
|
||||
this.logger = logger
|
||||
}
|
||||
|
||||
/**
|
||||
* 错误处理包装函数,捕获并记录 PocketBase 操作中的错误
|
||||
*
|
||||
* @template R - 返回结果类型
|
||||
* @param fn - 需要执行的异步函数
|
||||
* @returns 成功时返回执行结果,失败时返回 null 并记录错误
|
||||
*/
|
||||
protected managePbError = async <R>(fn: () => Promise<R>) => {
|
||||
try {
|
||||
return await fn()
|
||||
} catch (err: any) {
|
||||
this.logger.error(`pocketbase error: ${err.message}`)
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建新记录
|
||||
*
|
||||
* @param data - 要创建的记录数据
|
||||
* @returns 成功时返回创建的记录,失败时返回 null
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* const record = await pbTool.create({ name: "示例", value: 100 });
|
||||
* ```
|
||||
*/
|
||||
public create = async (data: Partial<T>) => {
|
||||
return this.managePbError<T>(() =>
|
||||
this.pbClient.collection(this.dbName).create(data)
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定 ID 的记录
|
||||
*
|
||||
* @template R - 返回记录的类型,默认为 T
|
||||
* @param id - 记录 ID
|
||||
* @param options - 获取记录的选项参数
|
||||
* @returns 成功时返回查询到的记录,失败时返回 null
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* const record = await pbTool.get("record123", { expand: "relation_field" });
|
||||
* ```
|
||||
*/
|
||||
public get = async <R extends T = T>(id: string, options?: RecordOptions) => {
|
||||
return this.managePbError<R>(() =>
|
||||
this.pbClient.collection(this.dbName).getOne(id, options)
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新指定 ID 的记录
|
||||
*
|
||||
* @template R - 返回记录的类型,默认为 T
|
||||
* @param id - 记录 ID
|
||||
* @param data - 更新的数据
|
||||
* @param options - 更新记录的选项参数
|
||||
* @returns 成功时返回更新后的记录,失败时返回 null
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* const updatedRecord = await pbTool.update("record123", { name: "新名称" });
|
||||
* ```
|
||||
*/
|
||||
public update = async <R extends T = T>(
|
||||
id: string,
|
||||
data: Partial<T>,
|
||||
options?: RecordOptions
|
||||
) => {
|
||||
return this.managePbError<R>(() =>
|
||||
this.pbClient.collection(this.dbName).update(id, data, options)
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除指定 ID 的记录
|
||||
*
|
||||
* @param id - 要删除的记录 ID
|
||||
* @param options - 删除记录的选项参数
|
||||
* @returns 成功时返回 true,失败时返回 null
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* const result = await pbTool.delete("record123");
|
||||
* ```
|
||||
*/
|
||||
public delete = async (id: string, options?: CommonOptions) => {
|
||||
return this.managePbError(() =>
|
||||
this.pbClient.collection(this.dbName).delete(id, options)
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取记录列表
|
||||
*
|
||||
* @template R - 返回记录的类型,默认为 T
|
||||
* @param options - 列表查询选项,可包含排序、过滤和扩展等参数
|
||||
* @returns 成功时返回记录数组,失败时返回 null
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* const records = await pbTool.list({
|
||||
* sort: "-created",
|
||||
* filter: "active=true"
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
public list = async <R extends T = T>(options?: RecordFullListOptions) => {
|
||||
return this.managePbError<R[]>(() =>
|
||||
this.pbClient.collection(this.dbName).getFullList(options)
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取符合过滤条件的第一条记录
|
||||
*
|
||||
* @template R - 返回记录的类型,默认为 T
|
||||
* @param filter - 过滤条件
|
||||
* @param options - 查询选项
|
||||
* @returns 成功时返回第一条匹配记录,失败时返回 null
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* const user = await pbTool.getFirstOne("email='test@example.com'");
|
||||
* ```
|
||||
*/
|
||||
public getFirstOne = async <R extends T = T>(
|
||||
filter: string,
|
||||
options?: RecordListOptions
|
||||
) => {
|
||||
return this.managePbError<R>(() =>
|
||||
this.pbClient.collection(this.dbName).getFirstListItem(filter, options)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
export default PbToolBase
|
218
db/chat/index.ts
218
db/chat/index.ts
@ -1,129 +1,133 @@
|
||||
import { RecordModel } from "pocketbase"
|
||||
import PocketBase, { RecordModel } from "pocketbase"
|
||||
import { Logger } from "winston"
|
||||
|
||||
import { Context } from "../../types"
|
||||
import { managePbError } from "../../utils/pbTools"
|
||||
import pbClient from "../pbClient"
|
||||
import PbToolBase, { WithExpand } from "../base"
|
||||
import { SheetModel } from "../sheet"
|
||||
|
||||
/** 聊天集合名称 */
|
||||
const DB_NAME = "chat"
|
||||
|
||||
/**
|
||||
* 聊天数据接口
|
||||
*/
|
||||
export interface Chat {
|
||||
/** 飞书聊天 ID */
|
||||
chatId: string
|
||||
/** 聊天名称 */
|
||||
name: string
|
||||
/** 聊天头像 URL */
|
||||
avatar: string
|
||||
/** 聊天模式: 群组、点对点或话题 */
|
||||
mode: "group" | "p2p" | "topic"
|
||||
/** 是否启用周报汇总 */
|
||||
weeklySummary: boolean
|
||||
/** 是否启用日报汇总 */
|
||||
dailySummary: boolean
|
||||
/** 关联表单 ID */
|
||||
sheet: string
|
||||
}
|
||||
|
||||
/** 聊天数据模型,继承基础的 RecordModel */
|
||||
export type ChatModel = Chat & RecordModel
|
||||
|
||||
export interface ChatModelWithExpand extends ChatModel {
|
||||
expand: {
|
||||
/**
|
||||
* 带有关联表单数据的聊天模型
|
||||
* 扩展了表单关联字段
|
||||
*/
|
||||
export type ChatModelWithSheet = ChatModel &
|
||||
WithExpand<{
|
||||
sheet: SheetModel
|
||||
}>
|
||||
|
||||
/**
|
||||
* 聊天数据管理类
|
||||
* 提供对飞书聊天相关数据的存储、查询和管理功能
|
||||
* 继承自 PbToolBase 基础工具类
|
||||
*/
|
||||
class ChatDB extends PbToolBase<ChatModel> {
|
||||
/**
|
||||
* 创建 ChatDB 实例
|
||||
*
|
||||
* @param pbClient - PocketBase 客户端实例
|
||||
* @param logger - 日志记录器实例
|
||||
*/
|
||||
constructor(pbClient: PocketBase, logger: Logger) {
|
||||
super(DB_NAME, pbClient, logger)
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过聊天 ID 获取聊天信息
|
||||
*
|
||||
* @param chatId - 飞书聊天 ID
|
||||
* @returns 聊天数据模型,包含关联的表单数据,失败时返回 null
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* const chat = await chatDB.getOneByChatId("oc_123456");
|
||||
* ```
|
||||
*/
|
||||
public getOneByChatId = (chatId: string) => {
|
||||
const filter = `chatId = "${chatId}"`
|
||||
return this.getFirstOne<ChatModelWithSheet>(filter, { expand: "sheet" })
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据上下文获取聊天信息
|
||||
* 如果数据库中不存在,则尝试从飞书 API 获取并创建新记录
|
||||
*
|
||||
* @param context - 上下文对象,包含飞书服务和请求体
|
||||
* @returns 聊天数据模型,失败时返回 null
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* const chat = await chatDB.getByCtx(ctx);
|
||||
* ```
|
||||
*/
|
||||
public getByCtx = async ({ larkService, larkBody }: Context) => {
|
||||
const { chatId } = larkBody
|
||||
if (!chatId) {
|
||||
this.logger.error(`chatId is empty`)
|
||||
return null
|
||||
}
|
||||
const chat = await this.getOneByChatId(chatId)
|
||||
if (chat) return chat
|
||||
this.logger.info(`chat ${chatId} not found, try to get from lark`)
|
||||
const chatInfo = await larkService.chat.getChatInfo(chatId)
|
||||
if (!chatInfo || chatInfo.code !== 0) return null
|
||||
const { name, avatar, chat_mode } = chatInfo.data
|
||||
return this.create({
|
||||
chatId,
|
||||
name,
|
||||
avatar,
|
||||
mode: chat_mode,
|
||||
weeklySummary: false,
|
||||
dailySummary: false,
|
||||
sheet: "",
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取需要汇总的聊天列表
|
||||
*
|
||||
* @param timeScope - 汇总时间范围:"daily"(日报)、"weekly"(周报)或"all"(全部)
|
||||
* @returns 符合条件的聊天数据模型列表,失败时返回 null
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* const dailyChats = await chatDB.getNeedSummaryChats("daily");
|
||||
* ```
|
||||
*/
|
||||
public getNeedSummaryChats = async (
|
||||
timeScope: "daily" | "weekly" | "all"
|
||||
) => {
|
||||
const filterMap = {
|
||||
daily: "dailySummary = true",
|
||||
weekly: "weeklySummary = true",
|
||||
all: "dailySummary = true && weeklySummary = true",
|
||||
}
|
||||
return this.list<ChatModel>({ filter: filterMap[timeScope] })
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取单个群组信息
|
||||
* @param id
|
||||
* @returns
|
||||
*/
|
||||
const getOneByChatId = (chatId: string) =>
|
||||
managePbError<ChatModelWithExpand>(() =>
|
||||
pbClient
|
||||
.collection<ChatModelWithExpand>(DB_NAME)
|
||||
.getFirstListItem(`chatId = "${chatId}"`, {
|
||||
expand: "sheet",
|
||||
})
|
||||
)
|
||||
|
||||
/**
|
||||
* 创建群组
|
||||
* @param chat
|
||||
* @returns
|
||||
*/
|
||||
const create = (chat: Chat) =>
|
||||
managePbError<ChatModel>(() => pbClient.collection(DB_NAME).create(chat))
|
||||
|
||||
/**
|
||||
* 获取并创建群组
|
||||
* @param chatId
|
||||
* @param context
|
||||
* @returns
|
||||
*/
|
||||
const getAndCreate = async ({ larkService, logger, larkBody }: Context) => {
|
||||
const { chatId } = larkBody
|
||||
if (!chatId) {
|
||||
logger.error(`chatId is empty`)
|
||||
return null
|
||||
}
|
||||
const chat = await getOneByChatId(chatId)
|
||||
if (chat) return chat
|
||||
logger.info(`chat ${chatId} not found, try to get from lark`)
|
||||
const chatInfo = await larkService.chat.getChatInfo(chatId)
|
||||
if (!chatInfo || chatInfo.code !== 0) return null
|
||||
const { name, avatar, chat_mode } = chatInfo.data
|
||||
const newChat = {
|
||||
chatId,
|
||||
name,
|
||||
avatar,
|
||||
mode: chat_mode,
|
||||
weeklySummary: false,
|
||||
dailySummary: false,
|
||||
sheet: "",
|
||||
}
|
||||
return create(newChat)
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新群组
|
||||
* @param id
|
||||
* @param chat
|
||||
* @returns
|
||||
*/
|
||||
const update = (id: string, chat: Partial<Chat>) =>
|
||||
managePbError<ChatModel>(() => pbClient.collection(DB_NAME).update(id, chat))
|
||||
|
||||
/**
|
||||
* 更新群组总结
|
||||
* @param id
|
||||
* @param timeScope
|
||||
* @param value
|
||||
* @returns
|
||||
*/
|
||||
const updateSummary = async (
|
||||
id: string,
|
||||
timeScope: "daily" | "weekly",
|
||||
value: boolean
|
||||
) =>
|
||||
managePbError<ChatModel>(() =>
|
||||
pbClient.collection(DB_NAME).update(id, { [`${timeScope}Summary`]: value })
|
||||
)
|
||||
|
||||
/**
|
||||
* 获取需要总结的群组
|
||||
* @param timeScope
|
||||
* @returns
|
||||
*/
|
||||
const getNeedSummaryChats = async (timeScope: "daily" | "weekly" | "all") => {
|
||||
const filterMap = {
|
||||
daily: "dailySummary = true",
|
||||
weekly: "weeklySummary = true",
|
||||
all: "dailySummary = true && weeklySummary = true",
|
||||
}
|
||||
return managePbError<ChatModel[]>(() =>
|
||||
pbClient.collection(DB_NAME).getFullList({ filter: filterMap[timeScope] })
|
||||
)
|
||||
}
|
||||
|
||||
const chat = {
|
||||
update,
|
||||
getAndCreate,
|
||||
getOneByChatId,
|
||||
updateSummary,
|
||||
getNeedSummaryChats,
|
||||
}
|
||||
|
||||
export default chat
|
||||
export default ChatDB
|
||||
|
@ -1,97 +1,121 @@
|
||||
import { Gitlab, GitlabService } from "@egg/net-tool"
|
||||
import { RecordModel } from "pocketbase"
|
||||
import PocketBase, { RecordModel } from "pocketbase"
|
||||
import { Logger } from "winston"
|
||||
|
||||
import { Context } from "../../types"
|
||||
import { managePbError } from "../../utils/pbTools"
|
||||
import pbClient from "../pbClient"
|
||||
import PbToolBase from "../base"
|
||||
|
||||
const DB_NAME = "gitlabProject"
|
||||
|
||||
// Gitlab项目接口定义
|
||||
/**
|
||||
* Gitlab项目接口定义
|
||||
* 描述Gitlab项目的基本属性和配置
|
||||
*/
|
||||
export interface GitlabProject {
|
||||
/** Gitlab项目ID */
|
||||
projectId: number
|
||||
/** 项目名称 */
|
||||
name: string
|
||||
/** 项目描述 */
|
||||
desc: string
|
||||
/** 带命名空间的项目路径 */
|
||||
pathWithNamespace: string
|
||||
/** 项目网页URL */
|
||||
webUrl: string
|
||||
/** 是否开启CI/CD通知 */
|
||||
openCICDNotify: boolean
|
||||
/** 是否开启合并请求总结 */
|
||||
openMRSummary: boolean
|
||||
}
|
||||
|
||||
// Gitlab项目模型类型
|
||||
/**
|
||||
* Gitlab项目模型类型
|
||||
* 将Gitlab项目接口与PocketBase记录模型合并
|
||||
*/
|
||||
export type GitlabProjectModel = GitlabProject & RecordModel
|
||||
|
||||
/**
|
||||
* 创建Gitlab项目
|
||||
* @param {GitlabProject} project - Gitlab项目信息
|
||||
* @returns {Promise<GitlabProjectModel>} - 创建的Gitlab项目模型
|
||||
* GitlabProject数据库操作类
|
||||
* 提供Gitlab项目相关的数据库操作方法,继承自PbToolBase
|
||||
*/
|
||||
const create = async (project: GitlabProject) =>
|
||||
managePbError<GitlabProjectModel>(() =>
|
||||
pbClient.collection(DB_NAME).create(project)
|
||||
)
|
||||
|
||||
/**
|
||||
* 通过项目ID获取Gitlab项目
|
||||
* @param {number} projectId - 项目ID
|
||||
* @returns {Promise<GitlabProjectModel | null>} - Gitlab项目模型或null
|
||||
*/
|
||||
const getByProjectId = async (projectId: number) =>
|
||||
managePbError<GitlabProjectModel>(() =>
|
||||
pbClient.collection(DB_NAME).getFirstListItem(`projectId = "${projectId}"`)
|
||||
)
|
||||
|
||||
/**
|
||||
* 通过项目ID获取Gitlab项目,如果不存在则创建
|
||||
* @param {number} projectId - 项目ID
|
||||
* @param {GitlabService} gitlabService - Gitlab服务
|
||||
* @returns {Promise<GitlabProjectModel | null>} - Gitlab项目模型或null
|
||||
*/
|
||||
const getAndCreate = async (
|
||||
projectId: number,
|
||||
gitlabService: GitlabService
|
||||
) => {
|
||||
const project = await getByProjectId(projectId)
|
||||
if (project) return project
|
||||
gitlabService.setProjectId(projectId)
|
||||
const projectInfo = await gitlabService.project.getDetail()
|
||||
if (!projectInfo) return null
|
||||
const { name, description, path_with_namespace, web_url } = projectInfo
|
||||
const newProject = {
|
||||
projectId,
|
||||
name,
|
||||
desc: description,
|
||||
pathWithNamespace: path_with_namespace,
|
||||
webUrl: web_url,
|
||||
openCICDNotify: false,
|
||||
openMRSummary: false,
|
||||
class GitlabProjectDB extends PbToolBase<GitlabProjectModel> {
|
||||
/**
|
||||
* 创建GitlabProjectDB实例
|
||||
*
|
||||
* @param pbClient - PocketBase客户端实例
|
||||
* @param logger - 日志记录器实例
|
||||
*/
|
||||
constructor(pbClient: PocketBase, logger: Logger) {
|
||||
super(DB_NAME, pbClient, logger)
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据项目ID获取Gitlab项目
|
||||
*
|
||||
* @param projectId - Gitlab项目ID
|
||||
* @returns 成功时返回项目记录,失败时返回null
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* const project = await gitlabProjectDB.getByProjectId(12345);
|
||||
* ```
|
||||
*/
|
||||
public getByProjectId = (projectId: number) => {
|
||||
return this.getFirstOne(`projectId = "${projectId}"`)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取项目信息,如不存在则从Gitlab获取并创建
|
||||
*
|
||||
* @param projectId - Gitlab项目ID
|
||||
* @param gitlabService - Gitlab服务实例
|
||||
* @returns 成功时返回项目记录,失败时返回null
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* const project = await gitlabProjectDB.getAndCreate(12345, gitlabService);
|
||||
* ```
|
||||
*/
|
||||
public getAndCreate = async (
|
||||
projectId: number,
|
||||
gitlabService: GitlabService
|
||||
) => {
|
||||
const project = await this.getByProjectId(projectId)
|
||||
if (project) return project
|
||||
gitlabService.setProjectId(projectId)
|
||||
const projectInfo = await gitlabService.project.getDetail()
|
||||
if (!projectInfo) return null
|
||||
const { name, description, path_with_namespace, web_url } = projectInfo
|
||||
const newProject = {
|
||||
projectId,
|
||||
name,
|
||||
desc: description,
|
||||
pathWithNamespace: path_with_namespace,
|
||||
webUrl: web_url,
|
||||
openCICDNotify: false,
|
||||
openMRSummary: false,
|
||||
}
|
||||
return await this.create(newProject)
|
||||
}
|
||||
|
||||
/**
|
||||
* 从上下文获取Gitlab项目信息
|
||||
* 解析请求上下文中的项目ID,获取或创建项目记录
|
||||
*
|
||||
* @param context - 请求上下文,包含请求体和Gitlab服务
|
||||
* @returns 成功时返回项目记录,失败时返回null
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* const project = await gitlabProjectDB.getByCtx(ctx);
|
||||
* ```
|
||||
*/
|
||||
public getByCtx = async ({ body: rawBody, gitlabService }: Context) => {
|
||||
const body = rawBody as Gitlab.PipelineEvent | Gitlab.MergeRequestEvent
|
||||
const projectId = body.project.id
|
||||
if (!projectId) return null
|
||||
return await this.getAndCreate(projectId, gitlabService)
|
||||
}
|
||||
return await create(newProject)
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过上下文获取Gitlab项目
|
||||
* @param {Context} context - 上下文对象
|
||||
* @returns {Promise<GitlabProjectModel | null>} - Gitlab项目模型或null
|
||||
*/
|
||||
const getByCtx = async ({ body: rawBody, gitlabService }: Context) => {
|
||||
const body = rawBody as Gitlab.PipelineEvent | Gitlab.MergeRequestEvent
|
||||
const projectId = body.project.id
|
||||
if (!projectId) return null
|
||||
return await getAndCreate(projectId, gitlabService)
|
||||
}
|
||||
|
||||
const update = async (id: string, project: Partial<GitlabProjectModel>) =>
|
||||
managePbError<GitlabProjectModel>(() =>
|
||||
pbClient.collection(DB_NAME).update(id, project)
|
||||
)
|
||||
|
||||
const gitlabProject = {
|
||||
create,
|
||||
update,
|
||||
getByProjectId,
|
||||
getByCtx,
|
||||
getAndCreate,
|
||||
}
|
||||
|
||||
export default gitlabProject
|
||||
export default GitlabProjectDB
|
||||
|
@ -1,30 +1,51 @@
|
||||
import { RecordModel } from "pocketbase"
|
||||
import PocketBase, { RecordModel } from "pocketbase"
|
||||
import { Logger } from "winston"
|
||||
|
||||
import { managePbError } from "../../utils/pbTools"
|
||||
import pbClient from "../pbClient"
|
||||
import PbToolBase from "../base"
|
||||
|
||||
/** GroupSummaryLog 集合名称 */
|
||||
const DB_NAME = "grpSumLog"
|
||||
|
||||
/**
|
||||
* 群组摘要日志接口
|
||||
* 定义了群组摘要记录的数据结构
|
||||
*/
|
||||
export interface GroupSummaryLog {
|
||||
/** 关联的聊天 ID */
|
||||
chat: string
|
||||
/** 摘要内容 */
|
||||
content: string
|
||||
/** Langfuse 链接引用 */
|
||||
langfuseLink: string
|
||||
}
|
||||
|
||||
/**
|
||||
* 群组摘要日志模型类型
|
||||
* 结合了 GroupSummaryLog 接口和 RecordModel 基础类型
|
||||
*/
|
||||
export type GroupSummaryLogModel = GroupSummaryLog & RecordModel
|
||||
|
||||
/**
|
||||
* 创建群总结日志
|
||||
* @param log
|
||||
* @returns
|
||||
* 群组摘要日志数据库操作类
|
||||
* 提供对群组摘要日志集合的 CRUD 操作
|
||||
*
|
||||
* @extends PbToolBase<GroupSummaryLogModel>
|
||||
*/
|
||||
const create = async (log: GroupSummaryLog) =>
|
||||
managePbError<GroupSummaryLogModel>(() =>
|
||||
pbClient.collection(DB_NAME).create(log)
|
||||
)
|
||||
|
||||
const grpSumLog = {
|
||||
create,
|
||||
class GroupSummaryLogDB extends PbToolBase<GroupSummaryLogModel> {
|
||||
/**
|
||||
* 创建群组摘要日志数据库操作实例
|
||||
*
|
||||
* @param pbClient - PocketBase 客户端实例
|
||||
* @param logger - 日志记录器实例
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* const summaryLogDB = new GroupSummaryLogDB(pbClient, logger);
|
||||
* ```
|
||||
*/
|
||||
constructor(pbClient: PocketBase, logger: Logger) {
|
||||
super(DB_NAME, pbClient, logger)
|
||||
}
|
||||
}
|
||||
|
||||
export default grpSumLog
|
||||
export default GroupSummaryLogDB
|
||||
|
55
db/index.ts
55
db/index.ts
@ -1,23 +1,38 @@
|
||||
import apiKey from "./apiKey"
|
||||
import chat from "./chat"
|
||||
import gitlabProject from "./gitlabProject/index."
|
||||
import grpSumLog from "./grpSumLog"
|
||||
import log from "./log"
|
||||
import receiveGroup from "./receiveGroup"
|
||||
import sheet from "./sheet"
|
||||
import soupGame from "./soupGame"
|
||||
import user from "./user"
|
||||
import { Logger } from "winston"
|
||||
|
||||
const db = {
|
||||
chat,
|
||||
apiKey,
|
||||
receiveGroup,
|
||||
log,
|
||||
user,
|
||||
grpSumLog,
|
||||
gitlabProject,
|
||||
soupGame,
|
||||
sheet,
|
||||
import ApiKeyDB from "./apiKey"
|
||||
import ChatDB from "./chat"
|
||||
import GitlabProjectDB from "./gitlabProject/index."
|
||||
import GroupSummaryLogDB from "./grpSumLog"
|
||||
import LogDB from "./log"
|
||||
import pbClient from "./pbClient"
|
||||
import ReceiveGroupDB from "./receiveGroup"
|
||||
import SheetDB from "./sheet"
|
||||
import SoupGameDB from "./soupGame"
|
||||
import UserDB from "./user"
|
||||
|
||||
class DB {
|
||||
public user: UserDB
|
||||
public apiKey: ApiKeyDB
|
||||
public chat: ChatDB
|
||||
public receiveGroup: ReceiveGroupDB
|
||||
public log: LogDB
|
||||
public grpSumLog: GroupSummaryLogDB
|
||||
public gitlabProject: GitlabProjectDB
|
||||
public soupGame: SoupGameDB
|
||||
public sheet: SheetDB
|
||||
|
||||
constructor(logger: Logger) {
|
||||
this.user = new UserDB(pbClient, logger)
|
||||
this.apiKey = new ApiKeyDB(pbClient, logger)
|
||||
this.chat = new ChatDB(pbClient, logger)
|
||||
this.receiveGroup = new ReceiveGroupDB(pbClient, logger)
|
||||
this.log = new LogDB(pbClient, logger)
|
||||
this.grpSumLog = new GroupSummaryLogDB(pbClient, logger)
|
||||
this.gitlabProject = new GitlabProjectDB(pbClient, logger)
|
||||
this.soupGame = new SoupGameDB(pbClient, logger)
|
||||
this.sheet = new SheetDB(pbClient, logger)
|
||||
}
|
||||
}
|
||||
|
||||
export default db
|
||||
export default DB
|
||||
|
@ -1,34 +1,58 @@
|
||||
import { RecordModel } from "pocketbase"
|
||||
import PocketBase, { RecordModel } from "pocketbase"
|
||||
import { Logger } from "winston"
|
||||
|
||||
import { managePbError } from "../../utils/pbTools"
|
||||
import pbClient from "../pbClient"
|
||||
import PbToolBase from "../base"
|
||||
|
||||
const DB_NAME = "messageLog"
|
||||
|
||||
/**
|
||||
* 消息日志接口,定义消息日志的数据结构
|
||||
* 用于记录系统消息的发送、接收和处理过程
|
||||
*/
|
||||
export interface Log {
|
||||
/** API 密钥,用于身份验证和追踪 */
|
||||
apiKey: string
|
||||
/** 消息所属群组 ID,可选 */
|
||||
groupId?: string
|
||||
/** 接收者 ID,可选 */
|
||||
receiveId?: string
|
||||
/** 接收者 ID 类型,例如用户ID、群组ID等,可选 */
|
||||
receiveIdType?: string
|
||||
/** 消息类型,例如文本、图片、语音等 */
|
||||
msgType: string
|
||||
/** 原始消息内容 */
|
||||
content: string
|
||||
/** 处理后的最终消息内容,可选 */
|
||||
finalContent?: string
|
||||
/** 消息发送结果,可包含发送状态、时间等信息,可选 */
|
||||
sendResult?: any
|
||||
/** 处理过程中的错误信息,可选 */
|
||||
error?: string
|
||||
}
|
||||
|
||||
/**
|
||||
* 消息日志模型类型,结合 Log 接口和 PocketBase 的 RecordModel
|
||||
*/
|
||||
export type LogModel = Log & RecordModel
|
||||
|
||||
/**
|
||||
* 创建一条日志
|
||||
* @param log
|
||||
* @returns
|
||||
* 消息日志数据库操作类
|
||||
*
|
||||
* 提供消息日志相关的数据库操作,继承自 PbToolBase 基础类
|
||||
* 用于记录和查询系统中的消息传递过程,便于调试和审计
|
||||
*
|
||||
* @extends PbToolBase<LogModel> 基础数据库操作类
|
||||
*/
|
||||
const create = (log: Log) =>
|
||||
managePbError(() => pbClient.collection(DB_NAME).create(log))
|
||||
|
||||
const log = {
|
||||
create,
|
||||
class LogDB extends PbToolBase<LogModel> {
|
||||
/**
|
||||
* 创建 LogDB 实例
|
||||
*
|
||||
* @param pbClient - PocketBase 客户端实例,用于与数据库通信
|
||||
* @param logger - 日志记录器实例,用于记录操作日志
|
||||
*/
|
||||
constructor(pbClient: PocketBase, logger: Logger) {
|
||||
super(DB_NAME, pbClient, logger)
|
||||
}
|
||||
}
|
||||
|
||||
export default log
|
||||
export default LogDB
|
||||
|
@ -1,39 +1,69 @@
|
||||
import { RecordModel } from "pocketbase"
|
||||
import PocketBase, { RecordModel } from "pocketbase"
|
||||
import { Logger } from "winston"
|
||||
|
||||
import { AppInfoModel } from "../../constant/config"
|
||||
import { managePbError } from "../../utils/pbTools"
|
||||
import pbClient from "../pbClient"
|
||||
import PbToolBase, { WithExpand } from "../base"
|
||||
|
||||
const DB_NAME = "receiveGroup"
|
||||
|
||||
/**
|
||||
* 接收组接口,定义接收消息的群组数据结构
|
||||
* 用于管理消息接收者分组信息
|
||||
*/
|
||||
export interface ReceiveGroup {
|
||||
/** 接收组名称 */
|
||||
name: string
|
||||
/** 聊天群组ID列表,可选 */
|
||||
chatId?: string[]
|
||||
/** 用户ID列表,可选 */
|
||||
userId?: string[]
|
||||
}
|
||||
|
||||
/**
|
||||
* 接收组模型类型,结合 ReceiveGroup 接口和 PocketBase 的 RecordModel
|
||||
*/
|
||||
export type ReceiveGroupModel = ReceiveGroup & RecordModel
|
||||
|
||||
export interface ReceiveGroupModelWithApp extends ReceiveGroupModel {
|
||||
expand: {
|
||||
app: AppInfoModel
|
||||
/**
|
||||
* 带应用信息的接收组模型类型
|
||||
* 扩展了基础接收组模型,包含关联的应用信息
|
||||
*/
|
||||
export type ReceiveGroupModelWithApp = ReceiveGroupModel &
|
||||
WithExpand<{ app: AppInfoModel }>
|
||||
|
||||
/**
|
||||
* 接收组数据库操作类
|
||||
*
|
||||
* 提供接收组相关的数据库操作,继承自 PbToolBase 基础类
|
||||
* 用于管理消息发送目标群组,支持查询带应用信息的接收组
|
||||
*
|
||||
* @extends PbToolBase<ReceiveGroupModel> 基础数据库操作类
|
||||
*/
|
||||
class ReceiveGroupDB extends PbToolBase<ReceiveGroupModel> {
|
||||
/**
|
||||
* 创建 ReceiveGroupDB 实例
|
||||
*
|
||||
* @param pbClient - PocketBase 客户端实例,用于与数据库通信
|
||||
* @param logger - 日志记录器实例,用于记录操作日志
|
||||
*/
|
||||
constructor(pbClient: PocketBase, logger: Logger) {
|
||||
super(DB_NAME, pbClient, logger)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取带应用信息的接收组
|
||||
*
|
||||
* @param id - 接收组ID
|
||||
* @returns 带应用信息的接收组记录,失败时返回 null
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* const groupWithApp = await receiveGroupDB.getWithApp("group123");
|
||||
* ```
|
||||
*/
|
||||
public getWithApp = (id: string) => {
|
||||
return this.get<ReceiveGroupModelWithApp>(id, { expand: "app" })
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID获取指定消息组
|
||||
* @param id
|
||||
* @returns
|
||||
*/
|
||||
const getOne = (id: string) =>
|
||||
managePbError<ReceiveGroupModelWithApp>(() =>
|
||||
pbClient.collection(DB_NAME).getOne(id, {
|
||||
expand: "app",
|
||||
})
|
||||
)
|
||||
|
||||
const receiveGroup = {
|
||||
getOne,
|
||||
}
|
||||
|
||||
export default receiveGroup
|
||||
export default ReceiveGroupDB
|
||||
|
@ -1,44 +1,66 @@
|
||||
import { RecordModel } from "pocketbase"
|
||||
import PocketBase, { RecordModel } from "pocketbase"
|
||||
import { Logger } from "winston"
|
||||
|
||||
import { managePbError } from "../../utils/pbTools"
|
||||
import pbClient from "../pbClient"
|
||||
import PbToolBase from "../base"
|
||||
|
||||
const DB_NAME = "sheet"
|
||||
|
||||
/**
|
||||
* 表格数据接口,定义了表格的基本属性
|
||||
*/
|
||||
export interface Sheet {
|
||||
/***
|
||||
* 表格区间
|
||||
/**
|
||||
* 表格区间,例如 "A1:Z100"
|
||||
*/
|
||||
range: string
|
||||
/***
|
||||
* 表格Token
|
||||
/**
|
||||
* 表格访问令牌,用于API验证
|
||||
*/
|
||||
sheetToken: string
|
||||
/***
|
||||
* 表格链接
|
||||
/**
|
||||
* 表格的完整URL地址
|
||||
*/
|
||||
sheetUrl: string
|
||||
}
|
||||
|
||||
/**
|
||||
* 表格数据模型类型,继承基础数据接口并添加RecordModel属性
|
||||
*
|
||||
* RecordModel提供了id、created、updated等基础字段
|
||||
*/
|
||||
export type SheetModel = Sheet & RecordModel
|
||||
|
||||
const getByUrl = (sheetUrl: string) =>
|
||||
managePbError<SheetModel>(() =>
|
||||
pbClient.collection(DB_NAME).getFirstListItem(`sheetUrl = "${sheetUrl}"`)
|
||||
)
|
||||
/**
|
||||
* 表格数据库操作类
|
||||
*
|
||||
* 提供表格数据的增删改查及特定查询方法
|
||||
* 继承自PbToolBase类,复用基础CRUD操作
|
||||
*/
|
||||
class SheetDB extends PbToolBase<SheetModel> {
|
||||
/**
|
||||
* 创建表格数据库操作实例
|
||||
*
|
||||
* @param pbClient - PocketBase客户端实例
|
||||
* @param logger - 日志记录器实例
|
||||
*/
|
||||
constructor(pbClient: PocketBase, logger: Logger) {
|
||||
super(DB_NAME, pbClient, logger)
|
||||
}
|
||||
|
||||
const update = (id: string, sheet: Partial<SheetModel>) =>
|
||||
managePbError<SheetModel>(() =>
|
||||
pbClient.collection(DB_NAME).update(id, sheet)
|
||||
)
|
||||
|
||||
const create = (sheet: Sheet) =>
|
||||
managePbError<SheetModel>(() => pbClient.collection(DB_NAME).create(sheet))
|
||||
|
||||
const sheet = {
|
||||
getByUrl,
|
||||
update,
|
||||
create,
|
||||
/**
|
||||
* 根据表格URL获取表格记录
|
||||
*
|
||||
* @param sheetUrl - 表格的URL地址
|
||||
* @returns 成功时返回匹配的表格记录,失败时返回null
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* const sheet = await sheetDB.getByUrl("https://example.com/sheets/12345");
|
||||
* ```
|
||||
*/
|
||||
public getByUrl = (sheetUrl: string) => {
|
||||
return this.getFirstOne(`sheetUrl = "${sheetUrl}"`)
|
||||
}
|
||||
}
|
||||
|
||||
export default sheet
|
||||
export default SheetDB
|
||||
|
@ -1,69 +1,97 @@
|
||||
import { RecordModel } from "pocketbase"
|
||||
import PocketBase, { RecordModel } from "pocketbase"
|
||||
import { Logger } from "winston"
|
||||
|
||||
import { managePbError } from "../../utils/pbTools"
|
||||
import pbClient from "../pbClient"
|
||||
import PbToolBase from "../base"
|
||||
|
||||
const DB_NAME = "soupGame"
|
||||
|
||||
/**
|
||||
* 表示海龟汤游戏的数据结构
|
||||
* 海龟汤是一种推理游戏,玩家根据故事的开头和结局,通过提问来猜测故事完整内容
|
||||
* 存储游戏的基本信息、历史记录和状态
|
||||
*/
|
||||
export interface SoupGame {
|
||||
/** 聊天会话的唯一标识符 */
|
||||
chatId: string
|
||||
/** 海龟汤游戏标题 */
|
||||
title: string
|
||||
/** 游戏的初始问题或谜题 */
|
||||
query: string
|
||||
/** 海龟汤游戏的正确答案或完整故事 */
|
||||
answer: string
|
||||
/** 游戏过程中的提问和回答历史记录 */
|
||||
history: string[]
|
||||
/** 游戏是否处于活跃状态 */
|
||||
active: boolean
|
||||
}
|
||||
|
||||
/**
|
||||
* 海龟汤游戏数据模型类型,继承基本游戏接口和PocketBase记录模型
|
||||
*/
|
||||
export type SoupGameModel = SoupGame & RecordModel
|
||||
|
||||
/**
|
||||
* 创建一个新的SoupGame记录
|
||||
* @param {SoupGame} soupGame - SoupGame对象
|
||||
* @returns {Promise<SoupGameModel>} - 创建的SoupGame记录
|
||||
* 海龟汤游戏数据库操作类
|
||||
* 提供获取、更新和关闭游戏等功能
|
||||
*
|
||||
* @extends PbToolBase<SoupGameModel> 继承PocketBase基础工具类
|
||||
*/
|
||||
const create = (soupGame: SoupGame) =>
|
||||
managePbError<SoupGameModel>(() =>
|
||||
pbClient.collection(DB_NAME).create(soupGame)
|
||||
)
|
||||
class SoupGameDB extends PbToolBase<SoupGameModel> {
|
||||
/**
|
||||
* 创建海龟汤游戏数据库操作实例
|
||||
*
|
||||
* @param pbClient - PocketBase 客户端实例
|
||||
* @param logger - 日志记录器实例
|
||||
*/
|
||||
constructor(pbClient: PocketBase, logger: Logger) {
|
||||
super(DB_NAME, pbClient, logger)
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据chatId获取一个活跃的SoupGame记录
|
||||
* @param {string} chatId - 聊天ID
|
||||
* @returns {Promise<SoupGameModel>} - 获取的SoupGame记录
|
||||
*/
|
||||
const getActiveOneByChatId = (chatId: string) =>
|
||||
managePbError<SoupGameModel>(() =>
|
||||
pbClient
|
||||
.collection(DB_NAME)
|
||||
.getFirstListItem(`chatId = "${chatId}" && active = true`)
|
||||
)
|
||||
/**
|
||||
* 根据聊天ID获取当前活跃的海龟汤游戏
|
||||
*
|
||||
* @param chatId - 聊天会话的唯一标识符
|
||||
* @returns 成功时返回活跃的游戏记录,失败时返回null
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* const activeGame = await soupGameDb.getActiveOneByChatId("chat123");
|
||||
* ```
|
||||
*/
|
||||
public getActiveOneByChatId = (chatId: string) => {
|
||||
return this.getFirstOne(`chatId = "${chatId}" && active = true`)
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据chatId关闭一个SoupGame记录
|
||||
* @param {string} chatId - 聊天ID
|
||||
* @returns {Promise<SoupGameModel>} - 更新的SoupGame记录
|
||||
*/
|
||||
const close = (id: string) =>
|
||||
managePbError<SoupGameModel>(() =>
|
||||
pbClient.collection(DB_NAME).update(id, { active: false })
|
||||
)
|
||||
/**
|
||||
* 关闭指定ID的海龟汤游戏,将其状态设置为非活跃
|
||||
*
|
||||
* @param id - 游戏记录的唯一标识符
|
||||
* @returns 成功时返回更新后的游戏记录,失败时返回null
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* const closedGame = await soupGameDb.close("game123");
|
||||
* ```
|
||||
*/
|
||||
public close = (id: string) => {
|
||||
return this.update(id, { active: false })
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据chatId插入历史记录
|
||||
* @param {string} chatId - 聊天ID
|
||||
* @param {string} history - 历史记录
|
||||
* @returns {Promise<SoupGameModel>} - 更新的SoupGame记录
|
||||
*/
|
||||
const insertHistory = (id: string, history: string[]) =>
|
||||
managePbError<SoupGameModel>(() =>
|
||||
pbClient.collection(DB_NAME).update(id, { history })
|
||||
)
|
||||
|
||||
const soupGame = {
|
||||
create,
|
||||
getActiveOneByChatId,
|
||||
close,
|
||||
insertHistory,
|
||||
/**
|
||||
* 覆盖更新指定海龟汤游戏的历史记录
|
||||
*
|
||||
* @param id - 游戏记录的唯一标识符
|
||||
* @param history - 新的历史记录数组,包含玩家提问和回答
|
||||
* @returns 成功时返回更新后的游戏记录,失败时返回null
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* const updatedGame = await soupGameDb.overrideHistory("game123", ["问题1", "回答1", "问题2", "回答2"]);
|
||||
* ```
|
||||
*/
|
||||
public overrideHistory = (id: string, history: string[]) => {
|
||||
return this.update(id, { history })
|
||||
}
|
||||
}
|
||||
|
||||
export default soupGame
|
||||
export default SoupGameDB
|
||||
|
140
db/user/index.ts
140
db/user/index.ts
@ -1,83 +1,103 @@
|
||||
import { RecordModel } from "pocketbase"
|
||||
import PocketBase, { RecordModel } from "pocketbase"
|
||||
import { Logger } from "winston"
|
||||
|
||||
import { Context } from "../../types"
|
||||
import { managePbError } from "../../utils/pbTools"
|
||||
import pbClient from "../pbClient"
|
||||
import PbToolBase from "../base"
|
||||
|
||||
const DB_NAME = "users"
|
||||
|
||||
// 用户接口定义
|
||||
/**
|
||||
* 用户基础信息接口定义
|
||||
*/
|
||||
interface User {
|
||||
/** 用户邮箱 */
|
||||
email: string
|
||||
/** 用户名称 */
|
||||
name: string
|
||||
/** 飞书用户 Open ID */
|
||||
openId: string
|
||||
/** 飞书用户 User ID */
|
||||
userId: string
|
||||
/** 用户头像链接 */
|
||||
avatar: string
|
||||
/** 用户密码 */
|
||||
password: string
|
||||
/** 邮箱可见性标志 */
|
||||
emailVisibility: boolean
|
||||
/** 用户邮箱是否已验证 */
|
||||
verified: boolean
|
||||
}
|
||||
|
||||
// 用户模型类型
|
||||
/** 完整用户模型类型,包含 PocketBase 记录基础字段 */
|
||||
export type UserModel = User & RecordModel
|
||||
|
||||
/**
|
||||
* 创建用户
|
||||
* @param {User} user - 用户信息
|
||||
* @returns {Promise<UserModel>} - 创建的用户模型
|
||||
* 用户数据库操作类
|
||||
* 提供用户相关的查询、创建等操作
|
||||
*/
|
||||
const create = async (user: User) =>
|
||||
managePbError<UserModel>(() => pbClient.collection(DB_NAME).create(user))
|
||||
|
||||
/**
|
||||
* 通过用户ID获取用户
|
||||
* @param {string} userId - 用户ID
|
||||
* @returns {Promise<UserModel | null>} - 用户模型或null
|
||||
*/
|
||||
const getByUserId = async (userId: string) =>
|
||||
managePbError<UserModel>(() =>
|
||||
pbClient.collection(DB_NAME).getFirstListItem(`userId = "${userId}"`)
|
||||
)
|
||||
|
||||
/**
|
||||
* 通过上下文获取用户
|
||||
* @param {Context} context - 上下文对象
|
||||
* @returns {Promise<UserModel | null>} - 用户模型或null
|
||||
*/
|
||||
const getByCtx = async ({ larkBody, larkService }: Context) => {
|
||||
if (!larkBody.userId) return null
|
||||
// 先从数据库获取用户信息
|
||||
const user = await getByUserId(larkBody.userId)
|
||||
if (user) return user
|
||||
// 如果数据库中没有用户信息,从larkService获取用户信息
|
||||
const userInfo = await larkService.user.getOne(larkBody.userId, "user_id")
|
||||
if (userInfo.code === 0) return null
|
||||
// 解构用户信息
|
||||
const {
|
||||
user_id,
|
||||
open_id,
|
||||
avatar: { avatar_origin },
|
||||
email,
|
||||
name,
|
||||
} = userInfo.data.user
|
||||
const newUser = {
|
||||
userId: user_id,
|
||||
openId: open_id,
|
||||
avatar: avatar_origin,
|
||||
email,
|
||||
name,
|
||||
emailVisibility: false,
|
||||
verified: false,
|
||||
password: email,
|
||||
class UserDB extends PbToolBase<UserModel> {
|
||||
/**
|
||||
* 创建用户数据库操作实例
|
||||
*
|
||||
* @param pbClient - PocketBase 客户端实例
|
||||
* @param logger - 日志记录器实例
|
||||
*/
|
||||
constructor(pbClient: PocketBase, logger: Logger) {
|
||||
super(DB_NAME, pbClient, logger)
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据飞书用户 ID 获取用户记录
|
||||
*
|
||||
* @param userId - 飞书用户 ID
|
||||
* @returns 成功时返回用户记录,失败时返回 null
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* const user = await userDB.getByUserId("ou_123456");
|
||||
* ```
|
||||
*/
|
||||
public getByUserId = (userId: string) => {
|
||||
return this.getFirstOne(`userId = "${userId}"`)
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据请求上下文获取用户信息
|
||||
* 如果用户不存在,则尝试从飞书获取用户信息并创建新用户
|
||||
*
|
||||
* @param context - 请求上下文,包含飞书请求体和飞书服务
|
||||
* @returns 成功时返回用户记录,失败时返回 null
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* const user = await userDB.getByCtx(ctx);
|
||||
* ```
|
||||
*/
|
||||
public getByCtx = async ({ larkBody, larkService }: Context) => {
|
||||
if (!larkBody.userId) return null
|
||||
const user = await this.getByUserId(larkBody.userId)
|
||||
if (user) return user
|
||||
const userInfo = await larkService.user.getOne(larkBody.userId, "user_id")
|
||||
if (userInfo.code === 0) return null
|
||||
const {
|
||||
user_id,
|
||||
open_id,
|
||||
avatar: { avatar_origin },
|
||||
email,
|
||||
name,
|
||||
} = userInfo.data.user
|
||||
const newUser = {
|
||||
userId: user_id,
|
||||
openId: open_id,
|
||||
avatar: avatar_origin,
|
||||
email,
|
||||
name,
|
||||
emailVisibility: false,
|
||||
verified: false,
|
||||
password: email,
|
||||
}
|
||||
return await this.create(newUser)
|
||||
}
|
||||
// 创建新用户
|
||||
return await create(newUser)
|
||||
}
|
||||
|
||||
// 用户对象
|
||||
const user = {
|
||||
getByCtx,
|
||||
getByUserId,
|
||||
}
|
||||
|
||||
export default user
|
||||
export default UserDB
|
||||
|
22
package.json
22
package.json
@ -17,37 +17,37 @@
|
||||
]
|
||||
},
|
||||
"devDependencies": {
|
||||
"@commitlint/cli": "^19.7.1",
|
||||
"@commitlint/config-conventional": "^19.7.1",
|
||||
"@eslint/js": "^9.21.0",
|
||||
"@commitlint/cli": "^19.8.0",
|
||||
"@commitlint/config-conventional": "^19.8.0",
|
||||
"@eslint/js": "^9.22.0",
|
||||
"@types/jsdom": "^21.1.7",
|
||||
"@types/node-schedule": "^2.1.7",
|
||||
"@types/uuid": "^10.0.0",
|
||||
"bun-types": "^1.2.4",
|
||||
"eslint": "^9.21.0",
|
||||
"bun-types": "^1.2.5",
|
||||
"eslint": "^9.22.0",
|
||||
"eslint-plugin-simple-import-sort": "^12.1.1",
|
||||
"eslint-plugin-unused-imports": "^4.1.4",
|
||||
"husky": "^9.1.7",
|
||||
"lint-staged": "^15.4.3",
|
||||
"lint-staged": "^15.5.0",
|
||||
"oxlint": "^0.13.2",
|
||||
"prettier": "^3.5.3",
|
||||
"typescript-eslint": "^8.26.0"
|
||||
"typescript-eslint": "^8.26.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"typescript": "^5.5.4"
|
||||
"typescript": "^5.8.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"@egg/hooks": "^1.2.0",
|
||||
"@egg/lark-msg-tool": "^1.21.0",
|
||||
"@egg/logger": "^1.6.0",
|
||||
"@egg/net-tool": "^1.31.2",
|
||||
"@egg/net-tool": "^1.32.2",
|
||||
"@egg/path-tool": "^1.4.1",
|
||||
"@langchain/core": "^0.3.42",
|
||||
"@langchain/langgraph": "^0.2.53",
|
||||
"@langchain/langgraph": "^0.2.56",
|
||||
"@langchain/openai": "^0.3.17",
|
||||
"joi": "^17.13.3",
|
||||
"jsdom": "^26.0.0",
|
||||
"langfuse-langchain": "^3.36.0",
|
||||
"langfuse-langchain": "^3.37.0",
|
||||
"node-schedule": "^2.1.1",
|
||||
"p-limit": "^6.2.0",
|
||||
"pocketbase": "^0.23.0",
|
||||
|
@ -92,42 +92,53 @@ const manageIntent = async (ctx: Context) => {
|
||||
return
|
||||
}
|
||||
switch (intentRes.intent) {
|
||||
// 获取聊天ID
|
||||
case 3:
|
||||
await message.updateOrReply(
|
||||
larkCard.genTempCard("chatId", { chat_id: chatId }) as string
|
||||
)
|
||||
break
|
||||
// CI监控
|
||||
case 4:
|
||||
await attachService.ciMonitor(chatId)
|
||||
break
|
||||
// 获取帮助
|
||||
case 6:
|
||||
await message.updateOrReply(
|
||||
larkCard.genTempCard("eggGuide", { chat_id: chatId }) as string
|
||||
)
|
||||
break
|
||||
// 开启日报订阅
|
||||
case 7:
|
||||
groupAgent.report.setSubscription(ctx, "daily", true).catch(() => null)
|
||||
break
|
||||
// 开启周报订阅
|
||||
case 8:
|
||||
groupAgent.report.setSubscription(ctx, "weekly", true).catch(() => null)
|
||||
break
|
||||
// 关闭日报订阅
|
||||
case 9:
|
||||
groupAgent.report.setSubscription(ctx, "daily", false).catch(() => null)
|
||||
break
|
||||
// 关闭周报订阅
|
||||
case 10:
|
||||
groupAgent.report
|
||||
.setSubscription(ctx, "weekly", false)
|
||||
.catch(() => null)
|
||||
break
|
||||
// 生成日报
|
||||
case 11:
|
||||
groupAgent.report.gen4Test(ctx, "daily").catch(() => null)
|
||||
break
|
||||
// 生成周报
|
||||
case 12:
|
||||
groupAgent.report.gen4Test(ctx, "weekly").catch(() => null)
|
||||
break
|
||||
// 开始海龟汤游戏
|
||||
case 13:
|
||||
soupAgent.startOrStopGame(ctx, true, "manual").catch(() => null)
|
||||
break
|
||||
// 默认为使用群聊上下文的意图
|
||||
case 1:
|
||||
default:
|
||||
groupAgent.agent(ctx).catch(() => null)
|
||||
|
@ -1,7 +1,6 @@
|
||||
import { stringifyJson } from "@egg/hooks"
|
||||
import { LarkService } from "@egg/net-tool"
|
||||
|
||||
import db from "../../db"
|
||||
import { Log } from "../../db/log"
|
||||
import { Context, LarkServer, MsgProxy } from "../../types"
|
||||
import genLarkService from "../../utils/genLarkService"
|
||||
@ -44,7 +43,7 @@ const validateMessageReq = ({ body, genResp }: Context): false | Response => {
|
||||
* @returns {Promise<Response>} 返回响应对象
|
||||
*/
|
||||
export const manageMessageReq = async (ctx: Context): Promise<Response> => {
|
||||
const { body: rawBody, genResp, requestId } = ctx
|
||||
const { body: rawBody, genResp, requestId, db } = ctx
|
||||
const body = rawBody as MsgProxy.Body
|
||||
|
||||
// 校验参数
|
||||
@ -84,7 +83,7 @@ export const manageMessageReq = async (ctx: Context): Promise<Response> => {
|
||||
|
||||
if (body.api_key) {
|
||||
// 校验 api_key
|
||||
const apiKeyInfo = await db.apiKey.getOne(body.api_key)
|
||||
const apiKeyInfo = await db.apiKey.getWithApp(body.api_key)
|
||||
if (!apiKeyInfo) {
|
||||
const error = "api key not found"
|
||||
await db.log.create({ ...baseLog, error })
|
||||
@ -98,7 +97,7 @@ export const manageMessageReq = async (ctx: Context): Promise<Response> => {
|
||||
// 如果有 group_id,则发送给所有 group_id 中的人
|
||||
if (body.group_id) {
|
||||
// 获取所有接收者
|
||||
const group = await db.receiveGroup.getOne(body.group_id!)
|
||||
const group = await db.receiveGroup.getWithApp(body.group_id!)
|
||||
if (!group) {
|
||||
const error = "message group not found"
|
||||
await db.log.create({ ...baseLog, error })
|
||||
|
@ -3,7 +3,6 @@ import Joi from "joi"
|
||||
|
||||
import { APP_MAP } from "../../constant/config"
|
||||
import insertSheet from "../../controller/sheet/insert"
|
||||
import db from "../../db"
|
||||
import { Context } from "../../types"
|
||||
import { SheetProxy } from "../../types/sheetProxy"
|
||||
|
||||
@ -65,7 +64,7 @@ const validateSheetReq = async ({
|
||||
* @returns {Promise<Response>} 返回响应对象
|
||||
*/
|
||||
export const manageSheetReq = async (ctx: Context): Promise<Response> => {
|
||||
const { body: rawBody, genResp, requestId } = ctx
|
||||
const { body: rawBody, genResp, requestId, db } = ctx
|
||||
const body = rawBody as SheetProxy.InsertData
|
||||
|
||||
// 校验参数
|
||||
@ -73,7 +72,7 @@ export const manageSheetReq = async (ctx: Context): Promise<Response> => {
|
||||
if (validateRes) return validateRes
|
||||
|
||||
// 校验 api_key
|
||||
const apiKeyInfo = await db.apiKey.getOne(body.api_key)
|
||||
const apiKeyInfo = await db.apiKey.getWithApp(body.api_key)
|
||||
if (!apiKeyInfo) {
|
||||
return genResp.notFound("api key not found")
|
||||
}
|
||||
|
@ -1,5 +1,14 @@
|
||||
import db from "../../db"
|
||||
import initAppConfig from "../../constant/config"
|
||||
import DB from "../../db"
|
||||
import pbClient from "../../db/pbClient"
|
||||
import { genContextManually } from "../../utils/genContext"
|
||||
|
||||
const res = await db.apiKey.getOne("uwnpzb9hvoft28h")
|
||||
await initAppConfig()
|
||||
|
||||
const ctx = await genContextManually()
|
||||
|
||||
const dbInstance = new DB(pbClient, ctx.logger)
|
||||
|
||||
const res = await dbInstance.apiKey.getWithApp("uwnpzb9hvoft28h")
|
||||
|
||||
console.log("🚀 ~ res", res)
|
||||
|
@ -7,6 +7,7 @@ import cardMap from "../constant/card"
|
||||
import { AppInfoModel } from "../constant/config"
|
||||
import functionMap from "../constant/function"
|
||||
import tempMap from "../constant/template"
|
||||
import DB from "../db"
|
||||
import { AttachService } from "../services"
|
||||
|
||||
export interface Context {
|
||||
@ -26,4 +27,5 @@ export interface Context {
|
||||
headers: Headers
|
||||
app: "michat" | "egg" | string
|
||||
appInfo: AppInfoModel
|
||||
db: DB
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import cardMap from "../constant/card"
|
||||
import { APP_CONFIG, APP_MAP } from "../constant/config"
|
||||
import functionMap from "../constant/function"
|
||||
import tempMap from "../constant/template"
|
||||
import DB from "../db"
|
||||
import { AttachService } from "../services"
|
||||
import { Context } from "../types"
|
||||
import genLarkService from "./genLarkService"
|
||||
@ -58,6 +59,7 @@ const genContext = async (req: Request, rId?: string) => {
|
||||
})
|
||||
const attachService = new AttachService({ requestId })
|
||||
const path = new PathCheckTool(req.url)
|
||||
const db = new DB(logger)
|
||||
const larkCard = new LarkCard(
|
||||
"egg",
|
||||
false,
|
||||
@ -84,6 +86,7 @@ const genContext = async (req: Request, rId?: string) => {
|
||||
headers,
|
||||
app,
|
||||
appInfo,
|
||||
db,
|
||||
} as Context
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user