Merge 0c6f43901b into 4583f88626
This commit is contained in:
commit
9874b3dc55
@ -61,6 +61,9 @@ function resolveOxfmtCommand(repoRoot) {
|
||||
const binName = process.platform === "win32" ? "oxfmt.cmd" : "oxfmt";
|
||||
const local = path.join(repoRoot, "node_modules", ".bin", binName);
|
||||
if (fs.existsSync(local)) {
|
||||
if (process.platform === "win32" && local.toLowerCase().endsWith(".cmd")) {
|
||||
return { command: "cmd.exe", args: ["/d", "/s", "/c", local] };
|
||||
}
|
||||
return { command: local, args: [] };
|
||||
}
|
||||
|
||||
|
||||
@ -13,6 +13,7 @@ import type { EmbeddedContextFile } from "../pi-embedded-helpers.js";
|
||||
import { buildSystemPromptParams } from "../system-prompt-params.js";
|
||||
import { resolveDefaultModelForAgent } from "../model-selection.js";
|
||||
import { buildAgentSystemPrompt } from "../system-prompt.js";
|
||||
import { detectRuntimeShell } from "../shell-utils.js";
|
||||
import { buildTtsSystemPromptHint } from "../../tts/tts.js";
|
||||
|
||||
const CLI_RUN_QUEUE = new Map<string, Promise<unknown>>();
|
||||
@ -193,6 +194,7 @@ export function buildSystemPrompt(params: {
|
||||
node: process.version,
|
||||
model: params.modelDisplay,
|
||||
defaultModel: defaultModelLabel,
|
||||
shell: detectRuntimeShell(),
|
||||
},
|
||||
});
|
||||
const ttsHint = params.config ? buildTtsSystemPromptHint(params.config) : undefined;
|
||||
|
||||
@ -67,6 +67,7 @@ import { buildEmbeddedSystemPrompt, createSystemPromptOverride } from "./system-
|
||||
import { splitSdkTools } from "./tool-split.js";
|
||||
import type { EmbeddedPiCompactResult } from "./types.js";
|
||||
import { formatUserTime, resolveUserTimeFormat, resolveUserTimezone } from "../date-time.js";
|
||||
import { detectRuntimeShell } from "../shell-utils.js";
|
||||
import { describeUnknownError, mapThinkingLevel, resolveExecToolDefaults } from "./utils.js";
|
||||
import { buildTtsSystemPromptHint } from "../../tts/tts.js";
|
||||
|
||||
@ -300,6 +301,7 @@ export async function compactEmbeddedPiSessionDirect(
|
||||
arch: os.arch(),
|
||||
node: process.version,
|
||||
model: `${provider}/${modelId}`,
|
||||
shell: detectRuntimeShell(),
|
||||
channel: runtimeChannel,
|
||||
capabilities: runtimeCapabilities,
|
||||
channelActions,
|
||||
|
||||
@ -77,6 +77,7 @@ import { buildEmbeddedSystemPrompt, createSystemPromptOverride } from "../system
|
||||
import { splitSdkTools } from "../tool-split.js";
|
||||
import { toClientToolDefinitions } from "../../pi-tool-definition-adapter.js";
|
||||
import { buildSystemPromptParams } from "../../system-prompt-params.js";
|
||||
import { detectRuntimeShell } from "../../shell-utils.js";
|
||||
import { describeUnknownError, mapThinkingLevel } from "../utils.js";
|
||||
import { resolveSandboxRuntimeStatus } from "../../sandbox/runtime-status.js";
|
||||
import { buildTtsSystemPromptHint } from "../../../tts/tts.js";
|
||||
@ -319,6 +320,7 @@ export async function runEmbeddedAttempt(
|
||||
node: process.version,
|
||||
model: `${params.provider}/${params.modelId}`,
|
||||
defaultModel: defaultModelLabel,
|
||||
shell: detectRuntimeShell(),
|
||||
channel: runtimeChannel,
|
||||
capabilities: runtimeCapabilities,
|
||||
channelActions,
|
||||
|
||||
@ -59,6 +59,42 @@ function resolveShellFromPath(name: string): string | undefined {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function normalizeShellName(value: string): string {
|
||||
const trimmed = value.trim();
|
||||
if (!trimmed) return "";
|
||||
return path.basename(trimmed).replace(/\.(exe|cmd|bat)$/i, "");
|
||||
}
|
||||
|
||||
export function detectRuntimeShell(): string | undefined {
|
||||
const overrideShell = process.env.CLAWDBOT_SHELL?.trim();
|
||||
if (overrideShell) {
|
||||
const name = normalizeShellName(overrideShell);
|
||||
if (name) return name;
|
||||
}
|
||||
|
||||
if (process.platform === "win32") {
|
||||
if (process.env.POWERSHELL_DISTRIBUTION_CHANNEL) {
|
||||
return "pwsh";
|
||||
}
|
||||
return "powershell";
|
||||
}
|
||||
|
||||
const envShell = process.env.SHELL?.trim();
|
||||
if (envShell) {
|
||||
const name = normalizeShellName(envShell);
|
||||
if (name) return name;
|
||||
}
|
||||
|
||||
if (process.env.POWERSHELL_DISTRIBUTION_CHANNEL) return "pwsh";
|
||||
if (process.env.BASH_VERSION) return "bash";
|
||||
if (process.env.ZSH_VERSION) return "zsh";
|
||||
if (process.env.FISH_VERSION) return "fish";
|
||||
if (process.env.KSH_VERSION) return "ksh";
|
||||
if (process.env.NU_VERSION || process.env.NUSHELL_VERSION) return "nu";
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export function sanitizeBinaryOutput(text: string): string {
|
||||
const scrubbed = text.replace(/[\p{Format}\p{Surrogate}]/gu, "");
|
||||
if (!scrubbed) return scrubbed;
|
||||
|
||||
@ -17,6 +17,7 @@ export type RuntimeInfoInput = {
|
||||
node: string;
|
||||
model: string;
|
||||
defaultModel?: string;
|
||||
shell?: string;
|
||||
channel?: string;
|
||||
capabilities?: string[];
|
||||
/** Supported message actions for the current channel (e.g., react, edit, unsend) */
|
||||
|
||||
@ -155,6 +155,7 @@ export function buildAgentSystemPrompt(params: {
|
||||
node?: string;
|
||||
model?: string;
|
||||
defaultModel?: string;
|
||||
shell?: string;
|
||||
channel?: string;
|
||||
capabilities?: string[];
|
||||
repoRoot?: string;
|
||||
@ -562,6 +563,7 @@ export function buildRuntimeLine(
|
||||
node?: string;
|
||||
model?: string;
|
||||
defaultModel?: string;
|
||||
shell?: string;
|
||||
repoRoot?: string;
|
||||
},
|
||||
runtimeChannel?: string,
|
||||
@ -580,6 +582,7 @@ export function buildRuntimeLine(
|
||||
runtimeInfo?.node ? `node=${runtimeInfo.node}` : "",
|
||||
runtimeInfo?.model ? `model=${runtimeInfo.model}` : "",
|
||||
runtimeInfo?.defaultModel ? `default_model=${runtimeInfo.defaultModel}` : "",
|
||||
runtimeInfo?.shell ? `shell=${runtimeInfo.shell}` : "",
|
||||
runtimeChannel ? `channel=${runtimeChannel}` : "",
|
||||
runtimeChannel
|
||||
? `capabilities=${runtimeCapabilities.length > 0 ? runtimeCapabilities.join(",") : "none"}`
|
||||
|
||||
Loading…
Reference in New Issue
Block a user