iosm-cli 0.2.13 → 0.2.15
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/.npmignore +2 -0
- package/CHANGELOG.md +49 -0
- package/README.md +12 -2
- package/dist/cli/args.d.ts +1 -1
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +9 -2
- package/dist/cli/args.js.map +1 -1
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +17 -2
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/command-dispatcher.d.ts +16 -0
- package/dist/core/command-dispatcher.d.ts.map +1 -0
- package/dist/core/command-dispatcher.js +678 -0
- package/dist/core/command-dispatcher.js.map +1 -0
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +13 -1
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver.d.ts +2 -2
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +1 -2
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/provider-policy.d.ts +7 -0
- package/dist/core/provider-policy.d.ts.map +1 -0
- package/dist/core/provider-policy.js +19 -0
- package/dist/core/provider-policy.js.map +1 -0
- package/dist/core/settings-manager.d.ts +25 -0
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +32 -0
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +4 -1
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/subagent-background-runs.d.ts +56 -0
- package/dist/core/subagent-background-runs.d.ts.map +1 -0
- package/dist/core/subagent-background-runs.js +275 -0
- package/dist/core/subagent-background-runs.js.map +1 -0
- package/dist/core/tools/task.d.ts.map +1 -1
- package/dist/core/tools/task.js +39 -35
- package/dist/core/tools/task.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +16 -2
- package/dist/main.js.map +1 -1
- package/dist/modes/index.d.ts +1 -0
- package/dist/modes/index.d.ts.map +1 -1
- package/dist/modes/index.js +1 -0
- package/dist/modes/index.js.map +1 -1
- package/dist/modes/interactive/components/login-dialog.d.ts +1 -1
- package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
- package/dist/modes/interactive/components/login-dialog.js +1 -4
- package/dist/modes/interactive/components/login-dialog.js.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.js +1 -2
- package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +7 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +253 -10
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts +11 -1
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +54 -0
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +87 -3
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +69 -0
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/modes/telegram/telegram-bridge-mode.d.ts +15 -0
- package/dist/modes/telegram/telegram-bridge-mode.d.ts.map +1 -0
- package/dist/modes/telegram/telegram-bridge-mode.js +2164 -0
- package/dist/modes/telegram/telegram-bridge-mode.js.map +1 -0
- package/docs/cli-reference.md +10 -1
- package/docs/configuration.md +21 -0
- package/docs/rpc-json-sdk.md +23 -0
- package/examples/extensions/README.md +1 -2
- package/package.json +4 -3
- package/examples/extensions/antigravity-image-gen.ts +0 -415
|
@@ -20,6 +20,7 @@ import { loadModelsDevProviderCatalog, } from "../../core/models-dev-provider-ca
|
|
|
20
20
|
import { ModelRegistry } from "../../core/model-registry.js";
|
|
21
21
|
import { MODELS_DEV_PROVIDERS } from "../../core/models-dev-providers.js";
|
|
22
22
|
import { loadOpenRouterProviderConfig } from "../../core/openrouter-model-catalog.js";
|
|
23
|
+
import { isProviderAllowed } from "../../core/provider-policy.js";
|
|
23
24
|
import { resolveModelScope } from "../../core/model-resolver.js";
|
|
24
25
|
import { getMcpCommandHelp, parseMcpAddCommand, parseMcpTargetCommand, } from "../../core/mcp/index.js";
|
|
25
26
|
import { addMemoryEntry, getMemoryFilePath, readMemoryEntries, removeMemoryEntry, updateMemoryEntry, } from "../../core/memory.js";
|
|
@@ -36,6 +37,7 @@ import { buildSwarmPlanFromSingular, buildSwarmPlanFromTask, runSwarmScheduler,
|
|
|
36
37
|
import { loadCustomSubagents, resolveCustomSubagentReference, } from "../../core/subagents.js";
|
|
37
38
|
import { getSubagentRun, listSubagentRuns } from "../../core/subagent-runs.js";
|
|
38
39
|
import { getBackgroundProcess, listBackgroundProcesses, pruneBackgroundProcesses, readBackgroundProcessLogTail, stopBackgroundProcess, } from "../../core/background-processes.js";
|
|
40
|
+
import { getSubagentBackgroundRun, listSubagentBackgroundRuns, pruneSubagentBackgroundRuns, readSubagentBackgroundRunLogTail, requestStopAllSubagentBackgroundRuns, requestStopSubagentBackgroundRun, } from "../../core/subagent-background-runs.js";
|
|
39
41
|
import { SessionManager } from "../../core/session-manager.js";
|
|
40
42
|
import { SettingsManager } from "../../core/settings-manager.js";
|
|
41
43
|
import { BUILTIN_SLASH_COMMANDS } from "../../core/slash-commands.js";
|
|
@@ -800,7 +802,6 @@ function resolveDoctorCliToolStatuses() {
|
|
|
800
802
|
const OPENROUTER_PROVIDER_ID = "openrouter";
|
|
801
803
|
const PROVIDER_DISPLAY_NAME_OVERRIDES = {
|
|
802
804
|
"azure-openai-responses": "Azure OpenAI Responses",
|
|
803
|
-
"google-antigravity": "Google Antigravity",
|
|
804
805
|
"google-gemini-cli": "Google Gemini CLI",
|
|
805
806
|
"kimi-coding": "Kimi Coding",
|
|
806
807
|
"openai-codex": "OpenAI Codex",
|
|
@@ -998,8 +999,8 @@ export class InteractiveMode {
|
|
|
998
999
|
this.asciiLogo = undefined;
|
|
999
1000
|
// API-key provider labels cached for /login and status messages.
|
|
1000
1001
|
this.apiKeyProviderDisplayNames = new Map();
|
|
1001
|
-
this.modelsDevProviderCatalog = MODELS_DEV_PROVIDERS;
|
|
1002
|
-
this.modelsDevProviderCatalogById = new Map(MODELS_DEV_PROVIDERS.map((provider) => [
|
|
1002
|
+
this.modelsDevProviderCatalog = MODELS_DEV_PROVIDERS.filter((provider) => isProviderAllowed(provider.id));
|
|
1003
|
+
this.modelsDevProviderCatalogById = new Map(MODELS_DEV_PROVIDERS.filter((provider) => isProviderAllowed(provider.id)).map((provider) => [
|
|
1003
1004
|
provider.id,
|
|
1004
1005
|
{
|
|
1005
1006
|
...provider,
|
|
@@ -6431,8 +6432,8 @@ export class InteractiveMode {
|
|
|
6431
6432
|
}
|
|
6432
6433
|
this.modelsDevProviderCatalogRefreshPromise = (async () => {
|
|
6433
6434
|
const catalog = await loadModelsDevProviderCatalog();
|
|
6434
|
-
this.modelsDevProviderCatalogById = catalog;
|
|
6435
|
-
this.modelsDevProviderCatalog = Array.from(
|
|
6435
|
+
this.modelsDevProviderCatalogById = new Map(Array.from(catalog.entries()).filter(([providerId]) => isProviderAllowed(providerId)));
|
|
6436
|
+
this.modelsDevProviderCatalog = Array.from(this.modelsDevProviderCatalogById.values())
|
|
6436
6437
|
.map((provider) => ({
|
|
6437
6438
|
id: provider.id,
|
|
6438
6439
|
name: provider.name,
|
|
@@ -6441,8 +6442,8 @@ export class InteractiveMode {
|
|
|
6441
6442
|
.sort((a, b) => a.name.localeCompare(b.name, "en") || a.id.localeCompare(b.id, "en"));
|
|
6442
6443
|
})()
|
|
6443
6444
|
.catch(() => {
|
|
6444
|
-
this.modelsDevProviderCatalog = MODELS_DEV_PROVIDERS;
|
|
6445
|
-
this.modelsDevProviderCatalogById = new Map(MODELS_DEV_PROVIDERS.map((provider) => [
|
|
6445
|
+
this.modelsDevProviderCatalog = MODELS_DEV_PROVIDERS.filter((provider) => isProviderAllowed(provider.id));
|
|
6446
|
+
this.modelsDevProviderCatalogById = new Map(MODELS_DEV_PROVIDERS.filter((provider) => isProviderAllowed(provider.id)).map((provider) => [
|
|
6446
6447
|
provider.id,
|
|
6447
6448
|
{
|
|
6448
6449
|
...provider,
|
|
@@ -6613,11 +6614,15 @@ export class InteractiveMode {
|
|
|
6613
6614
|
const providerNames = new Map();
|
|
6614
6615
|
this.apiKeyProviderDisplayNames.clear();
|
|
6615
6616
|
for (const model of this.session.modelRegistry.getAll()) {
|
|
6617
|
+
if (!isProviderAllowed(model.provider))
|
|
6618
|
+
continue;
|
|
6616
6619
|
if (!providerNames.has(model.provider)) {
|
|
6617
6620
|
providerNames.set(model.provider, toProviderDisplayName(model.provider));
|
|
6618
6621
|
}
|
|
6619
6622
|
}
|
|
6620
6623
|
for (const provider of modelsDevProviders) {
|
|
6624
|
+
if (!isProviderAllowed(provider.id))
|
|
6625
|
+
continue;
|
|
6621
6626
|
const fallbackName = toProviderDisplayName(provider.id);
|
|
6622
6627
|
const current = providerNames.get(provider.id);
|
|
6623
6628
|
if (!current || current === fallbackName) {
|
|
@@ -6625,6 +6630,8 @@ export class InteractiveMode {
|
|
|
6625
6630
|
}
|
|
6626
6631
|
}
|
|
6627
6632
|
for (const providerId of this.session.modelRegistry.authStorage.list()) {
|
|
6633
|
+
if (!isProviderAllowed(providerId))
|
|
6634
|
+
continue;
|
|
6628
6635
|
if (!providerNames.has(providerId)) {
|
|
6629
6636
|
providerNames.set(providerId, toProviderDisplayName(providerId));
|
|
6630
6637
|
}
|
|
@@ -6701,7 +6708,7 @@ export class InteractiveMode {
|
|
|
6701
6708
|
// Providers that use callback servers (can paste redirect URL)
|
|
6702
6709
|
const usesCallbackServer = providerInfo?.usesCallbackServer ?? false;
|
|
6703
6710
|
// Create login dialog component
|
|
6704
|
-
const dialog = new LoginDialogComponent(this.ui,
|
|
6711
|
+
const dialog = new LoginDialogComponent(this.ui, providerName, (_success, _message) => {
|
|
6705
6712
|
// Completion handled below
|
|
6706
6713
|
});
|
|
6707
6714
|
// Show dialog in editor container
|
|
@@ -12417,15 +12424,251 @@ export class InteractiveMode {
|
|
|
12417
12424
|
this.ui.requestRender();
|
|
12418
12425
|
}
|
|
12419
12426
|
}
|
|
12427
|
+
getSubagentBackgroundUsage() {
|
|
12428
|
+
return "/subagent-runs bg [list|running|queued|done|error|cancelled] [limit: 1..200] | /subagent-runs bg status <id> | /subagent-runs bg logs <id> [lines: 1..1000] | /subagent-runs bg stop <id> | /subagent-runs bg stop-all | /subagent-runs bg prune [hours: 1..2160]";
|
|
12429
|
+
}
|
|
12430
|
+
getSubagentBackgroundStatusWeight(status) {
|
|
12431
|
+
switch (status) {
|
|
12432
|
+
case "running":
|
|
12433
|
+
return 0;
|
|
12434
|
+
case "queued":
|
|
12435
|
+
return 1;
|
|
12436
|
+
case "error":
|
|
12437
|
+
return 2;
|
|
12438
|
+
case "cancelled":
|
|
12439
|
+
return 3;
|
|
12440
|
+
case "done":
|
|
12441
|
+
return 4;
|
|
12442
|
+
default:
|
|
12443
|
+
return 5;
|
|
12444
|
+
}
|
|
12445
|
+
}
|
|
12446
|
+
formatSubagentBackgroundStatusLabel(status) {
|
|
12447
|
+
switch (status) {
|
|
12448
|
+
case "running":
|
|
12449
|
+
return "RUNNING";
|
|
12450
|
+
case "queued":
|
|
12451
|
+
return "QUEUED";
|
|
12452
|
+
case "done":
|
|
12453
|
+
return "DONE";
|
|
12454
|
+
case "error":
|
|
12455
|
+
return "ERROR";
|
|
12456
|
+
case "cancelled":
|
|
12457
|
+
return "CANCELLED";
|
|
12458
|
+
default:
|
|
12459
|
+
return "UNKNOWN";
|
|
12460
|
+
}
|
|
12461
|
+
}
|
|
12462
|
+
sortSubagentBackgroundRecords(records) {
|
|
12463
|
+
return [...records].sort((left, right) => {
|
|
12464
|
+
const byStatus = this.getSubagentBackgroundStatusWeight(left.status) - this.getSubagentBackgroundStatusWeight(right.status);
|
|
12465
|
+
if (byStatus !== 0)
|
|
12466
|
+
return byStatus;
|
|
12467
|
+
return right.createdAt.localeCompare(left.createdAt);
|
|
12468
|
+
});
|
|
12469
|
+
}
|
|
12470
|
+
formatSubagentBackgroundOptionLabel(record, index) {
|
|
12471
|
+
const statusLabel = this.formatSubagentBackgroundStatusLabel(record.status);
|
|
12472
|
+
const age = this.formatRelativeTime(record.createdAt);
|
|
12473
|
+
const runtime = this.formatDurationMs(record.startedAt, record.finishedAt);
|
|
12474
|
+
const profile = record.profile || "-";
|
|
12475
|
+
const agent = record.agent?.trim() ? record.agent : "-";
|
|
12476
|
+
const stopFlag = record.requestedStopAt ? " · stop requested" : "";
|
|
12477
|
+
const description = record.description.length > 80 ? `${record.description.slice(0, 77)}...` : record.description;
|
|
12478
|
+
return `${index + 1}. [${statusLabel}] ${record.runId} · profile=${profile} · agent=${agent} · age=${age} · runtime=${runtime}${stopFlag}\n ${description}`;
|
|
12479
|
+
}
|
|
12480
|
+
buildSubagentBackgroundReport(records) {
|
|
12481
|
+
const counts = {
|
|
12482
|
+
queued: 0,
|
|
12483
|
+
running: 0,
|
|
12484
|
+
done: 0,
|
|
12485
|
+
error: 0,
|
|
12486
|
+
cancelled: 0,
|
|
12487
|
+
};
|
|
12488
|
+
for (const record of records) {
|
|
12489
|
+
counts[record.status] += 1;
|
|
12490
|
+
}
|
|
12491
|
+
const header = `Summary: total=${records.length} · queued=${counts.queued} · running=${counts.running} · done=${counts.done} · error=${counts.error} · cancelled=${counts.cancelled}`;
|
|
12492
|
+
const items = records.map((record, index) => this.formatSubagentBackgroundOptionLabel(record, index));
|
|
12493
|
+
const hints = [
|
|
12494
|
+
"Quick actions:",
|
|
12495
|
+
"- /subagent-runs bg status <id>",
|
|
12496
|
+
"- /subagent-runs bg logs <id> [lines]",
|
|
12497
|
+
"- /subagent-runs bg stop <id>",
|
|
12498
|
+
"- /subagent-runs bg stop-all",
|
|
12499
|
+
"- /subagent-runs bg prune [hours]",
|
|
12500
|
+
];
|
|
12501
|
+
return [header, "", ...items, "", ...hints].join("\n");
|
|
12502
|
+
}
|
|
12503
|
+
handleSubagentBackgroundRunsSlashCommand(args, cwd) {
|
|
12504
|
+
const usage = this.getSubagentBackgroundUsage();
|
|
12505
|
+
const firstArg = (args[0] ?? "").toLowerCase();
|
|
12506
|
+
const subcommand = firstArg || "list";
|
|
12507
|
+
const listFilters = {
|
|
12508
|
+
list: undefined,
|
|
12509
|
+
running: ["running"],
|
|
12510
|
+
queued: ["queued"],
|
|
12511
|
+
done: ["done"],
|
|
12512
|
+
error: ["error"],
|
|
12513
|
+
failed: ["error"],
|
|
12514
|
+
cancelled: ["cancelled"],
|
|
12515
|
+
};
|
|
12516
|
+
const hasListFilter = Object.prototype.hasOwnProperty.call(listFilters, subcommand);
|
|
12517
|
+
if (hasListFilter || /^\d+$/.test(subcommand)) {
|
|
12518
|
+
const limitRaw = subcommand === "list" ? args[1] : hasListFilter ? args[1] : subcommand;
|
|
12519
|
+
const limit = limitRaw ? Number.parseInt(limitRaw, 10) : 20;
|
|
12520
|
+
if (!Number.isInteger(limit) || limit < 1 || limit > 200) {
|
|
12521
|
+
this.showWarning(`Usage: ${usage}`);
|
|
12522
|
+
return;
|
|
12523
|
+
}
|
|
12524
|
+
const records = this.sortSubagentBackgroundRecords(listSubagentBackgroundRuns(cwd, limit));
|
|
12525
|
+
const statusFilter = hasListFilter ? listFilters[subcommand] : undefined;
|
|
12526
|
+
const filtered = statusFilter && statusFilter.length > 0
|
|
12527
|
+
? records.filter((record) => statusFilter.includes(record.status))
|
|
12528
|
+
: records;
|
|
12529
|
+
if (filtered.length === 0) {
|
|
12530
|
+
if (statusFilter && statusFilter.length > 0) {
|
|
12531
|
+
this.showStatus(`No background subagent runs found for "${subcommand}" filter.`);
|
|
12532
|
+
}
|
|
12533
|
+
else {
|
|
12534
|
+
this.showStatus("No background subagent runs found.");
|
|
12535
|
+
}
|
|
12536
|
+
return;
|
|
12537
|
+
}
|
|
12538
|
+
this.showCommandTextBlock("Subagent Background Runs", this.buildSubagentBackgroundReport(filtered));
|
|
12539
|
+
return;
|
|
12540
|
+
}
|
|
12541
|
+
if (subcommand === "status") {
|
|
12542
|
+
const runId = args[1];
|
|
12543
|
+
if (!runId) {
|
|
12544
|
+
this.showWarning(`Usage: ${usage}`);
|
|
12545
|
+
return;
|
|
12546
|
+
}
|
|
12547
|
+
const record = getSubagentBackgroundRun(cwd, runId);
|
|
12548
|
+
if (!record) {
|
|
12549
|
+
this.showWarning(`Background subagent run not found: ${runId}`);
|
|
12550
|
+
return;
|
|
12551
|
+
}
|
|
12552
|
+
const lines = [
|
|
12553
|
+
`Run: ${record.runId}`,
|
|
12554
|
+
`Status: ${this.formatSubagentBackgroundStatusLabel(record.status)}${record.requestedStopAt ? " (stop requested)" : ""}`,
|
|
12555
|
+
`Created: ${record.createdAt} (${this.formatRelativeTime(record.createdAt)})`,
|
|
12556
|
+
`Started: ${record.startedAt ?? "-"}`,
|
|
12557
|
+
`Runtime: ${this.formatDurationMs(record.startedAt, record.finishedAt)}`,
|
|
12558
|
+
`Finished: ${record.finishedAt ?? "-"}`,
|
|
12559
|
+
`Profile: ${record.profile}`,
|
|
12560
|
+
`Agent: ${record.agent ?? "-"}`,
|
|
12561
|
+
`Model: ${record.model ?? "-"}`,
|
|
12562
|
+
`Cwd: ${record.cwd}`,
|
|
12563
|
+
`Requested stop: ${record.requestedStopAt ?? "-"}`,
|
|
12564
|
+
`Status file: ${record.metaPath}`,
|
|
12565
|
+
`Log file: ${record.logPath}`,
|
|
12566
|
+
`Transcript: ${record.transcriptPath ?? "-"}`,
|
|
12567
|
+
record.error ? `Error: ${record.error}` : "",
|
|
12568
|
+
"",
|
|
12569
|
+
"Quick actions:",
|
|
12570
|
+
`- /subagent-runs bg logs ${record.runId} 120`,
|
|
12571
|
+
`- /subagent-runs bg stop ${record.runId}`,
|
|
12572
|
+
].filter((line) => line.length > 0);
|
|
12573
|
+
this.showCommandTextBlock("Subagent Background Status", lines.join("\n"));
|
|
12574
|
+
return;
|
|
12575
|
+
}
|
|
12576
|
+
if (subcommand === "logs") {
|
|
12577
|
+
const runId = args[1];
|
|
12578
|
+
if (!runId) {
|
|
12579
|
+
this.showWarning(`Usage: ${usage}`);
|
|
12580
|
+
return;
|
|
12581
|
+
}
|
|
12582
|
+
const linesRaw = args[2];
|
|
12583
|
+
const tailLines = linesRaw ? Number.parseInt(linesRaw, 10) : 120;
|
|
12584
|
+
if (!Number.isInteger(tailLines) || tailLines < 1 || tailLines > 1000) {
|
|
12585
|
+
this.showWarning(`Usage: ${usage}`);
|
|
12586
|
+
return;
|
|
12587
|
+
}
|
|
12588
|
+
const record = getSubagentBackgroundRun(cwd, runId);
|
|
12589
|
+
if (!record) {
|
|
12590
|
+
this.showWarning(`Background subagent run not found: ${runId}`);
|
|
12591
|
+
return;
|
|
12592
|
+
}
|
|
12593
|
+
const tail = readSubagentBackgroundRunLogTail(cwd, runId, tailLines);
|
|
12594
|
+
if (tail === undefined) {
|
|
12595
|
+
this.showWarning(`Background subagent run not found: ${runId}`);
|
|
12596
|
+
return;
|
|
12597
|
+
}
|
|
12598
|
+
const body = tail.trim().length > 0 ? tail : "(no output yet)";
|
|
12599
|
+
this.showCommandTextBlock("Subagent Background Logs", [
|
|
12600
|
+
`Run: ${record.runId} · status=${this.formatSubagentBackgroundStatusLabel(record.status)} · tail=${tailLines} lines`,
|
|
12601
|
+
`Runtime: ${this.formatDurationMs(record.startedAt, record.finishedAt)} · stop_requested=${record.requestedStopAt ? "yes" : "no"}`,
|
|
12602
|
+
`Description: ${record.description}`,
|
|
12603
|
+
"",
|
|
12604
|
+
body,
|
|
12605
|
+
].join("\n"));
|
|
12606
|
+
return;
|
|
12607
|
+
}
|
|
12608
|
+
if (subcommand === "stop" || subcommand === "cancel" || subcommand === "kill") {
|
|
12609
|
+
const runId = args[1];
|
|
12610
|
+
if (!runId) {
|
|
12611
|
+
this.showWarning(`Usage: ${usage}`);
|
|
12612
|
+
return;
|
|
12613
|
+
}
|
|
12614
|
+
const updated = requestStopSubagentBackgroundRun(cwd, runId);
|
|
12615
|
+
if (!updated) {
|
|
12616
|
+
this.showWarning(`Background subagent run not found: ${runId}`);
|
|
12617
|
+
return;
|
|
12618
|
+
}
|
|
12619
|
+
this.showStatus(`Stop requested for subagent run ${updated.runId} (status=${this.formatSubagentBackgroundStatusLabel(updated.status)}).`);
|
|
12620
|
+
return;
|
|
12621
|
+
}
|
|
12622
|
+
if (subcommand === "stop-all") {
|
|
12623
|
+
const result = requestStopAllSubagentBackgroundRuns(cwd);
|
|
12624
|
+
if (result.requested === 0) {
|
|
12625
|
+
this.showStatus("No running or queued background subagent runs found.");
|
|
12626
|
+
return;
|
|
12627
|
+
}
|
|
12628
|
+
const lines = [
|
|
12629
|
+
`Stop-all requested for ${result.requested} run(s).`,
|
|
12630
|
+
"",
|
|
12631
|
+
...result.requestedIds.map((id, index) => `${index + 1}. ${id}`),
|
|
12632
|
+
];
|
|
12633
|
+
this.showCommandTextBlock("Subagent Background Stop-All", lines.join("\n"));
|
|
12634
|
+
return;
|
|
12635
|
+
}
|
|
12636
|
+
if (subcommand === "prune") {
|
|
12637
|
+
const hoursRaw = args[1];
|
|
12638
|
+
const hours = hoursRaw ? Number.parseInt(hoursRaw, 10) : 24;
|
|
12639
|
+
if (!Number.isInteger(hours) || hours < 1 || hours > 2160) {
|
|
12640
|
+
this.showWarning(`Usage: ${usage}`);
|
|
12641
|
+
return;
|
|
12642
|
+
}
|
|
12643
|
+
const result = pruneSubagentBackgroundRuns(cwd, hours);
|
|
12644
|
+
const lines = [
|
|
12645
|
+
`Threshold: ${result.thresholdHours}h`,
|
|
12646
|
+
`Removed: ${result.removed}`,
|
|
12647
|
+
`Skipped running/queued: ${result.skippedRunning}`,
|
|
12648
|
+
`Skipped recent: ${result.skippedRecent}`,
|
|
12649
|
+
];
|
|
12650
|
+
if (result.removedIds.length > 0) {
|
|
12651
|
+
lines.push("", ...result.removedIds.map((id, index) => `${index + 1}. ${id}`));
|
|
12652
|
+
}
|
|
12653
|
+
this.showCommandTextBlock("Subagent Background Prune", lines.join("\n"));
|
|
12654
|
+
return;
|
|
12655
|
+
}
|
|
12656
|
+
this.showWarning(`Usage: ${usage}`);
|
|
12657
|
+
}
|
|
12420
12658
|
handleSubagentRunsSlashCommand(text) {
|
|
12421
12659
|
const args = this.parseSlashArgs(text).slice(1);
|
|
12660
|
+
const cwd = this.sessionManager.getCwd();
|
|
12661
|
+
const firstArg = (args[0] ?? "").toLowerCase();
|
|
12662
|
+
if (firstArg === "bg" || firstArg === "background") {
|
|
12663
|
+
this.handleSubagentBackgroundRunsSlashCommand(args.slice(1), cwd);
|
|
12664
|
+
return;
|
|
12665
|
+
}
|
|
12422
12666
|
const limitRaw = args[0];
|
|
12423
12667
|
const limit = limitRaw ? Number.parseInt(limitRaw, 10) : 20;
|
|
12424
12668
|
if (!Number.isInteger(limit) || limit < 1 || limit > 200) {
|
|
12425
|
-
this.showWarning("Usage: /subagent-runs [limit: 1..200]");
|
|
12669
|
+
this.showWarning("Usage: /subagent-runs [limit: 1..200] | /subagent-runs bg ...");
|
|
12426
12670
|
return;
|
|
12427
12671
|
}
|
|
12428
|
-
const cwd = this.sessionManager.getCwd();
|
|
12429
12672
|
const runs = listSubagentRuns(cwd, limit);
|
|
12430
12673
|
if (runs.length === 0) {
|
|
12431
12674
|
this.showStatus("No subagent runs found.");
|