@mininglamp-oss/octo-runtime 1.1.4 → 1.1.6
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 +61 -37
- package/apps/cli/README.md +58 -22
- package/apps/cli/dist/adapter-configurations.d.ts +4 -0
- package/apps/cli/dist/adapter-configurations.js +102 -0
- 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 -79
- package/apps/cli/dist/logs.js +8 -4
- package/apps/cli/dist/main.d.ts +2 -0
- package/apps/cli/dist/main.js +38 -68
- package/apps/cli/dist/manifest.json +48 -3
- package/apps/cli/dist/module-manifest.d.ts +1 -1
- package/apps/cli/dist/module-manifest.js +3 -2
- package/apps/cli/dist/output.js +18 -2
- package/apps/cli/dist/playboard.js +3 -2
- 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/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 +5 -2
- package/node_modules/@mininglamp-oss/octo-runtime-acp-client/package.json +3 -3
- 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/dist/index.d.ts +3 -4
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codebuddy/dist/index.js +161 -26
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codebuddy/package.json +4 -4
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/app-server.js +3 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/{chunk-G5PWGRL5.js → chunk-3GXX5VD5.js} +24 -90
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/{chunk-UOQRXV3Q.js → chunk-FWAPYRV2.js} +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/{chunk-DYOJCNWF.js → chunk-IW62UM3C.js} +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/errors.d.ts +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/errors.js +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/index.js +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/launch.d.ts +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/launch.js +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/trajectory.js +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/dist/client.js +8 -2
- 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/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/index.d.ts +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/index.js +8 -4
- 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/process-launch.d.ts +12 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/process-launch.js +91 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/runtime-log-worker.js +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/runtime-log.js +13 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/service-status.d.ts +9 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/service-status.js +40 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/package.json +3 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-zcode-gui/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/adapter-configurations.d.ts +4 -0
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/adapter-configurations.js +102 -0
- 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 -79
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/logs.js +8 -4
- 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 +38 -68
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/manifest.json +48 -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/output.js +18 -2
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/playboard.js +3 -2
- 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 -24
- 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 +8 -3
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/watchdog.js +47 -4
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/client.js +2 -0
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/invocation-manifest.js +4 -1
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/process.d.ts +7 -0
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/process.js +79 -5
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/server.d.ts +3 -1
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/server.js +22 -6
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/service.js +2 -1
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/submission-error.d.ts +5 -3
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/submission-error.js +12 -6
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/supervisor.d.ts +4 -2
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/supervisor.js +131 -43
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/package.json +4 -4
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/application/context-gap.js +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/application/im-channel.js +36 -20
- 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/execution/dispatcher.js +3 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/execution/model-wait.d.ts +29 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/execution/model-wait.js +171 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/execution/task.d.ts +4 -1
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/execution/task.js +48 -6
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/presentation/run-projector.d.ts +2 -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 +2 -2
- 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/contexts.js +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/reasoning-frame.js +37 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/wukong.js +8 -5
- 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/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/package.json +7 -3
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/endpoint.d.ts +2 -0
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/endpoint.js +5 -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/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 +2 -1
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/failure.js +9 -1
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/generated/protocol-types.d.ts +9 -0
- 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 +41 -27
- package/packages/octo-runtime-protocol/schema/protocol.schema.json +14 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/desktop-entry.d.ts +0 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/desktop-entry.js +0 -16
- 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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mininglamp-oss/octo-runtime-adapter-hermes",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.6",
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": "./dist/index.js",
|
|
@@ -9,6 +9,6 @@
|
|
|
9
9
|
"dist"
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@mininglamp-oss/octo-runtime-adapter-acp": "1.1.
|
|
12
|
+
"@mininglamp-oss/octo-runtime-adapter-acp": "1.1.6"
|
|
13
13
|
}
|
|
14
14
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mininglamp-oss/octo-runtime-adapter-kimi-code",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.6",
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": "./dist/index.js",
|
|
@@ -9,6 +9,6 @@
|
|
|
9
9
|
"dist"
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@mininglamp-oss/octo-runtime-adapter-acp": "1.1.
|
|
12
|
+
"@mininglamp-oss/octo-runtime-adapter-acp": "1.1.6"
|
|
13
13
|
}
|
|
14
14
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mininglamp-oss/octo-runtime-adapter-mcode",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.6",
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": "./dist/index.js",
|
|
@@ -9,6 +9,6 @@
|
|
|
9
9
|
"dist"
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@mininglamp-oss/octo-runtime-adapter-acp": "1.1.
|
|
12
|
+
"@mininglamp-oss/octo-runtime-adapter-acp": "1.1.6"
|
|
13
13
|
}
|
|
14
14
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mininglamp-oss/octo-runtime-adapter-openclaw",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.6",
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": "./dist/index.js",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@mininglamp-oss/octo-runtime-protocol": "1.1.
|
|
9
|
-
"@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.
|
|
8
|
+
"@mininglamp-oss/octo-runtime-protocol": "1.1.6",
|
|
9
|
+
"@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.6",
|
|
10
10
|
"ws": "8.22.0"
|
|
11
11
|
},
|
|
12
12
|
"types": "./dist/index.d.ts",
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mininglamp-oss/octo-runtime-adapter-opencode",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.6",
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": "./dist/index.js",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@mininglamp-oss/octo-runtime-protocol": "1.1.
|
|
9
|
-
"@mininglamp-oss/octo-runtime-adapter-acp": "1.1.
|
|
10
|
-
"@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.
|
|
8
|
+
"@mininglamp-oss/octo-runtime-protocol": "1.1.6",
|
|
9
|
+
"@mininglamp-oss/octo-runtime-adapter-acp": "1.1.6",
|
|
10
|
+
"@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.6"
|
|
11
11
|
},
|
|
12
12
|
"types": "./dist/index.d.ts",
|
|
13
13
|
"files": [
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mininglamp-oss/octo-runtime-adapter-qodercli",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.6",
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": "./dist/index.js",
|
|
@@ -9,6 +9,6 @@
|
|
|
9
9
|
"dist"
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@mininglamp-oss/octo-runtime-adapter-acp": "1.1.
|
|
12
|
+
"@mininglamp-oss/octo-runtime-adapter-acp": "1.1.6"
|
|
13
13
|
}
|
|
14
14
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mininglamp-oss/octo-runtime-adapter-qoderclicn",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.6",
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": "./dist/index.js",
|
|
@@ -9,6 +9,6 @@
|
|
|
9
9
|
"dist"
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@mininglamp-oss/octo-runtime-adapter-acp": "1.1.
|
|
12
|
+
"@mininglamp-oss/octo-runtime-adapter-acp": "1.1.6"
|
|
13
13
|
}
|
|
14
14
|
}
|
|
@@ -15,7 +15,7 @@ export { watchLineLimit } from "./line-limit.js";
|
|
|
15
15
|
export { readBoundedLines } from "./bounded-lines.js";
|
|
16
16
|
export { HourlyLogWriter, HOURLY_LOG_MAX_BYTES } from "./hourly-log.js";
|
|
17
17
|
export { RuntimeLogging, assertRuntimeLogging, noopRuntimeLog, type RuntimeLog, type RuntimeLogLevel, type RuntimeLoggingOptions } from "./runtime-log.js";
|
|
18
|
-
export { extraStatusRecord, type ExtraStatusRecord } from "./service-status.js";
|
|
18
|
+
export { extraStatusRecord, kernelStatusRecord, type ExtraStatusRecord, type KernelStatusRecord } from "./service-status.js";
|
|
19
19
|
export { sanitizePublicValue } from "./public-display.js";
|
|
20
20
|
export { DEFAULT_REASONING_LEVEL_MAPS, OMNI_REASONING_LEVELS, mapReasoningEffort, reasoningLevelMap, type OmniReasoningLevel, type ReasoningLevelMap } from "./reasoning.js";
|
|
21
21
|
export interface AdapterMetadata {
|
|
@@ -6,6 +6,7 @@ import { createInterface } from "node:readline";
|
|
|
6
6
|
import { promisify } from "node:util";
|
|
7
7
|
import { invocationEnvironment, mergeProcessEnvironment, processEnvironmentValue } from "./environment.js";
|
|
8
8
|
import { createProcessCleanup } from "./process-cleanup.js";
|
|
9
|
+
import { resolveProcessLaunch } from "./process-launch.js";
|
|
9
10
|
import { watchLineLimit } from "./line-limit.js";
|
|
10
11
|
import { mapReasoningEffort, reasoningLevelMap } from "./reasoning.js";
|
|
11
12
|
export { invocationEnvironment, invocationEnvs, mergeProcessEnvironment, processEnvironmentValue } from "./environment.js";
|
|
@@ -21,7 +22,7 @@ export { watchLineLimit } from "./line-limit.js";
|
|
|
21
22
|
export { readBoundedLines } from "./bounded-lines.js";
|
|
22
23
|
export { HourlyLogWriter, HOURLY_LOG_MAX_BYTES } from "./hourly-log.js";
|
|
23
24
|
export { RuntimeLogging, assertRuntimeLogging, noopRuntimeLog } from "./runtime-log.js";
|
|
24
|
-
export { extraStatusRecord } from "./service-status.js";
|
|
25
|
+
export { extraStatusRecord, kernelStatusRecord } from "./service-status.js";
|
|
25
26
|
export { sanitizePublicValue } from "./public-display.js";
|
|
26
27
|
export { DEFAULT_REASONING_LEVEL_MAPS, OMNI_REASONING_LEVELS, mapReasoningEffort, reasoningLevelMap } from "./reasoning.js";
|
|
27
28
|
/**
|
|
@@ -88,9 +89,11 @@ export function defineAdapter(adapter, levels = reasoningLevelMap(adapter.metada
|
|
|
88
89
|
*/
|
|
89
90
|
export async function* spawnJsonLines(options) {
|
|
90
91
|
const { command, args = [], cwd, env, input, signal, parseLine, onInputWritten } = options;
|
|
91
|
-
const
|
|
92
|
+
const processEnv = mergeProcessEnvironment(process.env, env ?? {});
|
|
93
|
+
const launch = resolveProcessLaunch(command, args, { cwd, env: processEnv });
|
|
94
|
+
const child = spawn(launch.command, launch.args, {
|
|
92
95
|
cwd,
|
|
93
|
-
env:
|
|
96
|
+
env: processEnv,
|
|
94
97
|
stdio: ["pipe", "pipe", "pipe"],
|
|
95
98
|
detached: process.platform !== "win32"
|
|
96
99
|
});
|
|
@@ -288,7 +291,8 @@ export async function probeCommand(command, { env = process.env, cwd } = {}) {
|
|
|
288
291
|
continue;
|
|
289
292
|
let version = null;
|
|
290
293
|
try {
|
|
291
|
-
const
|
|
294
|
+
const launch = resolveProcessLaunch(resolve(candidate), ["--version"], { env, cwd });
|
|
295
|
+
const { stdout } = await promisify(execFile)(launch.command, launch.args, {
|
|
292
296
|
env,
|
|
293
297
|
cwd,
|
|
294
298
|
timeout: 2_000,
|
|
@@ -7,6 +7,12 @@ export interface AdapterModuleEntry {
|
|
|
7
7
|
sourceManifest: string;
|
|
8
8
|
}
|
|
9
9
|
export interface ExtraModuleEntry {
|
|
10
|
+
/** CLI 目录的静态用途说明;根帮助读取此字段,不导入服务或命令模块。 */
|
|
11
|
+
description?: string;
|
|
12
|
+
/** 公开的业务配置示例,仅供 CLI 帮助展示;不得包含真实凭据,不参与运行时默认值。 */
|
|
13
|
+
configExample?: Record<string, unknown>;
|
|
14
|
+
/** 可选独立命令入口;与服务模块使用同一个清单来源解析。 */
|
|
15
|
+
commands?: string;
|
|
10
16
|
name: string;
|
|
11
17
|
module: string;
|
|
12
18
|
sourceManifest: string;
|
|
@@ -32,7 +32,18 @@ export function parseModuleManifest(value, source, { legacy = false } = {}) {
|
|
|
32
32
|
const name = text(entry.name, "extra.name");
|
|
33
33
|
if (!/^[a-z][a-z0-9-]{0,63}$/.test(name))
|
|
34
34
|
throw new TypeError("extra.name is invalid");
|
|
35
|
-
return {
|
|
35
|
+
return {
|
|
36
|
+
name,
|
|
37
|
+
...(entry.description === undefined
|
|
38
|
+
? {}
|
|
39
|
+
: { description: text(entry.description, "extra.description") }),
|
|
40
|
+
...(entry.configExample === undefined
|
|
41
|
+
? {}
|
|
42
|
+
: { configExample: record(entry.configExample, "extra.configExample") }),
|
|
43
|
+
module: text(entry.module, "extra.module"),
|
|
44
|
+
sourceManifest,
|
|
45
|
+
...(entry.commands === undefined ? {} : { commands: text(entry.commands, "extra.commands") })
|
|
46
|
+
};
|
|
36
47
|
});
|
|
37
48
|
unique(adapters, (entry) => entry.type, "adapter.type");
|
|
38
49
|
unique(extraEntries, (entry) => entry.name, "extra.name");
|
|
@@ -59,17 +70,18 @@ export async function readModuleManifest(file, { optional = false, legacy = fals
|
|
|
59
70
|
/** 内置优先、用户追加;冲突项在解析/import 前剔除,诊断不得包含 options 或业务配置。 */
|
|
60
71
|
export function mergeModuleManifests(builtin, extension, report = () => { }) {
|
|
61
72
|
function merge(first, second, key) {
|
|
62
|
-
const seen = new
|
|
73
|
+
const seen = new Map(first.map((entry) => [key(entry), entry]));
|
|
63
74
|
return [
|
|
64
75
|
...first,
|
|
65
76
|
...second.filter((entry) => {
|
|
66
77
|
const name = key(entry);
|
|
67
78
|
if (name !== undefined && seen.has(name)) {
|
|
68
|
-
|
|
79
|
+
const selected = seen.get(name);
|
|
80
|
+
report(`Ignoring extension module "${name}": built-in declaration takes precedence; selected ${JSON.stringify({ module: selected.module, source: selected.sourceManifest })}; ignored ${JSON.stringify({ module: entry.module, source: entry.sourceManifest })}`);
|
|
69
81
|
return false;
|
|
70
82
|
}
|
|
71
83
|
if (name !== undefined)
|
|
72
|
-
seen.
|
|
84
|
+
seen.set(name, entry);
|
|
73
85
|
return true;
|
|
74
86
|
})
|
|
75
87
|
];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 在 Provider 启动和版本探测前同步解析 Windows npm 包装器,保持 spawn 的同步返回合同。
|
|
3
|
+
* JS 入口交给 Node,原生入口直接执行;argv 独立传递,未知 batch 沿原路径报错。
|
|
4
|
+
* 返回启动命令和参数;ChildProcess、管道及清理仍由调用方负责。
|
|
5
|
+
*/
|
|
6
|
+
export declare function resolveProcessLaunch(command: string, args: readonly string[], { env, cwd }?: {
|
|
7
|
+
env?: NodeJS.ProcessEnv;
|
|
8
|
+
cwd?: string;
|
|
9
|
+
}): {
|
|
10
|
+
command: string;
|
|
11
|
+
args: readonly string[];
|
|
12
|
+
};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { readFileSync, statSync } from "node:fs";
|
|
2
|
+
import { basename, delimiter, dirname, extname, join, resolve } from "node:path";
|
|
3
|
+
import { processEnvironmentValue } from "./environment.js";
|
|
4
|
+
function fileSize(file) {
|
|
5
|
+
try {
|
|
6
|
+
const info = statSync(file);
|
|
7
|
+
return info.isFile() ? info.size : undefined;
|
|
8
|
+
}
|
|
9
|
+
catch (error) {
|
|
10
|
+
if (["ENOENT", "ENOTDIR"].includes(error.code ?? ""))
|
|
11
|
+
return undefined;
|
|
12
|
+
throw error;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function commandPath(command, env, cwd) {
|
|
16
|
+
if (/[/\\]/.test(command) || /^[A-Za-z]:/.test(command))
|
|
17
|
+
return resolve(cwd, command);
|
|
18
|
+
const extensions = extname(command)
|
|
19
|
+
? [""]
|
|
20
|
+
: (processEnvironmentValue(env, "PATHEXT") ?? ".COM;.EXE;.BAT;.CMD")
|
|
21
|
+
.split(";")
|
|
22
|
+
.filter((extension) => /^\.(exe|com|cmd|bat)$/i.test(extension));
|
|
23
|
+
const path = processEnvironmentValue(env, "PATH") ?? processEnvironmentValue(process.env, "PATH") ?? "";
|
|
24
|
+
for (const directory of [cwd, ...path.split(delimiter)]) {
|
|
25
|
+
for (const extension of extensions) {
|
|
26
|
+
const candidate = resolve(cwd, directory.replace(/^"(.*)"$/, "$1"), command + extension);
|
|
27
|
+
if (fileSize(candidate) !== undefined)
|
|
28
|
+
return candidate;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* 在 Provider 启动和版本探测前同步解析 Windows npm 包装器,保持 spawn 的同步返回合同。
|
|
35
|
+
* JS 入口交给 Node,原生入口直接执行;argv 独立传递,未知 batch 沿原路径报错。
|
|
36
|
+
* 返回启动命令和参数;ChildProcess、管道及清理仍由调用方负责。
|
|
37
|
+
*/
|
|
38
|
+
export function resolveProcessLaunch(command, args, { env = process.env, cwd = process.cwd() } = {}) {
|
|
39
|
+
const original = { command, args };
|
|
40
|
+
if (process.platform !== "win32")
|
|
41
|
+
return original;
|
|
42
|
+
let carrier = commandPath(command, env, cwd);
|
|
43
|
+
if (!carrier)
|
|
44
|
+
return original;
|
|
45
|
+
// probeCommand 可能返回 npm 同时生成的 Unix 入口,仍绑定同一目录的 Windows shim。
|
|
46
|
+
if (!extname(carrier)) {
|
|
47
|
+
const size = fileSize(carrier);
|
|
48
|
+
if (size !== undefined &&
|
|
49
|
+
size <= 64 * 1024 &&
|
|
50
|
+
/^#!.*\bsh\b/.test(readFileSync(carrier, "utf8"))) {
|
|
51
|
+
const sibling = `${carrier}.cmd`;
|
|
52
|
+
if (fileSize(sibling) !== undefined)
|
|
53
|
+
carrier = sibling;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
if (!/\.(cmd|bat)$/i.test(carrier))
|
|
57
|
+
return { command: carrier, args };
|
|
58
|
+
const size = fileSize(carrier);
|
|
59
|
+
if (size === undefined || size > 64 * 1024)
|
|
60
|
+
return { command: carrier, args };
|
|
61
|
+
const shim = readFileSync(carrier, "utf8");
|
|
62
|
+
if (!/^:find_dp0\s*$/im.test(shim) || !/^\s*CALL :find_dp0\s*$/im.test(shim))
|
|
63
|
+
return { command: carrier, args };
|
|
64
|
+
const match = /^(.*)"%(?:~dp0|dp0%)([^"\r\n]+?\.(?:[cm]?js|exe|com))"\s+%\*\s*$/im.exec(shim);
|
|
65
|
+
// 不解释自定义 batch、额外参数或变量展开;保留 Node 对不支持载体的原始失败。
|
|
66
|
+
if (!match || match[2].includes("%"))
|
|
67
|
+
return { command: carrier, args };
|
|
68
|
+
const entry = resolve(dirname(carrier), match[2].replace(/^[/\\]+/, ""));
|
|
69
|
+
if (/\.(exe|com)$/i.test(entry)) {
|
|
70
|
+
if (match[1].trim() && !/[&|]\s*$/.test(match[1]))
|
|
71
|
+
return { command: carrier, args };
|
|
72
|
+
return { command: entry, args };
|
|
73
|
+
}
|
|
74
|
+
if (!/(?:\bnode(?:\.exe)?|"%_prog%")\s*$/i.test(match[1]))
|
|
75
|
+
return { command: carrier, args };
|
|
76
|
+
if (fileSize(entry) === undefined)
|
|
77
|
+
throw Object.assign(new Error("Provider command entry not found"), {
|
|
78
|
+
code: "ENOENT",
|
|
79
|
+
path: entry
|
|
80
|
+
});
|
|
81
|
+
const adjacentNode = join(dirname(carrier), "node.exe");
|
|
82
|
+
const pathNode = commandPath("node", env, cwd);
|
|
83
|
+
const node = fileSize(adjacentNode) !== undefined
|
|
84
|
+
? adjacentNode
|
|
85
|
+
: pathNode && /\.(exe|com)$/i.test(pathNode)
|
|
86
|
+
? pathNode
|
|
87
|
+
: basename(process.execPath).toLowerCase() === "node.exe"
|
|
88
|
+
? process.execPath
|
|
89
|
+
: "node";
|
|
90
|
+
return { command: node, args: [entry, ...args] };
|
|
91
|
+
}
|
|
@@ -15,8 +15,8 @@ parentPort.on("message", (message) => {
|
|
|
15
15
|
try {
|
|
16
16
|
const category = message.extra
|
|
17
17
|
? `${message.extra}${message.status ? "-status" : ""}`
|
|
18
|
-
:
|
|
19
|
-
const key = message.extra ? `extra:${category}` :
|
|
18
|
+
: `kernel${message.status ? "-status" : ""}`;
|
|
19
|
+
const key = message.extra ? `extra:${category}` : category;
|
|
20
20
|
let writer = writers.get(key);
|
|
21
21
|
if (!writer && writers.size < 128) {
|
|
22
22
|
writer = new HourlyLogWriter(message.extra ? join(directory, "extras") : directory, category, { onError: () => { } });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** Optional metadata logging; bounded queues isolate filesystem writes in a dedicated worker. */
|
|
2
2
|
import { isAbsolute } from "node:path";
|
|
3
3
|
import { Worker } from "node:worker_threads";
|
|
4
|
-
import { extraStatusRecord } from "./service-status.js";
|
|
4
|
+
import { extraStatusRecord, kernelStatusRecord } from "./service-status.js";
|
|
5
5
|
export const noopRuntimeLog = () => { };
|
|
6
6
|
const strings = new Set([
|
|
7
7
|
"run_id",
|
|
@@ -94,6 +94,18 @@ export class RuntimeLogging {
|
|
|
94
94
|
#write(source, extra, level, event, data) {
|
|
95
95
|
if (this.#closed)
|
|
96
96
|
return;
|
|
97
|
+
if (source === "kernel" && this.#worker && this.#statusPending < 128) {
|
|
98
|
+
try {
|
|
99
|
+
const status = kernelStatusRecord(level, event, data);
|
|
100
|
+
if (status) {
|
|
101
|
+
this.#worker.postMessage({ status: true, line: `${JSON.stringify(status)}\n` });
|
|
102
|
+
this.#statusPending++;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
catch {
|
|
106
|
+
/* 状态镜像失败不影响执行或普通日志。 */
|
|
107
|
+
}
|
|
108
|
+
}
|
|
97
109
|
if (extra) {
|
|
98
110
|
try {
|
|
99
111
|
const status = extraStatusRecord(extra, level, event, data);
|
|
@@ -7,5 +7,14 @@ export interface ExtraStatusRecord {
|
|
|
7
7
|
event: string;
|
|
8
8
|
data: Record<string, string | number>;
|
|
9
9
|
}
|
|
10
|
+
export interface KernelStatusRecord {
|
|
11
|
+
time: string;
|
|
12
|
+
level: RuntimeLogLevel;
|
|
13
|
+
source: "kernel";
|
|
14
|
+
event: string;
|
|
15
|
+
data: Record<string, string | number>;
|
|
16
|
+
}
|
|
17
|
+
/** Kernel 父进程的监督诊断白名单;读盘时也重建,绝不包含执行正文或原始异常。 */
|
|
18
|
+
export declare function kernelStatusRecord(level: RuntimeLogLevel, event: string, data?: Readonly<Record<string, unknown>>, time?: string): KernelStatusRecord | undefined;
|
|
10
19
|
/** Rebuild status records from a separate allowlist, including when reading persisted files. */
|
|
11
20
|
export declare function extraStatusRecord(extra: string, level: RuntimeLogLevel, event: string, data?: Readonly<Record<string, unknown>>, time?: string): ExtraStatusRecord | undefined;
|
|
@@ -1,3 +1,43 @@
|
|
|
1
|
+
/** Kernel 父进程的监督诊断白名单;读盘时也重建,绝不包含执行正文或原始异常。 */
|
|
2
|
+
export function kernelStatusRecord(level, event, data, time = new Date().toISOString()) {
|
|
3
|
+
if (!["info", "warn", "error"].includes(level) ||
|
|
4
|
+
![
|
|
5
|
+
"worker.ready",
|
|
6
|
+
"worker.lost",
|
|
7
|
+
"worker.recovery_blocked",
|
|
8
|
+
"worker.retry_scheduled",
|
|
9
|
+
"worker.start_failed"
|
|
10
|
+
].includes(event) ||
|
|
11
|
+
!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/.test(time) ||
|
|
12
|
+
!Number.isFinite(Date.parse(time)))
|
|
13
|
+
return;
|
|
14
|
+
const safe = {};
|
|
15
|
+
for (const key of ["code", "signal", "trigger", "stage", "occurred_at", "retry_at"]) {
|
|
16
|
+
const value = data?.[key];
|
|
17
|
+
if (typeof value !== "string")
|
|
18
|
+
continue;
|
|
19
|
+
const valid = key === "code"
|
|
20
|
+
? /^[A-Z][A-Z0-9_]{0,95}$/.test(value)
|
|
21
|
+
: key === "signal"
|
|
22
|
+
? /^SIG[A-Z0-9]+$/.test(value)
|
|
23
|
+
: key === "trigger"
|
|
24
|
+
? ["exit", "error", "heartbeat", "ipc"].includes(value)
|
|
25
|
+
: key === "stage"
|
|
26
|
+
? ["cleanup", "manifest", "starting", "backoff"].includes(value)
|
|
27
|
+
: /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/.test(value) &&
|
|
28
|
+
Number.isFinite(Date.parse(value));
|
|
29
|
+
if (valid)
|
|
30
|
+
safe[key] = value;
|
|
31
|
+
}
|
|
32
|
+
for (const key of ["pid", "generation", "attempt", "delay_ms", "exit_code"]) {
|
|
33
|
+
const value = data?.[key];
|
|
34
|
+
if (typeof value === "number" &&
|
|
35
|
+
Number.isSafeInteger(value) &&
|
|
36
|
+
(key === "exit_code" || value >= 0))
|
|
37
|
+
safe[key] = value;
|
|
38
|
+
}
|
|
39
|
+
return Object.freeze({ time, level, source: "kernel", event, data: Object.freeze(safe) });
|
|
40
|
+
}
|
|
1
41
|
const events = new Set([
|
|
2
42
|
"service.initializing",
|
|
3
43
|
"service.ready",
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mininglamp-oss/octo-runtime-adapter-sdk",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.6",
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": "./dist/index.js",
|
|
8
8
|
"./process-cleanup": "./dist/process-cleanup.js",
|
|
9
|
+
"./process-launch": "./dist/process-launch.js",
|
|
9
10
|
"./module-manifest": "./dist/module-manifest.js"
|
|
10
11
|
},
|
|
11
12
|
"dependencies": {
|
|
12
|
-
"@mininglamp-oss/octo-runtime-protocol": "1.1.
|
|
13
|
+
"@mininglamp-oss/octo-runtime-protocol": "1.1.6",
|
|
13
14
|
"import-meta-resolve": "4.2.0"
|
|
14
15
|
},
|
|
15
16
|
"types": "./dist/index.d.ts",
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mininglamp-oss/octo-runtime-adapter-zcode-gui",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.6",
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": "./dist/index.js",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@mininglamp-oss/octo-runtime-protocol": "1.1.
|
|
9
|
-
"@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.
|
|
8
|
+
"@mininglamp-oss/octo-runtime-protocol": "1.1.6",
|
|
9
|
+
"@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.6"
|
|
10
10
|
},
|
|
11
11
|
"types": "./dist/index.d.ts",
|
|
12
12
|
"files": [
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ModuleManifest } from "@mininglamp-oss/octo-runtime-adapter-sdk/module-manifest";
|
|
2
|
+
import { readAdapterConfigurations } from "@mininglamp-oss/octo-runtime-executor-kernel";
|
|
3
|
+
/** CLI 宿主在创建 Kernel 前补齐 npm DSH 入口;探测与调用共享快照,显式配置始终优先。 */
|
|
4
|
+
export declare function readCliAdapterConfigurations(profileRoot: string, adapters: unknown, manifest: ModuleManifest, env?: NodeJS.ProcessEnv): Promise<ReturnType<typeof readAdapterConfigurations>>;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { constants } from "node:fs";
|
|
2
|
+
import { access, lstat, readFile, realpath, stat } from "node:fs/promises";
|
|
3
|
+
import { delimiter, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
4
|
+
import { processEnvironmentValue } from "@mininglamp-oss/octo-runtime-adapter-sdk";
|
|
5
|
+
import { readAdapterConfigurations } from "@mininglamp-oss/octo-runtime-executor-kernel";
|
|
6
|
+
/** CLI 宿主在创建 Kernel 前补齐 npm DSH 入口;探测与调用共享快照,显式配置始终优先。 */
|
|
7
|
+
export async function readCliAdapterConfigurations(profileRoot, adapters, manifest, env = process.env) {
|
|
8
|
+
const configurations = readAdapterConfigurations(profileRoot, adapters);
|
|
9
|
+
if (configurations.dsh?.providerOptions?.dshBin !== undefined ||
|
|
10
|
+
!manifest.adapters.some((entry) => entry.type === "dsh" || entry.type === undefined))
|
|
11
|
+
return configurations;
|
|
12
|
+
const dshBin = await discoverDshEntry(env);
|
|
13
|
+
if (dshBin)
|
|
14
|
+
configurations.dsh = {
|
|
15
|
+
...configurations.dsh,
|
|
16
|
+
providerOptions: { ...configurations.dsh?.providerOptions, dshBin }
|
|
17
|
+
};
|
|
18
|
+
return configurations;
|
|
19
|
+
}
|
|
20
|
+
async function discoverDshEntry(env) {
|
|
21
|
+
const extensions = process.platform === "win32"
|
|
22
|
+
? (processEnvironmentValue(env, "PATHEXT") ?? ".COM;.EXE;.BAT;.CMD").split(";")
|
|
23
|
+
: [""];
|
|
24
|
+
for (const directory of (processEnvironmentValue(env, "PATH") ?? "").split(delimiter)) {
|
|
25
|
+
if (!directory)
|
|
26
|
+
continue;
|
|
27
|
+
for (const extension of extensions) {
|
|
28
|
+
const command = resolve(directory, `dsh${extension}`);
|
|
29
|
+
// 只有路径不存在才能继续;lstat 保留损坏链接,首个已存在候选不可因不可用而换安装。
|
|
30
|
+
try {
|
|
31
|
+
await lstat(command);
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
const code = error.code;
|
|
35
|
+
if (code === "ENOENT" || code === "ENOTDIR")
|
|
36
|
+
continue;
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
try {
|
|
40
|
+
await access(command, process.platform === "win32" ? constants.F_OK : constants.X_OK);
|
|
41
|
+
if (!(await stat(command)).isFile())
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
// 先固定 PATH 中的命令,再读取安装元数据;不执行 shim,也不因版本不兼容换另一安装。
|
|
48
|
+
return packageEntryForCommand(command);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
async function packageEntryForCommand(command) {
|
|
53
|
+
let target;
|
|
54
|
+
try {
|
|
55
|
+
target = await realpath(command);
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
// npm 在 Unix 上使用符号链接;从链接目标向上确认包名,兼容自定义 prefix。
|
|
61
|
+
for (let directory = dirname(target);; directory = dirname(directory)) {
|
|
62
|
+
const entry = await packageEntry(directory);
|
|
63
|
+
if (entry)
|
|
64
|
+
return entry;
|
|
65
|
+
if (directory === dirname(directory))
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
const binDirectory = dirname(command);
|
|
69
|
+
// Windows npm shim、Unix 全局 prefix/bin、以及项目 node_modules/.bin 均只读相邻安装。
|
|
70
|
+
for (const directory of [
|
|
71
|
+
join(binDirectory, "node_modules", "@deepseek-ai", "dsh"),
|
|
72
|
+
join(binDirectory, "..", "lib", "node_modules", "@deepseek-ai", "dsh"),
|
|
73
|
+
join(binDirectory, "..", "@deepseek-ai", "dsh")
|
|
74
|
+
]) {
|
|
75
|
+
const entry = await packageEntry(directory);
|
|
76
|
+
if (entry)
|
|
77
|
+
return entry;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
async function packageEntry(directory) {
|
|
81
|
+
try {
|
|
82
|
+
const metadata = JSON.parse(await readFile(join(directory, "package.json"), "utf8"));
|
|
83
|
+
if (metadata?.name !== "@deepseek-ai/dsh")
|
|
84
|
+
return;
|
|
85
|
+
const bin = typeof metadata.bin === "string"
|
|
86
|
+
? metadata.bin
|
|
87
|
+
: metadata.bin && typeof metadata.bin === "object"
|
|
88
|
+
? metadata.bin.dsh
|
|
89
|
+
: undefined;
|
|
90
|
+
if (typeof bin !== "string" || !bin.trim() || isAbsolute(bin))
|
|
91
|
+
return;
|
|
92
|
+
const entry = resolve(directory, bin);
|
|
93
|
+
const location = relative(directory, entry);
|
|
94
|
+
if (location === ".." || location.startsWith(`..${sep}`) || isAbsolute(location))
|
|
95
|
+
return;
|
|
96
|
+
// 文件与版本由 Adapter 校验;即使入口缺失,也不能改选 PATH 中的另一安装。
|
|
97
|
+
return entry;
|
|
98
|
+
}
|
|
99
|
+
catch {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { realpathSync } from "node:fs";
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
/** 保留包管理器入口中的安装组路径;只有指向本 CLI 的 argv 才能影响服务部署与发现。 */
|
|
5
|
+
export function cliEntrypoint(invocation = process.argv[1], installed = fileURLToPath(new URL("./index.js", import.meta.url))) {
|
|
6
|
+
if (invocation) {
|
|
7
|
+
try {
|
|
8
|
+
if (realpathSync(invocation) === realpathSync(installed))
|
|
9
|
+
return resolve(invocation);
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
// 库内调用、测试 runner 或已移除的入口不拥有本 CLI 的安装来源。
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return installed;
|
|
16
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ExtraModuleEntry } from "@mininglamp-oss/octo-runtime-adapter-sdk/module-manifest";
|
|
2
|
+
import type { ExtraCommand, ExtraCommandInput } from "@mininglamp-oss/octo-runtime-host-sdk";
|
|
3
|
+
import type { CliDependencies } from "./main.js";
|
|
4
|
+
export interface ParsedCliCommand {
|
|
5
|
+
flags: Record<string, string>;
|
|
6
|
+
positional: string[];
|
|
7
|
+
help?: string;
|
|
8
|
+
extra?: {
|
|
9
|
+
entry: ExtraModuleEntry;
|
|
10
|
+
command: ExtraCommand;
|
|
11
|
+
input: ExtraCommandInput;
|
|
12
|
+
home: string;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* 两阶段装配:先只解析宿主选择参数,再为有效目录挂载命令。
|
|
17
|
+
* 根帮助不 import Extra;离线服务动作不加载 /commands;所选业务树才递归适配。
|
|
18
|
+
* 本函数只返回调用描述或帮助文本,不运行 handler、不访问服务管理器、不写 Home。
|
|
19
|
+
*/
|
|
20
|
+
export declare function parseCliCommand(raw: string[], dependencies: CliDependencies): Promise<ParsedCliCommand>;
|