@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
package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-wecom/dist/application/im-channel.js
CHANGED
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
* 管理会话、排队、取消和交互归属;平台协议交给 connector,领域业务交给发起方。
|
|
4
4
|
*/
|
|
5
5
|
import { randomUUID } from "node:crypto";
|
|
6
|
+
import { performance } from "node:perf_hooks";
|
|
7
|
+
import { shutdownDeadline, withinShutdown } from "@mininglamp-oss/octo-runtime-host-sdk/shutdown";
|
|
8
|
+
import { isInvocationNotSubmitted } from "@mininglamp-oss/octo-runtime-executor-kernel";
|
|
9
|
+
import { failurePayload, failureMessage } from "@mininglamp-oss/octo-runtime-protocol";
|
|
6
10
|
import { imBotIdentity, validateImConfig } from "../lifecycle/configuration.js";
|
|
7
11
|
import { WecomTransport } from "../transport/channel.js";
|
|
8
12
|
import { createImInvocation } from "../execution/dispatcher.js";
|
|
@@ -21,6 +25,8 @@ export class ImRuntime {
|
|
|
21
25
|
#queuedOccurrences = new Set();
|
|
22
26
|
#interactions = new Map();
|
|
23
27
|
#responding = new Set();
|
|
28
|
+
#failureNotifications = new Map();
|
|
29
|
+
#finishIncomplete;
|
|
24
30
|
#closed = true;
|
|
25
31
|
#state = "stopped";
|
|
26
32
|
#reconnect;
|
|
@@ -182,11 +188,11 @@ export class ImRuntime {
|
|
|
182
188
|
}, Math.min(30_000, 5_000 * 2 ** this.#retry++));
|
|
183
189
|
this.#reconnect.unref();
|
|
184
190
|
}
|
|
185
|
-
#diagnostic(code, runId) {
|
|
186
|
-
this.#error = code;
|
|
191
|
+
#diagnostic(code, runId, data = {}) {
|
|
187
192
|
try {
|
|
188
193
|
this.dependencies.log?.("warn", "channel.diagnostic", {
|
|
189
194
|
code,
|
|
195
|
+
...data,
|
|
190
196
|
endpoint_id: imBotIdentity(this.config),
|
|
191
197
|
...(runId ? { run_id: runId } : {})
|
|
192
198
|
});
|
|
@@ -242,6 +248,16 @@ export class ImRuntime {
|
|
|
242
248
|
let session;
|
|
243
249
|
try {
|
|
244
250
|
session = this.#session(key);
|
|
251
|
+
}
|
|
252
|
+
catch {
|
|
253
|
+
const failure = failurePayload({ code: "IM_SESSION_STORE_FAILED" }, {
|
|
254
|
+
stage: "channel_session_read",
|
|
255
|
+
defaultDomain: "runtime"
|
|
256
|
+
}).failure;
|
|
257
|
+
void this.#notifyFailure(message, failure).finally(() => this.#seen.delete(dedupe));
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
try {
|
|
245
261
|
if (command === "/reset") {
|
|
246
262
|
try {
|
|
247
263
|
const binding = this.#sessionStore.reset(key, message.messageId);
|
|
@@ -280,7 +296,7 @@ export class ImRuntime {
|
|
|
280
296
|
}
|
|
281
297
|
catch {
|
|
282
298
|
this.#seen.delete(dedupe);
|
|
283
|
-
this.#diagnostic("
|
|
299
|
+
this.#diagnostic("IM_INBOUND_PROCESSING_FAILED");
|
|
284
300
|
}
|
|
285
301
|
finally {
|
|
286
302
|
if (session)
|
|
@@ -325,7 +341,9 @@ export class ImRuntime {
|
|
|
325
341
|
const previous = this.#sessionStore.occurrence(key, id);
|
|
326
342
|
if (previous) {
|
|
327
343
|
void this.#reply(message, previous.text === message.text
|
|
328
|
-
?
|
|
344
|
+
? previous.notSubmittedFailure
|
|
345
|
+
? `原消息尚未提交,请修复故障后重新发送。\n错误码:${previous.notSubmittedFailure.code}\n诊断编号:${previous.notSubmittedFailure.diagnosticId}`
|
|
346
|
+
: "该消息已经提交,请查看原执行结果。"
|
|
329
347
|
: "消息身份冲突,请重新发送。", `duplicate:${id}`);
|
|
330
348
|
return false;
|
|
331
349
|
}
|
|
@@ -355,6 +373,43 @@ export class ImRuntime {
|
|
|
355
373
|
this.#releaseSession(key, session);
|
|
356
374
|
}
|
|
357
375
|
}
|
|
376
|
+
/** WeCom 沿自身文本回复协议消费共享错误;没有独立错误卡片端口,不复用已坏的展示实例。 */
|
|
377
|
+
#notifyFailure(message, failure, identity) {
|
|
378
|
+
const data = {
|
|
379
|
+
code: failure.code,
|
|
380
|
+
reason_code: failure.reasonCode,
|
|
381
|
+
diagnostic_id: failure.diagnosticId,
|
|
382
|
+
stage: failure.stage,
|
|
383
|
+
failure_component: failure.source.component,
|
|
384
|
+
occurred_at: failure.occurredAt,
|
|
385
|
+
...(failure.source.adapter ? { adapter_type: failure.source.adapter } : {}),
|
|
386
|
+
...(identity ? { invocation_id: identity.invocationId, session_id: identity.sessionId } : {})
|
|
387
|
+
};
|
|
388
|
+
this.#diagnostic(failure.reasonCode, identity?.runId, data);
|
|
389
|
+
if (this.#failureNotifications.size >= 64 || this.#closed || !this.#delivery)
|
|
390
|
+
return Promise.resolve();
|
|
391
|
+
const until = shutdownDeadline(this.dependencies.signal);
|
|
392
|
+
const effect = `failure:${message.messageId}:${failure.diagnosticId}`;
|
|
393
|
+
const text = `${failureMessage(failure.code)}\n错误码:${failure.code}\n诊断编号:${failure.diagnosticId}`;
|
|
394
|
+
const secondary = (code) => this.#diagnostic(code, identity?.runId, {
|
|
395
|
+
...data,
|
|
396
|
+
code,
|
|
397
|
+
reason_code: code,
|
|
398
|
+
primary_code: failure.code
|
|
399
|
+
});
|
|
400
|
+
const notification = withinShutdown(this.#delivery.deliver(effect, () => message.reply(text, effect), {
|
|
401
|
+
transient: true,
|
|
402
|
+
obsolete: () => this.#closed || performance.now() >= until
|
|
403
|
+
}), until, "IM_DELIVERY_UNKNOWN")
|
|
404
|
+
.then((receipt) => {
|
|
405
|
+
if (receipt.state !== "delivered")
|
|
406
|
+
secondary(receipt.code ?? "IM_DELIVERY_FAILED");
|
|
407
|
+
})
|
|
408
|
+
.catch(() => secondary("IM_DELIVERY_UNKNOWN"))
|
|
409
|
+
.finally(() => this.#failureNotifications.delete(failure.diagnosticId));
|
|
410
|
+
this.#failureNotifications.set(failure.diagnosticId, notification);
|
|
411
|
+
return notification;
|
|
412
|
+
}
|
|
358
413
|
async #reply(message, text, effectKey, requireDelivered = false) {
|
|
359
414
|
if (this.#closed || this.#signal.aborted || !this.#delivery)
|
|
360
415
|
return;
|
|
@@ -462,12 +517,17 @@ export class ImRuntime {
|
|
|
462
517
|
invocation_id: request.invocationId,
|
|
463
518
|
session_id: request.sessionId
|
|
464
519
|
});
|
|
465
|
-
|
|
520
|
+
let projector = new ImRunProjector(request.runId, message.conversationKind === "direct");
|
|
466
521
|
const controls = this.#runControls(message, key, request.invocationId);
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
522
|
+
let presentation;
|
|
523
|
+
let presentationFailed = false;
|
|
524
|
+
let executionStarted = false;
|
|
525
|
+
let localFailure;
|
|
470
526
|
try {
|
|
527
|
+
presentation = message.beginPresentation?.(request.runId, (code) => this.#diagnostic(code, request.runId), controls);
|
|
528
|
+
presentation?.update(projector.snapshot());
|
|
529
|
+
session.activeInvocationId = request.invocationId;
|
|
530
|
+
executionStarted = true;
|
|
471
531
|
for await (const event of this.dependencies.kernel.invoke(request, {
|
|
472
532
|
signal: this.#signal
|
|
473
533
|
})) {
|
|
@@ -485,6 +545,15 @@ export class ImRuntime {
|
|
|
485
545
|
event.payload.request.policy?.mode === "full_access")
|
|
486
546
|
continue;
|
|
487
547
|
if (event.type === "interaction.requested") {
|
|
548
|
+
if (Array.isArray(event.payload.request.questions) &&
|
|
549
|
+
event.payload.request.questions.some((question) => question !== null &&
|
|
550
|
+
typeof question === "object" &&
|
|
551
|
+
"isSecret" in question &&
|
|
552
|
+
question.isSecret === true)) {
|
|
553
|
+
this.#diagnostic("IM_INTERACTION_SECRET_UNSUPPORTED", request.runId);
|
|
554
|
+
await this.dependencies.kernel.cancelInvocation(request.invocationId, "IM secret input unsupported");
|
|
555
|
+
continue;
|
|
556
|
+
}
|
|
488
557
|
if (this.#interactions.size >= 64)
|
|
489
558
|
throw new Error("IM_INTERACTION_CAPACITY_EXHAUSTED");
|
|
490
559
|
this.#interactions.set(event.payload.interactionId, {
|
|
@@ -503,25 +572,60 @@ export class ImRuntime {
|
|
|
503
572
|
const instruction = interaction.kind === "approval"
|
|
504
573
|
? `/approve ${interaction.interactionId} 或 /decline ${interaction.interactionId}`
|
|
505
574
|
: `/respond ${interaction.interactionId} ${interaction.kind === "elicitation" ? "<JSON>" : "<回答>"}`;
|
|
506
|
-
await this.#reply(message, `${summary?.slice(0, 1000) ?? "执行需要你的确认或输入。"}\n${instruction}`, `interaction:${interaction.interactionId}
|
|
575
|
+
await this.#reply(message, `${summary?.slice(0, 1000) ?? "执行需要你的确认或输入。"}\n${instruction}`, `interaction:${interaction.interactionId}`, true);
|
|
507
576
|
}
|
|
508
577
|
if (event.type === "interaction.resolved")
|
|
509
578
|
this.#interactions.delete(event.payload.interactionId);
|
|
510
579
|
projector.accept(event);
|
|
511
580
|
controls.failed = projector.snapshot().terminal === "failed";
|
|
512
|
-
|
|
581
|
+
if (!presentationFailed) {
|
|
582
|
+
try {
|
|
583
|
+
presentation?.update(projector.snapshot());
|
|
584
|
+
}
|
|
585
|
+
catch {
|
|
586
|
+
presentationFailed = true;
|
|
587
|
+
this.#diagnostic("IM_PRESENTATION_FAILED", request.runId);
|
|
588
|
+
if (!projector.snapshot().terminal)
|
|
589
|
+
void this.dependencies.kernel
|
|
590
|
+
.cancelInvocation(request.invocationId, "IM presentation failed")
|
|
591
|
+
.catch(() => this.#diagnostic("IM_CANCEL_FAILED", request.runId));
|
|
592
|
+
}
|
|
593
|
+
}
|
|
513
594
|
}
|
|
514
595
|
if (!projector.snapshot().terminal)
|
|
515
596
|
throw new Error("IM_RUN_WITHOUT_TERMINAL");
|
|
516
597
|
}
|
|
517
|
-
catch {
|
|
518
|
-
if (!
|
|
598
|
+
catch (error) {
|
|
599
|
+
if (!executionStarted || isInvocationNotSubmitted(error)) {
|
|
600
|
+
localFailure = failurePayload({
|
|
601
|
+
code: executionStarted
|
|
602
|
+
? "CLIENT_INVOCATION_ADMISSION_CLOSED"
|
|
603
|
+
: "IM_PRESENTATION_INITIALIZATION_FAILED"
|
|
604
|
+
}, {
|
|
605
|
+
stage: executionStarted ? "channel_admission" : "channel_presentation_initialize",
|
|
606
|
+
defaultDomain: "runtime",
|
|
607
|
+
invocationNotSubmitted: executionStarted,
|
|
608
|
+
runId: request.runId
|
|
609
|
+
}).failure;
|
|
610
|
+
controls.failed = false;
|
|
611
|
+
await this.#notifyFailure(message, localFailure, request);
|
|
612
|
+
}
|
|
613
|
+
else {
|
|
519
614
|
// 流断开无法证明执行失败;尽力取消并提示核查,不自动重跑潜在的业务副作用。
|
|
520
615
|
await this.dependencies.kernel
|
|
521
616
|
.cancelInvocation(request.invocationId, "IM execution stream failed")
|
|
522
617
|
.catch(() => undefined);
|
|
523
618
|
this.#diagnostic("IM_EXECUTION_RESULT_UNKNOWN", request.runId);
|
|
524
|
-
|
|
619
|
+
controls.failed = false;
|
|
620
|
+
projector = new ImRunProjector(request.runId, message.conversationKind === "direct");
|
|
621
|
+
if (!presentationFailed) {
|
|
622
|
+
try {
|
|
623
|
+
presentation?.update({ ...projector.snapshot(), resultUnknown: true });
|
|
624
|
+
}
|
|
625
|
+
catch {
|
|
626
|
+
this.#diagnostic("IM_PRESENTATION_FAILED", request.runId);
|
|
627
|
+
}
|
|
628
|
+
}
|
|
525
629
|
}
|
|
526
630
|
}
|
|
527
631
|
finally {
|
|
@@ -529,19 +633,37 @@ export class ImRuntime {
|
|
|
529
633
|
run_id: request.runId,
|
|
530
634
|
invocation_id: request.invocationId,
|
|
531
635
|
session_id: request.sessionId,
|
|
532
|
-
status: projector.snapshot().terminal ?? "unknown"
|
|
636
|
+
status: localFailure ? "not_submitted" : (projector.snapshot().terminal ?? "unknown")
|
|
533
637
|
});
|
|
638
|
+
if (localFailure && !this.#closed) {
|
|
639
|
+
try {
|
|
640
|
+
this.#sessionStore.remember(key, occurrenceId ?? message.messageId, {
|
|
641
|
+
text: message.text,
|
|
642
|
+
sessionId: request.sessionId,
|
|
643
|
+
runId: request.runId,
|
|
644
|
+
snapshot: { ...request },
|
|
645
|
+
notSubmittedFailure: localFailure
|
|
646
|
+
});
|
|
647
|
+
}
|
|
648
|
+
catch {
|
|
649
|
+
this.#diagnostic("IM_SESSION_STORE_FAILED", request.runId);
|
|
650
|
+
}
|
|
651
|
+
}
|
|
534
652
|
session.activeInvocationId = undefined;
|
|
535
653
|
for (const [id, entry] of this.#interactions)
|
|
536
654
|
if (entry.invocationId === request.invocationId)
|
|
537
655
|
this.#interactions.delete(id);
|
|
538
656
|
try {
|
|
539
|
-
await presentation?.finish();
|
|
657
|
+
await withinShutdown(Promise.resolve().then(() => presentation?.finish()), shutdownDeadline(this.dependencies.signal), "IM_PRESENTATION_FINISH_INCOMPLETE");
|
|
540
658
|
}
|
|
541
|
-
catch {
|
|
659
|
+
catch (error) {
|
|
660
|
+
if (error instanceof Error && error.message === "IM_PRESENTATION_FINISH_INCOMPLETE")
|
|
661
|
+
this.#finishIncomplete ??= error;
|
|
542
662
|
this.#diagnostic("IM_PRESENTATION_FAILED", request.runId);
|
|
543
663
|
}
|
|
544
664
|
}
|
|
665
|
+
if (localFailure)
|
|
666
|
+
return;
|
|
545
667
|
if (this.#closed || this.#signal.aborted)
|
|
546
668
|
return;
|
|
547
669
|
const snapshot = projector.snapshot();
|
|
@@ -592,9 +714,12 @@ export class ImRuntime {
|
|
|
592
714
|
.filter((session) => session.activeInvocationId)
|
|
593
715
|
.map((session) => attempt(() => this.dependencies.kernel.cancelInvocation(session.activeInvocationId, "IM shutdown"))));
|
|
594
716
|
await attempt(() => this.#connecting);
|
|
717
|
+
await Promise.all([...this.#failureNotifications.values()].map((notification) => attempt(() => notification)));
|
|
595
718
|
await Promise.all([...this.#sessions.values()].map((session) => attempt(() => session.tail)));
|
|
596
719
|
if (!this.dependencies.sessions)
|
|
597
720
|
await attempt(() => this.#sessionStore.close?.());
|
|
721
|
+
if (this.#finishIncomplete)
|
|
722
|
+
errors.push(this.#finishIncomplete);
|
|
598
723
|
if (errors.length)
|
|
599
724
|
throw new AggregateError(errors, "IM_DISPOSE_FAILED");
|
|
600
725
|
this.#sessions.clear();
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type { ImInvocationInput } from "../execution/dispatcher.js";
|
|
2
|
-
import type { ProviderSession } from "@mininglamp-oss/octo-runtime-protocol";
|
|
2
|
+
import type { FailureEnvelope, ProviderSession } from "@mininglamp-oss/octo-runtime-protocol";
|
|
3
3
|
export interface ImSessionOccurrence {
|
|
4
4
|
text: string;
|
|
5
5
|
sessionId: string;
|
|
6
6
|
runId: string;
|
|
7
7
|
snapshot?: ImInvocationInput;
|
|
8
|
+
/** 本轮确定未提交;可选字段保持旧宿主存储兼容。 */
|
|
9
|
+
notSubmittedFailure?: FailureEnvelope;
|
|
8
10
|
}
|
|
9
11
|
export interface ImSessionBinding {
|
|
10
12
|
id?: string;
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { ExtraCommandError, savedConfigResult } from "@mininglamp-oss/octo-runtime-host-sdk/extra-commands";
|
|
2
|
+
import { validateImBots } from "./lifecycle/configuration.js";
|
|
3
|
+
/** 离线业务校验复用运行时 Bot 合同;不认证、不构造 manager 或服务。 */
|
|
4
|
+
function validate(config) {
|
|
5
|
+
try {
|
|
6
|
+
validateImBots(config.bots ?? []);
|
|
7
|
+
const spaces = config.authorized_space_ids;
|
|
8
|
+
if (spaces !== undefined &&
|
|
9
|
+
(!Array.isArray(spaces) || spaces.some((id) => typeof id !== "string" || !id.trim())))
|
|
10
|
+
throw new Error("IM_AUTHORIZED_SPACES_INVALID");
|
|
11
|
+
const settings = config.context_loading;
|
|
12
|
+
if (settings !== undefined) {
|
|
13
|
+
if (!settings ||
|
|
14
|
+
typeof settings !== "object" ||
|
|
15
|
+
Array.isArray(settings) ||
|
|
16
|
+
Object.keys(settings).some((key) => !["timeout_ms", "max_in_flight"].includes(key)))
|
|
17
|
+
throw new Error("IM_CONTEXT_LOADING_CONFIG_INVALID");
|
|
18
|
+
for (const [key, max] of [
|
|
19
|
+
["timeout_ms", 30000],
|
|
20
|
+
["max_in_flight", 32]
|
|
21
|
+
]) {
|
|
22
|
+
const value = settings[key];
|
|
23
|
+
if (value !== undefined &&
|
|
24
|
+
(typeof value !== "number" || !Number.isInteger(value) || value < 1 || value > max))
|
|
25
|
+
throw new Error("IM_CONTEXT_LOADING_CONFIG_INVALID");
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
const hints = {
|
|
31
|
+
IM_BOT_ID_REQUIRED: "Provide a non-empty --bot_id (JSON: bots[].bot_id).",
|
|
32
|
+
IM_ADAPTER_REQUIRED: "Each Bot requires an adapter object; configure maps --adapter_type/--workdir to it.",
|
|
33
|
+
IM_WORKDIR_ABSOLUTE_REQUIRED: "Provide an absolute --workdir for a local adapter.",
|
|
34
|
+
IM_OPENCLAW_WORKDIR_UNSUPPORTED: "OpenClaw uses its own workspace; remove config.bots[].adapter.workdir using extraset.",
|
|
35
|
+
IM_PROVIDER_AGENT_ID_UNSUPPORTED: "--provider_agent_id is supported only by OpenClaw.",
|
|
36
|
+
IM_API_URL_INVALID: "Use a valid endpoint URL without credentials, query or fragment; insecure URLs are loopback-only.",
|
|
37
|
+
IM_BOT_DUPLICATED: "Duplicate Bot identity in bots; keep one entry per endpoint and bot_id.",
|
|
38
|
+
IM_CONFIG_LIST_REQUIRED: "bots must be an array within this Extra's Bot limit.",
|
|
39
|
+
IM_AUTHORIZED_SPACES_INVALID: "authorized_space_ids must contain non-empty strings.",
|
|
40
|
+
IM_CONTEXT_LOADING_CONFIG_INVALID: "context_loading accepts timeout_ms (1..30000) and max_in_flight (1..32)."
|
|
41
|
+
};
|
|
42
|
+
const code = error instanceof Error && Object.hasOwn(hints, error.message)
|
|
43
|
+
? error.message
|
|
44
|
+
: "EXTRA_CONFIG_INVALID";
|
|
45
|
+
throw new ExtraCommandError(code, hints[code] ??
|
|
46
|
+
"Invalid Bot configuration. Check configure --help and this Extra's configuration schema.");
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/** 单 Bot 配置命令按 bot_id upsert;省略字段保留,重复调用不会追加相同 Bot。 */
|
|
50
|
+
const extension = {
|
|
51
|
+
apiVersion: 1,
|
|
52
|
+
commands: [
|
|
53
|
+
{
|
|
54
|
+
name: "configure",
|
|
55
|
+
description: "Add or update one Bot by bot_id; saves config only",
|
|
56
|
+
options: [
|
|
57
|
+
{ name: "bot_id", type: "string", required: true, description: "Platform Bot ID" },
|
|
58
|
+
{
|
|
59
|
+
name: "ws_url",
|
|
60
|
+
type: "string",
|
|
61
|
+
description: "WeCom WebSocket URL; preserved on update, official endpoint for new Bots"
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
name: "adapter_type",
|
|
65
|
+
type: "string",
|
|
66
|
+
description: "Execution adapter type (adapter.adapter_type)"
|
|
67
|
+
},
|
|
68
|
+
{ name: "workdir", type: "string", description: "Absolute local execution directory" },
|
|
69
|
+
{ name: "model", type: "string", description: "Provider model ID" },
|
|
70
|
+
{
|
|
71
|
+
name: "effort",
|
|
72
|
+
type: "string",
|
|
73
|
+
description: "Reasoning effort: low, medium, high, xhigh"
|
|
74
|
+
},
|
|
75
|
+
{ name: "provider_agent_id", type: "string", description: "Existing OpenClaw Agent ID" },
|
|
76
|
+
{
|
|
77
|
+
name: "app_secret",
|
|
78
|
+
type: "string",
|
|
79
|
+
description: "Raw credential (bots[].app_secret); omitted values are preserved"
|
|
80
|
+
}
|
|
81
|
+
],
|
|
82
|
+
examples: [
|
|
83
|
+
"octo-runtime channel-wecom configure --bot_id assistant --adapter_type codex --workdir /absolute/workspace --app_secret EXAMPLE_CREDENTIAL"
|
|
84
|
+
],
|
|
85
|
+
async run(context, input) {
|
|
86
|
+
const snapshot = await context.readConfig();
|
|
87
|
+
validate(snapshot.config);
|
|
88
|
+
const bots = snapshot.config.bots ?? [];
|
|
89
|
+
validateImBots(bots);
|
|
90
|
+
// configure 用 bot_id 定位,更新 endpoint 不产生第二个 Bot。
|
|
91
|
+
// 旧 extraset 跨 endpoint 的同 ID 保留首项省略字段并合并;省略 ws_url 不重置已有地址。
|
|
92
|
+
const position = bots.findIndex((bot) => bot.bot_id === input.options.bot_id);
|
|
93
|
+
const old = position < 0 ? undefined : bots[position];
|
|
94
|
+
const identityFields = {
|
|
95
|
+
bot_id: input.options.bot_id,
|
|
96
|
+
ws_url: input.options.ws_url ?? old?.ws_url ?? "wss://openws.work.weixin.qq.com"
|
|
97
|
+
};
|
|
98
|
+
const adapter = { ...old?.adapter };
|
|
99
|
+
for (const field of ["adapter_type", "workdir", "model", "effort", "provider_agent_id"]) {
|
|
100
|
+
const value = input.options[field];
|
|
101
|
+
if (typeof value === "string")
|
|
102
|
+
adapter[field] = value;
|
|
103
|
+
}
|
|
104
|
+
if (adapter.effort !== undefined &&
|
|
105
|
+
(typeof adapter.effort !== "string" ||
|
|
106
|
+
!["low", "medium", "high", "xhigh"].includes(adapter.effort)))
|
|
107
|
+
throw new ExtraCommandError("EXTRA_CONFIG_INVALID", "--effort must be low, medium, high or xhigh.");
|
|
108
|
+
const bot = { ...old, ...identityFields, adapter };
|
|
109
|
+
const credential = input.options.app_secret;
|
|
110
|
+
if (typeof credential === "string") {
|
|
111
|
+
if (!credential.trim())
|
|
112
|
+
throw new ExtraCommandError("EXTRA_CONFIG_INVALID", "--app_secret must not be blank.");
|
|
113
|
+
// 与 extraset 的业务字段同名;保存传入原文,省略时保留已有凭据。
|
|
114
|
+
bot.app_secret = credential;
|
|
115
|
+
}
|
|
116
|
+
const nextBots = bots.filter((bot, index) => index === position || bot.bot_id !== identityFields.bot_id);
|
|
117
|
+
if (position < 0)
|
|
118
|
+
nextBots.push(bot);
|
|
119
|
+
else
|
|
120
|
+
nextBots[position] = bot;
|
|
121
|
+
const config = { ...snapshot.config, bots: nextBots };
|
|
122
|
+
validate(config);
|
|
123
|
+
return savedConfigResult(await context.saveConfig(config, snapshot.revision));
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
]
|
|
127
|
+
};
|
|
128
|
+
export default extension;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mininglamp-oss/octo-runtime-extra-channel-wecom",
|
|
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,10 +22,10 @@
|
|
|
18
22
|
"docs"
|
|
19
23
|
],
|
|
20
24
|
"dependencies": {
|
|
21
|
-
"@mininglamp-oss/octo-runtime-host-sdk": "1.1.
|
|
22
|
-
"@mininglamp-oss/octo-runtime-executor-core": "1.1.
|
|
23
|
-
"@mininglamp-oss/octo-runtime-executor-kernel": "1.1.
|
|
25
|
+
"@mininglamp-oss/octo-runtime-host-sdk": "1.1.5",
|
|
26
|
+
"@mininglamp-oss/octo-runtime-executor-core": "1.1.5",
|
|
27
|
+
"@mininglamp-oss/octo-runtime-executor-kernel": "1.1.5",
|
|
24
28
|
"ws": "8.22.0",
|
|
25
|
-
"@mininglamp-oss/octo-runtime-protocol": "1.1.
|
|
29
|
+
"@mininglamp-oss/octo-runtime-protocol": "1.1.5"
|
|
26
30
|
}
|
|
27
31
|
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { isAbsolute, join } from "node:path";
|
|
2
|
+
import { assertContextEnvelope } from "@mininglamp-oss/octo-runtime-protocol";
|
|
3
|
+
import { ExtraCommandError, savedConfigResult } from "@mininglamp-oss/octo-runtime-host-sdk/extra-commands";
|
|
4
|
+
/** WebUI 在一个 Home 内只有 webui 这份配置;端口不是实例 ID,不创建多实例列表。 */
|
|
5
|
+
function validate(config) {
|
|
6
|
+
const port = config.port ?? 13888;
|
|
7
|
+
if (typeof port !== "number" || !Number.isInteger(port) || port < 1 || port > 65535)
|
|
8
|
+
throw new ExtraCommandError("WEBUI_PORT_INVALID", "--port must be an integer from 1 to 65535.");
|
|
9
|
+
if (typeof config.sessionStorePath !== "string" || !isAbsolute(config.sessionStorePath))
|
|
10
|
+
throw new ExtraCommandError("WEBUI_STORE_PATH_REQUIRED", "config.sessionStorePath must refer to an absolute session JSON file path.");
|
|
11
|
+
if (config.defaultProjectPath !== undefined && typeof config.defaultProjectPath !== "string")
|
|
12
|
+
throw new ExtraCommandError("WEBUI_PROJECT_PATH_INVALID", "defaultProjectPath must be a string.");
|
|
13
|
+
if (config.context !== undefined) {
|
|
14
|
+
try {
|
|
15
|
+
assertContextEnvelope(config.context);
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
throw new ExtraCommandError("WEBUI_CONTEXT_INVALID", "context must follow the Context v3 contract.");
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
const extension = {
|
|
23
|
+
apiVersion: 1,
|
|
24
|
+
commands: [
|
|
25
|
+
{
|
|
26
|
+
name: "configure",
|
|
27
|
+
description: "Update the single WebUI configuration; saves only, restart to apply",
|
|
28
|
+
options: [
|
|
29
|
+
{ name: "port", type: "string", description: "Loopback HTTP port (default 13888)" }
|
|
30
|
+
],
|
|
31
|
+
examples: ["octo-runtime webui configure --port 13888"],
|
|
32
|
+
async run(context, input) {
|
|
33
|
+
const snapshot = await context.readConfig();
|
|
34
|
+
const config = { ...snapshot.config };
|
|
35
|
+
// 简化入口只暴露端口;首次会话存储从宿主 Home 推导,已有路径和项目配置保持。
|
|
36
|
+
// 高级 extraset 仍按完整声明的 JSON 合同替换,不改存储字段名或隐式迁移数据。
|
|
37
|
+
if (config.sessionStorePath === undefined)
|
|
38
|
+
config.sessionStorePath = join(context.home, "extras", context.name, "sessions.json");
|
|
39
|
+
const port = input.options.port;
|
|
40
|
+
if (typeof port === "string") {
|
|
41
|
+
if (!/^[0-9]+$/.test(port))
|
|
42
|
+
throw new ExtraCommandError("WEBUI_PORT_INVALID", "--port must be an integer from 1 to 65535.");
|
|
43
|
+
config.port = Number(port);
|
|
44
|
+
}
|
|
45
|
+
validate(config);
|
|
46
|
+
return savedConfigResult(await context.saveConfig(config, snapshot.revision));
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
]
|
|
50
|
+
};
|
|
51
|
+
export default extension;
|