@mininglamp-oss/octo-runtime 1.1.10 → 1.1.11
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 +1 -1
- package/apps/cli/README.md +1 -1
- package/apps/cli/dist/adapters.js +40 -14
- package/apps/cli/dist/build-info.json +2 -2
- package/apps/cli/dist/command-tree.js +2 -3
- package/apps/cli/dist/extras.js +11 -1
- package/apps/cli/dist/index.js +14 -1
- package/apps/cli/dist/main.js +58 -23
- package/apps/cli/dist/module-manifest.js +21 -3
- package/apps/cli/dist/output.d.ts +19 -1
- package/apps/cli/dist/output.js +179 -27
- package/apps/cli/dist/playboard.js +2 -2
- package/apps/cli/dist/state.d.ts +5 -2
- package/apps/cli/dist/state.js +48 -13
- package/dist/public/codex.d.ts +1 -0
- package/dist/public/codex.js +1 -0
- package/dist/public/executor-kernel.d.ts +4 -0
- package/dist/public/executor-kernel.js +2 -0
- package/dist/public/extra.d.ts +1 -1
- package/dist/public/host.d.ts +5 -0
- package/dist/public/host.js +2 -0
- package/node_modules/@mininglamp-oss/octo-runtime-acp-client/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-acp/dist/index.js +20 -0
- 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/app-server.d.ts +6 -6
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/app-server.js +68 -253
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/index.d.ts +11 -6
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/index.js +198 -52
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/service.d.ts +58 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/service.js +650 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/stdin-writer.d.ts +3 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/stdin-writer.js +15 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/package.json +3 -3
- 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 +2 -0
- 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 +5 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/execution-scope.d.ts +25 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/execution-scope.js +1 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/index.d.ts +3 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/package.json +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/adapters.js +40 -14
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/build-info.json +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/command-tree.js +2 -3
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/extras.js +11 -1
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/index.js +14 -1
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/main.js +58 -23
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/module-manifest.js +21 -3
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/output.d.ts +19 -1
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/output.js +179 -27
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/playboard.js +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/state.d.ts +5 -2
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/state.js +48 -13
- package/node_modules/@mininglamp-oss/octo-runtime-cli/package.json +23 -23
- package/node_modules/@mininglamp-oss/octo-runtime-client/build-info.json +5 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/dist/async-question-reply.d.ts +30 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/dist/async-question-reply.js +199 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/dist/browser.d.ts +1 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/dist/browser.js +1 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/dist/client.d.ts +10 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/dist/client.js +465 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/dist/index.d.ts +6 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/dist/index.js +6 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/dist/internal.d.ts +4 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/dist/internal.js +5 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/dist/invocation-lifecycle.d.ts +59 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/dist/invocation-lifecycle.js +287 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/dist/notification.d.ts +1 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/dist/notification.js +1 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/dist/protocol.d.ts +1 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/dist/protocol.js +1 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/dist/runtime-path.d.ts +21 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/dist/runtime-path.js +138 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/dist/startup-catalog.d.ts +8 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/dist/startup-catalog.js +65 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/dist/startup-diagnostics.d.ts +82 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/dist/startup-diagnostics.js +371 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/dist/submission-error.d.ts +10 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/dist/submission-error.js +23 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/dist/types.d.ts +72 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/dist/types.js +10 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/package.json +54 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/schema/context-configuration-fixtures.json +1219 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/schema/context-fixtures.json +5988 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/schema/kernel-client.behavior.json +56 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/schema/kernel-ipc-fixtures.json +53 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/schema/kernel-ipc.schema.json +538 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/schema/native-invoke-fixtures.json +116 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/schema/protocol.schema.json +4525 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/schema/run-protocol-fixtures.json +761 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/schema/runtime-selection-fixtures.json +663 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/schema/session-name-fixtures.json +191 -0
- package/node_modules/@mininglamp-oss/octo-runtime-cross-service/package.json +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/index.d.ts +26 -18
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/index.js +151 -11
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/async-question-reply.d.ts +1 -30
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/async-question-reply.js +2 -199
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/client.d.ts +1 -10
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/client.js +2 -446
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/endpoint.js +2 -0
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/host-run-service.d.ts +2 -0
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/host-run-service.js +13 -2
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/index.d.ts +4 -1
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/index.js +4 -1
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/invocation-lifecycle.d.ts +1 -53
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/invocation-lifecycle.js +2 -280
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/lifecycle.d.ts +5 -10
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/lifecycle.js +4 -1
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/runtime-home.d.ts +20 -0
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/runtime-home.js +180 -0
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/server.js +31 -8
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/service.d.ts +5 -2
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/service.js +48 -5
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/startup-catalog.d.ts +1 -0
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/startup-catalog.js +1 -0
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/startup-diagnostics.d.ts +1 -0
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/startup-diagnostics.js +1 -0
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/startup-logging.d.ts +4 -0
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/startup-logging.js +18 -0
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/submission-error.d.ts +1 -10
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/submission-error.js +2 -23
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/types.d.ts +2 -72
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/types.js +2 -10
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/package.json +5 -4
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/extra.js +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/ports.d.ts +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/package.json +6 -6
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-wecom/dist/extra.js +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-wecom/dist/ports.d.ts +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-wecom/package.json +5 -5
- package/node_modules/@mininglamp-oss/octo-runtime-extra-webui/dist/index.js +4 -4
- package/node_modules/@mininglamp-oss/octo-runtime-extra-webui/package.json +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/endpoint.d.ts +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/endpoint.js +12 -5
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/errors.d.ts +5 -1
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/errors.js +9 -0
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/execution.d.ts +44 -0
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/execution.js +207 -0
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/extra-config.js +23 -3
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/extra-service.d.ts +27 -4
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/extra-service.js +133 -25
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/extras.d.ts +10 -3
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/extras.js +18 -4
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/home.d.ts +5 -6
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/home.js +33 -45
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/identity.js +6 -0
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/index.d.ts +4 -0
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/index.js +3 -0
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/package.json +5 -4
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/adapter-metadata.d.ts +7 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/adapter-metadata.js +1 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/generated/protocol-types.d.ts +19 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/index.d.ts +3 -1
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/index.js +1 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/service-processes.d.ts +5 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/service-processes.js +65 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/package.json +1 -1
- package/package.json +33 -27
- package/packages/octo-runtime-protocol/schema/protocol.schema.json +42 -0
|
@@ -1,12 +1,15 @@
|
|
|
1
|
+
import { assertStartupLogging } from "./startup-logging.js";
|
|
1
2
|
import net from "node:net";
|
|
2
3
|
import { randomUUID } from "node:crypto";
|
|
3
|
-
import { chmod,
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { chmod, rm } from "node:fs/promises";
|
|
5
|
+
import { join } from "node:path";
|
|
6
|
+
import { assertIpcEndpoint, runtimePathFailure } from "./runtime-home.js";
|
|
7
|
+
import { readBoundedLines, RuntimeLogging } from "@mininglamp-oss/octo-runtime-adapter-sdk";
|
|
6
8
|
import { assertHostRunReceipt, createInputInvoke, contextItem, INVOKE_REQUEST_MAX_BYTES, HOST_RPC_MAX_LINE_BYTES, resolveStreamLimitPolicy } from "@mininglamp-oss/octo-runtime-protocol";
|
|
7
9
|
import { HostRunService } from "./host-run-service.js";
|
|
8
10
|
import { AgentExecutor } from "@mininglamp-oss/octo-runtime-executor-core";
|
|
9
11
|
import { beforeDeadline } from "./lifecycle.js";
|
|
12
|
+
import { withStartupContext } from "./startup-diagnostics.js";
|
|
10
13
|
import { probeOptions } from "./execution-source.js";
|
|
11
14
|
import { acquireEndpoint } from "./endpoint.js";
|
|
12
15
|
import { InvocationManifest } from "./invocation-manifest.js";
|
|
@@ -73,7 +76,8 @@ function validateParams(method, params) {
|
|
|
73
76
|
* 启动失败也执行回收;close 失败会保留所有权证据,客户端断开不等同于 owner 关闭。
|
|
74
77
|
*/
|
|
75
78
|
export async function startKernelServer(options, signal) {
|
|
76
|
-
|
|
79
|
+
assertIpcEndpoint(options.endpoint);
|
|
80
|
+
assertStartupLogging(options.logging, { component: "executor-kernel", phase: "initializing" });
|
|
77
81
|
const instance = randomUUID();
|
|
78
82
|
const logging = new RuntimeLogging(options.logging);
|
|
79
83
|
let manifest;
|
|
@@ -107,7 +111,8 @@ export async function startKernelServer(options, signal) {
|
|
|
107
111
|
ipc_version: 1,
|
|
108
112
|
kernel_instance_id: instance,
|
|
109
113
|
pid: process.pid,
|
|
110
|
-
execution_ready: !closing && ready
|
|
114
|
+
execution_ready: !closing && ready,
|
|
115
|
+
service_processes: [...executor.processes()]
|
|
111
116
|
});
|
|
112
117
|
const snapshot = (key, expected) => {
|
|
113
118
|
if (expected !== undefined && expected !== instance)
|
|
@@ -382,14 +387,18 @@ export async function startKernelServer(options, signal) {
|
|
|
382
387
|
throw new AggregateError(errors, "KERNEL_CLEANUP_INCOMPLETE");
|
|
383
388
|
}
|
|
384
389
|
};
|
|
390
|
+
let startupContext = { operation: "register-adapters", configKey: "adapters" };
|
|
385
391
|
try {
|
|
386
392
|
signal?.throwIfAborted();
|
|
387
393
|
for (const adapter of options.adapters) {
|
|
388
394
|
executor.register(adapter);
|
|
389
395
|
logging.kernel("info", "adapter.registered", { adapter_type: adapter.metadata.type });
|
|
390
396
|
}
|
|
391
|
-
|
|
392
|
-
|
|
397
|
+
startupContext = {
|
|
398
|
+
resource: "ipc-endpoint",
|
|
399
|
+
endpoint: options.endpoint,
|
|
400
|
+
operation: "acquire-endpoint"
|
|
401
|
+
};
|
|
393
402
|
signal?.throwIfAborted();
|
|
394
403
|
releaseEndpoint = await acquireEndpoint(options.endpoint);
|
|
395
404
|
signal?.throwIfAborted();
|
|
@@ -399,10 +408,12 @@ export async function startKernelServer(options, signal) {
|
|
|
399
408
|
? `${options.endpoint}.runs`
|
|
400
409
|
: undefined;
|
|
401
410
|
if (statePath) {
|
|
411
|
+
startupContext = { resource: "kernel-state", path: statePath, operation: "open-manifest" };
|
|
402
412
|
manifest = (await InvocationManifest.open(statePath)).manifest;
|
|
403
413
|
await manifest.markNativeOwner();
|
|
404
414
|
}
|
|
405
415
|
signal?.throwIfAborted();
|
|
416
|
+
startupContext = { resource: "ipc-endpoint", endpoint: options.endpoint, operation: "listen" };
|
|
406
417
|
await new Promise((resolve, reject) => {
|
|
407
418
|
server.once("error", reject);
|
|
408
419
|
server.listen(options.endpoint, () => {
|
|
@@ -417,7 +428,19 @@ export async function startKernelServer(options, signal) {
|
|
|
417
428
|
ready = true;
|
|
418
429
|
logging.kernel("info", "kernel.ready", { pid: process.pid });
|
|
419
430
|
}
|
|
420
|
-
catch (
|
|
431
|
+
catch (cause) {
|
|
432
|
+
const io = cause;
|
|
433
|
+
const error = startupContext.resource &&
|
|
434
|
+
["ipc-endpoint", "kernel-state"].includes(startupContext.resource) &&
|
|
435
|
+
["ENOENT", "ENOTDIR", "EACCES", "EPERM", "EROFS", "ENAMETOOLONG"].includes(io?.code ?? "")
|
|
436
|
+
? runtimePathFailure(cause, typeof io.path === "string" ? io.path : (startupContext.path ?? options.endpoint), startupContext.resource, typeof io.syscall === "string" ? io.syscall : "listen")
|
|
437
|
+
: cause;
|
|
438
|
+
// 附加已确认的启动步骤,不改变原错误类型、公共码或底层 cause。
|
|
439
|
+
withStartupContext(error, {
|
|
440
|
+
component: "executor-kernel",
|
|
441
|
+
phase: "initializing",
|
|
442
|
+
context: startupContext
|
|
443
|
+
});
|
|
421
444
|
logging.kernel("error", "kernel.start_failed", { code: safeCode(error) });
|
|
422
445
|
try {
|
|
423
446
|
await teardown();
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { type KernelServerOptions } from "./server.js";
|
|
2
2
|
import type { KernelClient, KernelStatus } from "./types.js";
|
|
3
3
|
import { type ServiceLifecycle, type ServicePhase } from "./lifecycle.js";
|
|
4
|
-
export
|
|
4
|
+
export interface KernelServiceOptions extends KernelServerOptions {
|
|
5
|
+
/** 宿主选择并预先准备的绝对目录;SDK 不选择默认 Home 或创建根。 */
|
|
6
|
+
home: string;
|
|
7
|
+
}
|
|
5
8
|
export interface KernelServiceStatus {
|
|
6
9
|
phase: ServicePhase;
|
|
7
10
|
endpoint: string;
|
|
@@ -12,7 +15,7 @@ export interface KernelService extends ServiceLifecycle<KernelServiceStatus> {
|
|
|
12
15
|
readonly client: KernelClient;
|
|
13
16
|
}
|
|
14
17
|
/**
|
|
15
|
-
*
|
|
18
|
+
* 宿主传入已存在的 Home、本地 RPC 地址和已装配的 Adapter;initialize 校验后启动并开放 client。
|
|
16
19
|
* socket、Core 和本服务创建的日志由 close 回收;宿主依赖仍由宿主拥有。
|
|
17
20
|
* 即使与调用方同进程,client 也始终通过 RPC,不能绕过 Run 接纳和观察管理。
|
|
18
21
|
*/
|
|
@@ -1,21 +1,36 @@
|
|
|
1
|
+
import { assertStartupLogging } from "./startup-logging.js";
|
|
1
2
|
import { attachKernel } from "./client.js";
|
|
3
|
+
import { dirname } from "node:path";
|
|
4
|
+
import { assertIpcEndpoint, kernelStartupPaths, validateRuntimeHome, prepareHomeDirectory } from "./runtime-home.js";
|
|
5
|
+
import { describeStartupError } from "./startup-diagnostics.js";
|
|
2
6
|
import { startKernelServer } from "./server.js";
|
|
3
7
|
import { beforeDeadline, ServiceInitializationError } from "./lifecycle.js";
|
|
4
8
|
/**
|
|
5
|
-
*
|
|
9
|
+
* 宿主传入已存在的 Home、本地 RPC 地址和已装配的 Adapter;initialize 校验后启动并开放 client。
|
|
6
10
|
* socket、Core 和本服务创建的日志由 close 回收;宿主依赖仍由宿主拥有。
|
|
7
11
|
* 即使与调用方同进程,client 也始终通过 RPC,不能绕过 Run 接纳和观察管理。
|
|
8
12
|
*/
|
|
9
13
|
export function createKernelService(options) {
|
|
14
|
+
const invalid = (message, configKey) => {
|
|
15
|
+
const error = new TypeError(message);
|
|
16
|
+
Object.defineProperty(error, "diagnostic", {
|
|
17
|
+
value: describeStartupError({ code: "KERNEL_CONFIGURATION_INVALID" }, {
|
|
18
|
+
component: "executor-kernel",
|
|
19
|
+
phase: "created",
|
|
20
|
+
context: { configKey, operation: "validate-options" }
|
|
21
|
+
})
|
|
22
|
+
});
|
|
23
|
+
return error;
|
|
24
|
+
};
|
|
10
25
|
if (!options ||
|
|
11
26
|
typeof options.endpoint !== "string" ||
|
|
12
27
|
!options.endpoint ||
|
|
13
28
|
!Array.isArray(options.adapters))
|
|
14
|
-
throw
|
|
29
|
+
throw invalid("Kernel requires endpoint and adapters", "endpoint/adapters");
|
|
15
30
|
// 旧 JS 接入不能静默退回文件加载或忽略 worker 环境;模块装配完全归宿主。
|
|
16
31
|
for (const field of ["workerEntrypoint", "manifest", "adapterModules", "env"])
|
|
17
32
|
if (field in options)
|
|
18
|
-
throw
|
|
33
|
+
throw invalid(`Kernel does not accept ${field}; compose adapters in the host`, field);
|
|
19
34
|
const configuration = {
|
|
20
35
|
...options,
|
|
21
36
|
adapters: [...options.adapters],
|
|
@@ -87,7 +102,22 @@ export function createKernelService(options) {
|
|
|
87
102
|
onAbort();
|
|
88
103
|
});
|
|
89
104
|
// 原 server 负责部分启动的回滚;初始化失败后仍保留其清理事实。
|
|
90
|
-
starting =
|
|
105
|
+
starting = Promise.resolve()
|
|
106
|
+
.then(async () => {
|
|
107
|
+
combined.throwIfAborted();
|
|
108
|
+
assertStartupLogging(configuration.logging, {
|
|
109
|
+
component: "executor-kernel",
|
|
110
|
+
phase: "initializing"
|
|
111
|
+
});
|
|
112
|
+
const home = validateRuntimeHome(configuration.home, kernelStartupPaths(configuration.endpoint, configuration.stateDirectory, configuration.logging?.directory));
|
|
113
|
+
assertIpcEndpoint(configuration.endpoint);
|
|
114
|
+
if (process.platform !== "win32") {
|
|
115
|
+
// 只为 Home 内的端点准备内部目录;自选外部 endpoint 的父目录由高级宿主准备。
|
|
116
|
+
// helper 按完整 .. 路径分量判断边界,合法的 ..hidden 子目录仍属于 Home。
|
|
117
|
+
prepareHomeDirectory(home, dirname(configuration.endpoint));
|
|
118
|
+
}
|
|
119
|
+
return startKernelServer(configuration, combined);
|
|
120
|
+
})
|
|
91
121
|
.then((value) => {
|
|
92
122
|
server = value;
|
|
93
123
|
combined.throwIfAborted();
|
|
@@ -102,7 +132,20 @@ export function createKernelService(options) {
|
|
|
102
132
|
});
|
|
103
133
|
initialized = Promise.race([starting, cancelled])
|
|
104
134
|
.catch(async (error) => {
|
|
105
|
-
|
|
135
|
+
const cleanup = await close();
|
|
136
|
+
// 取消可能先赢得 race,而实际启动回滚随后失败;等待 close 后再合并已确认的错误。
|
|
137
|
+
// 保留最初取消原因和 server 的完整清理链,不把 incomplete 简化成只有取消原因。
|
|
138
|
+
// 截止时仍未结束的回滚继续由 starting 观察,不改写已经返回的清理结果。
|
|
139
|
+
const cause = startupFailure instanceof AggregateError && startupFailure !== error
|
|
140
|
+
? new AggregateError([error, startupFailure], "KERNEL_START_CLEANUP_INCOMPLETE", {
|
|
141
|
+
cause: error
|
|
142
|
+
})
|
|
143
|
+
: error;
|
|
144
|
+
throw new ServiceInitializationError(cause, cleanup, {
|
|
145
|
+
component: "executor-kernel",
|
|
146
|
+
phase: "initializing",
|
|
147
|
+
context: { endpoint: configuration.endpoint }
|
|
148
|
+
});
|
|
106
149
|
})
|
|
107
150
|
.finally(() => combined.removeEventListener("abort", onAbort));
|
|
108
151
|
return initialized;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { STARTUP_CATALOG, type StartupCatalogEntry } from "@mininglamp-oss/octo-runtime-client/internal";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { STARTUP_CATALOG } from "@mininglamp-oss/octo-runtime-client/internal";
|
package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/startup-diagnostics.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { STARTUP_CATALOG, StartupError, describeStartupError, formatStartupDiagnostic, restoreStartupDiagnostic, safeStartupValue, startupPathDiagnostic, withStartupContext, type StartupCatalogEntry, type StartupCause, type StartupContext, type StartupDiagnostic, type StartupLocation, type StartupPathDiagnostic } from "@mininglamp-oss/octo-runtime-client/internal";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { STARTUP_CATALOG, StartupError, describeStartupError, formatStartupDiagnostic, restoreStartupDiagnostic, safeStartupValue, startupPathDiagnostic, withStartupContext } from "@mininglamp-oss/octo-runtime-client/internal";
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type RuntimeLoggingOptions } from "@mininglamp-oss/octo-runtime-adapter-sdk";
|
|
2
|
+
import { type StartupLocation } from "./startup-diagnostics.js";
|
|
3
|
+
/** 先验证纯配置再启动资源;各宿主保留原错误类型及调用阶段。 */
|
|
4
|
+
export declare function assertStartupLogging(logging: RuntimeLoggingOptions | undefined, location: StartupLocation): void;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { assertRuntimeLogging } from "@mininglamp-oss/octo-runtime-adapter-sdk";
|
|
2
|
+
import { withStartupContext } from "./startup-diagnostics.js";
|
|
3
|
+
/** 先验证纯配置再启动资源;各宿主保留原错误类型及调用阶段。 */
|
|
4
|
+
export function assertStartupLogging(logging, location) {
|
|
5
|
+
try {
|
|
6
|
+
assertRuntimeLogging(logging);
|
|
7
|
+
}
|
|
8
|
+
catch (error) {
|
|
9
|
+
throw withStartupContext(error, {
|
|
10
|
+
...location,
|
|
11
|
+
context: {
|
|
12
|
+
resource: "logging",
|
|
13
|
+
operation: "validate-logging",
|
|
14
|
+
...(typeof logging?.directory === "string" ? { path: logging.directory } : {})
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/submission-error.d.ts
CHANGED
|
@@ -1,10 +1 @@
|
|
|
1
|
-
|
|
2
|
-
/** 包内接纳检查专用;当前 client 在请求写出前拒绝时创建证据。 */
|
|
3
|
-
export declare function admissionClosedError(): KernelError;
|
|
4
|
-
/** 仅实际 invoke RPC 的拒绝响应、且实例和专用证据均匹配,才标记未进入执行源。 */
|
|
5
|
-
export declare function markSubmissionRejected(error: unknown, instance: string): void;
|
|
6
|
-
/**
|
|
7
|
-
* 判断本模块验证的未执行拒绝;包装、序列化及同名错误均返回 false。
|
|
8
|
-
* 只证明本次未进入执行源,不证明此前业务尝试没有执行,也不授权自动重放。
|
|
9
|
-
*/
|
|
10
|
-
export declare function isInvocationNotSubmitted(error: unknown): boolean;
|
|
1
|
+
export { admissionClosedError, markSubmissionRejected, isInvocationNotSubmitted } from "@mininglamp-oss/octo-runtime-client/internal";
|
|
@@ -1,23 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
/** 包内接纳检查专用;当前 client 在请求写出前拒绝时创建证据。 */
|
|
4
|
-
export function admissionClosedError() {
|
|
5
|
-
const error = new KernelError("CLIENT_INVOCATION_ADMISSION_CLOSED");
|
|
6
|
-
notSubmitted.add(error);
|
|
7
|
-
return error;
|
|
8
|
-
}
|
|
9
|
-
/** 仅实际 invoke RPC 的拒绝响应、且实例和专用证据均匹配,才标记未进入执行源。 */
|
|
10
|
-
export function markSubmissionRejected(error, instance) {
|
|
11
|
-
if (error instanceof KernelError &&
|
|
12
|
-
["KERNEL_UNAVAILABLE", "WORKER_RESTART_EXHAUSTED"].includes(error.code) &&
|
|
13
|
-
error.data?.invocation_not_submitted === true &&
|
|
14
|
-
error.data.kernel_instance_id === instance)
|
|
15
|
-
notSubmitted.add(error);
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* 判断本模块验证的未执行拒绝;包装、序列化及同名错误均返回 false。
|
|
19
|
-
* 只证明本次未进入执行源,不证明此前业务尝试没有执行,也不授权自动重放。
|
|
20
|
-
*/
|
|
21
|
-
export function isInvocationNotSubmitted(error) {
|
|
22
|
-
return error instanceof KernelError && notSubmitted.has(error);
|
|
23
|
-
}
|
|
1
|
+
// 兼容旧入口;客户端状态、错误身份和恢复实现由独立包统一持有。
|
|
2
|
+
export { admissionClosedError, markSubmissionRejected, isInvocationNotSubmitted } from "@mininglamp-oss/octo-runtime-client/internal";
|
|
@@ -1,72 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export type LookupKey = KernelLookupKey;
|
|
4
|
-
export type RunRef = KernelRunRef;
|
|
5
|
-
export type RunSnapshot = KernelRunSnapshot;
|
|
6
|
-
export type { KernelStatus };
|
|
7
|
-
export interface KernelInvocationRecord {
|
|
8
|
-
readonly key: LookupKey;
|
|
9
|
-
readonly ref?: RunRef;
|
|
10
|
-
readonly phase: "admitting" | "accepted" | "acceptance_unknown" | "unobserved";
|
|
11
|
-
readonly cancellation: "none" | "requested" | "acknowledged" | "unknown";
|
|
12
|
-
readonly lastSeq: number;
|
|
13
|
-
readonly observationError?: string;
|
|
14
|
-
}
|
|
15
|
-
/** 只确认本 client 登记的执行是否排空;不代表卡片投递或业务 dispose 已完成。 */
|
|
16
|
-
export interface KernelInvocationDrainResult {
|
|
17
|
-
readonly complete: boolean;
|
|
18
|
-
readonly unresolved: readonly KernelInvocationRecord[];
|
|
19
|
-
}
|
|
20
|
-
export interface KernelInvocationLifecycle {
|
|
21
|
-
/** 身份与观察状态的副本,不缓存消息正文;结果未知的执行仍保留在列表中。 */
|
|
22
|
-
snapshot(): readonly KernelInvocationRecord[];
|
|
23
|
-
/** 同步关闭 invoke 接纳;已有执行仍可取消、查询和消费尾流。 */
|
|
24
|
-
stopAdmission(): void;
|
|
25
|
-
/** 共享 Date.now() 毫秒绝对期限;首次调用确定预算,后续调用复用同一排空结果。 */
|
|
26
|
-
drain(options: {
|
|
27
|
-
deadline: number;
|
|
28
|
-
reason: string;
|
|
29
|
-
}): Promise<KernelInvocationDrainResult>;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* 附着到独立 Kernel 的客户端,不拥有 Kernel 进程。
|
|
33
|
-
* 常规接入使用 invoke;owner 退出时先 stopAdmission,再并行 drain 与业务收尾,最后 close。
|
|
34
|
-
* submit/subscribe 是低层入口,调用方自行保存 RunRef、管理取消与尾流,不自动登记为 invoke。
|
|
35
|
-
*/
|
|
36
|
-
export interface KernelClient {
|
|
37
|
-
readonly topology: "kernel-ipc";
|
|
38
|
-
readonly ownership: "attached";
|
|
39
|
-
/** 开始消费才提交;signal 请求取消但保留尾流,提前结束迭代则仅停止观察。 */
|
|
40
|
-
readonly invoke: InputInvoke;
|
|
41
|
-
readonly invocations: KernelInvocationLifecycle;
|
|
42
|
-
/** 仅操作当前 client 的 invoke 登记;accepted 是取消受理,不是终态或清理完成。 */
|
|
43
|
-
cancelInvocation(invocationId: string, reason?: string): Promise<{
|
|
44
|
-
accepted: boolean;
|
|
45
|
-
}>;
|
|
46
|
-
respondInteraction(invocationId: string, response: InteractionResponse): Promise<void>;
|
|
47
|
-
respondNativeInteraction(invocationId: string, response: NativeInteractionResponse): Promise<void>;
|
|
48
|
-
status(): Promise<KernelStatus>;
|
|
49
|
-
list(): Promise<HostedAdapterMetadata[]>;
|
|
50
|
-
/** 接纳后由 Kernel 持续驱动执行;ACK 丢失只查原身份,不重复执行。 */
|
|
51
|
-
submit(input: InvokeInput, environment?: InvokeEnvironment): Promise<{
|
|
52
|
-
ref: RunRef;
|
|
53
|
-
}>;
|
|
54
|
-
/** 按完整 LookupKey 查询原执行;指定 expectedInstance 可拒绝服务重启后的同名身份。 */
|
|
55
|
-
get(key: LookupKey, expectedInstance?: string): Promise<RunSnapshot>;
|
|
56
|
-
/** 从 afterSeq 之后观察同一执行;signal 只关闭订阅,游标过期/身份变化须交给调用方处理。 */
|
|
57
|
-
subscribe(ref: RunRef, afterSeq?: number, signal?: AbortSignal): AsyncGenerator<HostFrame>;
|
|
58
|
-
/** 显式控制原 RunRef;ACK 丢失报结果未知,不能自动重试可能已受理的控制动作。 */
|
|
59
|
-
cancel(ref: RunRef, reason?: string): Promise<{
|
|
60
|
-
accepted: boolean;
|
|
61
|
-
}>;
|
|
62
|
-
/** 交互响应必须匹配原引用和协议模式,过期/未知的响应不能改投其他 Run。 */
|
|
63
|
-
respond(ref: RunRef, response: InteractionResponse): Promise<void>;
|
|
64
|
-
respondNative(ref: RunRef, response: NativeInteractionResponse): Promise<void>;
|
|
65
|
-
/** 释放本 client 的连接和控制请求,不取消已接纳 Run,也不关闭共享 Kernel。 */
|
|
66
|
-
close(): void;
|
|
67
|
-
}
|
|
68
|
-
export declare class KernelError extends Error {
|
|
69
|
-
readonly code: string;
|
|
70
|
-
readonly data?: Record<string, unknown> | undefined;
|
|
71
|
-
constructor(code: string, data?: Record<string, unknown> | undefined);
|
|
72
|
-
}
|
|
1
|
+
export { KernelError } from "@mininglamp-oss/octo-runtime-client";
|
|
2
|
+
export type { LookupKey, RunRef, RunSnapshot, KernelStatus, KernelClient, KernelInvocationRecord, KernelInvocationDrainResult, KernelInvocationLifecycle } from "@mininglamp-oss/octo-runtime-client";
|
|
@@ -1,10 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
data;
|
|
4
|
-
constructor(code, data) {
|
|
5
|
-
super(code);
|
|
6
|
-
this.code = code;
|
|
7
|
-
this.data = data;
|
|
8
|
-
this.name = "KernelError";
|
|
9
|
-
}
|
|
10
|
-
}
|
|
1
|
+
// 兼容旧入口;客户端状态、错误身份和恢复实现由独立包统一持有。
|
|
2
|
+
export { KernelError } from "@mininglamp-oss/octo-runtime-client";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mininglamp-oss/octo-runtime-executor-kernel",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.11",
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -10,9 +10,10 @@
|
|
|
10
10
|
}
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@mininglamp-oss/octo-runtime-
|
|
14
|
-
"@mininglamp-oss/octo-runtime-
|
|
15
|
-
"@mininglamp-oss/octo-runtime-
|
|
13
|
+
"@mininglamp-oss/octo-runtime-client": "1.1.11",
|
|
14
|
+
"@mininglamp-oss/octo-runtime-executor-core": "1.1.11",
|
|
15
|
+
"@mininglamp-oss/octo-runtime-protocol": "1.1.11",
|
|
16
|
+
"@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.11"
|
|
16
17
|
},
|
|
17
18
|
"types": "./dist/index.d.ts",
|
|
18
19
|
"files": [
|
|
@@ -28,7 +28,7 @@ async function initialize(context, config, dependencies) {
|
|
|
28
28
|
}
|
|
29
29
|
const allowed = spaces;
|
|
30
30
|
channels = new ImChannelManager({
|
|
31
|
-
kernel: context.
|
|
31
|
+
kernel: context.execution,
|
|
32
32
|
signal: context.signal,
|
|
33
33
|
log: context.log,
|
|
34
34
|
createSessionStore: dependencies.createSessionStore,
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* 宿主依赖入口:注入执行能力、凭据来源和脱敏诊断。
|
|
3
3
|
* SDK 应用自行决定账号目录和凭据生命周期,通道无需依赖 CLI 或具体 Provider。
|
|
4
4
|
*/
|
|
5
|
-
import type {
|
|
5
|
+
import type { ExtraExecutionContext } from "@mininglamp-oss/octo-runtime-host-sdk";
|
|
6
6
|
import type { ImBotConfig } from "./contracts.js";
|
|
7
7
|
import type { ImSessionStore } from "./application/session-store.js";
|
|
8
8
|
import type { RuntimeLog, JsonObject, ChannelDependencies } from "@mininglamp-oss/octo-runtime-host-sdk";
|
|
@@ -21,7 +21,7 @@ export interface ImChannelManagerDependencies extends ImModuleDependencies {
|
|
|
21
21
|
export interface ImModuleDependencies {
|
|
22
22
|
prepareContexts?: (config: JsonObject, signal: AbortSignal) => Promise<ContextItem[]>;
|
|
23
23
|
log?: RuntimeLog;
|
|
24
|
-
kernel: Pick<
|
|
24
|
+
kernel: Pick<ExtraExecutionContext, "invoke" | "cancelInvocation" | "respondInteraction">;
|
|
25
25
|
/** Owning Extra/manager lifetime; aborts connections, execution and delivery. */
|
|
26
26
|
signal?: AbortSignal;
|
|
27
27
|
authorizeSpace?: (spaceId: string) => void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mininglamp-oss/octo-runtime-extra-channel-gateway",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.11",
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -22,11 +22,11 @@
|
|
|
22
22
|
"docs"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@mininglamp-oss/octo-runtime-executor-kernel": "1.1.
|
|
26
|
-
"@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.
|
|
27
|
-
"@mininglamp-oss/octo-runtime-executor-core": "1.1.
|
|
28
|
-
"@mininglamp-oss/octo-runtime-host-sdk": "1.1.
|
|
29
|
-
"@mininglamp-oss/octo-runtime-protocol": "1.1.
|
|
25
|
+
"@mininglamp-oss/octo-runtime-executor-kernel": "1.1.11",
|
|
26
|
+
"@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.11",
|
|
27
|
+
"@mininglamp-oss/octo-runtime-executor-core": "1.1.11",
|
|
28
|
+
"@mininglamp-oss/octo-runtime-host-sdk": "1.1.11",
|
|
29
|
+
"@mininglamp-oss/octo-runtime-protocol": "1.1.11",
|
|
30
30
|
"mdast-util-from-markdown": "2.1.0",
|
|
31
31
|
"ws": "8.22.0"
|
|
32
32
|
}
|
|
@@ -27,7 +27,7 @@ async function initialize(context, config, dependencies) {
|
|
|
27
27
|
}
|
|
28
28
|
const allowed = spaces;
|
|
29
29
|
channels = new ImChannelManager({
|
|
30
|
-
kernel: context.
|
|
30
|
+
kernel: context.execution,
|
|
31
31
|
signal: context.signal,
|
|
32
32
|
log: context.log,
|
|
33
33
|
// 与 Gateway 共用逐轮合同:宿主数据可变,连接与 manager 仍由 Extra 整体封装。
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* 宿主依赖入口:注入执行能力、凭据来源和脱敏诊断。
|
|
3
3
|
* SDK 应用自行决定账号目录和凭据生命周期,通道无需依赖 CLI 或具体 Provider。
|
|
4
4
|
*/
|
|
5
|
-
import type {
|
|
5
|
+
import type { ExtraExecutionContext } from "@mininglamp-oss/octo-runtime-host-sdk";
|
|
6
6
|
import type { ImBotConfig } from "./contracts.js";
|
|
7
7
|
import type { ImSessionStore } from "./application/session-store.js";
|
|
8
8
|
import type { RuntimeLog, JsonObject } from "@mininglamp-oss/octo-runtime-host-sdk";
|
|
@@ -11,7 +11,7 @@ export type ImCredentialSource = (config: ImBotConfig, signal: AbortSignal) => P
|
|
|
11
11
|
export interface ImModuleDependencies {
|
|
12
12
|
prepareContexts?: (config: JsonObject, signal: AbortSignal) => Promise<ContextItem[]>;
|
|
13
13
|
log?: RuntimeLog;
|
|
14
|
-
kernel: Pick<
|
|
14
|
+
kernel: Pick<ExtraExecutionContext, "invoke" | "cancelInvocation" | "respondInteraction">;
|
|
15
15
|
/** Owning Extra/manager lifetime; aborts connections, execution and delivery. */
|
|
16
16
|
signal?: AbortSignal;
|
|
17
17
|
authorizeSpace?: (spaceId: string) => void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mininglamp-oss/octo-runtime-extra-channel-wecom",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.11",
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -22,10 +22,10 @@
|
|
|
22
22
|
"docs"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@mininglamp-oss/octo-runtime-host-sdk": "1.1.
|
|
26
|
-
"@mininglamp-oss/octo-runtime-executor-core": "1.1.
|
|
27
|
-
"@mininglamp-oss/octo-runtime-executor-kernel": "1.1.
|
|
25
|
+
"@mininglamp-oss/octo-runtime-host-sdk": "1.1.11",
|
|
26
|
+
"@mininglamp-oss/octo-runtime-executor-core": "1.1.11",
|
|
27
|
+
"@mininglamp-oss/octo-runtime-executor-kernel": "1.1.11",
|
|
28
28
|
"ws": "8.22.0",
|
|
29
|
-
"@mininglamp-oss/octo-runtime-protocol": "1.1.
|
|
29
|
+
"@mininglamp-oss/octo-runtime-protocol": "1.1.11"
|
|
30
30
|
}
|
|
31
31
|
}
|
|
@@ -152,7 +152,7 @@ async function initialize(ctx, config) {
|
|
|
152
152
|
if (req.method === "GET" && url.pathname === "/api/bootstrap")
|
|
153
153
|
return json(res, 200, { token: secret, defaultProjectPath });
|
|
154
154
|
if (req.method === "GET" && url.pathname === "/api/adapters") {
|
|
155
|
-
const adapters = await ctx.
|
|
155
|
+
const adapters = await ctx.execution.list();
|
|
156
156
|
return json(res, 200, adapters.map((adapter) => ({
|
|
157
157
|
providerType: adapter.type,
|
|
158
158
|
available: adapter.available === true,
|
|
@@ -330,7 +330,7 @@ async function initialize(ctx, config) {
|
|
|
330
330
|
try {
|
|
331
331
|
await pipeline(Readable.from((async function* () {
|
|
332
332
|
try {
|
|
333
|
-
for await (const event of ctx.
|
|
333
|
+
for await (const event of ctx.execution.invoke(input, {
|
|
334
334
|
signal: controller.signal
|
|
335
335
|
}))
|
|
336
336
|
yield `data: ${JSON.stringify(event)}\n\n`;
|
|
@@ -359,10 +359,10 @@ async function initialize(ctx, config) {
|
|
|
359
359
|
if (!run)
|
|
360
360
|
throw new HttpError(409, "WEBUI_INVOCATION_INACTIVE");
|
|
361
361
|
if (runMatch[2] === "cancel") {
|
|
362
|
-
await ctx.
|
|
362
|
+
await ctx.execution.cancelInvocation(runMatch[1], "user");
|
|
363
363
|
return json(res, 200, { requested: true });
|
|
364
364
|
}
|
|
365
|
-
await ctx.
|
|
365
|
+
await ctx.execution.respondInteraction(runMatch[1], (await bodyJson(req)));
|
|
366
366
|
return json(res, 200, { submitted: true });
|
|
367
367
|
}
|
|
368
368
|
throw new HttpError(404, "NOT_FOUND");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mininglamp-oss/octo-runtime-extra-webui",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.11",
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Local Runtime workbench with canonical SSE presentation",
|
|
@@ -23,6 +23,6 @@
|
|
|
23
23
|
"porting-map.md"
|
|
24
24
|
],
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@mininglamp-oss/octo-runtime-protocol": "1.1.
|
|
26
|
+
"@mininglamp-oss/octo-runtime-protocol": "1.1.11"
|
|
27
27
|
}
|
|
28
28
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** 按选定平台规范化 Home 字符串;Windows 忽略大小写,其他平台保留大小写,不访问文件系统。 */
|
|
2
2
|
export declare function normalizedHome(home: string, platform?: NodeJS.Platform): string;
|
|
3
3
|
export declare function homeHash(home: string, platform?: NodeJS.Platform): string;
|
|
4
|
-
/**
|
|
4
|
+
/** 纯计算 Home 对应地址并检查传输预算;不准备目录,真实存在/权限由服务 initialize 再校验。 */
|
|
5
5
|
export declare function componentEndpoint(home: string, component?: string, platform?: NodeJS.Platform): string;
|
|
6
6
|
export declare function componentServiceId(home: string, component: string, platform?: NodeJS.Platform): string;
|
|
@@ -1,19 +1,26 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
|
-
import { posix
|
|
2
|
+
import { posix } from "node:path";
|
|
3
|
+
import { normalizeRuntimeHome, assertIpcEndpoint, assertRuntimePath } from "@mininglamp-oss/octo-runtime-executor-kernel";
|
|
3
4
|
/** 按选定平台规范化 Home 字符串;Windows 忽略大小写,其他平台保留大小写,不访问文件系统。 */
|
|
4
5
|
export function normalizedHome(home, platform = process.platform) {
|
|
5
|
-
|
|
6
|
+
const absolute = normalizeRuntimeHome(home, platform);
|
|
7
|
+
return platform === "win32" ? absolute.toLowerCase() : absolute;
|
|
6
8
|
}
|
|
7
9
|
export function homeHash(home, platform = process.platform) {
|
|
8
10
|
return createHash("sha256").update(normalizedHome(home, platform)).digest("hex").slice(0, 16);
|
|
9
11
|
}
|
|
10
|
-
/**
|
|
12
|
+
/** 纯计算 Home 对应地址并检查传输预算;不准备目录,真实存在/权限由服务 initialize 再校验。 */
|
|
11
13
|
export function componentEndpoint(home, component = "executor-kernel", platform = process.platform) {
|
|
12
14
|
if (!/^[a-z][a-z0-9-]{0,69}$/.test(component))
|
|
13
15
|
throw new Error("COMPONENT_INVALID");
|
|
14
|
-
|
|
16
|
+
assertRuntimePath(normalizedHome(home, platform), "home", platform);
|
|
17
|
+
const endpoint = platform === "win32"
|
|
15
18
|
? `\\\\.\\pipe\\octo-runtime-${component === "executor-kernel" ? "kernel" : component}-${homeHash(home, platform)}`
|
|
16
|
-
:
|
|
19
|
+
: component === "executor-kernel"
|
|
20
|
+
? posix.join(normalizedHome(home, platform), "executor-kernel.sock")
|
|
21
|
+
: posix.join(normalizedHome(home, platform), "sockets", `octo-runtime-${component}.sock`);
|
|
22
|
+
assertIpcEndpoint(endpoint, platform);
|
|
23
|
+
return endpoint;
|
|
17
24
|
}
|
|
18
25
|
export function componentServiceId(home, component, platform = process.platform) {
|
|
19
26
|
if (!/^[a-z][a-z0-9-]{0,69}$/.test(component))
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
import { type StartupContext, type StartupDiagnostic } from "@mininglamp-oss/octo-runtime-executor-kernel";
|
|
1
2
|
export declare class HostRuntimeError extends Error {
|
|
2
3
|
readonly code: string;
|
|
3
4
|
readonly scope: string;
|
|
4
5
|
readonly retryable: boolean;
|
|
5
|
-
|
|
6
|
+
readonly diagnostic?: StartupDiagnostic;
|
|
7
|
+
constructor(code: string, scope: string, retryable: boolean, message: string, options?: ErrorOptions & {
|
|
8
|
+
context?: StartupContext;
|
|
9
|
+
});
|
|
6
10
|
}
|
|
@@ -1,12 +1,21 @@
|
|
|
1
|
+
import { describeStartupError } from "@mininglamp-oss/octo-runtime-executor-kernel";
|
|
1
2
|
export class HostRuntimeError extends Error {
|
|
2
3
|
code;
|
|
3
4
|
scope;
|
|
4
5
|
retryable;
|
|
6
|
+
diagnostic;
|
|
5
7
|
constructor(code, scope, retryable, message, options) {
|
|
6
8
|
super(message, options);
|
|
7
9
|
this.code = code;
|
|
8
10
|
this.scope = scope;
|
|
9
11
|
this.retryable = retryable;
|
|
10
12
|
this.name = "HostRuntimeError";
|
|
13
|
+
// Host 的执行/身份错误仍属于原 scope;只有启动相关 Home 错误附加启动投影。
|
|
14
|
+
if (/^HOME_|^(LOCAL_STATE_INVALID|WRITE_FAILED)$/.test(code))
|
|
15
|
+
this.diagnostic = describeStartupError(this, {
|
|
16
|
+
component: "host",
|
|
17
|
+
phase: "created",
|
|
18
|
+
context: options?.context
|
|
19
|
+
});
|
|
11
20
|
}
|
|
12
21
|
}
|