@mininglamp-oss/octo-runtime 1.1.2 → 1.1.4
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/dist/build-info.json +2 -2
- package/apps/cli/dist/help.js +5 -1
- package/apps/cli/dist/main.js +32 -6
- package/apps/cli/dist/manifest.json +5 -0
- package/apps/cli/dist/openclaw.js +32 -8
- package/apps/cli/dist/output.js +3 -0
- package/apps/cli/dist/playboard.d.ts +5 -0
- package/apps/cli/dist/playboard.js +41 -13
- 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/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/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/help.js +5 -1
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/main.js +32 -6
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/manifest.json +5 -0
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/openclaw.js +32 -8
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/output.js +3 -0
- 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/package.json +24 -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 +181 -27
- 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 +57 -1
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/application/im-channel.js +167 -25
- 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/contracts.d.ts +20 -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.js +2 -1
- 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 +49 -17
- 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/normalize.d.ts +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/normalize.js +4 -2
- 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 +10 -7
- 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/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/package.json +5 -5
- 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 +2 -2
- 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/package.json +4 -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/package.json +35 -29
- package/packages/octo-runtime-extra-channel-gateway/config-schema.json +57 -1
- 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
|
@@ -119,9 +119,11 @@ export class WindowsUserTaskBackend {
|
|
|
119
119
|
detail: "PowerShell returned an invalid task status payload"
|
|
120
120
|
};
|
|
121
121
|
}
|
|
122
|
+
const identityUnknown = windowsAccountIdentity(task.principal_user_id, task.principal_user_matches, this.#windowsUserId) === undefined ||
|
|
123
|
+
windowsAccountIdentity(task.trigger_user_id, task.trigger_user_matches, this.#windowsUserId) === undefined;
|
|
122
124
|
return {
|
|
123
125
|
manager: this.kind,
|
|
124
|
-
state: windowsTaskState(task.state),
|
|
126
|
+
state: identityUnknown ? "unknown" : windowsTaskState(task.state),
|
|
125
127
|
enabled: task.enabled === true,
|
|
126
128
|
lastExitCode: task.last_exit_code,
|
|
127
129
|
definitionPath,
|
|
@@ -129,7 +131,11 @@ export class WindowsUserTaskBackend {
|
|
|
129
131
|
...definitionDrift(actual, desired),
|
|
130
132
|
...windowsManagerDrift(task, normalized, this.#windowsUserId)
|
|
131
133
|
],
|
|
132
|
-
detail:
|
|
134
|
+
detail: identityUnknown
|
|
135
|
+
? "Task Scheduler account identity could not be resolved"
|
|
136
|
+
: task.state
|
|
137
|
+
? undefined
|
|
138
|
+
: "Task Scheduler did not report a state"
|
|
133
139
|
};
|
|
134
140
|
}
|
|
135
141
|
/**
|
|
@@ -146,7 +152,9 @@ export class WindowsUserTaskBackend {
|
|
|
146
152
|
const previous = await this.inspect(spec);
|
|
147
153
|
if (previous.state === "running" || previous.state === "starting")
|
|
148
154
|
await this.stop(spec);
|
|
149
|
-
await writeDefinition(definitionPath, renderWindowsTaskXmlNormalized(normalized, taskName, this.#windowsUserId)
|
|
155
|
+
await writeDefinition(definitionPath, renderWindowsTaskXmlNormalized(normalized, taskName, this.#windowsUserId),
|
|
156
|
+
// schtasks 的 XML 导入使用带 BOM 的 UTF-16LE,声明与字节编码必须一致。
|
|
157
|
+
"utf16le");
|
|
150
158
|
await this.#schtasksCommand(["/Create", "/TN", taskName, "/XML", definitionPath, "/F"]);
|
|
151
159
|
// Restore only a previously running enabled task. A stopped task remains
|
|
152
160
|
// stopped, so setup controls the explicit first start and readiness wait.
|
|
@@ -265,7 +273,7 @@ export class WindowsUserTaskBackend {
|
|
|
265
273
|
: join(this.#definitionDirectory, fileName);
|
|
266
274
|
}
|
|
267
275
|
#query(taskName) {
|
|
268
|
-
const script = windowsTaskQueryScript(taskName);
|
|
276
|
+
const script = windowsTaskQueryScript(taskName, this.#windowsUserId);
|
|
269
277
|
return runCommand(this.#runner, this.kind, this.#powershell, powershellArguments(script), {
|
|
270
278
|
checked: false,
|
|
271
279
|
env: this.#environment
|
|
@@ -299,7 +307,10 @@ export class WindowsUserTaskBackend {
|
|
|
299
307
|
});
|
|
300
308
|
}
|
|
301
309
|
}
|
|
302
|
-
/**
|
|
310
|
+
/**
|
|
311
|
+
* 为一个 Windows 用户校验并返回确定的 XML 文本;声明为 UTF-16。
|
|
312
|
+
* 调用者写文件时必须使用带 BOM 的 UTF-16LE,不能按默认 UTF-8 序列化。
|
|
313
|
+
*/
|
|
303
314
|
export function renderWindowsTaskXml(spec, userId) {
|
|
304
315
|
assertSingleLine(userId, "Windows user id");
|
|
305
316
|
const normalized = normalizeServiceSpec(spec, "win32");
|
|
@@ -335,7 +346,7 @@ function renderWindowsTaskXmlNormalized(spec, taskName, userId) {
|
|
|
335
346
|
const restart = spec.restart.policy === "on-failure"
|
|
336
347
|
? ` <RestartOnFailure>\n <Interval>PT${Math.max(TASK_RESTART_MINIMUM_SECONDS, spec.restart.delaySeconds)}S</Interval>\n <Count>${spec.restart.maxBurst}</Count>\n </RestartOnFailure>\n`
|
|
337
348
|
: "";
|
|
338
|
-
return `<?xml version="1.0" encoding="UTF-
|
|
349
|
+
return `<?xml version="1.0" encoding="UTF-16"?>
|
|
339
350
|
<Task version="1.4" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
|
|
340
351
|
<RegistrationInfo>
|
|
341
352
|
<Description>${escapeXml(spec.description)}</Description>
|
|
@@ -403,13 +414,21 @@ function assertWindowsSupported(spec) {
|
|
|
403
414
|
});
|
|
404
415
|
}
|
|
405
416
|
}
|
|
406
|
-
function windowsTaskQueryScript(taskName) {
|
|
417
|
+
function windowsTaskQueryScript(taskName, userId) {
|
|
407
418
|
const task = taskName.slice(1);
|
|
408
419
|
const quotedTask = powershellSingleQuote(task);
|
|
409
|
-
|
|
420
|
+
// Scheduler 可把 DOMAIN\\user 规范化为短账号或 SID;比较系统身份,不能把同一账号报成 drift。
|
|
421
|
+
const identity = `function Get-AccountSid([string]$value){if($value -match '^S-1-'){return $value};return ([System.Security.Principal.NTAccount]$value).Translate([System.Security.Principal.SecurityIdentifier]).Value};function Test-AccountIdentity([string]$value){try{return (Get-AccountSid $value) -eq (Get-AccountSid '${powershellSingleQuote(userId)}')}catch{return $null}};`;
|
|
422
|
+
return `$ErrorActionPreference='Stop';${identity}$task=Get-ScheduledTask -TaskPath '\\' -TaskName '${quotedTask}';$info=Get-ScheduledTaskInfo -InputObject $task;$action=@($task.Actions)[0];$trigger=@($task.Triggers)[0];[ordered]@{state=[string]$task.State;enabled=([string]$task.State -ne 'Disabled');last_exit_code=[long]$info.LastTaskResult;execute=[string]$action.Execute;arguments=[string]$action.Arguments;working_directory=[string]$action.WorkingDirectory;principal_user_id=[string]$task.Principal.UserId;principal_user_matches=(Test-AccountIdentity ([string]$task.Principal.UserId));principal_logon_type=[string]$task.Principal.LogonType;trigger_user_id=[string]$trigger.UserId;trigger_user_matches=(Test-AccountIdentity ([string]$trigger.UserId))}|ConvertTo-Json -Compress`;
|
|
410
423
|
}
|
|
411
424
|
function powershellArguments(script) {
|
|
412
|
-
return [
|
|
425
|
+
return [
|
|
426
|
+
"-NoLogo",
|
|
427
|
+
"-NoProfile",
|
|
428
|
+
"-NonInteractive",
|
|
429
|
+
"-Command",
|
|
430
|
+
`[Console]::OutputEncoding=[System.Text.UTF8Encoding]::new($false);${script}`
|
|
431
|
+
];
|
|
413
432
|
}
|
|
414
433
|
function powershellSingleQuote(value) {
|
|
415
434
|
return value.replaceAll("'", "''");
|
|
@@ -423,12 +442,12 @@ function windowsManagerDrift(task, spec, userId) {
|
|
|
423
442
|
drift.push("manager.arguments");
|
|
424
443
|
if (!equalWindowsPath(task.working_directory, spec.workingDirectory))
|
|
425
444
|
drift.push("manager.working_directory");
|
|
426
|
-
if (
|
|
445
|
+
if (windowsAccountIdentity(task.principal_user_id, task.principal_user_matches, userId) === false)
|
|
427
446
|
drift.push("manager.principal_user");
|
|
428
447
|
if (!["interactivetoken", "interactive", "3"].includes(task.principal_logon_type?.toLowerCase() ?? "")) {
|
|
429
448
|
drift.push("manager.logon_type");
|
|
430
449
|
}
|
|
431
|
-
if (
|
|
450
|
+
if (windowsAccountIdentity(task.trigger_user_id, task.trigger_user_matches, userId) === false)
|
|
432
451
|
drift.push("manager.trigger_user");
|
|
433
452
|
if (task.enabled !== spec.enabled)
|
|
434
453
|
drift.push("manager.enabled");
|
|
@@ -440,6 +459,12 @@ function equalWindowsPath(actual, expected) {
|
|
|
440
459
|
function equalWindowsIdentity(actual, expected) {
|
|
441
460
|
return actual?.toLowerCase() === expected.toLowerCase();
|
|
442
461
|
}
|
|
462
|
+
/** null 表示系统身份查询失败;相同原文可确认,否则保留未知,不能伪造匹配或漂移。 */
|
|
463
|
+
function windowsAccountIdentity(actual, matches, expected) {
|
|
464
|
+
if (matches === null)
|
|
465
|
+
return equalWindowsIdentity(actual, expected) ? true : undefined;
|
|
466
|
+
return matches ?? equalWindowsIdentity(actual, expected);
|
|
467
|
+
}
|
|
443
468
|
function windowsTaskState(value) {
|
|
444
469
|
switch (value?.toLowerCase()) {
|
|
445
470
|
case "running":
|
|
@@ -290,6 +290,7 @@ export class AgentExecutor {
|
|
|
290
290
|
};
|
|
291
291
|
let state;
|
|
292
292
|
let failureCode;
|
|
293
|
+
let failureReasonCode;
|
|
293
294
|
const pendingInteractions = new Set();
|
|
294
295
|
const source = receipt.protocol_mode === "canonical"
|
|
295
296
|
? this.#invokeCanonical(adapterType, request, streamLimits, owner)
|
|
@@ -303,8 +304,10 @@ export class AgentExecutor {
|
|
|
303
304
|
if (next.done)
|
|
304
305
|
break;
|
|
305
306
|
const output = next.value;
|
|
306
|
-
if (!("kind" in output) && output.type === "run.failed")
|
|
307
|
+
if (!("kind" in output) && output.type === "run.failed") {
|
|
307
308
|
failureCode = output.payload.failure?.code;
|
|
309
|
+
failureReasonCode = output.payload.failure?.reasonCode;
|
|
310
|
+
}
|
|
308
311
|
if ("kind" in output && output.kind === "control" && output.control.type === "error")
|
|
309
312
|
failureCode = output.control.code;
|
|
310
313
|
if ("kind" in output &&
|
|
@@ -422,7 +425,8 @@ export class AgentExecutor {
|
|
|
422
425
|
if (state?.state === "failed")
|
|
423
426
|
this.#log("error", "invoke.failed", {
|
|
424
427
|
...identity,
|
|
425
|
-
code: failureCode ?? "EXECUTION_FAILED"
|
|
428
|
+
code: failureCode ?? "EXECUTION_FAILED",
|
|
429
|
+
reason_code: failureReasonCode
|
|
426
430
|
});
|
|
427
431
|
this.#log(state?.state === "failed" ? "error" : "info", "invoke.finished", {
|
|
428
432
|
...identity,
|
|
@@ -556,6 +560,7 @@ export class AgentExecutor {
|
|
|
556
560
|
const context = {
|
|
557
561
|
protocolMode,
|
|
558
562
|
streamLimits,
|
|
563
|
+
log: this.#log,
|
|
559
564
|
reportConversion: () => {
|
|
560
565
|
if (protocolMode === "native")
|
|
561
566
|
throw protocolError("EXECUTION_PROTOCOL_MISMATCH", "Native execution invoked a canonical converter");
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mininglamp-oss/octo-runtime-executor-core",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.4",
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": "./dist/index.js",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.
|
|
9
|
-
"@mininglamp-oss/octo-runtime-protocol": "1.1.
|
|
8
|
+
"@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.4",
|
|
9
|
+
"@mininglamp-oss/octo-runtime-protocol": "1.1.4"
|
|
10
10
|
},
|
|
11
11
|
"types": "./dist/index.d.ts",
|
|
12
12
|
"files": [
|
|
@@ -3,8 +3,9 @@ export { HostRunService } from "./host-run-service.js";
|
|
|
3
3
|
export { createKernelService, type KernelService, type KernelServiceOptions, type KernelServiceStatus } from "./service.js";
|
|
4
4
|
export * from "./lifecycle.js";
|
|
5
5
|
export { attachKernel } from "./client.js";
|
|
6
|
+
export { isInvocationNotSubmitted } from "./submission-error.js";
|
|
6
7
|
export * from "./types.js";
|
|
7
|
-
export { InvocationManifest, processStartIdentity, reapOrphanedInvocationManifest } from "./invocation-manifest.js";
|
|
8
|
+
export { InvocationManifest, acknowledgeOrphanCleanup, inspectOrphanCleanup, processStartIdentity, reapOrphanedInvocationManifest } from "./invocation-manifest.js";
|
|
8
9
|
export { readAdapterConfigurations } from "./runtime-configuration.js";
|
|
9
10
|
export { spawnWorker } from "./process.js";
|
|
10
11
|
export { serveWorker } from "./serve.js";
|
|
@@ -4,8 +4,9 @@ export { HostRunService } from "./host-run-service.js";
|
|
|
4
4
|
export { createKernelService } from "./service.js";
|
|
5
5
|
export * from "./lifecycle.js";
|
|
6
6
|
export { attachKernel } from "./client.js";
|
|
7
|
+
export { isInvocationNotSubmitted } from "./submission-error.js";
|
|
7
8
|
export * from "./types.js";
|
|
8
|
-
export { InvocationManifest, processStartIdentity, reapOrphanedInvocationManifest } from "./invocation-manifest.js";
|
|
9
|
+
export { InvocationManifest, acknowledgeOrphanCleanup, inspectOrphanCleanup, processStartIdentity, reapOrphanedInvocationManifest } from "./invocation-manifest.js";
|
|
9
10
|
export { readAdapterConfigurations } from "./runtime-configuration.js";
|
|
10
11
|
export { spawnWorker } from "./process.js";
|
|
11
12
|
export { serveWorker } from "./serve.js";
|
package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/invocation-lifecycle.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { setTimeout as delay } from "node:timers/promises";
|
|
2
|
+
import { admissionClosedError } from "./submission-error.js";
|
|
2
3
|
import { isHostTerminal } from "@mininglamp-oss/octo-runtime-protocol";
|
|
3
4
|
import { KernelError } from "./types.js";
|
|
4
5
|
/**
|
|
@@ -42,7 +43,7 @@ export class InvocationRegistry {
|
|
|
42
43
|
}
|
|
43
44
|
assertSubmission() {
|
|
44
45
|
if (this.#stopped)
|
|
45
|
-
throw
|
|
46
|
+
throw admissionClosedError();
|
|
46
47
|
}
|
|
47
48
|
accepted(record, ref, terminal) {
|
|
48
49
|
record.ref = ref;
|
package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/invocation-manifest.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export interface OrphanReapResult {
|
|
|
8
8
|
found: boolean;
|
|
9
9
|
reaped: boolean;
|
|
10
10
|
pid?: number;
|
|
11
|
-
reason?: "kernel_alive" | "host_missing" | "identity_mismatch" | "unsupported_identity";
|
|
11
|
+
reason?: "kernel_alive" | "host_missing" | "identity_mismatch" | "unsupported_identity" | "cleanup_incomplete" | "cleanup_acknowledged";
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
14
|
* 持久化 Kernel/worker 身份与在途执行事实,用于下次启动时识别遗留资源,不保存业务历史。
|
|
@@ -31,5 +31,20 @@ export declare class InvocationManifest {
|
|
|
31
31
|
* 无法验证身份时保留清单并报告 unsupported_identity;worker 已消失不证明 Windows 后代已清空。
|
|
32
32
|
*/
|
|
33
33
|
export declare function reapOrphanedInvocationManifest(path: string): Promise<OrphanReapResult>;
|
|
34
|
+
/** 只读恢复诊断,不回收进程、不改写清单;用于 doctor 及 SDK 运维界面。 */
|
|
35
|
+
export declare function inspectOrphanCleanup(path: string): Promise<{
|
|
36
|
+
manifestPath: string;
|
|
37
|
+
state: "missing" | "available" | "cleanup_incomplete" | "acknowledged" | "unreadable";
|
|
38
|
+
workerPid?: number;
|
|
39
|
+
}>;
|
|
40
|
+
/**
|
|
41
|
+
* 操作者已停止未知后代后显式确认当前失败记录;不终止进程、不声称整树回收已验证。
|
|
42
|
+
* 仍存活的原 Kernel/worker 或无法核验的 PID 不能放行。备份保留,确认仅匹配原文摘要,
|
|
43
|
+
* 所以并发启动、后续调用或另一份清单不会复用旧确认;下一次 open 才替换失败记录。
|
|
44
|
+
*/
|
|
45
|
+
export declare function acknowledgeOrphanCleanup(path: string): Promise<{
|
|
46
|
+
manifestPath: string;
|
|
47
|
+
archivePath: string;
|
|
48
|
+
}>;
|
|
34
49
|
/** 查询系统启动时间以区分 PID 复用;失败时不返回可用于回收的身份,绝不以 PID 本身兜底。 */
|
|
35
50
|
export declare function processStartIdentity(pid: number): Promise<string | undefined>;
|
package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/invocation-manifest.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { execFile } from "node:child_process";
|
|
2
|
-
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
3
3
|
import { mkdir, readFile, rename, rm, writeFile } from "node:fs/promises";
|
|
4
4
|
import { dirname } from "node:path";
|
|
5
5
|
/**
|
|
@@ -16,11 +16,15 @@ export class InvocationManifest {
|
|
|
16
16
|
}
|
|
17
17
|
static async open(path) {
|
|
18
18
|
const reap = await reapOrphanedInvocationManifest(path);
|
|
19
|
+
if (reap.reason === "cleanup_incomplete") {
|
|
20
|
+
throw Object.assign(new Error(`Orphan cleanup is unconfirmed: ${path}. After stopping all orphan tools, use acknowledgeOrphanCleanup(path), then retry startup.`), { code: "ORPHAN_CLEANUP_INCOMPLETE" });
|
|
21
|
+
}
|
|
19
22
|
if (reap.reason === "kernel_alive" || reap.reason === "unsupported_identity") {
|
|
20
23
|
throw new Error(`cannot replace live or unverifiable invocation manifest (${reap.reason})`);
|
|
21
24
|
}
|
|
22
25
|
const manifest = new InvocationManifest(path);
|
|
23
26
|
await manifest.#persist();
|
|
27
|
+
await removeAcknowledgement(path);
|
|
24
28
|
return { manifest, reap };
|
|
25
29
|
}
|
|
26
30
|
async setWorker(pid, entrypoint) {
|
|
@@ -28,10 +32,15 @@ export class InvocationManifest {
|
|
|
28
32
|
this.#worker = undefined;
|
|
29
33
|
}
|
|
30
34
|
else {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
+
try {
|
|
36
|
+
const started = await queryProcessStartIdentity(pid);
|
|
37
|
+
if (!started)
|
|
38
|
+
throw new Error("system process start identity unavailable");
|
|
39
|
+
this.#worker = { pid, started, entrypoint };
|
|
40
|
+
}
|
|
41
|
+
catch (cause) {
|
|
42
|
+
throw new Error(`cannot identify worker process ${pid}`, { cause });
|
|
43
|
+
}
|
|
35
44
|
}
|
|
36
45
|
await this.#persist();
|
|
37
46
|
}
|
|
@@ -47,6 +56,7 @@ export class InvocationManifest {
|
|
|
47
56
|
async close() {
|
|
48
57
|
await this.#writes;
|
|
49
58
|
await rm(this.#path, { force: true });
|
|
59
|
+
await removeAcknowledgement(this.#path);
|
|
50
60
|
}
|
|
51
61
|
#persist() {
|
|
52
62
|
const snapshot = {
|
|
@@ -57,18 +67,7 @@ export class InvocationManifest {
|
|
|
57
67
|
invocations: [...this.#invocations.values()].map((entry) => ({ ...entry }))
|
|
58
68
|
};
|
|
59
69
|
this.#writes = this.#writes.then(async () => {
|
|
60
|
-
await
|
|
61
|
-
const temporary = `${this.#path}.${process.pid}.${randomUUID()}.tmp`;
|
|
62
|
-
try {
|
|
63
|
-
await writeFile(temporary, `${JSON.stringify(snapshot)}\n`, {
|
|
64
|
-
encoding: "utf8",
|
|
65
|
-
mode: 0o600
|
|
66
|
-
});
|
|
67
|
-
await rename(temporary, this.#path);
|
|
68
|
-
}
|
|
69
|
-
finally {
|
|
70
|
-
await rm(temporary, { force: true });
|
|
71
|
-
}
|
|
70
|
+
await writeManifest(this.#path, snapshot);
|
|
72
71
|
});
|
|
73
72
|
return this.#writes;
|
|
74
73
|
}
|
|
@@ -79,13 +78,18 @@ export class InvocationManifest {
|
|
|
79
78
|
*/
|
|
80
79
|
export async function reapOrphanedInvocationManifest(path) {
|
|
81
80
|
let parsed;
|
|
81
|
+
let source;
|
|
82
82
|
try {
|
|
83
|
-
|
|
83
|
+
source = await readFile(path, "utf8");
|
|
84
|
+
parsed = JSON.parse(source);
|
|
84
85
|
}
|
|
85
86
|
catch (error) {
|
|
86
|
-
if (error.code === "ENOENT")
|
|
87
|
+
if (error.code === "ENOENT") {
|
|
88
|
+
await removeAcknowledgement(path);
|
|
87
89
|
return { found: false, reaped: false };
|
|
90
|
+
}
|
|
88
91
|
await rm(path, { force: true });
|
|
92
|
+
await removeAcknowledgement(path);
|
|
89
93
|
return { found: true, reaped: false, reason: "host_missing" };
|
|
90
94
|
}
|
|
91
95
|
if (Number.isSafeInteger(parsed.kernelPid) &&
|
|
@@ -95,7 +99,18 @@ export async function reapOrphanedInvocationManifest(path) {
|
|
|
95
99
|
}
|
|
96
100
|
const host = parsed.worker;
|
|
97
101
|
if (!host || !Number.isSafeInteger(host.pid) || host.pid < 1 || !processAlive(host.pid)) {
|
|
102
|
+
if (parsed.cleanupIncomplete && process.platform === "win32") {
|
|
103
|
+
return {
|
|
104
|
+
found: true,
|
|
105
|
+
reaped: false,
|
|
106
|
+
pid: host?.pid,
|
|
107
|
+
reason: (await cleanupWasAcknowledged(path, source))
|
|
108
|
+
? "cleanup_acknowledged"
|
|
109
|
+
: "cleanup_incomplete"
|
|
110
|
+
};
|
|
111
|
+
}
|
|
98
112
|
await rm(path, { force: true });
|
|
113
|
+
await removeAcknowledgement(path);
|
|
99
114
|
return { found: true, reaped: false, reason: "host_missing" };
|
|
100
115
|
}
|
|
101
116
|
const currentIdentity = await processStartIdentity(host.pid);
|
|
@@ -103,15 +118,138 @@ export async function reapOrphanedInvocationManifest(path) {
|
|
|
103
118
|
return { found: true, reaped: false, pid: host.pid, reason: "unsupported_identity" };
|
|
104
119
|
}
|
|
105
120
|
if (currentIdentity !== host.started) {
|
|
121
|
+
if (parsed.cleanupIncomplete && process.platform === "win32") {
|
|
122
|
+
return {
|
|
123
|
+
found: true,
|
|
124
|
+
reaped: false,
|
|
125
|
+
pid: host.pid,
|
|
126
|
+
reason: (await cleanupWasAcknowledged(path, source))
|
|
127
|
+
? "cleanup_acknowledged"
|
|
128
|
+
: "cleanup_incomplete"
|
|
129
|
+
};
|
|
130
|
+
}
|
|
106
131
|
await rm(path, { force: true });
|
|
132
|
+
await removeAcknowledgement(path);
|
|
107
133
|
return { found: true, reaped: false, pid: host.pid, reason: "identity_mismatch" };
|
|
108
134
|
}
|
|
109
|
-
|
|
135
|
+
// 必须在 leader 仍可识别时回收 Windows 树;失败保留证据,禁止覆盖清单并启动替代 worker。
|
|
136
|
+
if (!(await terminateProcessGroup(host.pid)) && process.platform === "win32") {
|
|
137
|
+
// 失败事实必须跨重启保留;leader 后来消失或 PID 复用不能抹去未确认的后代归属。
|
|
138
|
+
await writeManifest(path, { ...parsed, cleanupIncomplete: true });
|
|
139
|
+
return { found: true, reaped: false, pid: host.pid, reason: "cleanup_incomplete" };
|
|
140
|
+
}
|
|
110
141
|
await rm(path, { force: true });
|
|
142
|
+
await removeAcknowledgement(path);
|
|
111
143
|
return { found: true, reaped: true, pid: host.pid };
|
|
112
144
|
}
|
|
145
|
+
async function removeAcknowledgement(path) {
|
|
146
|
+
try {
|
|
147
|
+
await rm(`${path}.acknowledgement`, { force: true });
|
|
148
|
+
}
|
|
149
|
+
catch {
|
|
150
|
+
// 旧确认已因清单删除或替换而失效;辅助文件清理失败不能阻止启动,原始归档始终保留。
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
/** 只读恢复诊断,不回收进程、不改写清单;用于 doctor 及 SDK 运维界面。 */
|
|
154
|
+
export async function inspectOrphanCleanup(path) {
|
|
155
|
+
try {
|
|
156
|
+
const source = await readFile(path, "utf8");
|
|
157
|
+
const parsed = JSON.parse(source);
|
|
158
|
+
return {
|
|
159
|
+
manifestPath: path,
|
|
160
|
+
state: parsed.cleanupIncomplete
|
|
161
|
+
? (await cleanupWasAcknowledged(path, source))
|
|
162
|
+
? "acknowledged"
|
|
163
|
+
: "cleanup_incomplete"
|
|
164
|
+
: "available",
|
|
165
|
+
workerPid: parsed.worker?.pid
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
catch (error) {
|
|
169
|
+
return {
|
|
170
|
+
manifestPath: path,
|
|
171
|
+
state: error.code === "ENOENT" ? "missing" : "unreadable"
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* 操作者已停止未知后代后显式确认当前失败记录;不终止进程、不声称整树回收已验证。
|
|
177
|
+
* 仍存活的原 Kernel/worker 或无法核验的 PID 不能放行。备份保留,确认仅匹配原文摘要,
|
|
178
|
+
* 所以并发启动、后续调用或另一份清单不会复用旧确认;下一次 open 才替换失败记录。
|
|
179
|
+
*/
|
|
180
|
+
export async function acknowledgeOrphanCleanup(path) {
|
|
181
|
+
const source = await readFile(path, "utf8");
|
|
182
|
+
const parsed = JSON.parse(source);
|
|
183
|
+
if (parsed.schemaVersion !== 1 ||
|
|
184
|
+
!Number.isSafeInteger(parsed.kernelPid) ||
|
|
185
|
+
parsed.kernelPid < 1 ||
|
|
186
|
+
parsed.cleanupIncomplete !== true ||
|
|
187
|
+
!parsed.worker ||
|
|
188
|
+
!Number.isSafeInteger(parsed.worker.pid) ||
|
|
189
|
+
parsed.worker.pid < 1) {
|
|
190
|
+
throw new Error("ORPHAN_CLEANUP_NOT_PENDING");
|
|
191
|
+
}
|
|
192
|
+
if (processAlive(parsed.kernelPid))
|
|
193
|
+
throw new Error("ORPHAN_CLEANUP_OWNER_ALIVE");
|
|
194
|
+
if (processAlive(parsed.worker.pid)) {
|
|
195
|
+
const identity = await processStartIdentity(parsed.worker.pid);
|
|
196
|
+
if (!identity || identity === parsed.worker.started)
|
|
197
|
+
throw new Error("ORPHAN_CLEANUP_OWNER_ALIVE");
|
|
198
|
+
}
|
|
199
|
+
const archivePath = `${path}.acknowledged.${randomUUID()}.json`;
|
|
200
|
+
await writeFile(archivePath, source, { encoding: "utf8", flag: "wx", mode: 0o600 });
|
|
201
|
+
const temporary = `${path}.${randomUUID()}.ack.tmp`;
|
|
202
|
+
try {
|
|
203
|
+
await writeFile(temporary, JSON.stringify({ digest: manifestDigest(source), archivePath }), {
|
|
204
|
+
mode: 0o600,
|
|
205
|
+
flag: "wx"
|
|
206
|
+
});
|
|
207
|
+
await rename(temporary, `${path}.acknowledgement`);
|
|
208
|
+
}
|
|
209
|
+
finally {
|
|
210
|
+
await rm(temporary, { force: true });
|
|
211
|
+
}
|
|
212
|
+
return { manifestPath: path, archivePath };
|
|
213
|
+
}
|
|
214
|
+
function manifestDigest(source) {
|
|
215
|
+
return createHash("sha256").update(source).digest("hex");
|
|
216
|
+
}
|
|
217
|
+
async function cleanupWasAcknowledged(path, source) {
|
|
218
|
+
try {
|
|
219
|
+
const ack = JSON.parse(await readFile(`${path}.acknowledgement`, "utf8"));
|
|
220
|
+
if (ack.digest !== manifestDigest(source) ||
|
|
221
|
+
typeof ack.archivePath !== "string" ||
|
|
222
|
+
!ack.archivePath.startsWith(path) ||
|
|
223
|
+
!/^\.acknowledged\.[0-9a-f-]{36}\.json$/.test(ack.archivePath.slice(path.length)))
|
|
224
|
+
return false;
|
|
225
|
+
return manifestDigest(await readFile(ack.archivePath, "utf8")) === ack.digest;
|
|
226
|
+
}
|
|
227
|
+
catch {
|
|
228
|
+
return false;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
async function writeManifest(path, snapshot) {
|
|
232
|
+
await mkdir(dirname(path), { recursive: true, mode: 0o700 });
|
|
233
|
+
const temporary = `${path}.${process.pid}.${randomUUID()}.tmp`;
|
|
234
|
+
try {
|
|
235
|
+
await writeFile(temporary, `${JSON.stringify(snapshot)}\n`, { encoding: "utf8", mode: 0o600 });
|
|
236
|
+
await rename(temporary, path);
|
|
237
|
+
}
|
|
238
|
+
finally {
|
|
239
|
+
await rm(temporary, { force: true });
|
|
240
|
+
}
|
|
241
|
+
}
|
|
113
242
|
/** 查询系统启动时间以区分 PID 复用;失败时不返回可用于回收的身份,绝不以 PID 本身兜底。 */
|
|
114
243
|
export async function processStartIdentity(pid) {
|
|
244
|
+
try {
|
|
245
|
+
return await queryProcessStartIdentity(pid);
|
|
246
|
+
}
|
|
247
|
+
catch {
|
|
248
|
+
return undefined;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
// 登记失败保留系统查询原因;公开探测与孤儿回收仍以 undefined 表示身份未知。
|
|
252
|
+
async function queryProcessStartIdentity(pid) {
|
|
115
253
|
if (!Number.isSafeInteger(pid) || pid < 1)
|
|
116
254
|
return undefined;
|
|
117
255
|
if (process.platform === "linux") {
|
|
@@ -136,33 +274,49 @@ export async function processStartIdentity(pid) {
|
|
|
136
274
|
});
|
|
137
275
|
}
|
|
138
276
|
if (process.platform === "win32") {
|
|
139
|
-
return new Promise((resolve) => {
|
|
277
|
+
return new Promise((resolve, reject) => {
|
|
140
278
|
execFile("powershell.exe", [
|
|
141
279
|
"-NoLogo",
|
|
142
280
|
"-NoProfile",
|
|
143
281
|
"-NonInteractive",
|
|
144
282
|
"-Command",
|
|
145
283
|
// 直接调用系统进程对象,避免 Get-Process 的命令发现/模块自动加载占用身份查询预算。
|
|
146
|
-
// 保持 UTC ticks
|
|
284
|
+
// 保持 UTC ticks 身份格式,不缓存可能已经复用的 PID。
|
|
147
285
|
`$PSModuleAutoLoadingPreference='None'; $target=[System.Diagnostics.Process]::GetProcessById(${pid}); try { [Console]::Out.Write($target.StartTime.ToUniversalTime().Ticks.ToString([Globalization.CultureInfo]::InvariantCulture)) } finally { $target.Dispose() }`
|
|
148
|
-
],
|
|
286
|
+
],
|
|
287
|
+
// PowerShell 冷启动与查询共用 40 秒;Windows CI 曾在 30 秒期限被系统命令超时终止。
|
|
288
|
+
// 身份登记独立于后续 RPC 就绪与关闭预算,失败仍禁止使用未知 PID。
|
|
289
|
+
{ encoding: "utf8", timeout: 40_000, windowsHide: true }, (error, stdout) => {
|
|
290
|
+
if (error) {
|
|
291
|
+
reject(error instanceof Error
|
|
292
|
+
? error
|
|
293
|
+
: new Error("Windows process identity query failed", { cause: error }));
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
149
296
|
const value = stdout.trim();
|
|
150
|
-
resolve(
|
|
297
|
+
resolve(!/^\d+$/.test(value) ? undefined : `windows:${value}`);
|
|
151
298
|
});
|
|
152
299
|
});
|
|
153
300
|
}
|
|
154
301
|
return undefined;
|
|
155
302
|
}
|
|
156
303
|
async function terminateProcessGroup(pid) {
|
|
304
|
+
if (process.platform === "win32") {
|
|
305
|
+
const terminated = await new Promise((resolve) => {
|
|
306
|
+
execFile("taskkill.exe", ["/PID", String(pid), "/T", "/F"], { windowsHide: true, timeout: 5_000 }, (error) => resolve(!error));
|
|
307
|
+
});
|
|
308
|
+
// taskkill 失败即使 leader 随后消失,也不能证明后代已回收。
|
|
309
|
+
return terminated && (await waitForExit(pid, 1_000));
|
|
310
|
+
}
|
|
157
311
|
signalProcessGroup(pid, "SIGTERM");
|
|
158
312
|
if (await waitForExit(pid, 1_000))
|
|
159
|
-
return;
|
|
313
|
+
return true;
|
|
160
314
|
signalProcessGroup(pid, "SIGKILL");
|
|
161
|
-
|
|
315
|
+
return waitForExit(pid, 1_000);
|
|
162
316
|
}
|
|
163
317
|
function signalProcessGroup(pid, signal) {
|
|
164
318
|
try {
|
|
165
|
-
process.kill(
|
|
319
|
+
process.kill(-pid, signal);
|
|
166
320
|
}
|
|
167
321
|
catch (error) {
|
|
168
322
|
if (error.code !== "ESRCH")
|
|
@@ -63,8 +63,15 @@ export function serveWorker(adapters, options = {}) {
|
|
|
63
63
|
await finish(1);
|
|
64
64
|
});
|
|
65
65
|
};
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
const onSignal = () => {
|
|
67
|
+
// Windows 控制台事件也会送达 worker;父 Kernel 须先经 RPC 取消并消费终态,再以 EOF 关闭。
|
|
68
|
+
// 抢先退出会丢失终态及树回收所需的 leader。父 IPC 已断开或独立运行时仍自行收尾。
|
|
69
|
+
if (process.platform !== "win32" || !process.connected)
|
|
70
|
+
stop();
|
|
71
|
+
};
|
|
72
|
+
// 保持监听到父进程关闭,避免重复控制台事件恢复默认的立即退出行为。
|
|
73
|
+
process.on("SIGINT", onSignal);
|
|
74
|
+
process.on("SIGTERM", onSignal);
|
|
68
75
|
process.once("SIGHUP", () => stop());
|
|
69
76
|
process.stdin.once("end", () => stop(process.platform === "win32"));
|
|
70
77
|
process.stdin.once("close", () => stop(process.platform === "win32"));
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { KernelError } from "./types.js";
|
|
2
|
+
/** 包内接纳检查专用;只有当前 client 在请求写出前拒绝时才能创建此证据。 */
|
|
3
|
+
export declare function admissionClosedError(): KernelError;
|
|
4
|
+
/**
|
|
5
|
+
* 判断同一模块实例产生的本地未提交拒绝;包装、序列化及同名错误均返回 false。
|
|
6
|
+
* 只证明本次 invoke 未写出,不证明此前业务尝试没有执行,也不授权自动重放。
|
|
7
|
+
*/
|
|
8
|
+
export declare function isInvocationNotSubmitted(error: unknown): boolean;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { KernelError } from "./types.js";
|
|
2
|
+
const notSubmitted = new WeakSet();
|
|
3
|
+
/** 包内接纳检查专用;只有当前 client 在请求写出前拒绝时才能创建此证据。 */
|
|
4
|
+
export function admissionClosedError() {
|
|
5
|
+
const error = new KernelError("CLIENT_INVOCATION_ADMISSION_CLOSED");
|
|
6
|
+
notSubmitted.add(error);
|
|
7
|
+
return error;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* 判断同一模块实例产生的本地未提交拒绝;包装、序列化及同名错误均返回 false。
|
|
11
|
+
* 只证明本次 invoke 未写出,不证明此前业务尝试没有执行,也不授权自动重放。
|
|
12
|
+
*/
|
|
13
|
+
export function isInvocationNotSubmitted(error) {
|
|
14
|
+
return (error instanceof KernelError &&
|
|
15
|
+
error.code === "CLIENT_INVOCATION_ADMISSION_CLOSED" &&
|
|
16
|
+
notSubmitted.has(error));
|
|
17
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mininglamp-oss/octo-runtime-executor-kernel",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.4",
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
}
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@mininglamp-oss/octo-runtime-executor-core": "1.1.
|
|
22
|
-
"@mininglamp-oss/octo-runtime-protocol": "1.1.
|
|
23
|
-
"@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.
|
|
21
|
+
"@mininglamp-oss/octo-runtime-executor-core": "1.1.4",
|
|
22
|
+
"@mininglamp-oss/octo-runtime-protocol": "1.1.4",
|
|
23
|
+
"@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.4"
|
|
24
24
|
},
|
|
25
25
|
"types": "./dist/index.d.ts",
|
|
26
26
|
"files": [
|