@saturn-universe/cli 0.1.2-dev.6 → 0.1.2-dev.8
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/renderer.js +1 -1
- package/dist/repl-host.d.ts +2 -0
- package/dist/repl-host.js +9 -1
- package/dist/repl.js +7 -7
- package/dist/slash-commands.js +14 -1
- package/package.json +3 -3
package/dist/renderer.js
CHANGED
|
@@ -4,7 +4,7 @@ import { reconciliationUsage } from './reconcile-command.js';
|
|
|
4
4
|
import { createTerminalPainter, padEndDisplay, paintSgr, stringDisplayWidth, stripAnsi, terminalColorEnabled, } from './terminal-text.js';
|
|
5
5
|
import { formatDuration } from './duration.js';
|
|
6
6
|
import { estimateUsageCostUsd, formatCacheRate, formatTokenCompact, formatTokenExact, formatUsd, resolveModelPricing, } from './usage.js';
|
|
7
|
-
const SATURN_CLI_VERSION = '0.1.2-dev.
|
|
7
|
+
const SATURN_CLI_VERSION = '0.1.2-dev.8';
|
|
8
8
|
const { bold, dim, cyan, brightCyan, green, yellow, red, magenta, whiteBold } = createTerminalPainter();
|
|
9
9
|
function padLogoLines(lines) {
|
|
10
10
|
const maxWidth = Math.max(0, ...lines.map(stringDisplayWidth));
|
package/dist/repl-host.d.ts
CHANGED
|
@@ -5,8 +5,10 @@ export interface ReplHostState {
|
|
|
5
5
|
host?: ManagedHost | undefined;
|
|
6
6
|
activeMode?: ModeSummary | undefined;
|
|
7
7
|
modeRef?: string | undefined;
|
|
8
|
+
sessionModeRef?: string | undefined;
|
|
8
9
|
}
|
|
9
10
|
export declare function applyReplMode(state: ReplHostState, activeMode: ModeSummary | undefined, modeRef?: string): void;
|
|
11
|
+
export declare function applyReplSessionMode(state: ReplHostState, modeRef: string | undefined): void;
|
|
10
12
|
export declare function createReplHostConnection(state: ReplHostState, initialOptions: HostLaunchOptions): {
|
|
11
13
|
launch: () => Promise<ManagedHost>;
|
|
12
14
|
accept: (host: ManagedHost) => ManagedHost;
|
package/dist/repl-host.js
CHANGED
|
@@ -4,12 +4,20 @@ export function applyReplMode(state, activeMode, modeRef) {
|
|
|
4
4
|
state.activeMode = activeMode;
|
|
5
5
|
state.modeRef = activeMode?.ref ?? modeRef;
|
|
6
6
|
}
|
|
7
|
+
export function applyReplSessionMode(state, modeRef) {
|
|
8
|
+
state.sessionModeRef = modeRef;
|
|
9
|
+
const status = state.host?.status;
|
|
10
|
+
if (modeRef)
|
|
11
|
+
applyReplMode(state, status?.availableModes.find(({ ref }) => ref === modeRef), modeRef);
|
|
12
|
+
else
|
|
13
|
+
applyReplMode(state, status?.activeMode);
|
|
14
|
+
}
|
|
7
15
|
export function createReplHostConnection(state, initialOptions) {
|
|
8
16
|
let launchOptions = { ...initialOptions };
|
|
9
17
|
let latestStatusRequest = 0;
|
|
10
18
|
function accept(host) {
|
|
11
19
|
state.host = host;
|
|
12
|
-
|
|
20
|
+
applyReplSessionMode(state, state.sessionModeRef);
|
|
13
21
|
return host;
|
|
14
22
|
}
|
|
15
23
|
async function refreshStatus({ signal, merge = false } = {}) {
|
package/dist/repl.js
CHANGED
|
@@ -4,7 +4,7 @@ import { isTerminalRunEventType, MAX_SESSION_HISTORY_PAGE_SIZE, mergeAgentContex
|
|
|
4
4
|
import { formatDuration } from './duration.js';
|
|
5
5
|
import { CliError, formatDiagnosticReference } from './cli-diagnostics.js';
|
|
6
6
|
import { approvalCommand, sendHostCommand } from './host-command.js';
|
|
7
|
-
import { createReplHostConnection } from './repl-host.js';
|
|
7
|
+
import { applyReplSessionMode, createReplHostConnection } from './repl-host.js';
|
|
8
8
|
import { createReplRunObserver } from './repl-run-observer.js';
|
|
9
9
|
import { renderApprovalPrompt, renderAssistantText, renderBanner, renderConversationEvent, renderProgressEvent, renderUnifiedToolBlock, } from './renderer.js';
|
|
10
10
|
import { createSessionHistoryLoader, historyEntryKey, messageEntryKey } from './session-history.js';
|
|
@@ -14,8 +14,6 @@ function replSubmission(state, runOptions, target) {
|
|
|
14
14
|
const config = {};
|
|
15
15
|
if (target.streamText)
|
|
16
16
|
config.streamText = target.streamText;
|
|
17
|
-
if (target.modeRef)
|
|
18
|
-
config.modeRef = target.modeRef;
|
|
19
17
|
if (runOptions.team)
|
|
20
18
|
config.team = { ...runOptions.team, members: [...runOptions.team.members] };
|
|
21
19
|
const reasoningEffort = state.reasoningEffort ?? state.profileDefaultReasoningEffort;
|
|
@@ -68,6 +66,8 @@ function formatCliError(error) {
|
|
|
68
66
|
if (error.code === 'CREDENTIAL_UNAVAILABLE') {
|
|
69
67
|
return `Error: ${error.code} (diagnosticId=${error.diagnosticId}). Configure credentials in ~/.saturn/credentials.toml or run \`/config check\`.`;
|
|
70
68
|
}
|
|
69
|
+
if (error.code === 'SESSION_BUSY')
|
|
70
|
+
return '当前会话有正在执行的任务,请等待完成或先 /cancel 后再切换 Mode';
|
|
71
71
|
if (error.code === 'MODE_MISMATCH') {
|
|
72
72
|
return `Error: MODE_MISMATCH (diagnosticId=${error.diagnosticId}). 当前工作区 Host 运行在其他 Mode 下;请使用 \`/mode <target>\` 切换或重启 Host。`;
|
|
73
73
|
}
|
|
@@ -189,7 +189,7 @@ export function showTeamEvent(event, member) {
|
|
|
189
189
|
return !event.memberId || event.memberId === 'main' || event.memberId === 'planner';
|
|
190
190
|
}
|
|
191
191
|
function activeModeRef(state, status) {
|
|
192
|
-
return status?.activeMode?.ref ?? state.activeMode?.ref ?? state.modeRef;
|
|
192
|
+
return state.sessionModeRef ?? status?.activeMode?.ref ?? state.activeMode?.ref ?? state.modeRef;
|
|
193
193
|
}
|
|
194
194
|
function hydrateDefaultsFromStatus(state, status) {
|
|
195
195
|
const defaults = status?.runDefaults;
|
|
@@ -342,6 +342,7 @@ async function runPipedRepl(options, hostOptions) {
|
|
|
342
342
|
sessionId: state.sessionId,
|
|
343
343
|
});
|
|
344
344
|
state.member = session.member;
|
|
345
|
+
applyReplSessionMode(state, session.modeRef);
|
|
345
346
|
if (session.member)
|
|
346
347
|
state.lastRunId = session.latestRun?.id;
|
|
347
348
|
await printMemberHistory();
|
|
@@ -557,7 +558,6 @@ async function runPipedRepl(options, hostOptions) {
|
|
|
557
558
|
const input = replSubmission(state, runOptions, {
|
|
558
559
|
workspaceId,
|
|
559
560
|
sessionId,
|
|
560
|
-
modeRef: state.activeMode?.ref ?? state.modeRef,
|
|
561
561
|
});
|
|
562
562
|
const result = await sendHostCommand(state.workdir, {
|
|
563
563
|
type: 'run.submit',
|
|
@@ -671,7 +671,7 @@ async function runTtyRepl(options, hostOptions) {
|
|
|
671
671
|
usage: retainedContextTelemetry,
|
|
672
672
|
permissionMode: state.permissionMode,
|
|
673
673
|
...(activeModeRef(state, status) ? { modeRef: activeModeRef(state, status) } : { modeRef: undefined }),
|
|
674
|
-
activeMode:
|
|
674
|
+
activeMode: state.activeMode ?? status?.activeMode,
|
|
675
675
|
sandbox: status?.sandbox,
|
|
676
676
|
skillRefs: [...state.skillRefs],
|
|
677
677
|
...(state.disabledSkills?.length ? { disabledSkills: [...state.disabledSkills] } : {}),
|
|
@@ -783,6 +783,7 @@ async function runTtyRepl(options, hostOptions) {
|
|
|
783
783
|
return;
|
|
784
784
|
if (info.member)
|
|
785
785
|
state.member = info.member;
|
|
786
|
+
applyReplSessionMode(state, info.modeRef);
|
|
786
787
|
if (history)
|
|
787
788
|
bindHistory(targetId);
|
|
788
789
|
if ((info.runCount ?? 0) > 0 || info.latestRun?.id)
|
|
@@ -1615,7 +1616,6 @@ async function runTtyRepl(options, hostOptions) {
|
|
|
1615
1616
|
const input = replSubmission(state, runOptions, {
|
|
1616
1617
|
workspaceId,
|
|
1617
1618
|
sessionId,
|
|
1618
|
-
modeRef: activeModeRef(state, state.host?.status),
|
|
1619
1619
|
streamText: true,
|
|
1620
1620
|
});
|
|
1621
1621
|
tui.updateTelemetry({
|
package/dist/slash-commands.js
CHANGED
|
@@ -7,7 +7,7 @@ import { compactionArguments, compactionOptions, compactionOptionUsage } from '.
|
|
|
7
7
|
import { ensureHostWorkspace, reconcileRunTool, resolveRunApproval, sendHostCommand, } from './host-command.js';
|
|
8
8
|
import { stopHost } from './host-launcher.js';
|
|
9
9
|
import { reconciliationCommand, reconciliationOptions } from './reconcile-command.js';
|
|
10
|
-
import { applyReplMode } from './repl-host.js';
|
|
10
|
+
import { applyReplMode, applyReplSessionMode } from './repl-host.js';
|
|
11
11
|
import { renderConfigCheck, renderConfigInit, renderConfigSummary, renderReplHelp, renderShortcutHelp, renderTeamBoard, renderUsageCard, } from './renderer.js';
|
|
12
12
|
import { initUserConfig, inspectUserConfig, syncUserConfigDefaults, } from './user-config.js';
|
|
13
13
|
import { authenticateMcpServer, formatMcpServerStatus, listMcpServersInfo, setWorkspaceMcpTrust, } from './mcp-cli.js';
|
|
@@ -364,6 +364,7 @@ export async function ensureWorkspaceId(state) {
|
|
|
364
364
|
function selectSession(state, hooks, sessionId, summary) {
|
|
365
365
|
state.sessionId = sessionId;
|
|
366
366
|
state.member = summary.member;
|
|
367
|
+
applyReplSessionMode(state, summary.modeRef);
|
|
367
368
|
state.lastRunId = summary.latestRun?.id;
|
|
368
369
|
state.hasRunHistory = (summary.runCount ?? 0) > 0 || state.lastRunId !== undefined;
|
|
369
370
|
hooks.onSessionChanged?.({ ...summary, id: sessionId });
|
|
@@ -1158,6 +1159,18 @@ export async function handleSlashCommand(line, state, hooks) {
|
|
|
1158
1159
|
if (hooks.isRunActive?.()) {
|
|
1159
1160
|
throw new Error('当前有正在执行的任务,请等待完成或先 /cancel 后再切换 Mode');
|
|
1160
1161
|
}
|
|
1162
|
+
if (state.sessionId) {
|
|
1163
|
+
await hooks.ensureConnected();
|
|
1164
|
+
const { mode } = await sendHostCommand(state.workdir, {
|
|
1165
|
+
type: 'session.mode.select',
|
|
1166
|
+
sessionId: state.member?.parentSessionId ?? state.sessionId,
|
|
1167
|
+
modeRef: normalizedInput,
|
|
1168
|
+
});
|
|
1169
|
+
state.sessionModeRef = mode.ref;
|
|
1170
|
+
applyReplMode(state, mode);
|
|
1171
|
+
hooks.writeLine('已切换当前会话的 Mode 为 ' + mode.displayName + ' (' + mode.ref + ')');
|
|
1172
|
+
return 'continue';
|
|
1173
|
+
}
|
|
1161
1174
|
if (state.lastRunId) {
|
|
1162
1175
|
try {
|
|
1163
1176
|
const run = await sendHostCommand(state.workdir, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@saturn-universe/cli",
|
|
3
|
-
"version": "0.1.2-dev.
|
|
3
|
+
"version": "0.1.2-dev.8",
|
|
4
4
|
"description": "Saturn local multi-agent runtime CLI",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
6
|
"type": "module",
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
],
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@clack/prompts": "1.9.0",
|
|
12
|
-
"@saturn-universe/protocol": "0.1.2-dev.
|
|
13
|
-
"@saturn-universe/runtime-host": "0.1.2-dev.
|
|
12
|
+
"@saturn-universe/protocol": "0.1.2-dev.8",
|
|
13
|
+
"@saturn-universe/runtime-host": "0.1.2-dev.8",
|
|
14
14
|
"mdast-util-from-markdown": "^2.1.0",
|
|
15
15
|
"mdast-util-gfm": "^3.1.0",
|
|
16
16
|
"micromark-extension-gfm": "^3.0.0",
|