@ai-setting/roy-agent-cli 1.5.94 → 1.5.96
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/dist/bin/roy-agent.js +186 -61
- package/dist/index.js +186 -61
- package/dist/roy-agent-linux-x64/bin/roy-agent +0 -0
- package/package.json +1 -1
package/dist/bin/roy-agent.js
CHANGED
|
@@ -7427,7 +7427,7 @@ var require_dist = __commonJS((exports) => {
|
|
|
7427
7427
|
var require_package = __commonJS((exports, module) => {
|
|
7428
7428
|
module.exports = {
|
|
7429
7429
|
name: "@ai-setting/roy-agent-cli",
|
|
7430
|
-
version: "1.5.
|
|
7430
|
+
version: "1.5.96",
|
|
7431
7431
|
type: "module",
|
|
7432
7432
|
description: "CLI for roy-agent - Non-interactive command execution",
|
|
7433
7433
|
main: "./dist/index.js",
|
|
@@ -8494,6 +8494,63 @@ function assembleMultimodalMessage(text, imageArgs) {
|
|
|
8494
8494
|
return imageParts;
|
|
8495
8495
|
}
|
|
8496
8496
|
|
|
8497
|
+
// src/commands/act-shutdown.ts
|
|
8498
|
+
import { TempFileManager } from "@ai-setting/roy-agent-core/utils/temp-file-manager";
|
|
8499
|
+
async function runActShutdownCleanup(deps) {
|
|
8500
|
+
const {
|
|
8501
|
+
stopTaskEventHandlerCleanup: stopTaskEventHandlerCleanupFn,
|
|
8502
|
+
lspManagerDispose,
|
|
8503
|
+
pluginAdapterDispose,
|
|
8504
|
+
envService,
|
|
8505
|
+
shouldDisposeEnvService,
|
|
8506
|
+
output,
|
|
8507
|
+
logger: logger4
|
|
8508
|
+
} = deps;
|
|
8509
|
+
const log = logger4 ?? {
|
|
8510
|
+
debug: () => {},
|
|
8511
|
+
warn: (msg) => console.warn(msg)
|
|
8512
|
+
};
|
|
8513
|
+
try {
|
|
8514
|
+
if (typeof stopTaskEventHandlerCleanupFn === "function") {
|
|
8515
|
+
stopTaskEventHandlerCleanupFn();
|
|
8516
|
+
}
|
|
8517
|
+
} catch (err) {
|
|
8518
|
+
log.warn(`[Act-Shutdown] Task Event Handler stop failed: ${err}`);
|
|
8519
|
+
}
|
|
8520
|
+
if (lspManagerDispose) {
|
|
8521
|
+
try {
|
|
8522
|
+
await lspManagerDispose();
|
|
8523
|
+
} catch (err) {
|
|
8524
|
+
log.warn(`[Act-Shutdown] LSP Manager dispose failed: ${err}`);
|
|
8525
|
+
}
|
|
8526
|
+
}
|
|
8527
|
+
if (pluginAdapterDispose) {
|
|
8528
|
+
try {
|
|
8529
|
+
await pluginAdapterDispose();
|
|
8530
|
+
} catch (err) {
|
|
8531
|
+
log.warn(`[Act-Shutdown] PluginAdapter dispose failed: ${err}`);
|
|
8532
|
+
}
|
|
8533
|
+
}
|
|
8534
|
+
if (shouldDisposeEnvService) {
|
|
8535
|
+
try {
|
|
8536
|
+
await envService.dispose();
|
|
8537
|
+
} catch (err) {
|
|
8538
|
+
log.warn(`[Act-Shutdown] envService.dispose failed: ${err}`);
|
|
8539
|
+
}
|
|
8540
|
+
}
|
|
8541
|
+
try {
|
|
8542
|
+
await TempFileManager.getInstance().cleanupAll();
|
|
8543
|
+
log.debug?.("[Act-Shutdown] TempFileManager cleaned up");
|
|
8544
|
+
} catch (err) {
|
|
8545
|
+
log.warn(`[Act-Shutdown] TempFileManager cleanup failed: ${err}`);
|
|
8546
|
+
if (output)
|
|
8547
|
+
output.warn(`⚠ TempFileManager cleanup failed: ${err}`);
|
|
8548
|
+
}
|
|
8549
|
+
if (shouldDisposeEnvService && typeof process !== "undefined" && process.env.ROY_AGENT_NO_EXIT !== "1") {
|
|
8550
|
+
process.exit(0);
|
|
8551
|
+
}
|
|
8552
|
+
}
|
|
8553
|
+
|
|
8497
8554
|
// src/commands/act.ts
|
|
8498
8555
|
function createActCommand(externalEnvService) {
|
|
8499
8556
|
return {
|
|
@@ -8569,6 +8626,7 @@ function createActCommand(externalEnvService) {
|
|
|
8569
8626
|
const envService = externalEnvService ?? new EnvironmentService(output);
|
|
8570
8627
|
let pluginAdapterDispose = null;
|
|
8571
8628
|
let lspManagerDispose = null;
|
|
8629
|
+
let stopTaskEventHandlerCleanup = null;
|
|
8572
8630
|
const rawPlugins = args.plugin;
|
|
8573
8631
|
const pluginNames = Array.isArray(rawPlugins) ? rawPlugins : rawPlugins ? [rawPlugins] : [];
|
|
8574
8632
|
const CODER_HARNESS_PLUGINS = new Set([
|
|
@@ -8626,7 +8684,7 @@ function createActCommand(externalEnvService) {
|
|
|
8626
8684
|
env,
|
|
8627
8685
|
enabled: true
|
|
8628
8686
|
});
|
|
8629
|
-
|
|
8687
|
+
stopTaskEventHandlerCleanup = taskEventHandlerForCleanup.start();
|
|
8630
8688
|
let sessionId = args.session;
|
|
8631
8689
|
if (args.continue && !sessionId) {
|
|
8632
8690
|
const activeSession = await sessionComponent.getActiveSession();
|
|
@@ -8826,21 +8884,15 @@ function createActCommand(externalEnvService) {
|
|
|
8826
8884
|
}
|
|
8827
8885
|
process.exit(1);
|
|
8828
8886
|
} finally {
|
|
8829
|
-
|
|
8830
|
-
stopTaskEventHandlerCleanup
|
|
8831
|
-
|
|
8832
|
-
|
|
8833
|
-
|
|
8834
|
-
|
|
8835
|
-
|
|
8836
|
-
|
|
8837
|
-
}
|
|
8838
|
-
if (shouldDisposeEnvService) {
|
|
8839
|
-
await envService.dispose();
|
|
8840
|
-
if (process.env.ROY_AGENT_NO_EXIT !== "1") {
|
|
8841
|
-
process.exit(0);
|
|
8842
|
-
}
|
|
8843
|
-
}
|
|
8887
|
+
await runActShutdownCleanup({
|
|
8888
|
+
stopTaskEventHandlerCleanup,
|
|
8889
|
+
lspManagerDispose,
|
|
8890
|
+
pluginAdapterDispose,
|
|
8891
|
+
envService,
|
|
8892
|
+
shouldDisposeEnvService,
|
|
8893
|
+
output,
|
|
8894
|
+
logger: { debug: () => {}, warn: console.warn }
|
|
8895
|
+
});
|
|
8844
8896
|
}
|
|
8845
8897
|
}
|
|
8846
8898
|
};
|
|
@@ -9626,6 +9678,98 @@ function parseUserInput(input, options) {
|
|
|
9626
9678
|
return { type: "text", value: trimmedInput };
|
|
9627
9679
|
}
|
|
9628
9680
|
|
|
9681
|
+
// src/commands/interactive-shutdown.ts
|
|
9682
|
+
import { TempFileManager as TempFileManager2 } from "@ai-setting/roy-agent-core/utils/temp-file-manager";
|
|
9683
|
+
async function shutdownInteractiveSteps(deps) {
|
|
9684
|
+
const {
|
|
9685
|
+
memoryPluginDispose,
|
|
9686
|
+
memoryPluginInstance,
|
|
9687
|
+
lspManagerDispose,
|
|
9688
|
+
pluginAdapterDispose,
|
|
9689
|
+
eventHandler,
|
|
9690
|
+
queryExecutor,
|
|
9691
|
+
env,
|
|
9692
|
+
envService,
|
|
9693
|
+
shouldDisposeEnvService,
|
|
9694
|
+
output,
|
|
9695
|
+
logger: logger4,
|
|
9696
|
+
console: consoleLike
|
|
9697
|
+
} = deps;
|
|
9698
|
+
const log = (msg) => consoleLike?.log?.(msg) ?? console.log(msg);
|
|
9699
|
+
if (memoryPluginDispose) {
|
|
9700
|
+
try {
|
|
9701
|
+
if (memoryPluginInstance?.hasPendingTasks?.()) {
|
|
9702
|
+
log("\uD83D\uDCBE 正在保存记忆,请稍候...");
|
|
9703
|
+
await memoryPluginInstance.waitForCompletion?.();
|
|
9704
|
+
}
|
|
9705
|
+
await memoryPluginDispose();
|
|
9706
|
+
log("\uD83D\uDCBE 记忆已保存完毕");
|
|
9707
|
+
} catch (err) {
|
|
9708
|
+
logger4.warn(`[Shutdown] MemoryPlugin dispose failed: ${err}`);
|
|
9709
|
+
output.warn(`⚠️ 记忆保存失败: ${err}`);
|
|
9710
|
+
}
|
|
9711
|
+
}
|
|
9712
|
+
if (lspManagerDispose) {
|
|
9713
|
+
try {
|
|
9714
|
+
await lspManagerDispose();
|
|
9715
|
+
} catch (err) {
|
|
9716
|
+
logger4.warn(`[Shutdown] LSP Manager dispose failed: ${err}`);
|
|
9717
|
+
}
|
|
9718
|
+
}
|
|
9719
|
+
if (pluginAdapterDispose) {
|
|
9720
|
+
try {
|
|
9721
|
+
await pluginAdapterDispose();
|
|
9722
|
+
} catch (err) {
|
|
9723
|
+
logger4.warn(`[Shutdown] PluginAdapter dispose failed: ${err}`);
|
|
9724
|
+
}
|
|
9725
|
+
}
|
|
9726
|
+
try {
|
|
9727
|
+
eventHandler.stop();
|
|
9728
|
+
} catch (err) {
|
|
9729
|
+
logger4.warn(`[Shutdown] EventHandler.stop failed: ${err}`);
|
|
9730
|
+
}
|
|
9731
|
+
try {
|
|
9732
|
+
queryExecutor.dispose();
|
|
9733
|
+
} catch (err) {
|
|
9734
|
+
logger4.warn(`[Shutdown] QueryExecutor.dispose failed: ${err}`);
|
|
9735
|
+
}
|
|
9736
|
+
try {
|
|
9737
|
+
const eventSourceComponent = env.getComponent("event-source");
|
|
9738
|
+
if (eventSourceComponent) {
|
|
9739
|
+
const sources = eventSourceComponent.list?.();
|
|
9740
|
+
if (sources && sources.length > 0) {
|
|
9741
|
+
for (const source of sources) {
|
|
9742
|
+
const status = eventSourceComponent.getStatus?.(source.id);
|
|
9743
|
+
logger4.debug(`[Shutdown] 检查事件源: ${source.id}, 状态: ${status}`);
|
|
9744
|
+
if (status !== "stopped" && status !== "created") {
|
|
9745
|
+
try {
|
|
9746
|
+
await eventSourceComponent.stopSource(source.id);
|
|
9747
|
+
output.info(`✓ 已停止事件源: ${source.name} (${status})`);
|
|
9748
|
+
} catch (error) {
|
|
9749
|
+
output.warn(`⚠️ 停止事件源 ${source.name} 失败: ${error}`);
|
|
9750
|
+
}
|
|
9751
|
+
}
|
|
9752
|
+
}
|
|
9753
|
+
}
|
|
9754
|
+
}
|
|
9755
|
+
} catch (err) {
|
|
9756
|
+
logger4.warn(`[Shutdown] EventSource cleanup failed: ${err}`);
|
|
9757
|
+
}
|
|
9758
|
+
if (shouldDisposeEnvService) {
|
|
9759
|
+
try {
|
|
9760
|
+
await envService.dispose();
|
|
9761
|
+
} catch (err) {
|
|
9762
|
+
logger4.warn(`[Shutdown] envService.dispose failed: ${err}`);
|
|
9763
|
+
}
|
|
9764
|
+
}
|
|
9765
|
+
try {
|
|
9766
|
+
await TempFileManager2.getInstance().cleanupAll();
|
|
9767
|
+
logger4.debug("[Shutdown] TempFileManager cleaned up");
|
|
9768
|
+
} catch (err) {
|
|
9769
|
+
logger4.warn(`[Shutdown] TempFileManager cleanup failed: ${err}`);
|
|
9770
|
+
}
|
|
9771
|
+
}
|
|
9772
|
+
|
|
9629
9773
|
// src/commands/interactive.ts
|
|
9630
9774
|
import { AskUserError } from "@ai-setting/roy-agent-core";
|
|
9631
9775
|
|
|
@@ -10441,43 +10585,20 @@ function createInteractiveCommand(externalEnvService) {
|
|
|
10441
10585
|
}
|
|
10442
10586
|
},
|
|
10443
10587
|
onShutdown: async () => {
|
|
10444
|
-
|
|
10445
|
-
|
|
10446
|
-
|
|
10447
|
-
|
|
10448
|
-
|
|
10449
|
-
|
|
10450
|
-
|
|
10451
|
-
|
|
10452
|
-
|
|
10453
|
-
|
|
10454
|
-
|
|
10455
|
-
|
|
10456
|
-
|
|
10457
|
-
}
|
|
10458
|
-
eventHandler.stop();
|
|
10459
|
-
queryExecutor.dispose();
|
|
10460
|
-
const eventSourceComponent = env.getComponent("event-source");
|
|
10461
|
-
if (eventSourceComponent) {
|
|
10462
|
-
const sources = eventSourceComponent.list?.();
|
|
10463
|
-
if (sources && sources.length > 0) {
|
|
10464
|
-
for (const source of sources) {
|
|
10465
|
-
const status = eventSourceComponent.getStatus?.(source.id);
|
|
10466
|
-
logger4.debug(`[Shutdown] 检查事件源: ${source.id}, 状态: ${status}`);
|
|
10467
|
-
if (status !== "stopped" && status !== "created") {
|
|
10468
|
-
try {
|
|
10469
|
-
await eventSourceComponent.stopSource(source.id);
|
|
10470
|
-
output.info(`✓ 已停止事件源: ${source.name} (${status})`);
|
|
10471
|
-
} catch (error) {
|
|
10472
|
-
output.warn(`⚠️ 停止事件源 ${source.name} 失败: ${error}`);
|
|
10473
|
-
}
|
|
10474
|
-
}
|
|
10475
|
-
}
|
|
10476
|
-
}
|
|
10477
|
-
}
|
|
10478
|
-
if (shouldDisposeEnvService) {
|
|
10479
|
-
await envService.dispose();
|
|
10480
|
-
}
|
|
10588
|
+
await shutdownInteractiveSteps({
|
|
10589
|
+
memoryPluginDispose,
|
|
10590
|
+
memoryPluginInstance,
|
|
10591
|
+
lspManagerDispose,
|
|
10592
|
+
pluginAdapterDispose,
|
|
10593
|
+
eventHandler,
|
|
10594
|
+
queryExecutor,
|
|
10595
|
+
env,
|
|
10596
|
+
envService,
|
|
10597
|
+
shouldDisposeEnvService,
|
|
10598
|
+
output,
|
|
10599
|
+
logger: logger4,
|
|
10600
|
+
console
|
|
10601
|
+
});
|
|
10481
10602
|
}
|
|
10482
10603
|
}, env);
|
|
10483
10604
|
const eventHandler = new EventHandler({
|
|
@@ -18987,16 +19108,20 @@ var runWorkflow = wrapFunction(async function runWorkflowImpl(args) {
|
|
|
18987
19108
|
try {
|
|
18988
19109
|
input = JSON.parse(args.input);
|
|
18989
19110
|
} catch {
|
|
18990
|
-
input = args.
|
|
19111
|
+
input = args.session ? args.input : undefined;
|
|
18991
19112
|
}
|
|
18992
19113
|
}
|
|
19114
|
+
if (args.session && !args.session.startsWith("workflow_")) {
|
|
19115
|
+
output.error(`Invalid session ID: must start with 'workflow_' (got: ${args.session})`);
|
|
19116
|
+
process.exit(1);
|
|
19117
|
+
}
|
|
18993
19118
|
const runOptions = {
|
|
18994
19119
|
debug: args.debug,
|
|
18995
19120
|
parallelLimit: args.parallelLimit,
|
|
18996
19121
|
timeout: args.timeout
|
|
18997
19122
|
};
|
|
18998
|
-
if (args.
|
|
18999
|
-
const sessionId = args.
|
|
19123
|
+
if (args.session) {
|
|
19124
|
+
const sessionId = args.session;
|
|
19000
19125
|
output.log(chalk68.blue(`\uD83D\uDD04 Resuming workflow from session: ${sessionId}`));
|
|
19001
19126
|
const sessionComponent = workflowComponent.sessionComponent;
|
|
19002
19127
|
if (!sessionComponent) {
|
|
@@ -19080,7 +19205,7 @@ var runWorkflow = wrapFunction(async function runWorkflowImpl(args) {
|
|
|
19080
19205
|
}));
|
|
19081
19206
|
if (result.status === "paused") {
|
|
19082
19207
|
output.log(chalk68.gray(`
|
|
19083
|
-
\uD83D\uDCA1 Use "roy-agent workflow run ${result.runId} --session
|
|
19208
|
+
\uD83D\uDCA1 Use "roy-agent workflow run ${result.runId} --session ${result.runId} --input '<response>'" to resume`));
|
|
19084
19209
|
}
|
|
19085
19210
|
} else {
|
|
19086
19211
|
const tool = createRunWorkflowTool(service);
|
|
@@ -19103,7 +19228,7 @@ var runWorkflow = wrapFunction(async function runWorkflowImpl(args) {
|
|
|
19103
19228
|
}));
|
|
19104
19229
|
if (runData.status === "paused") {
|
|
19105
19230
|
output.log(chalk68.gray(`
|
|
19106
|
-
\uD83D\uDCA1 Use "roy-agent workflow run ${runData.run_id} --session
|
|
19231
|
+
\uD83D\uDCA1 Use "roy-agent workflow run ${runData.run_id} --session ${runData.run_id} --input '<response>'" to resume`));
|
|
19107
19232
|
}
|
|
19108
19233
|
}
|
|
19109
19234
|
if (workflowSpan) {
|
|
@@ -19165,9 +19290,9 @@ var WorkflowRunCommand = {
|
|
|
19165
19290
|
}).option("config", {
|
|
19166
19291
|
describe: "配置文件路径",
|
|
19167
19292
|
type: "string"
|
|
19168
|
-
}).option("session
|
|
19293
|
+
}).option("session", {
|
|
19169
19294
|
alias: "s",
|
|
19170
|
-
describe: "从已有 session 恢复运行(支持 workflow pause/interrupt
|
|
19295
|
+
describe: "从已有 session 恢复运行(支持 workflow pause/interrupt 恢复,session ID 必须以 workflow_ 开头)",
|
|
19171
19296
|
type: "string"
|
|
19172
19297
|
}),
|
|
19173
19298
|
handler: runWorkflow
|
package/dist/index.js
CHANGED
|
@@ -7426,7 +7426,7 @@ var require_dist = __commonJS((exports) => {
|
|
|
7426
7426
|
var require_package = __commonJS((exports, module) => {
|
|
7427
7427
|
module.exports = {
|
|
7428
7428
|
name: "@ai-setting/roy-agent-cli",
|
|
7429
|
-
version: "1.5.
|
|
7429
|
+
version: "1.5.96",
|
|
7430
7430
|
type: "module",
|
|
7431
7431
|
description: "CLI for roy-agent - Non-interactive command execution",
|
|
7432
7432
|
main: "./dist/index.js",
|
|
@@ -8493,6 +8493,63 @@ function assembleMultimodalMessage(text, imageArgs) {
|
|
|
8493
8493
|
return imageParts;
|
|
8494
8494
|
}
|
|
8495
8495
|
|
|
8496
|
+
// src/commands/act-shutdown.ts
|
|
8497
|
+
import { TempFileManager } from "@ai-setting/roy-agent-core/utils/temp-file-manager";
|
|
8498
|
+
async function runActShutdownCleanup(deps) {
|
|
8499
|
+
const {
|
|
8500
|
+
stopTaskEventHandlerCleanup: stopTaskEventHandlerCleanupFn,
|
|
8501
|
+
lspManagerDispose,
|
|
8502
|
+
pluginAdapterDispose,
|
|
8503
|
+
envService,
|
|
8504
|
+
shouldDisposeEnvService,
|
|
8505
|
+
output,
|
|
8506
|
+
logger: logger4
|
|
8507
|
+
} = deps;
|
|
8508
|
+
const log = logger4 ?? {
|
|
8509
|
+
debug: () => {},
|
|
8510
|
+
warn: (msg) => console.warn(msg)
|
|
8511
|
+
};
|
|
8512
|
+
try {
|
|
8513
|
+
if (typeof stopTaskEventHandlerCleanupFn === "function") {
|
|
8514
|
+
stopTaskEventHandlerCleanupFn();
|
|
8515
|
+
}
|
|
8516
|
+
} catch (err) {
|
|
8517
|
+
log.warn(`[Act-Shutdown] Task Event Handler stop failed: ${err}`);
|
|
8518
|
+
}
|
|
8519
|
+
if (lspManagerDispose) {
|
|
8520
|
+
try {
|
|
8521
|
+
await lspManagerDispose();
|
|
8522
|
+
} catch (err) {
|
|
8523
|
+
log.warn(`[Act-Shutdown] LSP Manager dispose failed: ${err}`);
|
|
8524
|
+
}
|
|
8525
|
+
}
|
|
8526
|
+
if (pluginAdapterDispose) {
|
|
8527
|
+
try {
|
|
8528
|
+
await pluginAdapterDispose();
|
|
8529
|
+
} catch (err) {
|
|
8530
|
+
log.warn(`[Act-Shutdown] PluginAdapter dispose failed: ${err}`);
|
|
8531
|
+
}
|
|
8532
|
+
}
|
|
8533
|
+
if (shouldDisposeEnvService) {
|
|
8534
|
+
try {
|
|
8535
|
+
await envService.dispose();
|
|
8536
|
+
} catch (err) {
|
|
8537
|
+
log.warn(`[Act-Shutdown] envService.dispose failed: ${err}`);
|
|
8538
|
+
}
|
|
8539
|
+
}
|
|
8540
|
+
try {
|
|
8541
|
+
await TempFileManager.getInstance().cleanupAll();
|
|
8542
|
+
log.debug?.("[Act-Shutdown] TempFileManager cleaned up");
|
|
8543
|
+
} catch (err) {
|
|
8544
|
+
log.warn(`[Act-Shutdown] TempFileManager cleanup failed: ${err}`);
|
|
8545
|
+
if (output)
|
|
8546
|
+
output.warn(`⚠ TempFileManager cleanup failed: ${err}`);
|
|
8547
|
+
}
|
|
8548
|
+
if (shouldDisposeEnvService && typeof process !== "undefined" && process.env.ROY_AGENT_NO_EXIT !== "1") {
|
|
8549
|
+
process.exit(0);
|
|
8550
|
+
}
|
|
8551
|
+
}
|
|
8552
|
+
|
|
8496
8553
|
// src/commands/act.ts
|
|
8497
8554
|
function createActCommand(externalEnvService) {
|
|
8498
8555
|
return {
|
|
@@ -8568,6 +8625,7 @@ function createActCommand(externalEnvService) {
|
|
|
8568
8625
|
const envService = externalEnvService ?? new EnvironmentService(output);
|
|
8569
8626
|
let pluginAdapterDispose = null;
|
|
8570
8627
|
let lspManagerDispose = null;
|
|
8628
|
+
let stopTaskEventHandlerCleanup = null;
|
|
8571
8629
|
const rawPlugins = args.plugin;
|
|
8572
8630
|
const pluginNames = Array.isArray(rawPlugins) ? rawPlugins : rawPlugins ? [rawPlugins] : [];
|
|
8573
8631
|
const CODER_HARNESS_PLUGINS = new Set([
|
|
@@ -8625,7 +8683,7 @@ function createActCommand(externalEnvService) {
|
|
|
8625
8683
|
env,
|
|
8626
8684
|
enabled: true
|
|
8627
8685
|
});
|
|
8628
|
-
|
|
8686
|
+
stopTaskEventHandlerCleanup = taskEventHandlerForCleanup.start();
|
|
8629
8687
|
let sessionId = args.session;
|
|
8630
8688
|
if (args.continue && !sessionId) {
|
|
8631
8689
|
const activeSession = await sessionComponent.getActiveSession();
|
|
@@ -8825,21 +8883,15 @@ function createActCommand(externalEnvService) {
|
|
|
8825
8883
|
}
|
|
8826
8884
|
process.exit(1);
|
|
8827
8885
|
} finally {
|
|
8828
|
-
|
|
8829
|
-
stopTaskEventHandlerCleanup
|
|
8830
|
-
|
|
8831
|
-
|
|
8832
|
-
|
|
8833
|
-
|
|
8834
|
-
|
|
8835
|
-
|
|
8836
|
-
}
|
|
8837
|
-
if (shouldDisposeEnvService) {
|
|
8838
|
-
await envService.dispose();
|
|
8839
|
-
if (process.env.ROY_AGENT_NO_EXIT !== "1") {
|
|
8840
|
-
process.exit(0);
|
|
8841
|
-
}
|
|
8842
|
-
}
|
|
8886
|
+
await runActShutdownCleanup({
|
|
8887
|
+
stopTaskEventHandlerCleanup,
|
|
8888
|
+
lspManagerDispose,
|
|
8889
|
+
pluginAdapterDispose,
|
|
8890
|
+
envService,
|
|
8891
|
+
shouldDisposeEnvService,
|
|
8892
|
+
output,
|
|
8893
|
+
logger: { debug: () => {}, warn: console.warn }
|
|
8894
|
+
});
|
|
8843
8895
|
}
|
|
8844
8896
|
}
|
|
8845
8897
|
};
|
|
@@ -9625,6 +9677,98 @@ function parseUserInput(input, options) {
|
|
|
9625
9677
|
return { type: "text", value: trimmedInput };
|
|
9626
9678
|
}
|
|
9627
9679
|
|
|
9680
|
+
// src/commands/interactive-shutdown.ts
|
|
9681
|
+
import { TempFileManager as TempFileManager2 } from "@ai-setting/roy-agent-core/utils/temp-file-manager";
|
|
9682
|
+
async function shutdownInteractiveSteps(deps) {
|
|
9683
|
+
const {
|
|
9684
|
+
memoryPluginDispose,
|
|
9685
|
+
memoryPluginInstance,
|
|
9686
|
+
lspManagerDispose,
|
|
9687
|
+
pluginAdapterDispose,
|
|
9688
|
+
eventHandler,
|
|
9689
|
+
queryExecutor,
|
|
9690
|
+
env,
|
|
9691
|
+
envService,
|
|
9692
|
+
shouldDisposeEnvService,
|
|
9693
|
+
output,
|
|
9694
|
+
logger: logger4,
|
|
9695
|
+
console: consoleLike
|
|
9696
|
+
} = deps;
|
|
9697
|
+
const log = (msg) => consoleLike?.log?.(msg) ?? console.log(msg);
|
|
9698
|
+
if (memoryPluginDispose) {
|
|
9699
|
+
try {
|
|
9700
|
+
if (memoryPluginInstance?.hasPendingTasks?.()) {
|
|
9701
|
+
log("\uD83D\uDCBE 正在保存记忆,请稍候...");
|
|
9702
|
+
await memoryPluginInstance.waitForCompletion?.();
|
|
9703
|
+
}
|
|
9704
|
+
await memoryPluginDispose();
|
|
9705
|
+
log("\uD83D\uDCBE 记忆已保存完毕");
|
|
9706
|
+
} catch (err) {
|
|
9707
|
+
logger4.warn(`[Shutdown] MemoryPlugin dispose failed: ${err}`);
|
|
9708
|
+
output.warn(`⚠️ 记忆保存失败: ${err}`);
|
|
9709
|
+
}
|
|
9710
|
+
}
|
|
9711
|
+
if (lspManagerDispose) {
|
|
9712
|
+
try {
|
|
9713
|
+
await lspManagerDispose();
|
|
9714
|
+
} catch (err) {
|
|
9715
|
+
logger4.warn(`[Shutdown] LSP Manager dispose failed: ${err}`);
|
|
9716
|
+
}
|
|
9717
|
+
}
|
|
9718
|
+
if (pluginAdapterDispose) {
|
|
9719
|
+
try {
|
|
9720
|
+
await pluginAdapterDispose();
|
|
9721
|
+
} catch (err) {
|
|
9722
|
+
logger4.warn(`[Shutdown] PluginAdapter dispose failed: ${err}`);
|
|
9723
|
+
}
|
|
9724
|
+
}
|
|
9725
|
+
try {
|
|
9726
|
+
eventHandler.stop();
|
|
9727
|
+
} catch (err) {
|
|
9728
|
+
logger4.warn(`[Shutdown] EventHandler.stop failed: ${err}`);
|
|
9729
|
+
}
|
|
9730
|
+
try {
|
|
9731
|
+
queryExecutor.dispose();
|
|
9732
|
+
} catch (err) {
|
|
9733
|
+
logger4.warn(`[Shutdown] QueryExecutor.dispose failed: ${err}`);
|
|
9734
|
+
}
|
|
9735
|
+
try {
|
|
9736
|
+
const eventSourceComponent = env.getComponent("event-source");
|
|
9737
|
+
if (eventSourceComponent) {
|
|
9738
|
+
const sources = eventSourceComponent.list?.();
|
|
9739
|
+
if (sources && sources.length > 0) {
|
|
9740
|
+
for (const source of sources) {
|
|
9741
|
+
const status = eventSourceComponent.getStatus?.(source.id);
|
|
9742
|
+
logger4.debug(`[Shutdown] 检查事件源: ${source.id}, 状态: ${status}`);
|
|
9743
|
+
if (status !== "stopped" && status !== "created") {
|
|
9744
|
+
try {
|
|
9745
|
+
await eventSourceComponent.stopSource(source.id);
|
|
9746
|
+
output.info(`✓ 已停止事件源: ${source.name} (${status})`);
|
|
9747
|
+
} catch (error) {
|
|
9748
|
+
output.warn(`⚠️ 停止事件源 ${source.name} 失败: ${error}`);
|
|
9749
|
+
}
|
|
9750
|
+
}
|
|
9751
|
+
}
|
|
9752
|
+
}
|
|
9753
|
+
}
|
|
9754
|
+
} catch (err) {
|
|
9755
|
+
logger4.warn(`[Shutdown] EventSource cleanup failed: ${err}`);
|
|
9756
|
+
}
|
|
9757
|
+
if (shouldDisposeEnvService) {
|
|
9758
|
+
try {
|
|
9759
|
+
await envService.dispose();
|
|
9760
|
+
} catch (err) {
|
|
9761
|
+
logger4.warn(`[Shutdown] envService.dispose failed: ${err}`);
|
|
9762
|
+
}
|
|
9763
|
+
}
|
|
9764
|
+
try {
|
|
9765
|
+
await TempFileManager2.getInstance().cleanupAll();
|
|
9766
|
+
logger4.debug("[Shutdown] TempFileManager cleaned up");
|
|
9767
|
+
} catch (err) {
|
|
9768
|
+
logger4.warn(`[Shutdown] TempFileManager cleanup failed: ${err}`);
|
|
9769
|
+
}
|
|
9770
|
+
}
|
|
9771
|
+
|
|
9628
9772
|
// src/commands/interactive.ts
|
|
9629
9773
|
import { AskUserError } from "@ai-setting/roy-agent-core";
|
|
9630
9774
|
|
|
@@ -10440,43 +10584,20 @@ function createInteractiveCommand(externalEnvService) {
|
|
|
10440
10584
|
}
|
|
10441
10585
|
},
|
|
10442
10586
|
onShutdown: async () => {
|
|
10443
|
-
|
|
10444
|
-
|
|
10445
|
-
|
|
10446
|
-
|
|
10447
|
-
|
|
10448
|
-
|
|
10449
|
-
|
|
10450
|
-
|
|
10451
|
-
|
|
10452
|
-
|
|
10453
|
-
|
|
10454
|
-
|
|
10455
|
-
|
|
10456
|
-
}
|
|
10457
|
-
eventHandler.stop();
|
|
10458
|
-
queryExecutor.dispose();
|
|
10459
|
-
const eventSourceComponent = env.getComponent("event-source");
|
|
10460
|
-
if (eventSourceComponent) {
|
|
10461
|
-
const sources = eventSourceComponent.list?.();
|
|
10462
|
-
if (sources && sources.length > 0) {
|
|
10463
|
-
for (const source of sources) {
|
|
10464
|
-
const status = eventSourceComponent.getStatus?.(source.id);
|
|
10465
|
-
logger4.debug(`[Shutdown] 检查事件源: ${source.id}, 状态: ${status}`);
|
|
10466
|
-
if (status !== "stopped" && status !== "created") {
|
|
10467
|
-
try {
|
|
10468
|
-
await eventSourceComponent.stopSource(source.id);
|
|
10469
|
-
output.info(`✓ 已停止事件源: ${source.name} (${status})`);
|
|
10470
|
-
} catch (error) {
|
|
10471
|
-
output.warn(`⚠️ 停止事件源 ${source.name} 失败: ${error}`);
|
|
10472
|
-
}
|
|
10473
|
-
}
|
|
10474
|
-
}
|
|
10475
|
-
}
|
|
10476
|
-
}
|
|
10477
|
-
if (shouldDisposeEnvService) {
|
|
10478
|
-
await envService.dispose();
|
|
10479
|
-
}
|
|
10587
|
+
await shutdownInteractiveSteps({
|
|
10588
|
+
memoryPluginDispose,
|
|
10589
|
+
memoryPluginInstance,
|
|
10590
|
+
lspManagerDispose,
|
|
10591
|
+
pluginAdapterDispose,
|
|
10592
|
+
eventHandler,
|
|
10593
|
+
queryExecutor,
|
|
10594
|
+
env,
|
|
10595
|
+
envService,
|
|
10596
|
+
shouldDisposeEnvService,
|
|
10597
|
+
output,
|
|
10598
|
+
logger: logger4,
|
|
10599
|
+
console
|
|
10600
|
+
});
|
|
10480
10601
|
}
|
|
10481
10602
|
}, env);
|
|
10482
10603
|
const eventHandler = new EventHandler({
|
|
@@ -18986,16 +19107,20 @@ var runWorkflow = wrapFunction(async function runWorkflowImpl(args) {
|
|
|
18986
19107
|
try {
|
|
18987
19108
|
input = JSON.parse(args.input);
|
|
18988
19109
|
} catch {
|
|
18989
|
-
input = args.
|
|
19110
|
+
input = args.session ? args.input : undefined;
|
|
18990
19111
|
}
|
|
18991
19112
|
}
|
|
19113
|
+
if (args.session && !args.session.startsWith("workflow_")) {
|
|
19114
|
+
output.error(`Invalid session ID: must start with 'workflow_' (got: ${args.session})`);
|
|
19115
|
+
process.exit(1);
|
|
19116
|
+
}
|
|
18992
19117
|
const runOptions = {
|
|
18993
19118
|
debug: args.debug,
|
|
18994
19119
|
parallelLimit: args.parallelLimit,
|
|
18995
19120
|
timeout: args.timeout
|
|
18996
19121
|
};
|
|
18997
|
-
if (args.
|
|
18998
|
-
const sessionId = args.
|
|
19122
|
+
if (args.session) {
|
|
19123
|
+
const sessionId = args.session;
|
|
18999
19124
|
output.log(chalk68.blue(`\uD83D\uDD04 Resuming workflow from session: ${sessionId}`));
|
|
19000
19125
|
const sessionComponent = workflowComponent.sessionComponent;
|
|
19001
19126
|
if (!sessionComponent) {
|
|
@@ -19079,7 +19204,7 @@ var runWorkflow = wrapFunction(async function runWorkflowImpl(args) {
|
|
|
19079
19204
|
}));
|
|
19080
19205
|
if (result.status === "paused") {
|
|
19081
19206
|
output.log(chalk68.gray(`
|
|
19082
|
-
\uD83D\uDCA1 Use "roy-agent workflow run ${result.runId} --session
|
|
19207
|
+
\uD83D\uDCA1 Use "roy-agent workflow run ${result.runId} --session ${result.runId} --input '<response>'" to resume`));
|
|
19083
19208
|
}
|
|
19084
19209
|
} else {
|
|
19085
19210
|
const tool = createRunWorkflowTool(service);
|
|
@@ -19102,7 +19227,7 @@ var runWorkflow = wrapFunction(async function runWorkflowImpl(args) {
|
|
|
19102
19227
|
}));
|
|
19103
19228
|
if (runData.status === "paused") {
|
|
19104
19229
|
output.log(chalk68.gray(`
|
|
19105
|
-
\uD83D\uDCA1 Use "roy-agent workflow run ${runData.run_id} --session
|
|
19230
|
+
\uD83D\uDCA1 Use "roy-agent workflow run ${runData.run_id} --session ${runData.run_id} --input '<response>'" to resume`));
|
|
19106
19231
|
}
|
|
19107
19232
|
}
|
|
19108
19233
|
if (workflowSpan) {
|
|
@@ -19164,9 +19289,9 @@ var WorkflowRunCommand = {
|
|
|
19164
19289
|
}).option("config", {
|
|
19165
19290
|
describe: "配置文件路径",
|
|
19166
19291
|
type: "string"
|
|
19167
|
-
}).option("session
|
|
19292
|
+
}).option("session", {
|
|
19168
19293
|
alias: "s",
|
|
19169
|
-
describe: "从已有 session 恢复运行(支持 workflow pause/interrupt
|
|
19294
|
+
describe: "从已有 session 恢复运行(支持 workflow pause/interrupt 恢复,session ID 必须以 workflow_ 开头)",
|
|
19170
19295
|
type: "string"
|
|
19171
19296
|
}),
|
|
19172
19297
|
handler: runWorkflow
|
|
Binary file
|