Agents: include runtime shell
This commit is contained in:
parent
c8063bdcd8
commit
f9c49a80bb
@ -13,6 +13,7 @@ import type { EmbeddedContextFile } from "../pi-embedded-helpers.js";
|
|||||||
import { buildSystemPromptParams } from "../system-prompt-params.js";
|
import { buildSystemPromptParams } from "../system-prompt-params.js";
|
||||||
import { resolveDefaultModelForAgent } from "../model-selection.js";
|
import { resolveDefaultModelForAgent } from "../model-selection.js";
|
||||||
import { buildAgentSystemPrompt } from "../system-prompt.js";
|
import { buildAgentSystemPrompt } from "../system-prompt.js";
|
||||||
|
import { detectRuntimeShell } from "../shell-utils.js";
|
||||||
import { buildTtsSystemPromptHint } from "../../tts/tts.js";
|
import { buildTtsSystemPromptHint } from "../../tts/tts.js";
|
||||||
|
|
||||||
const CLI_RUN_QUEUE = new Map<string, Promise<unknown>>();
|
const CLI_RUN_QUEUE = new Map<string, Promise<unknown>>();
|
||||||
@ -193,6 +194,7 @@ export function buildSystemPrompt(params: {
|
|||||||
node: process.version,
|
node: process.version,
|
||||||
model: params.modelDisplay,
|
model: params.modelDisplay,
|
||||||
defaultModel: defaultModelLabel,
|
defaultModel: defaultModelLabel,
|
||||||
|
shell: detectRuntimeShell(),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const ttsHint = params.config ? buildTtsSystemPromptHint(params.config) : undefined;
|
const ttsHint = params.config ? buildTtsSystemPromptHint(params.config) : undefined;
|
||||||
|
|||||||
@ -67,6 +67,7 @@ import { buildEmbeddedSystemPrompt, createSystemPromptOverride } from "./system-
|
|||||||
import { splitSdkTools } from "./tool-split.js";
|
import { splitSdkTools } from "./tool-split.js";
|
||||||
import type { EmbeddedPiCompactResult } from "./types.js";
|
import type { EmbeddedPiCompactResult } from "./types.js";
|
||||||
import { formatUserTime, resolveUserTimeFormat, resolveUserTimezone } from "../date-time.js";
|
import { formatUserTime, resolveUserTimeFormat, resolveUserTimezone } from "../date-time.js";
|
||||||
|
import { detectRuntimeShell } from "../shell-utils.js";
|
||||||
import { describeUnknownError, mapThinkingLevel, resolveExecToolDefaults } from "./utils.js";
|
import { describeUnknownError, mapThinkingLevel, resolveExecToolDefaults } from "./utils.js";
|
||||||
import { buildTtsSystemPromptHint } from "../../tts/tts.js";
|
import { buildTtsSystemPromptHint } from "../../tts/tts.js";
|
||||||
|
|
||||||
@ -300,6 +301,7 @@ export async function compactEmbeddedPiSessionDirect(
|
|||||||
arch: os.arch(),
|
arch: os.arch(),
|
||||||
node: process.version,
|
node: process.version,
|
||||||
model: `${provider}/${modelId}`,
|
model: `${provider}/${modelId}`,
|
||||||
|
shell: detectRuntimeShell(),
|
||||||
channel: runtimeChannel,
|
channel: runtimeChannel,
|
||||||
capabilities: runtimeCapabilities,
|
capabilities: runtimeCapabilities,
|
||||||
channelActions,
|
channelActions,
|
||||||
@ -482,7 +484,9 @@ export async function compactEmbeddedPiSession(
|
|||||||
const globalLane = resolveGlobalLane(params.lane);
|
const globalLane = resolveGlobalLane(params.lane);
|
||||||
const enqueueGlobal =
|
const enqueueGlobal =
|
||||||
params.enqueue ?? ((task, opts) => enqueueCommandInLane(globalLane, task, opts));
|
params.enqueue ?? ((task, opts) => enqueueCommandInLane(globalLane, task, opts));
|
||||||
|
return enqueueCommandInLane(sessionLane, () =>
|
||||||
return enqueueCommandInLane(sessionLane, () =>
|
return enqueueCommandInLane(sessionLane, () =>
|
||||||
enqueueGlobal(async () => compactEmbeddedPiSessionDirect(params)),
|
enqueueGlobal(async () => compactEmbeddedPiSessionDirect(params)),
|
||||||
);
|
);
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -77,6 +77,7 @@ import { buildEmbeddedSystemPrompt, createSystemPromptOverride } from "../system
|
|||||||
import { splitSdkTools } from "../tool-split.js";
|
import { splitSdkTools } from "../tool-split.js";
|
||||||
import { toClientToolDefinitions } from "../../pi-tool-definition-adapter.js";
|
import { toClientToolDefinitions } from "../../pi-tool-definition-adapter.js";
|
||||||
import { buildSystemPromptParams } from "../../system-prompt-params.js";
|
import { buildSystemPromptParams } from "../../system-prompt-params.js";
|
||||||
|
import { detectRuntimeShell } from "../../shell-utils.js";
|
||||||
import { describeUnknownError, mapThinkingLevel } from "../utils.js";
|
import { describeUnknownError, mapThinkingLevel } from "../utils.js";
|
||||||
import { resolveSandboxRuntimeStatus } from "../../sandbox/runtime-status.js";
|
import { resolveSandboxRuntimeStatus } from "../../sandbox/runtime-status.js";
|
||||||
import { buildTtsSystemPromptHint } from "../../../tts/tts.js";
|
import { buildTtsSystemPromptHint } from "../../../tts/tts.js";
|
||||||
@ -315,6 +316,7 @@ export async function runEmbeddedAttempt(
|
|||||||
node: process.version,
|
node: process.version,
|
||||||
model: `${params.provider}/${params.modelId}`,
|
model: `${params.provider}/${params.modelId}`,
|
||||||
defaultModel: defaultModelLabel,
|
defaultModel: defaultModelLabel,
|
||||||
|
shell: detectRuntimeShell(),
|
||||||
channel: runtimeChannel,
|
channel: runtimeChannel,
|
||||||
capabilities: runtimeCapabilities,
|
capabilities: runtimeCapabilities,
|
||||||
channelActions,
|
channelActions,
|
||||||
|
|||||||
@ -59,6 +59,42 @@ function resolveShellFromPath(name: string): string | undefined {
|
|||||||
return 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 {
|
export function sanitizeBinaryOutput(text: string): string {
|
||||||
const scrubbed = text.replace(/[\p{Format}\p{Surrogate}]/gu, "");
|
const scrubbed = text.replace(/[\p{Format}\p{Surrogate}]/gu, "");
|
||||||
if (!scrubbed) return scrubbed;
|
if (!scrubbed) return scrubbed;
|
||||||
|
|||||||
@ -17,6 +17,7 @@ export type RuntimeInfoInput = {
|
|||||||
node: string;
|
node: string;
|
||||||
model: string;
|
model: string;
|
||||||
defaultModel?: string;
|
defaultModel?: string;
|
||||||
|
shell?: string;
|
||||||
channel?: string;
|
channel?: string;
|
||||||
capabilities?: string[];
|
capabilities?: string[];
|
||||||
/** Supported message actions for the current channel (e.g., react, edit, unsend) */
|
/** Supported message actions for the current channel (e.g., react, edit, unsend) */
|
||||||
|
|||||||
@ -155,6 +155,7 @@ export function buildAgentSystemPrompt(params: {
|
|||||||
node?: string;
|
node?: string;
|
||||||
model?: string;
|
model?: string;
|
||||||
defaultModel?: string;
|
defaultModel?: string;
|
||||||
|
shell?: string;
|
||||||
channel?: string;
|
channel?: string;
|
||||||
capabilities?: string[];
|
capabilities?: string[];
|
||||||
repoRoot?: string;
|
repoRoot?: string;
|
||||||
@ -576,6 +577,7 @@ export function buildRuntimeLine(
|
|||||||
node?: string;
|
node?: string;
|
||||||
model?: string;
|
model?: string;
|
||||||
defaultModel?: string;
|
defaultModel?: string;
|
||||||
|
shell?: string;
|
||||||
repoRoot?: string;
|
repoRoot?: string;
|
||||||
},
|
},
|
||||||
runtimeChannel?: string,
|
runtimeChannel?: string,
|
||||||
@ -594,6 +596,7 @@ export function buildRuntimeLine(
|
|||||||
runtimeInfo?.node ? `node=${runtimeInfo.node}` : "",
|
runtimeInfo?.node ? `node=${runtimeInfo.node}` : "",
|
||||||
runtimeInfo?.model ? `model=${runtimeInfo.model}` : "",
|
runtimeInfo?.model ? `model=${runtimeInfo.model}` : "",
|
||||||
runtimeInfo?.defaultModel ? `default_model=${runtimeInfo.defaultModel}` : "",
|
runtimeInfo?.defaultModel ? `default_model=${runtimeInfo.defaultModel}` : "",
|
||||||
|
runtimeInfo?.shell ? `shell=${runtimeInfo.shell}` : "",
|
||||||
runtimeChannel ? `channel=${runtimeChannel}` : "",
|
runtimeChannel ? `channel=${runtimeChannel}` : "",
|
||||||
runtimeChannel
|
runtimeChannel
|
||||||
? `capabilities=${runtimeCapabilities.length > 0 ? runtimeCapabilities.join(",") : "none"}`
|
? `capabilities=${runtimeCapabilities.length > 0 ? runtimeCapabilities.join(",") : "none"}`
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user