@luckylillia-dev/luckylillia 0.0.0-stage → 9.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/chunks/preload-helper-D5R8FHQt.js +342 -0
- package/chunks/preload-helper-D5R8FHQt.js.map +1 -0
- package/default_config.json +83 -0
- package/llbot-core.js +35013 -0
- package/llbot-core.js.map +1 -0
- package/llbot.js +138 -0
- package/llbot.js.map +1 -0
- package/node_modules/@luckylillia-dev/plugin-sdk/lib/commands.d.ts +86 -0
- package/node_modules/@luckylillia-dev/plugin-sdk/lib/commands.js +1 -0
- package/node_modules/@luckylillia-dev/plugin-sdk/lib/config.d.ts +14 -0
- package/node_modules/@luckylillia-dev/plugin-sdk/lib/config.js +1 -0
- package/node_modules/@luckylillia-dev/plugin-sdk/lib/ffmpeg.d.ts +41 -0
- package/node_modules/@luckylillia-dev/plugin-sdk/lib/ffmpeg.js +1 -0
- package/node_modules/@luckylillia-dev/plugin-sdk/lib/http.d.ts +88 -0
- package/node_modules/@luckylillia-dev/plugin-sdk/lib/http.js +1 -0
- package/node_modules/@luckylillia-dev/plugin-sdk/lib/index.d.ts +17 -0
- package/node_modules/@luckylillia-dev/plugin-sdk/lib/index.js +6 -0
- package/node_modules/@luckylillia-dev/plugin-sdk/lib/internal.d.ts +430 -0
- package/node_modules/@luckylillia-dev/plugin-sdk/lib/internal.js +7 -0
- package/node_modules/@luckylillia-dev/plugin-sdk/lib/manifest.d.ts +68 -0
- package/node_modules/@luckylillia-dev/plugin-sdk/lib/manifest.js +1 -0
- package/node_modules/@luckylillia-dev/plugin-sdk/lib/server.d.ts +23 -0
- package/node_modules/@luckylillia-dev/plugin-sdk/lib/server.js +1 -0
- package/node_modules/@luckylillia-dev/plugin-sdk/lib/storage.d.ts +21 -0
- package/node_modules/@luckylillia-dev/plugin-sdk/lib/storage.js +1 -0
- package/node_modules/@luckylillia-dev/plugin-sdk/lib/testing.d.ts +71 -0
- package/node_modules/@luckylillia-dev/plugin-sdk/lib/testing.js +1123 -0
- package/node_modules/@luckylillia-dev/plugin-sdk/lib/universal.d.ts +299 -0
- package/node_modules/@luckylillia-dev/plugin-sdk/lib/universal.js +1 -0
- package/node_modules/@luckylillia-dev/plugin-sdk/lib/webui.d.ts +762 -0
- package/node_modules/@luckylillia-dev/plugin-sdk/lib/webui.js +9 -0
- package/node_modules/@luckylillia-dev/plugin-sdk/package.json +63 -0
- package/node_modules/@satorijs/element/jsx-dev-runtime.d.ts +3 -0
- package/node_modules/@satorijs/element/jsx-runtime.d.ts +3 -0
- package/node_modules/@satorijs/element/lib/index.cjs +447 -0
- package/node_modules/@satorijs/element/lib/index.d.ts +116 -0
- package/node_modules/@satorijs/element/lib/index.mjs +455 -0
- package/node_modules/@satorijs/element/package.json +60 -0
- package/node_modules/@satorijs/element/src/index.ts +559 -0
- package/node_modules/@satorijs/protocol/lib/index.cjs +187 -0
- package/node_modules/@satorijs/protocol/lib/index.d.ts +328 -0
- package/node_modules/@satorijs/protocol/lib/index.mjs +148 -0
- package/node_modules/@satorijs/protocol/package.json +44 -0
- package/node_modules/@satorijs/protocol/src/index.ts +513 -0
- package/node_modules/@standard-schema/spec/LICENSE +21 -0
- package/node_modules/@standard-schema/spec/README.md +198 -0
- package/node_modules/@standard-schema/spec/dist/index.cjs +18 -0
- package/node_modules/@standard-schema/spec/dist/index.d.cts +119 -0
- package/node_modules/@standard-schema/spec/dist/index.d.ts +119 -0
- package/node_modules/@standard-schema/spec/dist/index.js +0 -0
- package/node_modules/@standard-schema/spec/package.json +52 -0
- package/node_modules/cordis/README.md +10 -0
- package/node_modules/cordis/bin.js +16 -0
- package/node_modules/cordis/lib/context.d.ts +32 -0
- package/node_modules/cordis/lib/events.d.ts +62 -0
- package/node_modules/cordis/lib/fiber.d.ts +85 -0
- package/node_modules/cordis/lib/index.d.ts +7 -0
- package/node_modules/cordis/lib/index.js +1577 -0
- package/node_modules/cordis/lib/logger.d.ts +74 -0
- package/node_modules/cordis/lib/reflect.d.ts +54 -0
- package/node_modules/cordis/lib/registry.d.ts +78 -0
- package/node_modules/cordis/lib/service.d.ts +19 -0
- package/node_modules/cordis/lib/utils.d.ts +50 -0
- package/node_modules/cordis/package.json +49 -0
- package/node_modules/cosmokit/LICENSE +21 -0
- package/node_modules/cosmokit/README.md +24 -0
- package/node_modules/cosmokit/lib/index.cjs +419 -0
- package/node_modules/cosmokit/lib/index.cjs.map +6 -0
- package/node_modules/cosmokit/lib/index.d.ts +142 -0
- package/node_modules/cosmokit/lib/index.mjs +357 -0
- package/node_modules/cosmokit/lib/index.mjs.map +6 -0
- package/node_modules/cosmokit/package.json +57 -0
- package/node_modules/cosmokit/src/array.ts +35 -0
- package/node_modules/cosmokit/src/index.ts +5 -0
- package/node_modules/cosmokit/src/misc.ts +57 -0
- package/node_modules/cosmokit/src/string.ts +101 -0
- package/node_modules/cosmokit/src/time.ts +91 -0
- package/node_modules/cosmokit/src/types.ts +131 -0
- package/node_modules/schemastery/README.md +342 -0
- package/node_modules/schemastery/lib/index.cjs +648 -0
- package/node_modules/schemastery/lib/index.cjs.map +6 -0
- package/node_modules/schemastery/lib/index.d.ts +138 -0
- package/node_modules/schemastery/lib/index.mjs +656 -0
- package/node_modules/schemastery/lib/index.mjs.map +6 -0
- package/node_modules/schemastery/package.json +32 -0
- package/node_modules/schemastery/src/index.ts +841 -0
- package/node_modules/undici/LICENSE +21 -0
- package/node_modules/undici/README.md +741 -0
- package/node_modules/undici/docs/docs/api/Agent.md +84 -0
- package/node_modules/undici/docs/docs/api/BalancedPool.md +99 -0
- package/node_modules/undici/docs/docs/api/CacheStorage.md +30 -0
- package/node_modules/undici/docs/docs/api/CacheStore.md +164 -0
- package/node_modules/undici/docs/docs/api/Client.md +290 -0
- package/node_modules/undici/docs/docs/api/ClientStats.md +27 -0
- package/node_modules/undici/docs/docs/api/Connector.md +115 -0
- package/node_modules/undici/docs/docs/api/ContentType.md +57 -0
- package/node_modules/undici/docs/docs/api/Cookies.md +128 -0
- package/node_modules/undici/docs/docs/api/Debug.md +62 -0
- package/node_modules/undici/docs/docs/api/DiagnosticsChannel.md +317 -0
- package/node_modules/undici/docs/docs/api/Dispatcher.md +1393 -0
- package/node_modules/undici/docs/docs/api/EnvHttpProxyAgent.md +159 -0
- package/node_modules/undici/docs/docs/api/Errors.md +49 -0
- package/node_modules/undici/docs/docs/api/EventSource.md +45 -0
- package/node_modules/undici/docs/docs/api/Fetch.md +60 -0
- package/node_modules/undici/docs/docs/api/GlobalInstallation.md +139 -0
- package/node_modules/undici/docs/docs/api/H2CClient.md +263 -0
- package/node_modules/undici/docs/docs/api/MockAgent.md +603 -0
- package/node_modules/undici/docs/docs/api/MockCallHistory.md +197 -0
- package/node_modules/undici/docs/docs/api/MockCallHistoryLog.md +43 -0
- package/node_modules/undici/docs/docs/api/MockClient.md +81 -0
- package/node_modules/undici/docs/docs/api/MockErrors.md +12 -0
- package/node_modules/undici/docs/docs/api/MockPool.md +555 -0
- package/node_modules/undici/docs/docs/api/Pool.md +84 -0
- package/node_modules/undici/docs/docs/api/PoolStats.md +35 -0
- package/node_modules/undici/docs/docs/api/ProxyAgent.md +229 -0
- package/node_modules/undici/docs/docs/api/RedirectHandler.md +93 -0
- package/node_modules/undici/docs/docs/api/RetryAgent.md +50 -0
- package/node_modules/undici/docs/docs/api/RetryHandler.md +118 -0
- package/node_modules/undici/docs/docs/api/RoundRobinPool.md +145 -0
- package/node_modules/undici/docs/docs/api/SnapshotAgent.md +616 -0
- package/node_modules/undici/docs/docs/api/Socks5ProxyAgent.md +275 -0
- package/node_modules/undici/docs/docs/api/Util.md +25 -0
- package/node_modules/undici/docs/docs/api/WebSocket.md +141 -0
- package/node_modules/undici/docs/docs/api/api-lifecycle.md +91 -0
- package/node_modules/undici/docs/docs/best-practices/client-certificate.md +64 -0
- package/node_modules/undici/docs/docs/best-practices/crawling.md +58 -0
- package/node_modules/undici/docs/docs/best-practices/mocking-request.md +190 -0
- package/node_modules/undici/docs/docs/best-practices/proxy.md +127 -0
- package/node_modules/undici/docs/docs/best-practices/undici-vs-builtin-fetch.md +224 -0
- package/node_modules/undici/docs/docs/best-practices/writing-tests.md +63 -0
- package/node_modules/undici/index-fetch.js +65 -0
- package/node_modules/undici/index.d.ts +3 -0
- package/node_modules/undici/index.js +234 -0
- package/node_modules/undici/lib/api/abort-signal.js +59 -0
- package/node_modules/undici/lib/api/api-connect.js +110 -0
- package/node_modules/undici/lib/api/api-pipeline.js +252 -0
- package/node_modules/undici/lib/api/api-request.js +214 -0
- package/node_modules/undici/lib/api/api-stream.js +209 -0
- package/node_modules/undici/lib/api/api-upgrade.js +111 -0
- package/node_modules/undici/lib/api/index.js +7 -0
- package/node_modules/undici/lib/api/readable.js +580 -0
- package/node_modules/undici/lib/cache/memory-cache-store.js +279 -0
- package/node_modules/undici/lib/cache/sqlite-cache-store.js +467 -0
- package/node_modules/undici/lib/core/connect.js +159 -0
- package/node_modules/undici/lib/core/constants.js +143 -0
- package/node_modules/undici/lib/core/diagnostics.js +227 -0
- package/node_modules/undici/lib/core/errors.js +477 -0
- package/node_modules/undici/lib/core/request.js +485 -0
- package/node_modules/undici/lib/core/socks5-client.js +422 -0
- package/node_modules/undici/lib/core/socks5-utils.js +212 -0
- package/node_modules/undici/lib/core/symbols.js +76 -0
- package/node_modules/undici/lib/core/tree.js +160 -0
- package/node_modules/undici/lib/core/util.js +992 -0
- package/node_modules/undici/lib/dispatcher/agent.js +162 -0
- package/node_modules/undici/lib/dispatcher/balanced-pool.js +221 -0
- package/node_modules/undici/lib/dispatcher/client-h1.js +1744 -0
- package/node_modules/undici/lib/dispatcher/client-h2.js +1056 -0
- package/node_modules/undici/lib/dispatcher/client.js +669 -0
- package/node_modules/undici/lib/dispatcher/dispatcher-base.js +196 -0
- package/node_modules/undici/lib/dispatcher/dispatcher.js +48 -0
- package/node_modules/undici/lib/dispatcher/env-http-proxy-agent.js +146 -0
- package/node_modules/undici/lib/dispatcher/fixed-queue.js +135 -0
- package/node_modules/undici/lib/dispatcher/h2c-client.js +51 -0
- package/node_modules/undici/lib/dispatcher/pool-base.js +214 -0
- package/node_modules/undici/lib/dispatcher/pool.js +118 -0
- package/node_modules/undici/lib/dispatcher/proxy-agent.js +319 -0
- package/node_modules/undici/lib/dispatcher/retry-agent.js +35 -0
- package/node_modules/undici/lib/dispatcher/round-robin-pool.js +137 -0
- package/node_modules/undici/lib/dispatcher/socks5-proxy-agent.js +260 -0
- package/node_modules/undici/lib/encoding/index.js +33 -0
- package/node_modules/undici/lib/global.js +59 -0
- package/node_modules/undici/lib/handler/cache-handler.js +824 -0
- package/node_modules/undici/lib/handler/cache-revalidation-handler.js +124 -0
- package/node_modules/undici/lib/handler/decorator-handler.js +67 -0
- package/node_modules/undici/lib/handler/deduplication-handler.js +504 -0
- package/node_modules/undici/lib/handler/redirect-handler.js +245 -0
- package/node_modules/undici/lib/handler/retry-handler.js +504 -0
- package/node_modules/undici/lib/handler/unwrap-handler.js +106 -0
- package/node_modules/undici/lib/handler/wrap-handler.js +105 -0
- package/node_modules/undici/lib/interceptor/cache.js +621 -0
- package/node_modules/undici/lib/interceptor/decompress.js +561 -0
- package/node_modules/undici/lib/interceptor/deduplicate.js +117 -0
- package/node_modules/undici/lib/interceptor/dns.js +571 -0
- package/node_modules/undici/lib/interceptor/dump.js +99 -0
- package/node_modules/undici/lib/interceptor/redirect.js +21 -0
- package/node_modules/undici/lib/interceptor/response-error.js +95 -0
- package/node_modules/undici/lib/interceptor/retry.js +19 -0
- package/node_modules/undici/lib/llhttp/constants.d.ts +195 -0
- package/node_modules/undici/lib/llhttp/constants.js +531 -0
- package/node_modules/undici/lib/llhttp/llhttp-wasm.js +15 -0
- package/node_modules/undici/lib/llhttp/llhttp_simd-wasm.js +15 -0
- package/node_modules/undici/lib/llhttp/utils.d.ts +2 -0
- package/node_modules/undici/lib/llhttp/utils.js +12 -0
- package/node_modules/undici/lib/mock/mock-agent.js +232 -0
- package/node_modules/undici/lib/mock/mock-call-history.js +248 -0
- package/node_modules/undici/lib/mock/mock-client.js +68 -0
- package/node_modules/undici/lib/mock/mock-errors.js +29 -0
- package/node_modules/undici/lib/mock/mock-interceptor.js +209 -0
- package/node_modules/undici/lib/mock/mock-pool.js +68 -0
- package/node_modules/undici/lib/mock/mock-symbols.js +32 -0
- package/node_modules/undici/lib/mock/mock-utils.js +486 -0
- package/node_modules/undici/lib/mock/pending-interceptors-formatter.js +43 -0
- package/node_modules/undici/lib/mock/snapshot-agent.js +353 -0
- package/node_modules/undici/lib/mock/snapshot-recorder.js +588 -0
- package/node_modules/undici/lib/mock/snapshot-utils.js +158 -0
- package/node_modules/undici/lib/util/cache.js +676 -0
- package/node_modules/undici/lib/util/date.js +670 -0
- package/node_modules/undici/lib/util/promise.js +28 -0
- package/node_modules/undici/lib/util/runtime-features.js +124 -0
- package/node_modules/undici/lib/util/stats.js +32 -0
- package/node_modules/undici/lib/util/timers.js +425 -0
- package/node_modules/undici/lib/web/cache/cache.js +864 -0
- package/node_modules/undici/lib/web/cache/cachestorage.js +152 -0
- package/node_modules/undici/lib/web/cache/util.js +45 -0
- package/node_modules/undici/lib/web/cookies/constants.js +12 -0
- package/node_modules/undici/lib/web/cookies/index.js +201 -0
- package/node_modules/undici/lib/web/cookies/parse.js +315 -0
- package/node_modules/undici/lib/web/cookies/util.js +371 -0
- package/node_modules/undici/lib/web/eventsource/eventsource-stream.js +575 -0
- package/node_modules/undici/lib/web/eventsource/eventsource.js +504 -0
- package/node_modules/undici/lib/web/eventsource/util.js +29 -0
- package/node_modules/undici/lib/web/fetch/LICENSE +21 -0
- package/node_modules/undici/lib/web/fetch/body.js +509 -0
- package/node_modules/undici/lib/web/fetch/constants.js +131 -0
- package/node_modules/undici/lib/web/fetch/data-url.js +596 -0
- package/node_modules/undici/lib/web/fetch/formdata-parser.js +586 -0
- package/node_modules/undici/lib/web/fetch/formdata.js +259 -0
- package/node_modules/undici/lib/web/fetch/global.js +40 -0
- package/node_modules/undici/lib/web/fetch/headers.js +719 -0
- package/node_modules/undici/lib/web/fetch/index.js +2413 -0
- package/node_modules/undici/lib/web/fetch/request.js +1115 -0
- package/node_modules/undici/lib/web/fetch/response.js +641 -0
- package/node_modules/undici/lib/web/fetch/util.js +1522 -0
- package/node_modules/undici/lib/web/infra/index.js +243 -0
- package/node_modules/undici/lib/web/subresource-integrity/Readme.md +9 -0
- package/node_modules/undici/lib/web/subresource-integrity/subresource-integrity.js +307 -0
- package/node_modules/undici/lib/web/webidl/index.js +1006 -0
- package/node_modules/undici/lib/web/websocket/connection.js +339 -0
- package/node_modules/undici/lib/web/websocket/constants.js +126 -0
- package/node_modules/undici/lib/web/websocket/events.js +331 -0
- package/node_modules/undici/lib/web/websocket/frame.js +133 -0
- package/node_modules/undici/lib/web/websocket/permessage-deflate.js +105 -0
- package/node_modules/undici/lib/web/websocket/receiver.js +520 -0
- package/node_modules/undici/lib/web/websocket/sender.js +109 -0
- package/node_modules/undici/lib/web/websocket/stream/websocketerror.js +104 -0
- package/node_modules/undici/lib/web/websocket/stream/websocketstream.js +496 -0
- package/node_modules/undici/lib/web/websocket/util.js +347 -0
- package/node_modules/undici/lib/web/websocket/websocket.js +758 -0
- package/node_modules/undici/package.json +152 -0
- package/node_modules/undici/scripts/strip-comments.js +10 -0
- package/node_modules/undici/types/README.md +6 -0
- package/node_modules/undici/types/agent.d.ts +32 -0
- package/node_modules/undici/types/api.d.ts +43 -0
- package/node_modules/undici/types/balanced-pool.d.ts +30 -0
- package/node_modules/undici/types/cache-interceptor.d.ts +179 -0
- package/node_modules/undici/types/cache.d.ts +36 -0
- package/node_modules/undici/types/client-stats.d.ts +15 -0
- package/node_modules/undici/types/client.d.ts +153 -0
- package/node_modules/undici/types/connector.d.ts +36 -0
- package/node_modules/undici/types/content-type.d.ts +21 -0
- package/node_modules/undici/types/cookies.d.ts +30 -0
- package/node_modules/undici/types/diagnostics-channel.d.ts +74 -0
- package/node_modules/undici/types/dispatcher.d.ts +275 -0
- package/node_modules/undici/types/env-http-proxy-agent.d.ts +22 -0
- package/node_modules/undici/types/errors.d.ts +177 -0
- package/node_modules/undici/types/eventsource.d.ts +66 -0
- package/node_modules/undici/types/fetch.d.ts +231 -0
- package/node_modules/undici/types/formdata.d.ts +114 -0
- package/node_modules/undici/types/global-dispatcher.d.ts +9 -0
- package/node_modules/undici/types/global-origin.d.ts +7 -0
- package/node_modules/undici/types/h2c-client.d.ts +73 -0
- package/node_modules/undici/types/handlers.d.ts +14 -0
- package/node_modules/undici/types/header.d.ts +160 -0
- package/node_modules/undici/types/index.d.ts +91 -0
- package/node_modules/undici/types/interceptors.d.ts +82 -0
- package/node_modules/undici/types/mock-agent.d.ts +68 -0
- package/node_modules/undici/types/mock-call-history.d.ts +111 -0
- package/node_modules/undici/types/mock-client.d.ts +27 -0
- package/node_modules/undici/types/mock-errors.d.ts +12 -0
- package/node_modules/undici/types/mock-interceptor.d.ts +94 -0
- package/node_modules/undici/types/mock-pool.d.ts +27 -0
- package/node_modules/undici/types/patch.d.ts +29 -0
- package/node_modules/undici/types/pool-stats.d.ts +19 -0
- package/node_modules/undici/types/pool.d.ts +41 -0
- package/node_modules/undici/types/proxy-agent.d.ts +29 -0
- package/node_modules/undici/types/readable.d.ts +68 -0
- package/node_modules/undici/types/retry-agent.d.ts +8 -0
- package/node_modules/undici/types/retry-handler.d.ts +125 -0
- package/node_modules/undici/types/round-robin-pool.d.ts +41 -0
- package/node_modules/undici/types/snapshot-agent.d.ts +109 -0
- package/node_modules/undici/types/socks5-proxy-agent.d.ts +25 -0
- package/node_modules/undici/types/util.d.ts +18 -0
- package/node_modules/undici/types/utility.d.ts +7 -0
- package/node_modules/undici/types/webidl.d.ts +347 -0
- package/node_modules/undici/types/websocket.d.ts +188 -0
- package/node_modules/ws/LICENSE +20 -0
- package/node_modules/ws/README.md +548 -0
- package/node_modules/ws/browser.js +8 -0
- package/node_modules/ws/index.js +22 -0
- package/node_modules/ws/lib/buffer-util.js +131 -0
- package/node_modules/ws/lib/constants.js +19 -0
- package/node_modules/ws/lib/event-target.js +292 -0
- package/node_modules/ws/lib/extension.js +203 -0
- package/node_modules/ws/lib/limiter.js +55 -0
- package/node_modules/ws/lib/permessage-deflate.js +530 -0
- package/node_modules/ws/lib/receiver.js +743 -0
- package/node_modules/ws/lib/sender.js +607 -0
- package/node_modules/ws/lib/stream.js +161 -0
- package/node_modules/ws/lib/subprotocol.js +62 -0
- package/node_modules/ws/lib/validation.js +152 -0
- package/node_modules/ws/lib/websocket-server.js +562 -0
- package/node_modules/ws/lib/websocket.js +1407 -0
- package/node_modules/ws/package.json +74 -0
- package/node_modules/ws/wrapper.mjs +21 -0
- package/package.json +17 -4
- package/webui/assets/group-bot-profile-CYK81678.jpg +0 -0
- package/webui/assets/group-bot-settings-BBQBbfgh.jpg +0 -0
- package/webui/assets/index-CuH0UYYo.js +28 -0
- package/webui/assets/index-DjbPiYmB.css +2 -0
- package/webui/favicon.ico +0 -0
- package/webui/index.html +26 -0
- package/webui/logo-128.webp +0 -0
- package/webui/logo-192.webp +0 -0
- package/webui/logo-256.webp +0 -0
- package/webui/logo-64.webp +0 -0
- package/webui/logo.jpg +0 -0
- package/webui/plugin-shared/plugin-sdk-webui.js +3 -0
- package/webui/plugin-shared/react-dom.js +3 -0
- package/webui/plugin-shared/react-jsx-runtime.js +3 -0
- package/webui/plugin-shared/react.js +3 -0
- package//344/275/277/347/224/250/350/257/264/346/230/216.txt +6 -0
- package//346/233/264/346/226/260/346/227/245/345/277/227.txt +1091 -0
- package/README.md +0 -3
package/llbot.js
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { a as withoutParentPid, f as setRuntimeAside, i as parentPidOf, l as chooseCore, n as SUPERVISED_ENV, t as __vitePreload } from "./chunks/preload-helper-D5R8FHQt.js";
|
|
2
|
+
import { pathToFileURL } from "node:url";
|
|
3
|
+
import { spawn } from "node:child_process";
|
|
4
|
+
import { constants } from "node:os";
|
|
5
|
+
//#region src/main/supervisor.ts
|
|
6
|
+
var RESTART_WINDOW = 6e4;
|
|
7
|
+
/** A data-volume release that exits on its own sooner than this after starting failed to start */
|
|
8
|
+
var STARTUP_WINDOW = 6e4;
|
|
9
|
+
/** Failed starts in a row of a data-volume release before the image's own version takes over */
|
|
10
|
+
var MAX_FAILED_STARTS = 3;
|
|
11
|
+
/**
|
|
12
|
+
* Runs the bot as a child and starts it again when it exits with RESTART_EXIT_CODE, e.g. after an update replaced
|
|
13
|
+
* its files. Whatever started llbot.js keeps this process: its pid, its console and the bot's exit code, so the CLI
|
|
14
|
+
* launcher, the desktop app and Docker see no difference.
|
|
15
|
+
*
|
|
16
|
+
* The bot gets this process as its --parent-pid and stops on its own when this one is gone; this process watches
|
|
17
|
+
* the --parent-pid it was given and leaves when that one is gone.
|
|
18
|
+
*
|
|
19
|
+
* A release a container installed into its data volume survives recreating the container, so one that cannot
|
|
20
|
+
* start would otherwise keep the container down for good: after failing to start three times in a row it is set
|
|
21
|
+
* aside and the image's own version starts instead.
|
|
22
|
+
*/
|
|
23
|
+
function supervise(options) {
|
|
24
|
+
const log = options.log ?? ((message) => console.log(`[supervisor] ${message}`));
|
|
25
|
+
const choose = options.choose ?? (() => ({ core: options.core }));
|
|
26
|
+
const maxRestarts = options.maxRestarts ?? 5;
|
|
27
|
+
const posix = process.platform !== "win32";
|
|
28
|
+
const parent = parentPidOf(options.args);
|
|
29
|
+
const restarts = [];
|
|
30
|
+
let failedStarts = 0;
|
|
31
|
+
let child;
|
|
32
|
+
let stopping = false;
|
|
33
|
+
const start = () => {
|
|
34
|
+
const choice = choose();
|
|
35
|
+
if (choice.note) log(choice.note);
|
|
36
|
+
if (choice.runtime) log(`启动自动更新安装的 ${choice.runtime.version}`);
|
|
37
|
+
const startedAt = Date.now();
|
|
38
|
+
const current = spawn(process.execPath, [
|
|
39
|
+
...options.execArgv ?? process.execArgv,
|
|
40
|
+
choice.core,
|
|
41
|
+
...withoutParentPid(options.args),
|
|
42
|
+
`--parent-pid=${process.pid}`
|
|
43
|
+
], {
|
|
44
|
+
stdio: "inherit",
|
|
45
|
+
env: {
|
|
46
|
+
...process.env,
|
|
47
|
+
[SUPERVISED_ENV]: "1"
|
|
48
|
+
},
|
|
49
|
+
detached: posix
|
|
50
|
+
});
|
|
51
|
+
child = current;
|
|
52
|
+
current.once("error", (error) => {
|
|
53
|
+
log(`无法启动 Bot:${error.message}`);
|
|
54
|
+
process.exit(1);
|
|
55
|
+
});
|
|
56
|
+
current.once("exit", (code, signal) => {
|
|
57
|
+
child = void 0;
|
|
58
|
+
if (code === 75) {
|
|
59
|
+
if (stopping) process.exit(0);
|
|
60
|
+
failedStarts = 0;
|
|
61
|
+
const now = Date.now();
|
|
62
|
+
restarts.push(now);
|
|
63
|
+
while (now - restarts[0] > RESTART_WINDOW) restarts.shift();
|
|
64
|
+
if (restarts.length > maxRestarts) {
|
|
65
|
+
log(`Bot 在一分钟内要求重启 ${restarts.length} 次,不再重启`);
|
|
66
|
+
process.exit(1);
|
|
67
|
+
}
|
|
68
|
+
log("正在重启 Bot");
|
|
69
|
+
start();
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
if (choice.runtime && !stopping && code !== 0 && Date.now() - startedAt < STARTUP_WINDOW) {
|
|
73
|
+
failedStarts++;
|
|
74
|
+
if (failedStarts < MAX_FAILED_STARTS) {
|
|
75
|
+
log(`自动更新安装的 ${choice.runtime.version} 启动后很快退出(退出码 ${code ?? signal}),第 ${failedStarts} 次,稍后重试`);
|
|
76
|
+
setTimeout(start, 1e3);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
failedStarts = 0;
|
|
80
|
+
let where = "";
|
|
81
|
+
try {
|
|
82
|
+
where = options.onRuntimeFailed?.(choice) ?? "";
|
|
83
|
+
} catch (error) {
|
|
84
|
+
log(`无法移走自动更新安装的版本:${error.message}`);
|
|
85
|
+
process.exit(code ?? 1);
|
|
86
|
+
}
|
|
87
|
+
log(`自动更新安装的 ${choice.runtime.version} 连续 ${MAX_FAILED_STARTS} 次启动失败,已移到 ${where},改用自带的版本。配置可能已被新版本迁移过;问题解决后可以在「关于」页重新更新`);
|
|
88
|
+
start();
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
process.exit(code ?? 128 + (signal ? constants.signals[signal] ?? 0 : 0));
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
const stop = (signal) => {
|
|
95
|
+
stopping = true;
|
|
96
|
+
if (posix) child?.kill(signal);
|
|
97
|
+
};
|
|
98
|
+
process.on("SIGINT", () => stop("SIGINT"));
|
|
99
|
+
process.on("SIGTERM", () => stop("SIGTERM"));
|
|
100
|
+
if (posix) process.on("SIGHUP", () => stop("SIGTERM"));
|
|
101
|
+
if (!Number.isNaN(parent)) {
|
|
102
|
+
const timer = setInterval(() => {
|
|
103
|
+
try {
|
|
104
|
+
process.kill(parent, 0);
|
|
105
|
+
} catch (error) {
|
|
106
|
+
if (error.code !== "ESRCH") return;
|
|
107
|
+
clearInterval(timer);
|
|
108
|
+
stopping = true;
|
|
109
|
+
process.exit(0);
|
|
110
|
+
}
|
|
111
|
+
}, 1e3);
|
|
112
|
+
timer.unref();
|
|
113
|
+
}
|
|
114
|
+
start();
|
|
115
|
+
}
|
|
116
|
+
//#endregion
|
|
117
|
+
//#region src/main/llbot.ts
|
|
118
|
+
/**
|
|
119
|
+
* llbot.js: what every launcher runs. A small supervisor that runs the bot (llbot-core.js) as a child, so the bot
|
|
120
|
+
* can restart itself, e.g. after updating its own files. In a container it starts the release the bot installed
|
|
121
|
+
* into the data volume when that one is newer (see runtime.ts). `--no-supervisor` runs the bot in this process
|
|
122
|
+
* instead, as before; it then cannot restart itself.
|
|
123
|
+
*/
|
|
124
|
+
var args = process.argv.slice(2);
|
|
125
|
+
var choose = () => chooseCore({ installDir: import.meta.dirname });
|
|
126
|
+
if (args.includes("--no-supervisor")) {
|
|
127
|
+
const choice = choose();
|
|
128
|
+
if (choice.note) console.log(`[supervisor] ${choice.note}`);
|
|
129
|
+
await __vitePreload(() => import(pathToFileURL(choice.core).href), []);
|
|
130
|
+
} else supervise({
|
|
131
|
+
choose,
|
|
132
|
+
onRuntimeFailed: () => setRuntimeAside(),
|
|
133
|
+
args
|
|
134
|
+
});
|
|
135
|
+
//#endregion
|
|
136
|
+
export {};
|
|
137
|
+
|
|
138
|
+
//# sourceMappingURL=llbot.js.map
|
package/llbot.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"mappings":"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","names":[],"ignoreList":[],"sources":["../src/main/supervisor.ts","../src/main/llbot.ts"],"sourcesContent":["import { spawn, type ChildProcess } from 'node:child_process'\nimport { constants } from 'node:os'\nimport { parentPidOf, RESTART_EXIT_CODE, SUPERVISED_ENV, withoutParentPid } from './restart'\n\n/** What to start: the bot's entry, and whether it is the release a container installed into its data volume */\nexport interface CoreChoice {\n core: string\n runtime?: { version: string }\n /** Said in the log when it is chosen */\n note?: string\n}\n\nexport interface SuperviseOptions {\n /** The bot's entry, llbot-core.js next to llbot.js; used when `choose` is not given */\n core?: string\n /** Picks the entry on every start, so a restart after an update starts what is installed now */\n choose?: () => CoreChoice\n /** A data-volume release kept crashing at startup: set it aside; returns where it went */\n onRuntimeFailed?: (choice: CoreChoice) => string\n /** The arguments llbot.js was given */\n args: readonly string[]\n /** Node's own options, e.g. --enable-source-maps; process.execArgv by default */\n execArgv?: readonly string[]\n /** Restarts allowed within a minute before the supervisor gives up on a bot that keeps asking */\n maxRestarts?: number\n log?: (message: string) => void\n}\n\nconst RESTART_WINDOW = 60_000\n/** A data-volume release that exits on its own sooner than this after starting failed to start */\nconst STARTUP_WINDOW = 60_000\n/** Failed starts in a row of a data-volume release before the image's own version takes over */\nconst MAX_FAILED_STARTS = 3\n\n/**\n * Runs the bot as a child and starts it again when it exits with RESTART_EXIT_CODE, e.g. after an update replaced\n * its files. Whatever started llbot.js keeps this process: its pid, its console and the bot's exit code, so the CLI\n * launcher, the desktop app and Docker see no difference.\n *\n * The bot gets this process as its --parent-pid and stops on its own when this one is gone; this process watches\n * the --parent-pid it was given and leaves when that one is gone.\n *\n * A release a container installed into its data volume survives recreating the container, so one that cannot\n * start would otherwise keep the container down for good: after failing to start three times in a row it is set\n * aside and the image's own version starts instead.\n */\nexport function supervise(options: SuperviseOptions): void {\n const log = options.log ?? (message => console.log(`[supervisor] ${message}`))\n const choose: () => CoreChoice = options.choose ?? (() => ({ core: options.core! }))\n const maxRestarts = options.maxRestarts ?? 5\n const posix = process.platform !== 'win32'\n const parent = parentPidOf(options.args)\n const restarts: number[] = []\n let failedStarts = 0\n let child: ChildProcess | undefined\n let stopping = false\n\n const start = () => {\n const choice = choose()\n if (choice.note) log(choice.note)\n if (choice.runtime) log(`启动自动更新安装的 ${choice.runtime.version}`)\n const startedAt = Date.now()\n const current = spawn(process.execPath, [\n ...options.execArgv ?? process.execArgv,\n choice.core,\n ...withoutParentPid(options.args),\n `--parent-pid=${process.pid}`,\n ], {\n stdio: 'inherit',\n env: { ...process.env, [SUPERVISED_ENV]: '1' },\n // POSIX: a process group of its own, so a terminal's Ctrl+C reaches this process alone and is passed on\n // once; a second Ctrl+C still forces the bot down. Windows: a console's Ctrl+C reaches every process on it,\n // the bot included, and a group of its own would take a console of its own.\n detached: posix,\n })\n child = current\n current.once('error', (error) => {\n log(`无法启动 Bot:${error.message}`)\n process.exit(1)\n })\n current.once('exit', (code, signal) => {\n child = undefined\n if (code === RESTART_EXIT_CODE) {\n // Asked to stop meanwhile: the restart is moot, and the launcher should not see an unusual exit code\n if (stopping) process.exit(0)\n failedStarts = 0\n const now = Date.now()\n restarts.push(now)\n while (now - restarts[0] > RESTART_WINDOW) restarts.shift()\n if (restarts.length > maxRestarts) {\n log(`Bot 在一分钟内要求重启 ${restarts.length} 次,不再重启`)\n process.exit(1)\n }\n log('正在重启 Bot')\n start()\n return\n }\n if (choice.runtime && !stopping && code !== 0 && Date.now() - startedAt < STARTUP_WINDOW) {\n failedStarts++\n if (failedStarts < MAX_FAILED_STARTS) {\n log(`自动更新安装的 ${choice.runtime.version} 启动后很快退出(退出码 ${code ?? signal}),第 ${failedStarts} 次,稍后重试`)\n setTimeout(start, 1000)\n return\n }\n failedStarts = 0\n let where = ''\n try {\n where = options.onRuntimeFailed?.(choice) ?? ''\n } catch (error) {\n log(`无法移走自动更新安装的版本:${(error as Error).message}`)\n process.exit(code ?? 1)\n }\n log(`自动更新安装的 ${choice.runtime.version} 连续 ${MAX_FAILED_STARTS} 次启动失败,已移到 ${where},改用自带的版本。` +\n '配置可能已被新版本迁移过;问题解决后可以在「关于」页重新更新')\n start()\n return\n }\n process.exit(code ?? 128 + (signal ? constants.signals[signal] ?? 0 : 0))\n })\n }\n\n const stop = (signal: NodeJS.Signals) => {\n stopping = true\n // On Windows the console delivered the same Ctrl+C to the bot already\n if (posix) child?.kill(signal)\n }\n process.on('SIGINT', () => stop('SIGINT'))\n process.on('SIGTERM', () => stop('SIGTERM'))\n // A closed terminal hangs up this process group only, not the bot's\n if (posix) process.on('SIGHUP', () => stop('SIGTERM'))\n\n if (!Number.isNaN(parent)) {\n const timer = setInterval(() => {\n try {\n process.kill(parent, 0)\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== 'ESRCH') return\n clearInterval(timer)\n // The bot watches this process and shuts down cleanly once it is gone\n stopping = true\n process.exit(0)\n }\n }, 1000)\n timer.unref()\n }\n\n start()\n}\n","/**\n * llbot.js: what every launcher runs. A small supervisor that runs the bot (llbot-core.js) as a child, so the bot\n * can restart itself, e.g. after updating its own files. In a container it starts the release the bot installed\n * into the data volume when that one is newer (see runtime.ts). `--no-supervisor` runs the bot in this process\n * instead, as before; it then cannot restart itself.\n */\nimport { pathToFileURL } from 'node:url'\nimport { chooseCore, setRuntimeAside } from './runtime'\nimport { supervise } from './supervisor'\n\nconst args = process.argv.slice(2)\nconst choose = () => chooseCore({ installDir: import.meta.dirname })\n\nif (args.includes('--no-supervisor')) {\n const choice = choose()\n if (choice.note) console.log(`[supervisor] ${choice.note}`)\n await import(pathToFileURL(choice.core).href)\n} else {\n supervise({ choose, onRuntimeFailed: () => setRuntimeAside(), args })\n}\n"],"file":"llbot.js"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type h from '@satorijs/element';
|
|
2
|
+
import type { Session } from './universal.js';
|
|
3
|
+
/**
|
|
4
|
+
* How a parameter is read: `string` (default) one word, `text` the rest of the message, `number`, `integer`,
|
|
5
|
+
* `posint` (above 0), `natural` (0 and above), `user` the id of someone @-ed or typed out. Words are split at blanks;
|
|
6
|
+
* quotes ("…", '…', “…”, 「…」) keep the blanks inside one. Words and text come as element markup, so sending them
|
|
7
|
+
* on shows them as they were, @ included; `h.parse()` them for the elements.
|
|
8
|
+
*/
|
|
9
|
+
export type ArgumentType = 'string' | 'text' | 'number' | 'integer' | 'posint' | 'natural' | 'user';
|
|
10
|
+
export interface CommandConfig {
|
|
11
|
+
/** Left out of the platforms' command menus. */
|
|
12
|
+
hidden?: boolean;
|
|
13
|
+
/** Per user, in milliseconds: how long a user waits between two runs. */
|
|
14
|
+
cooldown?: number;
|
|
15
|
+
/**
|
|
16
|
+
* The default permission: `everyone` (default); `admin` group owners and admins too; `owner` only the owners
|
|
17
|
+
* in the command settings. Users may override it for this command in the host's command settings.
|
|
18
|
+
*/
|
|
19
|
+
authority?: 'everyone' | 'admin' | 'owner';
|
|
20
|
+
}
|
|
21
|
+
export interface OptionConfig {
|
|
22
|
+
/** The value when the option is not given. */
|
|
23
|
+
fallback?: unknown;
|
|
24
|
+
}
|
|
25
|
+
export interface Argv {
|
|
26
|
+
session: Session;
|
|
27
|
+
command: Command;
|
|
28
|
+
/** Continue the message middleware chain, at most once. Returning nothing does not continue it automatically. */
|
|
29
|
+
next(): Promise<void>;
|
|
30
|
+
/** By name: a flag is `true`, an option with a parameter has its value. */
|
|
31
|
+
options: Record<string, any>;
|
|
32
|
+
/** The arguments, also passed to the action after argv. */
|
|
33
|
+
args: any[];
|
|
34
|
+
}
|
|
35
|
+
/** What it returns, if anything, goes back to the session's channel. */
|
|
36
|
+
export type CommandAction = (argv: Argv, ...args: any[]) => h.Fragment | void | Promise<h.Fragment | void>;
|
|
37
|
+
export interface Command {
|
|
38
|
+
readonly name: string;
|
|
39
|
+
readonly description: string;
|
|
40
|
+
/** Other names that run it. */
|
|
41
|
+
alias(...names: string[]): this;
|
|
42
|
+
/**
|
|
43
|
+
* `syntax`: its flags, a parameter, a description, e.g. `-t <seconds:number> 等多久`. `--<name>` always works; one
|
|
44
|
+
* without a parameter is a flag, `true` when given.
|
|
45
|
+
*/
|
|
46
|
+
option(name: string, syntax: string, config?: OptionConfig): this;
|
|
47
|
+
action(action: CommandAction): this;
|
|
48
|
+
/** Removes it early; the plugin's disposal removes it anyway. */
|
|
49
|
+
dispose(): void;
|
|
50
|
+
}
|
|
51
|
+
/** A command as the command list shows it. */
|
|
52
|
+
export interface CommandInfo {
|
|
53
|
+
name: string;
|
|
54
|
+
aliases: string[];
|
|
55
|
+
description: string;
|
|
56
|
+
/** `签到 [days:number]` */
|
|
57
|
+
syntax: string;
|
|
58
|
+
hidden: boolean;
|
|
59
|
+
/** Effective permission, including the host's override. */
|
|
60
|
+
authority: 'everyone' | 'admin' | 'owner';
|
|
61
|
+
/** Permission declared by the plugin, or everyone when omitted. */
|
|
62
|
+
defaultAuthority: 'everyone' | 'admin' | 'owner';
|
|
63
|
+
/** The plugin entry it belongs to; undefined for the bot's own. */
|
|
64
|
+
owner?: string;
|
|
65
|
+
/** Names or aliases another command has too: the one registered first runs where both plugins take a message. */
|
|
66
|
+
conflicts: {
|
|
67
|
+
name: string;
|
|
68
|
+
with?: string;
|
|
69
|
+
}[];
|
|
70
|
+
}
|
|
71
|
+
export interface Commands {
|
|
72
|
+
/** The same as `ctx.command()`. */
|
|
73
|
+
command(def: string, description?: string, config?: CommandConfig): Command;
|
|
74
|
+
list(): CommandInfo[];
|
|
75
|
+
}
|
|
76
|
+
declare module 'cordis' {
|
|
77
|
+
interface Context {
|
|
78
|
+
commands: Commands;
|
|
79
|
+
/**
|
|
80
|
+
* Registers a command, `def` being its name and parameters (`签到 [days:number]`). A message runs it when it
|
|
81
|
+
* starts, after an @ of the bot, with one of the prefixes of the command settings (`/` or nothing by default)
|
|
82
|
+
* and then its name or an alias. Needs `commands` in `inject`.
|
|
83
|
+
*/
|
|
84
|
+
command(def: string, description?: string, config?: CommandConfig): Command;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compatibility API for trusted adapters that expose the legacy get_config / set_config actions.
|
|
3
|
+
* Obtain with ctx.get('config') after declaring the config service dependency.
|
|
4
|
+
* Ordinary plugins should keep their settings in their own configuration and storage.
|
|
5
|
+
*/
|
|
6
|
+
export interface HostConfig {
|
|
7
|
+
readonly version: string;
|
|
8
|
+
/** Includes adapter settings and their credentials; do not log the result. */
|
|
9
|
+
getLegacy(): Record<string, any>;
|
|
10
|
+
/** Merge only supplied settings, keeping instance and command-line overrides. */
|
|
11
|
+
patchLegacy(partial: Record<string, any>, options?: {
|
|
12
|
+
rules?: boolean;
|
|
13
|
+
}): Promise<void>;
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { Buffer } from 'node:buffer';
|
|
2
|
+
/** Formats supported by the optional @luckylillia-dev/plugin-ffmpeg package. */
|
|
3
|
+
export type FFmpegAudioFormat = 'mp3' | 'amr' | 'wma' | 'm4a' | 'spx' | 'ogg' | 'wav' | 'flac' | 'silk';
|
|
4
|
+
export interface FFmpegMediaInfo {
|
|
5
|
+
width: number;
|
|
6
|
+
height: number;
|
|
7
|
+
duration: number;
|
|
8
|
+
format: string;
|
|
9
|
+
size: number;
|
|
10
|
+
}
|
|
11
|
+
/** Optional media service. Declare inject: ['ffmpeg'], or use a local ctx.inject for optional features. */
|
|
12
|
+
export interface FFmpegAPI {
|
|
13
|
+
version(): string;
|
|
14
|
+
/** Native SILK support (plugin 1.1+). Absent on older plugin versions. */
|
|
15
|
+
silkVersion?(): string;
|
|
16
|
+
probe(inputPath: string): Promise<FFmpegMediaInfo>;
|
|
17
|
+
/** Decodes to signed 16-bit little-endian PCM; includes QQ/Skype SILK on plugin 1.1+. */
|
|
18
|
+
decodeAudio(inputPath: string, options: {
|
|
19
|
+
sampleRate: number;
|
|
20
|
+
channels: number;
|
|
21
|
+
}): Promise<Buffer>;
|
|
22
|
+
encodeAudio(pcm: Buffer, outputPath: string, options: {
|
|
23
|
+
sampleRate: number;
|
|
24
|
+
channels: number;
|
|
25
|
+
format: FFmpegAudioFormat;
|
|
26
|
+
}): Promise<void>;
|
|
27
|
+
transcodeAudio(inputPath: string, outputPath: string, options: {
|
|
28
|
+
format: FFmpegAudioFormat;
|
|
29
|
+
}): Promise<void>;
|
|
30
|
+
/** Returns a PNG thumbnail. */
|
|
31
|
+
thumbnail(inputPath: string, options?: {
|
|
32
|
+
maxWidth?: number;
|
|
33
|
+
maxHeight?: number;
|
|
34
|
+
time?: number;
|
|
35
|
+
}): Promise<Buffer>;
|
|
36
|
+
}
|
|
37
|
+
declare module 'cordis' {
|
|
38
|
+
interface Context {
|
|
39
|
+
ffmpeg: FFmpegAPI;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
export interface HttpConfig {
|
|
2
|
+
/** What relative URLs are resolved against */
|
|
3
|
+
baseURL?: string;
|
|
4
|
+
headers?: Record<string, string>;
|
|
5
|
+
/** Milliseconds */
|
|
6
|
+
timeout?: number;
|
|
7
|
+
/**
|
|
8
|
+
* The proxy for these requests: an http, https or socks5 address, or `''` to go direct. Left out, the address set
|
|
9
|
+
* in the builtin entry「代理」counts. Only that entry routes requests through proxies: with it switched off, none do.
|
|
10
|
+
*/
|
|
11
|
+
proxyAgent?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface HttpRequestConfig extends HttpConfig {
|
|
14
|
+
/** Added to the query */
|
|
15
|
+
params?: Record<string, string | number | boolean | undefined>;
|
|
16
|
+
/** The body: a plain object or array goes as JSON, anything fetch() takes as it is */
|
|
17
|
+
data?: unknown;
|
|
18
|
+
/** How to read the body; by its Content-Type when left out (JSON, text, else bytes) */
|
|
19
|
+
responseType?: 'json' | 'text' | 'arraybuffer' | 'stream';
|
|
20
|
+
signal?: AbortSignal;
|
|
21
|
+
redirect?: RequestRedirect;
|
|
22
|
+
}
|
|
23
|
+
export interface HttpResponse<T = any> {
|
|
24
|
+
url: string;
|
|
25
|
+
status: number;
|
|
26
|
+
statusText: string;
|
|
27
|
+
headers: Headers;
|
|
28
|
+
data: T;
|
|
29
|
+
}
|
|
30
|
+
/** What `ctx.http` throws: no connection (`code` such as ECONNREFUSED or ETIMEDOUT), or an answer that was not 2xx */
|
|
31
|
+
export interface HttpError extends Error {
|
|
32
|
+
name: 'HttpError';
|
|
33
|
+
code?: string;
|
|
34
|
+
response?: HttpResponse;
|
|
35
|
+
}
|
|
36
|
+
export interface HttpFile {
|
|
37
|
+
data: ArrayBuffer;
|
|
38
|
+
/** The Content-Type, or what the bytes are when the server says nothing useful */
|
|
39
|
+
type: string;
|
|
40
|
+
filename?: string;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* `ctx.http`: how plugins reach the outside. Every request passes `http/fetch-init`, where the builtin entry「代理」
|
|
44
|
+
* puts its proxy in; plain fetch() calls never get one. Plugins with HTTP settings of their own (a proxy, a base
|
|
45
|
+
* URL) make a client of them with `extend()`.
|
|
46
|
+
*/
|
|
47
|
+
export interface Http {
|
|
48
|
+
readonly config: HttpConfig;
|
|
49
|
+
/**
|
|
50
|
+
* Resolves the effective proxy for a native client without sending a request. Returns `''` for direct access.
|
|
51
|
+
* Uses the same merged settings and builtin proxy rules as fetch(). The returned address may contain
|
|
52
|
+
* authentication credentials: keep it private and resolve again when starting a new native connection.
|
|
53
|
+
*/
|
|
54
|
+
proxy(url: string | URL, config?: HttpConfig): string;
|
|
55
|
+
get<T = any>(url: string, config?: HttpRequestConfig): Promise<T>;
|
|
56
|
+
delete<T = any>(url: string, config?: HttpRequestConfig): Promise<T>;
|
|
57
|
+
head(url: string, config?: HttpRequestConfig): Promise<Headers>;
|
|
58
|
+
post<T = any>(url: string, data?: unknown, config?: HttpRequestConfig): Promise<T>;
|
|
59
|
+
put<T = any>(url: string, data?: unknown, config?: HttpRequestConfig): Promise<T>;
|
|
60
|
+
patch<T = any>(url: string, data?: unknown, config?: HttpRequestConfig): Promise<T>;
|
|
61
|
+
/** The whole answer; throws HttpError for one that is not 2xx */
|
|
62
|
+
request<T = any>(method: string, url: string, config?: HttpRequestConfig): Promise<HttpResponse<T>>;
|
|
63
|
+
/** fetch() through the same settings and hooks, the answer as it is, whatever its status */
|
|
64
|
+
fetch(url: string | URL, init?: RequestInit, config?: HttpConfig): Promise<Response>;
|
|
65
|
+
/** Downloads a file: http(s) and data: URLs */
|
|
66
|
+
file(url: string, config?: HttpRequestConfig): Promise<HttpFile>;
|
|
67
|
+
/** A client with these settings over this one's; headers merge */
|
|
68
|
+
extend(config: HttpConfig): Http;
|
|
69
|
+
}
|
|
70
|
+
/** What `http/fetch-init` lets a listener change: Node's fetch also takes undici's `dispatcher` */
|
|
71
|
+
export interface HttpFetchInit extends RequestInit {
|
|
72
|
+
dispatcher?: unknown;
|
|
73
|
+
}
|
|
74
|
+
/** Mutable result of resolving a native client's proxy. An empty URL means direct access. */
|
|
75
|
+
export interface HttpProxyResolution {
|
|
76
|
+
url: string;
|
|
77
|
+
}
|
|
78
|
+
declare module 'cordis' {
|
|
79
|
+
interface Context {
|
|
80
|
+
http: Http;
|
|
81
|
+
}
|
|
82
|
+
interface Events {
|
|
83
|
+
/** @mode emit. Synchronously resolve the effective proxy; initialized to direct access, with no request sent. */
|
|
84
|
+
'http/proxy'(url: URL, proxy: HttpProxyResolution, config: HttpConfig): void;
|
|
85
|
+
/** @mode emit. Before each request of `ctx.http`, with the settings it goes by; a listener may change `init` */
|
|
86
|
+
'http/fetch-init'(url: URL, init: HttpFetchInit, config: HttpConfig): void;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export { Context, Fiber, Inject, Service } from 'cordis';
|
|
2
|
+
export type { Disposable, Effect, Events, Plugin } from 'cordis';
|
|
3
|
+
export { default as Schema } from 'schemastery';
|
|
4
|
+
export { default as h } from '@satorijs/element';
|
|
5
|
+
export type * as Universal from '@satorijs/protocol';
|
|
6
|
+
export type { Database, Tables } from '@cordisjs/plugin-database';
|
|
7
|
+
export type { TimerService } from '@cordisjs/plugin-timer';
|
|
8
|
+
export type { LLBotManifest, PluginCategory } from './manifest.js';
|
|
9
|
+
export type * from './universal.js';
|
|
10
|
+
export type * from './commands.js';
|
|
11
|
+
export type * from './http.js';
|
|
12
|
+
export type * from './ffmpeg.js';
|
|
13
|
+
export { internalOf } from './internal.js';
|
|
14
|
+
export type { LuckyLilliaInternal, NTQQInternal, PlatformInternals, QQGuildInternal, QQInternal } from './internal.js';
|
|
15
|
+
export type * from './server.js';
|
|
16
|
+
export type * from './storage.js';
|
|
17
|
+
export type * from './config.js';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// Runtime values here must be the host's own copies. The host pins these specifiers to its
|
|
2
|
+
// node_modules at import time, so build plugins with all of them marked external.
|
|
3
|
+
export { Context, Fiber, Inject, Service } from 'cordis';
|
|
4
|
+
export { default as Schema } from 'schemastery';
|
|
5
|
+
export { default as h } from '@satorijs/element';
|
|
6
|
+
export { internalOf } from './internal.js';
|