@mininglamp-oss/octo-runtime 1.1.3 → 1.1.5
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/README.md +62 -38
- package/apps/cli/README.md +58 -22
- package/apps/cli/dist/build-info.json +2 -2
- package/apps/cli/dist/cli-entrypoint.d.ts +2 -0
- package/apps/cli/dist/cli-entrypoint.js +16 -0
- package/apps/cli/dist/command-tree.d.ts +20 -0
- package/apps/cli/dist/command-tree.js +402 -0
- package/apps/cli/dist/extra-command-config.d.ts +4 -0
- package/apps/cli/dist/extra-command-config.js +50 -0
- package/apps/cli/dist/extra-commands.d.ts +15 -0
- package/apps/cli/dist/extra-commands.js +275 -0
- package/apps/cli/dist/extras.js +14 -2
- package/apps/cli/dist/global-extras.d.ts +16 -0
- package/apps/cli/dist/global-extras.js +201 -0
- package/apps/cli/dist/help.d.ts +4 -1
- package/apps/cli/dist/help.js +31 -75
- package/apps/cli/dist/main.d.ts +2 -0
- package/apps/cli/dist/main.js +53 -63
- package/apps/cli/dist/manifest.json +53 -3
- package/apps/cli/dist/module-manifest.d.ts +1 -1
- package/apps/cli/dist/module-manifest.js +3 -2
- package/apps/cli/dist/openclaw.js +32 -8
- package/apps/cli/dist/output.js +16 -2
- package/apps/cli/dist/playboard.d.ts +5 -0
- package/apps/cli/dist/playboard.js +41 -13
- package/apps/cli/dist/service-control.js +2 -2
- package/apps/cli/dist/state.js +48 -19
- package/dist/public/channel-gateway-commands.d.ts +1 -0
- package/dist/public/channel-gateway-commands.js +1 -0
- package/dist/public/channel-wecom-commands.d.ts +1 -0
- package/dist/public/channel-wecom-commands.js +1 -0
- package/dist/public/dsh.d.ts +2 -0
- package/dist/public/dsh.js +1 -0
- package/dist/public/executor-kernel.d.ts +1 -1
- package/dist/public/executor-kernel.js +1 -1
- package/dist/public/extra.d.ts +1 -0
- package/dist/public/extra.js +1 -0
- package/dist/public/host.d.ts +2 -4
- package/dist/public/host.js +1 -2
- package/dist/public/webui-commands.d.ts +1 -0
- package/dist/public/webui-commands.js +1 -0
- package/node_modules/@mininglamp-oss/octo-runtime-acp-client/dist/index.js +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-acp-client/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-acp/dist/index.d.ts +4 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-acp/dist/index.js +26 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-acp/package.json +4 -4
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-antigravity/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-claude-code/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codebuddy/package.json +4 -4
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/index.js +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/chunk-DYOJCNWF.js +854 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/chunk-G5PWGRL5.js +209 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/chunk-UOQRXV3Q.js +340 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/desktop-entry.d.ts +1 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/desktop-entry.js +16 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/dsh-sdk-NOTICE.txt +6 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/dsh-sdk-client-LICENSE.txt +21 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/dsh-sdk-protocol-LICENSE.txt +21 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/errors.d.ts +35 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/errors.js +14 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/index.d.ts +52 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/index.js +306 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/launch.d.ts +11 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/launch.js +13 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/trajectory.d.ts +12 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/trajectory.js +7 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/package.json +15 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/dist/client.js +2 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/package.json +5 -5
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-hermes/package.json +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-kimi-code/package.json +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-mcode/package.json +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-openclaw/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-opencode/dist/index.d.ts +10 -5
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-opencode/dist/index.js +214 -55
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-opencode/package.json +4 -4
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-qodercli/package.json +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-qoderclicn/package.json +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/activity.d.ts +3 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/environment.d.ts +4 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/environment.js +24 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/hourly-log.js +11 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/index.d.ts +12 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/index.js +30 -8
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/mcp.js +4 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/module-manifest.d.ts +6 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/module-manifest.js +16 -4
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/public-display.js +15 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/runtime-log.js +29 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/package.json +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-zcode-gui/dist/index.js +5 -5
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-zcode-gui/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/build-info.json +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/cli-entrypoint.d.ts +2 -0
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/cli-entrypoint.js +16 -0
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/command-tree.d.ts +20 -0
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/command-tree.js +402 -0
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/extra-command-config.d.ts +4 -0
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/extra-command-config.js +50 -0
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/extra-commands.d.ts +15 -0
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/extra-commands.js +275 -0
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/extras.js +14 -2
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/global-extras.d.ts +16 -0
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/global-extras.js +201 -0
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/help.d.ts +4 -1
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/help.js +31 -75
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/main.d.ts +2 -0
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/main.js +53 -63
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/manifest.json +53 -3
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/module-manifest.d.ts +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/module-manifest.js +3 -2
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/openclaw.js +32 -8
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/output.js +16 -2
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/playboard.d.ts +5 -0
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/playboard.js +41 -13
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/service-control.js +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/state.js +48 -19
- package/node_modules/@mininglamp-oss/octo-runtime-cli/package.json +25 -23
- package/node_modules/@mininglamp-oss/octo-runtime-cross-service/dist/common.d.ts +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-cross-service/dist/common.js +16 -6
- package/node_modules/@mininglamp-oss/octo-runtime-cross-service/dist/systemd.js +9 -7
- package/node_modules/@mininglamp-oss/octo-runtime-cross-service/dist/windows-task.d.ts +4 -1
- package/node_modules/@mininglamp-oss/octo-runtime-cross-service/dist/windows-task.js +36 -11
- package/node_modules/@mininglamp-oss/octo-runtime-cross-service/package.json +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/index.js +7 -2
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/index.d.ts +2 -1
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/index.js +2 -1
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/invocation-lifecycle.js +2 -1
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/invocation-manifest.d.ts +16 -1
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/invocation-manifest.js +152 -21
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/serve.js +9 -2
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/submission-error.d.ts +8 -0
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/submission-error.js +17 -0
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/package.json +4 -4
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/config-schema.json +56 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/application/im-channel.js +170 -28
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/application/session-store.d.ts +3 -1
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/commands.d.ts +4 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/commands.js +124 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/contracts.d.ts +19 -1
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/delivery/artifact-policy.d.ts +23 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/delivery/artifact-policy.js +43 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/delivery/artifacts.d.ts +15 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/delivery/artifacts.js +283 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/execution/dispatcher.d.ts +2 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/execution/dispatcher.js +15 -1
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/execution/task.d.ts +5 -1
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/execution/task.js +48 -13
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/execution/tool-environment.d.ts +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/execution/tool-environment.js +5 -3
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/lifecycle/configuration.js +26 -1
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/api/cards.js +2 -1
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/api/client.d.ts +1 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/api/client.js +3 -2
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/api/conversations.js +3 -2
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/api/files.d.ts +4 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/api/files.js +104 -3
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/api/rules.js +4 -3
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/api/url.d.ts +2 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/api/url.js +7 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/auth.d.ts +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/auth.js +4 -3
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/channel.d.ts +9 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/channel.js +44 -13
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/connection-error.d.ts +7 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/connection-error.js +44 -3
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/image-input.js +2 -1
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/wukong.d.ts +7 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/wukong.js +18 -12
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/package.json +10 -6
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-wecom/dist/application/im-channel.js +141 -16
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-wecom/dist/application/session-store.d.ts +3 -1
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-wecom/dist/commands.d.ts +4 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-wecom/dist/commands.js +128 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-wecom/package.json +9 -5
- package/node_modules/@mininglamp-oss/octo-runtime-extra-webui/dist/commands.d.ts +3 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-webui/dist/commands.js +51 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-webui/dist/web/assets/index-CXTvRGim.js +74 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-webui/dist/web/index.html +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-extra-webui/package.json +7 -3
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/extra-commands.d.ts +70 -0
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/extra-commands.js +16 -0
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/extra-config.js +33 -9
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/home.js +9 -4
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/index.d.ts +1 -3
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/index.js +1 -2
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/package.json +8 -4
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/failure.d.ts +5 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/failure.js +39 -1
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/generated/protocol-types.d.ts +76 -7
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/package.json +1 -1
- package/node_modules/commander/LICENSE +22 -0
- package/node_modules/commander/Readme.md +1172 -0
- package/node_modules/commander/index.js +21 -0
- package/node_modules/commander/lib/argument.js +147 -0
- package/node_modules/commander/lib/command.js +2790 -0
- package/node_modules/commander/lib/error.js +36 -0
- package/node_modules/commander/lib/help.js +731 -0
- package/node_modules/commander/lib/option.js +377 -0
- package/node_modules/commander/lib/suggestSimilar.js +99 -0
- package/node_modules/commander/package-support.json +19 -0
- package/node_modules/commander/package.json +64 -0
- package/node_modules/commander/typings/index.d.ts +1113 -0
- package/package.json +49 -29
- package/packages/octo-runtime-extra-channel-gateway/config-schema.json +56 -0
- package/packages/octo-runtime-protocol/schema/kernel-ipc.schema.json +443 -56
- package/packages/octo-runtime-protocol/schema/protocol.schema.json +357 -37
- package/node_modules/@mininglamp-oss/octo-runtime-extra-webui/dist/web/assets/index-DiPc-ipL.js +0 -74
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/launch.d.ts +0 -15
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/launch.js +0 -22
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/native.d.ts +0 -16
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/native.js +0 -160
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/** 校验服务端返回的长期下载地址;不把 PUT 地址、签名有效期或 Bot 鉴权路由冒充附件。 */
|
|
2
|
+
export declare function attachmentUrl(raw: unknown, apiUrl: string): string;
|
|
3
|
+
/** 当前 Bot 获取聊天上传凭据后直传;只交付独立 downloadUrl,绝不转发 Bot Token。 */
|
|
4
|
+
export declare function uploadChatAttachment(apiUrl: string, token: string, bytes: Uint8Array, filename: string, mime: string, signal: AbortSignal): Promise<string>;
|
|
1
5
|
/**
|
|
2
6
|
* Infer MIME type from filename extension. Returns a sensible default if unknown.
|
|
3
7
|
*/
|
package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/api/files.js
CHANGED
|
@@ -1,11 +1,108 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* 决策:.octospec/tasks/pr1-yujiawei-review/brief.md
|
|
2
|
+
* 文件输入辅助与渠道固定产物交付;显式业务上传仍由 Agent 工具负责。
|
|
3
|
+
* 合同:.octospec/tasks/182-channel-artifact-delivery/brief.md
|
|
5
4
|
*/
|
|
6
5
|
// Adapted from Mininglamp-OSS/openclaw-channel-octo/src/api-fetch.ts.
|
|
7
6
|
import path from "node:path";
|
|
8
7
|
import { open } from "node:fs/promises";
|
|
8
|
+
import { readResponseText } from "./client.js";
|
|
9
|
+
import { trimTrailingSlashes } from "./url.js";
|
|
10
|
+
/** 校验服务端返回的长期下载地址;不把 PUT 地址、签名有效期或 Bot 鉴权路由冒充附件。 */
|
|
11
|
+
export function attachmentUrl(raw, apiUrl) {
|
|
12
|
+
if (typeof raw !== "string" || !raw.trim() || raw.length > 8192)
|
|
13
|
+
throw new Error("invalid-download-url");
|
|
14
|
+
let url;
|
|
15
|
+
try {
|
|
16
|
+
url = new URL(raw, `${trimTrailingSlashes(apiUrl)}/`);
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
throw new Error("invalid-download-url");
|
|
20
|
+
}
|
|
21
|
+
const api = new URL(apiUrl);
|
|
22
|
+
if (url.username ||
|
|
23
|
+
url.password ||
|
|
24
|
+
(url.protocol !== "https:" &&
|
|
25
|
+
!(url.protocol === "http:" &&
|
|
26
|
+
url.origin === api.origin &&
|
|
27
|
+
["localhost", "127.0.0.1", "[::1]"].includes(url.hostname))) ||
|
|
28
|
+
/\/(?:v1\/)?(?:bot\/)?file\/(?:preview|download|upload)(?:\/|$)/i.test(url.pathname) ||
|
|
29
|
+
/\/(?:v1\/)?botfile(?:\/|$)/i.test(url.pathname) ||
|
|
30
|
+
[...url.searchParams.keys()].some((key) => /^(?:x-amz-|x-goog-|q-sign-|signature$|sig$|expires$|expiry$|expire$|token$|access_token$|ossaccesskeyid$)/i.test(key)))
|
|
31
|
+
throw new Error("unstable-download-url");
|
|
32
|
+
return url.href;
|
|
33
|
+
}
|
|
34
|
+
/** 当前 Bot 获取聊天上传凭据后直传;只交付独立 downloadUrl,绝不转发 Bot Token。 */
|
|
35
|
+
export async function uploadChatAttachment(apiUrl, token, bytes, filename, mime, signal) {
|
|
36
|
+
signal = AbortSignal.any([signal, AbortSignal.timeout(30_000)]);
|
|
37
|
+
signal.throwIfAborted();
|
|
38
|
+
const query = new URLSearchParams({ filename, fileSize: String(bytes.byteLength) });
|
|
39
|
+
const response = await fetch(`${trimTrailingSlashes(apiUrl)}/v1/bot/upload/presigned?${query.toString()}`, {
|
|
40
|
+
method: "GET",
|
|
41
|
+
headers: { Authorization: `Bearer ${token}` },
|
|
42
|
+
signal,
|
|
43
|
+
redirect: "error"
|
|
44
|
+
});
|
|
45
|
+
const body = await readResponseText(response, 64 << 10);
|
|
46
|
+
if (!response.ok)
|
|
47
|
+
throw new Error("upload-rejected");
|
|
48
|
+
let result;
|
|
49
|
+
try {
|
|
50
|
+
result = JSON.parse(body);
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
throw new Error("invalid-upload-response");
|
|
54
|
+
}
|
|
55
|
+
if (!result || typeof result !== "object")
|
|
56
|
+
throw new Error("invalid-upload-response");
|
|
57
|
+
const download = attachmentUrl(result.downloadUrl, apiUrl);
|
|
58
|
+
if (result.method !== "PUT" ||
|
|
59
|
+
typeof result.uploadUrl !== "string" ||
|
|
60
|
+
result.uploadUrl.length > 16_384 ||
|
|
61
|
+
(result.maxFileSize !== undefined && result.maxFileSize !== bytes.byteLength) ||
|
|
62
|
+
(result.expiredTime !== undefined &&
|
|
63
|
+
(typeof result.expiredTime !== "number" || result.expiredTime * 1000 <= Date.now())))
|
|
64
|
+
throw new Error("invalid-upload-response");
|
|
65
|
+
let upload;
|
|
66
|
+
try {
|
|
67
|
+
upload = new URL(result.uploadUrl);
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
throw new Error("invalid-upload-response");
|
|
71
|
+
}
|
|
72
|
+
const api = new URL(apiUrl);
|
|
73
|
+
if (upload.username ||
|
|
74
|
+
upload.password ||
|
|
75
|
+
(upload.protocol !== "https:" &&
|
|
76
|
+
!(upload.protocol === "http:" &&
|
|
77
|
+
upload.origin === api.origin &&
|
|
78
|
+
["localhost", "127.0.0.1", "[::1]"].includes(upload.hostname))))
|
|
79
|
+
throw new Error("invalid-upload-response");
|
|
80
|
+
const headers = {};
|
|
81
|
+
const contentType = result.contentType ?? ensureTextCharset(mime);
|
|
82
|
+
for (const [name, value] of [
|
|
83
|
+
["Content-Type", contentType],
|
|
84
|
+
["Content-Disposition", result.contentDisposition]
|
|
85
|
+
]) {
|
|
86
|
+
if (value === undefined)
|
|
87
|
+
continue;
|
|
88
|
+
if (typeof value !== "string" || value.length > 8192 || /[\r\n]/.test(value))
|
|
89
|
+
throw new Error("invalid-upload-response");
|
|
90
|
+
headers[name] = value;
|
|
91
|
+
}
|
|
92
|
+
signal.throwIfAborted();
|
|
93
|
+
// PUT 必须原样回显签名的类型/文件名;临时上传地址仅在此使用,网络未知不自动重放。
|
|
94
|
+
const stored = await fetch(upload.href, {
|
|
95
|
+
method: "PUT",
|
|
96
|
+
headers,
|
|
97
|
+
body: new Uint8Array(bytes),
|
|
98
|
+
redirect: "error",
|
|
99
|
+
signal
|
|
100
|
+
});
|
|
101
|
+
await stored.body?.cancel();
|
|
102
|
+
if (!stored.ok)
|
|
103
|
+
throw new Error("upload-rejected");
|
|
104
|
+
return download;
|
|
105
|
+
}
|
|
9
106
|
/**
|
|
10
107
|
* Infer MIME type from filename extension. Returns a sensible default if unknown.
|
|
11
108
|
*/
|
|
@@ -20,6 +117,8 @@ export function inferContentType(filename) {
|
|
|
20
117
|
".svg": "image/svg+xml",
|
|
21
118
|
".bmp": "image/bmp",
|
|
22
119
|
".ico": "image/x-icon",
|
|
120
|
+
".tif": "image/tiff",
|
|
121
|
+
".tiff": "image/tiff",
|
|
23
122
|
".mp4": "video/mp4",
|
|
24
123
|
".webm": "video/webm",
|
|
25
124
|
".mov": "video/quicktime",
|
|
@@ -30,6 +129,8 @@ export function inferContentType(filename) {
|
|
|
30
129
|
".zip": "application/zip",
|
|
31
130
|
".doc": "application/msword",
|
|
32
131
|
".docx": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
132
|
+
".ppt": "application/vnd.ms-powerpoint",
|
|
133
|
+
".pptx": "application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
|
33
134
|
".xls": "application/vnd.ms-excel",
|
|
34
135
|
".xlsx": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
35
136
|
".txt": "text/plain",
|
package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/api/rules.js
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
// Adapted from Mininglamp-OSS/openclaw-channel-octo/src/api-fetch.ts.
|
|
6
6
|
import { DEFAULT_TIMEOUT_MS } from "./client.js";
|
|
7
7
|
import { OctoApiError } from "./errors.js";
|
|
8
|
+
import { trimTrailingSlashes } from "./url.js";
|
|
8
9
|
// Short timeout for the per-message mention_pref hot-path lookup. On a cache
|
|
9
10
|
// miss this fires on the first message of every group every TTL window; before
|
|
10
11
|
// the backend ships it 404s, and we must not stall the inbound pipeline for the
|
|
@@ -21,7 +22,7 @@ const MENTION_PREF_TIMEOUT_MS = 3_000;
|
|
|
21
22
|
* effective 回退为 no_mention,行为与升级前完全一致(零回归)。
|
|
22
23
|
*/
|
|
23
24
|
export async function getMentionPref(params) {
|
|
24
|
-
const url = `${params.apiUrl
|
|
25
|
+
const url = `${trimTrailingSlashes(params.apiUrl)}/v1/bot/groups/${encodeURIComponent(params.groupNo)}/mention_pref`;
|
|
25
26
|
try {
|
|
26
27
|
const resp = await fetch(url, {
|
|
27
28
|
method: "GET",
|
|
@@ -69,7 +70,7 @@ export async function getMentionPref(params) {
|
|
|
69
70
|
}
|
|
70
71
|
// Fetch GROUP.md content for a group
|
|
71
72
|
export async function getGroupMd(params) {
|
|
72
|
-
const url = `${params.apiUrl
|
|
73
|
+
const url = `${trimTrailingSlashes(params.apiUrl)}/v1/bot/groups/${encodeURIComponent(params.groupNo)}/md`;
|
|
73
74
|
const resp = await fetch(url, {
|
|
74
75
|
method: "GET",
|
|
75
76
|
headers: {
|
|
@@ -93,7 +94,7 @@ export async function getGroupMd(params) {
|
|
|
93
94
|
* and is used for background cache refresh where failures are non-fatal.
|
|
94
95
|
*/
|
|
95
96
|
export async function getThreadMd(params) {
|
|
96
|
-
const url = `${params.apiUrl
|
|
97
|
+
const url = `${trimTrailingSlashes(params.apiUrl)}/v1/bot/groups/${encodeURIComponent(params.groupNo)}/threads/${encodeURIComponent(params.shortId)}/md`;
|
|
97
98
|
const resp = await fetch(url, {
|
|
98
99
|
method: "GET",
|
|
99
100
|
headers: { Authorization: `Bearer ${params.botToken}` },
|
package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/auth.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { connectionFetch, connectionJson, httpConnectionFailure } from "./connection-error.js";
|
|
2
|
-
|
|
2
|
+
import { trimTrailingSlashes } from "./api/url.js";
|
|
3
|
+
/** 建联前用调用方提供的 Bot 凭据解析身份与租户;取消由调用方持有,不跟随重定向转发凭据。 */
|
|
3
4
|
export async function verifyBotIdentity(apiUrl, token, signal) {
|
|
4
|
-
const response = await connectionFetch(`${apiUrl
|
|
5
|
+
const response = await connectionFetch(`${trimTrailingSlashes(apiUrl)}/v1/auth/verify-bot`, {
|
|
5
6
|
method: "POST",
|
|
6
|
-
redirect: "
|
|
7
|
+
redirect: "manual",
|
|
7
8
|
signal: AbortSignal.any([signal, AbortSignal.timeout(15_000)]),
|
|
8
9
|
headers: { "Content-Type": "application/json" },
|
|
9
10
|
body: JSON.stringify({ bot_token: token })
|
package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/channel.d.ts
CHANGED
|
@@ -16,6 +16,15 @@ export declare class GatewayTransport {
|
|
|
16
16
|
group_ids?: string[] | null;
|
|
17
17
|
cards?: boolean;
|
|
18
18
|
typing?: boolean;
|
|
19
|
+
artifact_delivery?: {
|
|
20
|
+
mode?: "channel" | "tools";
|
|
21
|
+
allowed_roots?: string[];
|
|
22
|
+
allowed_mime_types?: string[];
|
|
23
|
+
max_file_bytes?: number;
|
|
24
|
+
max_total_bytes?: number;
|
|
25
|
+
max_files?: number;
|
|
26
|
+
timeout_ms?: number;
|
|
27
|
+
};
|
|
19
28
|
bot_id: string;
|
|
20
29
|
bot_name?: string;
|
|
21
30
|
enabled?: boolean;
|
package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/channel.js
CHANGED
|
@@ -28,6 +28,8 @@ import { sendReadReceipt } from "./api/messages.js";
|
|
|
28
28
|
import { deliveryNoticeCard } from "../presentation/delivery-notice.js";
|
|
29
29
|
import { ImSendError } from "../delivery/text-send.js";
|
|
30
30
|
import { observesImScope } from "./normalize.js";
|
|
31
|
+
import { prepareArtifacts } from "../delivery/artifacts.js";
|
|
32
|
+
import { uploadChatAttachment } from "./api/files.js";
|
|
31
33
|
/** Octo IM 平台连接器:WuKong 与 Octo REST 适配;不是 MCP 连接器。 */
|
|
32
34
|
export class GatewayTransport {
|
|
33
35
|
config;
|
|
@@ -191,28 +193,57 @@ export class GatewayTransport {
|
|
|
191
193
|
const key = stableEffectKey(this.identity, message, effectKey ?? message.messageId, "text");
|
|
192
194
|
await connection.sendText(message.channelId, message.channelType, text, key, this.#spaceId, undefined, undefined, outputObserver());
|
|
193
195
|
},
|
|
194
|
-
replyFinal: async (text, effectKey) => {
|
|
196
|
+
replyFinal: async (text, effectKey, options) => {
|
|
195
197
|
if (this.#closed || signal.aborted)
|
|
196
198
|
throw new Error("IM_CONNECTION_REPLACED");
|
|
199
|
+
const finalSignal = options ? AbortSignal.any([signal, options.signal]) : signal;
|
|
200
|
+
finalSignal.throwIfAborted();
|
|
201
|
+
if (options?.obsolete())
|
|
202
|
+
throw new ImSendError("IM_DELIVERY_CANCELLED", "failed");
|
|
197
203
|
if (finalReply?.key !== effectKey)
|
|
198
204
|
finalReply = {
|
|
199
205
|
key: effectKey,
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
206
|
+
// 整个准备按 effect 缓存,发送重试不再次上传;链接变化必须先于 mention 偏移计算。
|
|
207
|
+
value: (async () => {
|
|
208
|
+
const delivered = options
|
|
209
|
+
? await prepareArtifacts(text, options.artifacts, finalSignal, (bytes, name, mime, uploadSignal) => uploadChatAttachment(this.config.api_url, token, bytes, name, mime, uploadSignal))
|
|
210
|
+
: { text, files: [] };
|
|
211
|
+
const failures = [];
|
|
212
|
+
// 每张文件卡有独立回执;整段准备只执行一次,文本重试不重复卡片或上传。
|
|
213
|
+
for (const [index, file] of delivered.files.entries()) {
|
|
214
|
+
finalSignal.throwIfAborted();
|
|
215
|
+
if (options?.obsolete())
|
|
216
|
+
throw new ImSendError("IM_DELIVERY_CANCELLED", "failed");
|
|
217
|
+
const key = stableEffectKey(this.identity, message, effectKey, `file:${index}`);
|
|
218
|
+
const receipt = await this.#delivery.deliver(key, () => connection.sendFile(message.channelId, message.channelType, file, key, this.#spaceId, finalSignal, outputObserver()), { obsolete: () => finalSignal.aborted || Boolean(options?.obsolete()) });
|
|
219
|
+
if (receipt.state !== "delivered")
|
|
220
|
+
failures.push(`${file.name.replace(/[\r\n\x60[\]<>]/g, "_").slice(0, 120)} (${receipt.state}: ${receipt.code ?? "IM_DELIVERY_UNKNOWN"})`);
|
|
221
|
+
}
|
|
222
|
+
const finalText = delivered.text +
|
|
223
|
+
(failures.length
|
|
224
|
+
? `\n\nFile card delivery unconfirmed: ${failures.join("; ")}. The attachment download links above remain available; generation was not rerun.`
|
|
225
|
+
: "");
|
|
226
|
+
finalSignal.throwIfAborted();
|
|
227
|
+
return prepareFinalMention(finalText, async () => {
|
|
228
|
+
if ([2, 5].includes(message.channelType))
|
|
229
|
+
return getGroupMembers({
|
|
230
|
+
apiUrl: this.config.api_url,
|
|
231
|
+
botToken: token,
|
|
232
|
+
groupNo: groupScope(message.channelId).groupNo,
|
|
233
|
+
signal: finalSignal
|
|
234
|
+
});
|
|
235
|
+
const peer = await getJson(this.config.api_url, token, `/v1/bot/user/info?uid=${encodeURIComponent(message.fromUid)}`, AbortSignal.any([finalSignal, AbortSignal.timeout(5000)]), { maxResponseBytes: 64 << 10, logRateLimit: false });
|
|
236
|
+
return peer?.uid === message.fromUid ? [peer] : [];
|
|
237
|
+
});
|
|
238
|
+
})()
|
|
211
239
|
};
|
|
212
240
|
const result = await finalReply.value;
|
|
213
241
|
if (this.#closed || signal.aborted)
|
|
214
242
|
throw new Error("IM_CONNECTION_REPLACED");
|
|
215
|
-
|
|
243
|
+
finalSignal.throwIfAborted();
|
|
244
|
+
if (options?.obsolete())
|
|
245
|
+
throw new ImSendError("IM_DELIVERY_CANCELLED", "failed");
|
|
246
|
+
await connection.sendText(message.channelId, message.channelType, result.text, stableEffectKey(this.identity, message, effectKey, "text"), this.#spaceId, result.mention, finalSignal, outputObserver());
|
|
216
247
|
},
|
|
217
248
|
buildContext: async (turnSignal, options) => ({
|
|
218
249
|
schema: CONTEXT_SCHEMA,
|
|
@@ -4,6 +4,13 @@ export declare class ImConnectionError extends Error {
|
|
|
4
4
|
readonly retryAfterMs: number;
|
|
5
5
|
constructor(code: string, retryable: boolean, retryAfterMs?: number);
|
|
6
6
|
}
|
|
7
|
+
/**
|
|
8
|
+
* 保留 WuKong 原因码,区分连接中断与明确拒绝;不把服务端主动断开等同于凭据失效。
|
|
9
|
+
* DISCONNECT 与失败 CONNACK 均默认允许重新鉴权建联,覆盖滚动更新、节点迁移和新增码。
|
|
10
|
+
* 只有机器可读的明确认证、权限或协议拒绝才永久失败,不由原因文案猜测所有权。
|
|
11
|
+
*/
|
|
12
|
+
export declare function wukongConnectionFailure(phase: "CONNECT_REJECTED" | "SERVER_DISCONNECTED", reason: number): ImConnectionError;
|
|
13
|
+
/** 将连接依赖的异常归一为脱敏恢复事实;显式分类优先,调用方据此安排回收后的重试。 */
|
|
7
14
|
export declare function connectionFailure(error: unknown): ImConnectionError;
|
|
8
15
|
export declare function connectionFetch(url: string, init: RequestInit, phase: "AUTH" | "REGISTER"): Promise<Response>;
|
|
9
16
|
export declare function httpConnectionFailure(response: Response, phase: "AUTH" | "REGISTER"): Promise<ImConnectionError>;
|
|
@@ -8,13 +8,49 @@ export class ImConnectionError extends Error {
|
|
|
8
8
|
this.retryAfterMs = retryAfterMs;
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* 保留 WuKong 原因码,区分连接中断与明确拒绝;不把服务端主动断开等同于凭据失效。
|
|
13
|
+
* DISCONNECT 与失败 CONNACK 均默认允许重新鉴权建联,覆盖滚动更新、节点迁移和新增码。
|
|
14
|
+
* 只有机器可读的明确认证、权限或协议拒绝才永久失败,不由原因文案猜测所有权。
|
|
15
|
+
*/
|
|
16
|
+
export function wukongConnectionFailure(phase, reason) {
|
|
17
|
+
// 认证、黑/白名单、封禁、禁止发送及明确协议/密钥错误,不靠重新连接消除。
|
|
18
|
+
const terminal = [2, 4, 8, 9, 11, 13, 19, 20, 21, 23, 27].includes(reason);
|
|
19
|
+
return new ImConnectionError(`IM_${phase}_${reason}`, !terminal);
|
|
20
|
+
}
|
|
21
|
+
/** 将连接依赖的异常归一为脱敏恢复事实;显式分类优先,调用方据此安排回收后的重试。 */
|
|
11
22
|
export function connectionFailure(error) {
|
|
12
23
|
if (error instanceof ImConnectionError)
|
|
13
24
|
return error;
|
|
14
25
|
const code = error instanceof Error && /^IM_[A-Z0-9_]+$/.test(error.message)
|
|
15
26
|
? error.message
|
|
16
27
|
: "IM_CONNECTION_FAILED";
|
|
17
|
-
|
|
28
|
+
// 未分类异常可能来自宿主凭据服务或连接依赖,不能单凭缺少类型就永久停止恢复。
|
|
29
|
+
// 本地已确认的身份、配置、协议及资源所有权错误仍须修正后才能重新连接。
|
|
30
|
+
const terminal = [
|
|
31
|
+
"IM_CREDENTIALS_REQUIRED",
|
|
32
|
+
"IM_BOT_TOKEN_INVALID",
|
|
33
|
+
"IM_BOT_IDENTITY_MISMATCH",
|
|
34
|
+
"IM_TENANT_NOT_ACTIVE",
|
|
35
|
+
"IM_AUTH_IDENTITY_INVALID",
|
|
36
|
+
"IM_REGISTRATION_INVALID",
|
|
37
|
+
"IM_WS_URL_INVALID",
|
|
38
|
+
"IM_WS_TLS_REQUIRED",
|
|
39
|
+
"IM_ALREADY_CONNECTED",
|
|
40
|
+
"IM_DISPOSE_FAILED",
|
|
41
|
+
"IM_TRANSPORT_DISPOSE_FAILED",
|
|
42
|
+
"IM_FIELD_TOO_LARGE",
|
|
43
|
+
"IM_FRAME_TRUNCATED",
|
|
44
|
+
"IM_BINARY_REQUIRED",
|
|
45
|
+
"IM_FRAME_TOO_LARGE",
|
|
46
|
+
"IM_LENGTH_INVALID",
|
|
47
|
+
"IM_KEY_INVALID",
|
|
48
|
+
"IM_HANDSHAKE_REQUIRED",
|
|
49
|
+
"IM_PROTOCOL_ERROR",
|
|
50
|
+
"IM_MESSAGE_KEY_INVALID",
|
|
51
|
+
"IM_PAYLOAD_INVALID"
|
|
52
|
+
].includes(code);
|
|
53
|
+
return new ImConnectionError(code, !terminal);
|
|
18
54
|
}
|
|
19
55
|
export async function connectionFetch(url, init, phase) {
|
|
20
56
|
try {
|
|
@@ -35,8 +71,13 @@ export async function httpConnectionFailure(response, phase) {
|
|
|
35
71
|
const date = retryAfter ? Date.parse(retryAfter) : NaN;
|
|
36
72
|
const retryAfterMs = Math.max(0, seconds !== undefined ? seconds * 1000 : date - Date.now());
|
|
37
73
|
await response.body?.cancel();
|
|
38
|
-
//
|
|
39
|
-
|
|
74
|
+
// 仅明确认证、资源/请求或协议错误停止;服务超时、冲突、限流及未知服务故障默认重试。
|
|
75
|
+
// 禁止重定向仍是接入约束,不能自动把凭据带到另一个地址。
|
|
76
|
+
const terminal = response.status < 400 ||
|
|
77
|
+
[
|
|
78
|
+
400, 401, 403, 404, 405, 407, 410, 411, 413, 414, 415, 416, 417, 422, 426, 428, 431, 451
|
|
79
|
+
].includes(response.status);
|
|
80
|
+
return new ImConnectionError(`IM_${phase}_HTTP_${response.status}`, !terminal, Number.isFinite(retryAfterMs) ? retryAfterMs : 0);
|
|
40
81
|
}
|
|
41
82
|
export async function connectionJson(response, phase, invalidCode) {
|
|
42
83
|
try {
|
|
@@ -5,6 +5,7 @@ import { request as httpsRequest } from "node:https";
|
|
|
5
5
|
import { BlockList, isIP } from "node:net";
|
|
6
6
|
import { IMAGE_INPUT_LIMITS } from "@mininglamp-oss/octo-runtime-protocol";
|
|
7
7
|
import { parseImageDimensions } from "./api/files.js";
|
|
8
|
+
import { trimTrailingSlashes } from "./api/url.js";
|
|
8
9
|
export class ImImageInputError extends Error {
|
|
9
10
|
}
|
|
10
11
|
const blocked = new BlockList();
|
|
@@ -32,7 +33,7 @@ export function imageUrl(raw, apiUrl) {
|
|
|
32
33
|
if (/^[a-z][a-z0-9+.-]*:/i.test(value) || value.startsWith("/"))
|
|
33
34
|
return new URL(value, apiUrl);
|
|
34
35
|
const path = value.replace(/^file\/(?:preview\/)?/, "");
|
|
35
|
-
return new URL(`${apiUrl
|
|
36
|
+
return new URL(`${trimTrailingSlashes(apiUrl)}/file/${path}`);
|
|
36
37
|
}
|
|
37
38
|
catch {
|
|
38
39
|
throw new ImImageInputError("图片地址无效。");
|
package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/wukong.d.ts
CHANGED
|
@@ -42,6 +42,13 @@ export declare class WukongConnection {
|
|
|
42
42
|
get connected(): boolean;
|
|
43
43
|
connect(registration: BotRegistration): Promise<void>;
|
|
44
44
|
sendText(channelId: string, channelType: number, text: string, clientMsgNo?: string, spaceId?: string, mention?: ImTextMention, signal?: AbortSignal, onPosition?: (sequence: number) => void): Promise<string>;
|
|
45
|
+
/** 原生文件消息复用文本的加密、稳定编号、ACK/迟到确认和取消窗口;不使用互动卡服务。 */
|
|
46
|
+
sendFile(channelId: string, channelType: number, file: {
|
|
47
|
+
url: string;
|
|
48
|
+
name: string;
|
|
49
|
+
size: number;
|
|
50
|
+
extension: string;
|
|
51
|
+
}, clientMsgNo: string, spaceId?: string, signal?: AbortSignal, onPosition?: (sequence: number) => void): Promise<string>;
|
|
45
52
|
isDelivered(clientMsgNo: string): boolean;
|
|
46
53
|
close(): Promise<void>;
|
|
47
54
|
}
|
package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/wukong.js
CHANGED
|
@@ -6,13 +6,14 @@ import { createCipheriv, createDecipheriv, createHash, createPublicKey, diffieHe
|
|
|
6
6
|
import WebSocket from "ws";
|
|
7
7
|
import { ImSendError, ImTextSend } from "../delivery/text-send.js";
|
|
8
8
|
import { isRulesNotification } from "./normalize.js";
|
|
9
|
-
import { connectionFetch, connectionJson, httpConnectionFailure, ImConnectionError } from "./connection-error.js";
|
|
9
|
+
import { connectionFetch, connectionJson, httpConnectionFailure, ImConnectionError, wukongConnectionFailure } from "./connection-error.js";
|
|
10
10
|
const LIMIT = 1 << 20;
|
|
11
11
|
const md5 = (value) => createHash("md5").update(value).digest("hex");
|
|
12
12
|
export async function registerBot(apiUrl, token, signal) {
|
|
13
13
|
const response = await connectionFetch(`${apiUrl.replace(/\/$/, "")}/v1/bot/register`, {
|
|
14
14
|
method: "POST",
|
|
15
|
-
|
|
15
|
+
// 返回重定向状态供统一分类,不跟随到新地址,也不将其折叠成网络暂态。
|
|
16
|
+
redirect: "manual",
|
|
16
17
|
signal: signal
|
|
17
18
|
? AbortSignal.any([signal, AbortSignal.timeout(15_000)])
|
|
18
19
|
: AbortSignal.timeout(15_000),
|
|
@@ -243,7 +244,7 @@ export class WukongConnection {
|
|
|
243
244
|
reader.u64();
|
|
244
245
|
const reason = reader.byte();
|
|
245
246
|
if (reason !== 1)
|
|
246
|
-
throw
|
|
247
|
+
throw wukongConnectionFailure("CONNECT_REJECTED", reason);
|
|
247
248
|
const remoteKey = reader.string();
|
|
248
249
|
const salt = reader.string();
|
|
249
250
|
if (this.#version >= 4)
|
|
@@ -273,6 +274,10 @@ export class WukongConnection {
|
|
|
273
274
|
this.#heartbeat.unref();
|
|
274
275
|
resolve();
|
|
275
276
|
}
|
|
277
|
+
else if (kind === 9) {
|
|
278
|
+
// 滚动更新也可能在 CONNACK 前关闭连接;先按断开原因分类,不能误报握手协议错误。
|
|
279
|
+
throw wukongConnectionFailure("SERVER_DISCONNECTED", reader.byte());
|
|
280
|
+
}
|
|
276
281
|
else if (!ready)
|
|
277
282
|
throw new Error("IM_HANDSHAKE_REQUIRED");
|
|
278
283
|
else if (kind === 5)
|
|
@@ -294,8 +299,6 @@ export class WukongConnection {
|
|
|
294
299
|
pending.operation.ack(id, reason);
|
|
295
300
|
}
|
|
296
301
|
}
|
|
297
|
-
else if (kind === 9)
|
|
298
|
-
throw new ImConnectionError(`IM_SERVER_DISCONNECTED_${reader.byte()}`, false);
|
|
299
302
|
}
|
|
300
303
|
}
|
|
301
304
|
catch (error) {
|
|
@@ -366,18 +369,21 @@ export class WukongConnection {
|
|
|
366
369
|
this.#socket?.send(frame(6, new Writer().u64(messageId).u32(messageSeq).finish()));
|
|
367
370
|
}
|
|
368
371
|
sendText(channelId, channelType, text, clientMsgNo = randomUUID(), spaceId, mention, signal, onPosition) {
|
|
372
|
+
return this.#sendPayload(channelId, channelType, { type: 1, content: text, ...(mention ? { mention } : {}) }, clientMsgNo, spaceId, signal, onPosition);
|
|
373
|
+
}
|
|
374
|
+
/** 原生文件消息复用文本的加密、稳定编号、ACK/迟到确认和取消窗口;不使用互动卡服务。 */
|
|
375
|
+
sendFile(channelId, channelType, file, clientMsgNo, spaceId, signal, onPosition) {
|
|
376
|
+
return this.#sendPayload(channelId, channelType, { type: 8, url: file.url, name: file.name, size: file.size, extension: file.extension }, clientMsgNo, spaceId, signal, onPosition);
|
|
377
|
+
}
|
|
378
|
+
#sendPayload(channelId, channelType, payload, clientMsgNo, spaceId, signal, onPosition) {
|
|
369
379
|
if (this.#socket?.readyState !== WebSocket.OPEN || !this.#key)
|
|
370
380
|
return Promise.reject(new ImSendError("IM_NOT_READY", "failed"));
|
|
371
|
-
|
|
381
|
+
const serialized = JSON.stringify({ ...payload, ...(spaceId ? { space_id: spaceId } : {}) });
|
|
382
|
+
if (Buffer.byteLength(serialized) > 256 * 1024 ||
|
|
372
383
|
this.#active.size >= 64 ||
|
|
373
384
|
this.#socket.bufferedAmount > LIMIT)
|
|
374
385
|
return Promise.reject(new ImSendError("IM_SEND_CAPACITY_EXHAUSTED", "failed"));
|
|
375
|
-
const encrypted = this.#encrypt(
|
|
376
|
-
type: 1,
|
|
377
|
-
content: text,
|
|
378
|
-
...(spaceId ? { space_id: spaceId } : {}),
|
|
379
|
-
...(mention ? { mention } : {})
|
|
380
|
-
}));
|
|
386
|
+
const encrypted = this.#encrypt(serialized);
|
|
381
387
|
const operation = new ImTextSend(() => {
|
|
382
388
|
if (!this.connected)
|
|
383
389
|
throw new ImSendError("IM_NOT_READY", "failed");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mininglamp-oss/octo-runtime-extra-channel-gateway",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.5",
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -8,6 +8,10 @@
|
|
|
8
8
|
".": {
|
|
9
9
|
"types": "./dist/index.d.ts",
|
|
10
10
|
"import": "./dist/index.js"
|
|
11
|
+
},
|
|
12
|
+
"./commands": {
|
|
13
|
+
"types": "./dist/commands.d.ts",
|
|
14
|
+
"import": "./dist/commands.js"
|
|
11
15
|
}
|
|
12
16
|
},
|
|
13
17
|
"types": "./dist/index.d.ts",
|
|
@@ -18,11 +22,11 @@
|
|
|
18
22
|
"docs"
|
|
19
23
|
],
|
|
20
24
|
"dependencies": {
|
|
21
|
-
"@mininglamp-oss/octo-runtime-executor-kernel": "1.1.
|
|
22
|
-
"@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.
|
|
23
|
-
"@mininglamp-oss/octo-runtime-executor-core": "1.1.
|
|
24
|
-
"@mininglamp-oss/octo-runtime-host-sdk": "1.1.
|
|
25
|
-
"@mininglamp-oss/octo-runtime-protocol": "1.1.
|
|
25
|
+
"@mininglamp-oss/octo-runtime-executor-kernel": "1.1.5",
|
|
26
|
+
"@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.5",
|
|
27
|
+
"@mininglamp-oss/octo-runtime-executor-core": "1.1.5",
|
|
28
|
+
"@mininglamp-oss/octo-runtime-host-sdk": "1.1.5",
|
|
29
|
+
"@mininglamp-oss/octo-runtime-protocol": "1.1.5",
|
|
26
30
|
"mdast-util-from-markdown": "2.1.0",
|
|
27
31
|
"ws": "8.22.0"
|
|
28
32
|
}
|