mirror of
https://github.com/pchuan98/codex.git
synced 2026-07-01 00:31:56 +08:00
eafbc75612
https://github.com/user-attachments/assets/9ecb51be-fa65-4e99-8512-abb898dda569 Implemented it as a transformation between Responses API and Completion API so that it supports existing providers that implement the Completion API and minimizes the changes needed to the codex repo. --------- Co-authored-by: Thibault Sottiaux <tibo@openai.com> Co-authored-by: Fouad Matin <169186268+fouad-openai@users.noreply.github.com> Co-authored-by: Fouad Matin <fouad@openai.com>
100 lines
2.9 KiB
TypeScript
100 lines
2.9 KiB
TypeScript
import type { AgentLoop } from "../../utils/agent/agent-loop.js";
|
||
|
||
import { Box, Text } from "ink";
|
||
import path from "node:path";
|
||
import React from "react";
|
||
|
||
export interface TerminalHeaderProps {
|
||
terminalRows: number;
|
||
version: string;
|
||
PWD: string;
|
||
model: string;
|
||
provider?: string;
|
||
approvalPolicy: string;
|
||
colorsByPolicy: Record<string, string | undefined>;
|
||
agent?: AgentLoop;
|
||
initialImagePaths?: Array<string>;
|
||
flexModeEnabled?: boolean;
|
||
}
|
||
|
||
const TerminalHeader: React.FC<TerminalHeaderProps> = ({
|
||
terminalRows,
|
||
version,
|
||
PWD,
|
||
model,
|
||
provider = "openai",
|
||
approvalPolicy,
|
||
colorsByPolicy,
|
||
agent,
|
||
initialImagePaths,
|
||
flexModeEnabled = false,
|
||
}) => {
|
||
return (
|
||
<>
|
||
{terminalRows < 10 ? (
|
||
// Compact header for small terminal windows
|
||
<Text>
|
||
● Codex v{version} – {PWD} – {model} ({provider}) –{" "}
|
||
<Text color={colorsByPolicy[approvalPolicy]}>{approvalPolicy}</Text>
|
||
{flexModeEnabled ? " – flex-mode" : ""}
|
||
</Text>
|
||
) : (
|
||
<>
|
||
<Box borderStyle="round" paddingX={1} width={64}>
|
||
<Text>
|
||
● OpenAI <Text bold>Codex</Text>{" "}
|
||
<Text dimColor>
|
||
(research preview) <Text color="blueBright">v{version}</Text>
|
||
</Text>
|
||
</Text>
|
||
</Box>
|
||
<Box
|
||
borderStyle="round"
|
||
borderColor="gray"
|
||
paddingX={1}
|
||
width={64}
|
||
flexDirection="column"
|
||
>
|
||
<Text>
|
||
localhost <Text dimColor>session:</Text>{" "}
|
||
<Text color="magentaBright" dimColor>
|
||
{agent?.sessionId ?? "<no-session>"}
|
||
</Text>
|
||
</Text>
|
||
<Text dimColor>
|
||
<Text color="blueBright">↳</Text> workdir: <Text bold>{PWD}</Text>
|
||
</Text>
|
||
<Text dimColor>
|
||
<Text color="blueBright">↳</Text> model: <Text bold>{model}</Text>
|
||
</Text>
|
||
<Text dimColor>
|
||
<Text color="blueBright">↳</Text> provider:{" "}
|
||
<Text bold>{provider}</Text>
|
||
</Text>
|
||
<Text dimColor>
|
||
<Text color="blueBright">↳</Text> approval:{" "}
|
||
<Text bold color={colorsByPolicy[approvalPolicy]} dimColor>
|
||
{approvalPolicy}
|
||
</Text>
|
||
</Text>
|
||
{flexModeEnabled && (
|
||
<Text dimColor>
|
||
<Text color="blueBright">↳</Text> flex-mode:{" "}
|
||
<Text bold>enabled</Text>
|
||
</Text>
|
||
)}
|
||
{initialImagePaths?.map((img, idx) => (
|
||
<Text key={img ?? idx} color="gray">
|
||
<Text color="blueBright">↳</Text> image:{" "}
|
||
<Text bold>{path.basename(img)}</Text>
|
||
</Text>
|
||
))}
|
||
</Box>
|
||
</>
|
||
)}
|
||
</>
|
||
);
|
||
};
|
||
|
||
export default TerminalHeader;
|