env.d.ts 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. declare global {
  2. const Deno: {
  3. version: {
  4. deno: string;
  5. };
  6. } | undefined;
  7. }
  8. export declare const isBrowser: () => boolean;
  9. export declare const isWebWorker: () => boolean;
  10. export declare const isJsDom: () => boolean;
  11. export declare const isDeno: () => boolean;
  12. export declare const isNode: () => boolean;
  13. export declare const getEnv: () => string;
  14. export type RuntimeEnvironment = {
  15. library: string;
  16. libraryVersion?: string;
  17. sdk: string;
  18. sdk_version: string;
  19. runtime: string;
  20. runtimeVersion?: string;
  21. };
  22. export declare function getRuntimeEnvironment(): RuntimeEnvironment;
  23. /**
  24. * Retrieves the LangChain-specific environment variables from the current runtime environment.
  25. * Sensitive keys (containing the word "key", "token", or "secret") have their values redacted for security.
  26. *
  27. * @returns {Record<string, string>}
  28. * - A record of LangChain-specific environment variables.
  29. */
  30. export declare function getLangChainEnvVars(): Record<string, string>;
  31. /**
  32. * Retrieves the LangChain-specific metadata from the current runtime environment.
  33. *
  34. * @returns {Record<string, string>}
  35. * - A record of LangChain-specific metadata environment variables.
  36. */
  37. export declare function getLangChainEnvVarsMetadata(): Record<string, string>;
  38. /**
  39. * Retrieves the environment variables from the current runtime environment.
  40. *
  41. * This function is designed to operate in a variety of JS environments,
  42. * including Node.js, Deno, browsers, etc.
  43. *
  44. * @returns {Record<string, string> | undefined}
  45. * - A record of environment variables if available.
  46. * - `undefined` if the environment does not support or allows access to environment variables.
  47. */
  48. export declare function getEnvironmentVariables(): Record<string, string> | undefined;
  49. export declare function getEnvironmentVariable(name: string): string | undefined;
  50. export declare function getLangSmithEnvironmentVariable(name: string): string | undefined;
  51. export declare function setEnvironmentVariable(name: string, value: string): void;
  52. interface ICommitSHAs {
  53. [key: string]: string;
  54. }
  55. /**
  56. * Get the Git commit SHA from common environment variables
  57. * used by different CI/CD platforms.
  58. * @returns {string | undefined} The Git commit SHA or undefined if not found.
  59. */
  60. export declare function getShas(): ICommitSHAs;
  61. export {};