Skip to content

Add @genaiscript/globals #1632

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 23, 2025
Merged

Add @genaiscript/globals #1632

merged 4 commits into from
Jun 23, 2025

Conversation

pelikhan
Copy link
Member

  • Add helper package to load globals
  • Figure out types?

@pelikhan pelikhan changed the title Add @genaiscript/globas Add @genaiscript/globals Jun 23, 2025
@pelikhan pelikhan requested a review from mattpodwysocki June 23, 2025 12:06
@pelikhan
Copy link
Member Author

@mattpodwysocki we should figure out a way to package the typings in this helper package.

@@ -20,5 +20,5 @@ export function resolveGlobal(): any {
else if (typeof self !== "undefined")
return self; // Web worker environment
else if (typeof global !== "undefined") return global; // Node.js environment
throw new Error("Could not find global"); // Error if no global context is found
return globalThis;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing the error throw to return globalThis alters the function's semantics: it now silently returns globalThis even if none of the explicit checks matched, which could mask environment issues. Consider if this fallback is truly safe for all intended environments.

AI-generated content by pr-review-commit global_fallback_semantics may be incorrect. Use reactions to eval.

@@ -0,0 +1,8 @@
#!/usr/bin/env node
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shebang (#!/usr/bin/env node) is present in a TypeScript file. TypeScript compilers do not preserve shebangs, and this may cause issues if the file is compiled and then executed. Consider moving the shebang to the compiled output or using a JavaScript entry point.

AI-generated content by pr-review-commit shebang_in_typescript may be incorrect. Use reactions to eval.


import { installGlobals } from "@genaiscript/core";

installGlobals();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Calling installGlobals() at the top level causes side effects on import, which can lead to unpredictable behavior if this module is imported elsewhere. Consider exporting a function to explicitly install globals instead.

AI-generated content by pr-review-commit side_effect_import may be incorrect. Use reactions to eval.

Copy link
Contributor

Investigator report

Context collection

  • run id: 15823809407
  • failed job
  • last successful run not found

AI Analysis

AI-generated content by gai may be incorrect. Use reactions to eval.

@pelikhan pelikhan merged commit 3332309 into dev Jun 23, 2025
9 of 13 checks passed
@pelikhan pelikhan deleted the globalspackage branch June 23, 2025 18:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant