├── .cursor └── rules │ └── rules-location.mdc ├── .editorconfig ├── .env.test ├── .github ├── CODEOWNERS ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── PULL_REQUEST_TEMPLATE.md ├── actions │ ├── create-release-candidate │ │ └── action.yml │ └── setup-node │ │ └── action.yml ├── dependabot.yml ├── labels.yml ├── pr-scope-labeler.yml ├── settings.yml └── workflows │ ├── build-containers.yml │ ├── check-create-gensx-command.yml │ ├── lint-pr-title.yml │ ├── lint.yml │ ├── pr-scope-label.yml │ ├── release-cli-binary.yml │ ├── release.yml │ ├── sync-labels.yml │ ├── test-examples.yml │ └── test.yml ├── .gitignore ├── .husky ├── .gitignore └── install.mjs ├── .nvmrc ├── .prettierignore ├── .release-please-manifest.json ├── .vercelignore ├── .vscode ├── extensions.json ├── launch.json ├── settings.json └── tasks.json ├── CLAUDE.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── containers └── builder │ ├── Dockerfile │ ├── build.sh │ └── build_container.sh ├── create-rollup-config.js ├── eslint.config.mjs ├── examples ├── README.md ├── all-models-metadata │ ├── README.md │ ├── eslint.config.mjs │ ├── gensx.yaml │ ├── package.json │ ├── src │ │ ├── index.ts │ │ └── workflows.ts │ └── tsconfig.json ├── anthropic-examples │ ├── README.md │ ├── eslint.config.mjs │ ├── gensx.yaml │ ├── package.json │ ├── src │ │ ├── index.ts │ │ └── workflows.ts │ └── tsconfig.json ├── blog-writer │ ├── README.md │ ├── eslint.config.mjs │ ├── package.json │ ├── src │ │ ├── index.ts │ │ └── workflows.ts │ └── tsconfig.json ├── chat-memory │ ├── .gitignore │ ├── README.md │ ├── eslint.config.mjs │ ├── gensx.yaml │ ├── package.json │ ├── request.json │ ├── src │ │ ├── index.ts │ │ └── workflows.ts │ └── tsconfig.json ├── commonjs-compatibility │ ├── README.md │ ├── cjs-jsx.tsx │ ├── eslint.config.mjs │ ├── index.tsx │ ├── nodemon.json │ ├── package.json │ ├── test │ │ └── verify-commonjs.js │ └── tsconfig.json ├── deep-research │ ├── README.md │ ├── eslint.config.mjs │ ├── gensx.yaml │ ├── package.json │ ├── src │ │ ├── arxiv.ts │ │ ├── firecrawl.ts │ │ ├── grader.ts │ │ ├── index.ts │ │ ├── queryGenerator.ts │ │ ├── summarize.ts │ │ └── workflows.ts │ └── tsconfig.json ├── eslint.config.mjs ├── groq-deepseek │ ├── README.md │ ├── eslint.config.mjs │ ├── gensx.yaml │ ├── package.json │ ├── src │ │ ├── index.ts │ │ └── workflows.ts │ └── tsconfig.json ├── hacker-news-analyzer │ ├── .gitignore │ ├── README.md │ ├── eslint.config.mjs │ ├── gensx.yaml │ ├── package.json │ ├── src │ │ ├── hn.ts │ │ ├── index.ts │ │ └── workflows.ts │ └── tsconfig.json ├── llm-games │ ├── Board.ts │ ├── Game.tsx │ ├── MakeMove.tsx │ ├── README.md │ ├── Tournament.tsx │ ├── eslint.config.mjs │ ├── index.tsx │ ├── nodemon.json │ ├── package.json │ ├── tournament_results.jsonl │ ├── tsconfig.json │ ├── types.tsx │ └── visualize_results.ipynb ├── nextjs-ai-chatbot-template │ └── README.md ├── open-router │ ├── README.md │ ├── eslint.config.mjs │ ├── gensx.yaml │ ├── package.json │ ├── src │ │ ├── index.ts │ │ └── workflows.ts │ └── tsconfig.json ├── openai-computer-use │ ├── README.md │ ├── browserContext.tsx │ ├── computerUse.ts │ ├── eslint.config.mjs │ ├── index.tsx │ ├── nodemon.json │ ├── package.json │ └── tsconfig.json ├── openai-examples │ ├── README.md │ ├── eslint.config.mjs │ ├── gensx.yaml │ ├── package.json │ ├── src │ │ ├── index.ts │ │ └── workflows.ts │ └── tsconfig.json ├── rag │ ├── README.md │ ├── eslint.config.mjs │ ├── gensx.yaml │ ├── package.json │ ├── src │ │ ├── index.ts │ │ ├── initialize.ts │ │ └── workflows.ts │ └── tsconfig.json ├── reflection │ ├── README.md │ ├── eslint.config.mjs │ ├── gensx.yaml │ ├── package.json │ ├── src │ │ ├── index.ts │ │ ├── reflection.ts │ │ └── workflows.ts │ └── tsconfig.json ├── salty-ocean-model-comparison │ ├── README.md │ ├── eslint.config.mjs │ ├── nodemon.json │ ├── package.json │ ├── src │ │ └── index.tsx │ └── tsconfig.json ├── self-modifying-code │ ├── .gitignore │ ├── README.md │ ├── agent │ │ ├── codeAgent.tsx │ │ ├── smcAgent.tsx │ │ ├── steps │ │ │ ├── generateGoalState.tsx │ │ │ └── generatePlan.tsx │ │ └── tools │ │ │ ├── bashTool.tsx │ │ │ ├── buildTool.tsx │ │ │ └── editTool.tsx │ ├── agent_context.json │ ├── eslint.config.mjs │ ├── index.tsx │ ├── nodemon.json │ ├── package.json │ ├── tsconfig.json │ └── workspace.tsx ├── text-to-sql │ ├── README.md │ ├── eslint.config.mjs │ ├── gensx.yaml │ ├── package.json │ ├── src │ │ ├── index.ts │ │ └── workflows.ts │ └── tsconfig.json ├── tsconfig.base.json ├── typescript-compatibility │ ├── README.md │ ├── eslint.config.mjs │ ├── index.tsx │ ├── nodemon.json │ ├── package.json │ └── tsconfig.json └── vercel-ai │ ├── README.md │ ├── eslint.config.mjs │ ├── gensx.yaml │ ├── package.json │ ├── src │ ├── index.ts │ └── workflows.ts │ └── tsconfig.json ├── package.json ├── packages ├── create-gensx │ ├── CHANGELOG.md │ ├── README.md │ ├── eslint.config.mjs │ ├── package.json │ ├── src │ │ ├── cli.ts │ │ └── index.ts │ ├── tests │ │ ├── index.test.ts │ │ └── package.test.ts │ ├── tsconfig.build.json │ ├── tsconfig.json │ └── vitest.config.ts ├── gensx-anthropic │ ├── .gitignore │ ├── CHANGELOG.md │ ├── README.md │ ├── eslint.config.mjs │ ├── package.json │ ├── rollup.config.js │ ├── src │ │ ├── anthropic.ts │ │ └── index.ts │ ├── tests │ │ ├── anthropic.test.ts │ │ └── setup.ts │ ├── tsconfig.build.json │ ├── tsconfig.json │ └── vitest.config.ts ├── gensx-claude-md │ ├── .gitignore │ ├── CHANGELOG.md │ ├── README.md │ ├── eslint.config.mjs │ ├── package.json │ ├── src │ │ └── cli.ts │ ├── templates │ │ └── CLAUDE.md │ ├── tests │ │ └── cli.test.ts │ ├── tsconfig.build.json │ ├── tsconfig.json │ └── vitest.config.ts ├── gensx-cli │ ├── .gitignore │ ├── README.md │ ├── deno.json │ ├── deno.lock │ ├── eslint.config.mjs │ ├── main.ts │ ├── package.json │ └── tsconfig.json ├── gensx-cline-rules │ ├── .gitignore │ ├── CHANGELOG.md │ ├── README.md │ ├── eslint.config.mjs │ ├── package.json │ ├── src │ │ └── cli.ts │ ├── templates │ │ └── .clinerules │ ├── tests │ │ └── cli.test.ts │ ├── tsconfig.build.json │ ├── tsconfig.json │ └── vitest.config.ts ├── gensx-cloud-mcp │ ├── .gitignore │ ├── CHANGELOG.md │ ├── README.md │ ├── claude-desktop.png │ ├── eslint.config.mjs │ ├── package.json │ ├── src │ │ ├── index.ts │ │ └── utils │ │ │ └── user-agent.ts │ ├── tsconfig.build.json │ └── tsconfig.json ├── gensx-core │ ├── .npmignore │ ├── .npmrc │ ├── CHANGELOG.md │ ├── README.md │ ├── eslint.config.mjs │ ├── package.json │ ├── rollup.config.js │ ├── src │ │ ├── checkpoint.ts │ │ ├── component.ts │ │ ├── context.ts │ │ ├── index.ts │ │ ├── types.ts │ │ ├── utils │ │ │ ├── config.ts │ │ │ ├── env-config.ts │ │ │ ├── project-config.ts │ │ │ └── user-agent.ts │ │ ├── workflow-context.ts │ │ └── wrap.ts │ ├── tests │ │ ├── checkpoint.test.ts │ │ ├── component.test.ts │ │ ├── progress.test.ts │ │ ├── secrets.test.ts │ │ ├── utils │ │ │ └── executeWithCheckpoints.ts │ │ └── wrap.test.ts │ ├── tsconfig.build.json │ ├── tsconfig.json │ └── vitest.config.ts ├── gensx-cursor-rules │ ├── .gitignore │ ├── CHANGELOG.md │ ├── README.md │ ├── eslint.config.mjs │ ├── package.json │ ├── rules │ │ ├── gensx-ai-sdk.mdc │ │ ├── gensx-anthropic.mdc │ │ ├── gensx-openai.mdc │ │ └── gensx.mdc │ ├── src │ │ └── cli.ts │ ├── tests │ │ └── cli.test.ts │ ├── tsconfig.build.json │ ├── tsconfig.json │ └── vitest.config.ts ├── gensx-openai │ ├── .gitignore │ ├── CHANGELOG.md │ ├── README.md │ ├── __mocks__ │ │ └── openai.ts │ ├── eslint.config.mjs │ ├── package.json │ ├── rollup.config.js │ ├── src │ │ ├── index.ts │ │ └── openai.ts │ ├── tests │ │ ├── openai.test.ts │ │ └── setup.ts │ ├── tsconfig.build.json │ ├── tsconfig.json │ └── vitest.config.ts ├── gensx-storage │ ├── .gitignore │ ├── CHANGELOG.md │ ├── README.md │ ├── eslint.config.mjs │ ├── package.json │ ├── rollup.config.js │ ├── src │ │ ├── blob │ │ │ ├── blobClient.ts │ │ │ ├── filesystem.ts │ │ │ ├── remote.ts │ │ │ ├── types.ts │ │ │ └── useBlob.ts │ │ ├── database │ │ │ ├── databaseClient.ts │ │ │ ├── filesystem.ts │ │ │ ├── remote.ts │ │ │ ├── types.ts │ │ │ └── useDatabase.ts │ │ ├── index.ts │ │ ├── search │ │ │ ├── remote.ts │ │ │ ├── searchClient.ts │ │ │ ├── types.ts │ │ │ └── useSearch.ts │ │ └── utils │ │ │ ├── base64.ts │ │ │ ├── config.ts │ │ │ └── user-agent.ts │ ├── tests │ │ ├── blob │ │ │ ├── filesystem.test.ts │ │ │ ├── index.test.ts │ │ │ └── remote.test.ts │ │ ├── database │ │ │ ├── filesystem.test.ts │ │ │ ├── index.test.ts │ │ │ └── remote.test.ts │ │ ├── search │ │ │ ├── index.test.ts │ │ │ └── remote.test.ts │ │ └── setup.ts │ ├── tsconfig.build.json │ ├── tsconfig.json │ └── vitest.config.ts ├── gensx-vercel-ai │ ├── .gitignore │ ├── CHANGELOG.md │ ├── README.md │ ├── __mocks__ │ │ └── ai-sdk.ts │ ├── eslint.config.mjs │ ├── package.json │ ├── rollup.config.js │ ├── src │ │ └── index.ts │ ├── tests │ │ └── index.test.ts │ ├── tsconfig.build.json │ ├── tsconfig.json │ └── vitest.config.ts ├── gensx-windsurf-rules │ ├── .gitignore │ ├── CHANGELOG.md │ ├── README.md │ ├── eslint.config.mjs │ ├── package.json │ ├── src │ │ └── cli.ts │ ├── templates │ │ └── .windsurfrules │ ├── tests │ │ └── cli.test.ts │ ├── tsconfig.build.json │ ├── tsconfig.json │ └── vitest.config.ts ├── gensx │ ├── .npmignore │ ├── .npmrc │ ├── CHANGELOG.md │ ├── CONTRIBUTING.md │ ├── README.md │ ├── eslint.config.mjs │ ├── package.json │ ├── src │ │ ├── commands │ │ │ ├── build.tsx │ │ │ ├── deploy.tsx │ │ │ ├── environment │ │ │ │ ├── create.tsx │ │ │ │ ├── list.tsx │ │ │ │ ├── select.tsx │ │ │ │ ├── show.tsx │ │ │ │ └── unselect.tsx │ │ │ ├── login.tsx │ │ │ ├── new.tsx │ │ │ ├── run.tsx │ │ │ └── start.tsx │ │ ├── components │ │ │ ├── EnvironmentResolver.tsx │ │ │ ├── ErrorMessage.tsx │ │ │ ├── FirstTimeSetup.tsx │ │ │ └── LoadingSpinner.tsx │ │ ├── dev-server.ts │ │ ├── hooks │ │ │ └── useProjectName.ts │ │ ├── index.ts │ │ ├── models │ │ │ ├── environment.ts │ │ │ └── projects.ts │ │ ├── run.ts │ │ ├── templates │ │ │ └── projects │ │ │ │ └── typescript │ │ │ │ ├── README.md.template │ │ │ │ ├── package.json.template │ │ │ │ ├── src │ │ │ │ ├── index.ts.template │ │ │ │ └── workflows.ts.template │ │ │ │ ├── template.json │ │ │ │ └── tsconfig.json.template │ │ ├── types │ │ │ ├── ncc.d.ts │ │ │ └── prompt.ts │ │ └── utils │ │ │ ├── bundler.ts │ │ │ ├── config.ts │ │ │ ├── env-config.ts │ │ │ ├── exec.ts │ │ │ ├── project-config.ts │ │ │ ├── schema.ts │ │ │ └── user-agent.ts │ ├── tests │ │ ├── commands │ │ │ ├── deploy.test.ts │ │ │ ├── environment │ │ │ │ ├── create.test.ts │ │ │ │ ├── env.test.ts │ │ │ │ ├── list.test.ts │ │ │ │ ├── select.test.ts │ │ │ │ └── unselect.test.ts │ │ │ ├── login.test.ts │ │ │ ├── new.test.ts │ │ │ ├── run.test.ts │ │ │ └── start.test.ts │ │ ├── components │ │ │ └── EnvironmentResolver.test.ts │ │ ├── dev-server.test.ts │ │ ├── setup.ts │ │ ├── test-helpers.ts │ │ └── utils │ │ │ └── schema.test.ts │ ├── tsconfig.build.json │ ├── tsconfig.json │ └── vitest.config.ts └── tsconfig.base.json ├── pnpm-lock.yaml ├── pnpm-workspace.yaml ├── release-please-config.json ├── tsconfig.json ├── turbo.json ├── vitest.workspace.ts └── website ├── .DS_Store ├── docs ├── .gitignore ├── .npmrc ├── eslint.config.mjs ├── mdx-components.js ├── next-env.d.ts ├── next-sitemap.config.js ├── next.config.ts ├── package.json ├── postcss.config.mjs ├── public │ ├── cloud │ │ ├── claude-desktop.png │ │ ├── component-trace.png │ │ ├── console-playground.png │ │ ├── console-workflow-docs.png │ │ ├── console-workflows.png │ │ ├── local-swagger-ui.png │ │ ├── project-structure.png │ │ ├── swagger-execute.png │ │ └── trace.png │ ├── docs │ │ ├── computer-use-trace.png │ │ └── gensx-visualize-workflow.png │ ├── favicon.ico │ ├── logo-dark.svg │ ├── logo.svg │ └── quickstart │ │ ├── api-docs.png │ │ ├── blog-trace.png │ │ ├── run-console.png │ │ ├── trace-rag.png │ │ ├── trace.png │ │ └── writer-trace.png ├── src │ ├── app │ │ ├── _ignored │ │ │ ├── _meta.js │ │ │ └── page.mdx │ │ ├── _meta.ts │ │ ├── components │ │ │ └── Logo.tsx │ │ ├── docs │ │ │ └── [[...mdxPath]] │ │ │ │ └── page.tsx │ │ ├── globals.css │ │ └── layout.tsx │ └── content │ │ ├── _meta.ts │ │ ├── basic-concepts.mdx │ │ ├── cli-reference │ │ ├── _meta.ts │ │ ├── build.mdx │ │ ├── deploy.mdx │ │ ├── env │ │ │ ├── _meta.ts │ │ │ ├── create.mdx │ │ │ ├── ls.mdx │ │ │ ├── select.mdx │ │ │ ├── show.mdx │ │ │ └── unselect.mdx │ │ ├── index.mdx │ │ ├── login.mdx │ │ ├── new.mdx │ │ ├── run.mdx │ │ └── start.mdx │ │ ├── cloud │ │ ├── _meta.ts │ │ ├── index.mdx │ │ ├── local-development.mdx │ │ ├── mcp-server.mdx │ │ ├── observability.mdx │ │ ├── pricing.mdx │ │ ├── projects-environments.mdx │ │ ├── serverless-deployments.mdx │ │ └── storage │ │ │ ├── _meta.ts │ │ │ ├── blob-storage.mdx │ │ │ ├── search.mdx │ │ │ └── sql-database.mdx │ │ ├── component-reference │ │ ├── _meta.ts │ │ ├── anthropic.mdx │ │ ├── openai.mdx │ │ ├── openrouter.mdx │ │ ├── storage-components │ │ │ ├── blob-reference.mdx │ │ │ ├── database-reference.mdx │ │ │ └── search-reference.mdx │ │ └── vercel-ai.mdx │ │ ├── examples │ │ ├── blog-writing.mdx │ │ ├── hn.mdx │ │ └── openai-computer-use.mdx │ │ ├── index.mdx │ │ ├── patterns │ │ ├── reflection.mdx │ │ ├── structured-outputs.mdx │ │ └── tools.mdx │ │ ├── quickstart.mdx │ │ ├── typescript-compatibility.mdx │ │ └── why-components.mdx ├── tailwind.config.ts └── tsconfig.json └── home ├── .gitignore ├── .npmrc ├── README.md ├── _posts ├── _caching.md ├── _logging.md ├── llm-tic-tac-toe.md ├── self-modifying-code.md ├── wheres_the_graph.md └── why-react-is-the-best-backend-workflow-engine.md ├── app ├── blog │ ├── [slug] │ │ └── page.tsx │ ├── layout.tsx │ └── page.tsx ├── globals.css ├── layout.tsx ├── legal │ ├── privacy-policy │ │ ├── page.tsx │ │ └── privacy-policy.md │ ├── terms-of-service │ │ ├── page.tsx │ │ └── terms-of-service.md │ └── terms-of-use │ │ ├── page.tsx │ │ └── terms-of-use.md └── page.tsx ├── components.json ├── components ├── AnimatedPage.tsx ├── MarkdownRenderer.tsx ├── footer.tsx ├── markdown-to-html.tsx ├── nav.tsx └── ui │ ├── AnimatedArticle.tsx │ ├── AnimatedTitle.tsx │ ├── burning-fuse-animation.tsx │ ├── button.tsx │ ├── code-block.tsx │ ├── cycling-typing-animation.tsx │ ├── dropdown-menu.tsx │ ├── grid-pattern.tsx │ ├── hyper-text.tsx │ ├── interactive-grid-pattern.tsx │ ├── navigation-menu.tsx │ ├── script-copy-btn.tsx │ ├── sheet.tsx │ ├── shimmer-button.tsx │ ├── tabs.tsx │ └── typing-animation.tsx ├── eslint.config.mjs ├── interfaces ├── author.ts └── post.ts ├── lib ├── api.ts ├── constants.ts └── utils.ts ├── next-sitemap.config.js ├── next.config.ts ├── package.json ├── postcss.config.mjs ├── public ├── assets │ ├── blog │ │ ├── authors │ │ │ ├── derek.jpg │ │ │ ├── evan.jpg │ │ │ ├── jeremy.jpg │ │ │ ├── jj.jpeg │ │ │ ├── joe.jpeg │ │ │ └── tim.jpeg │ │ ├── dynamic-routing │ │ │ └── cover.jpg │ │ ├── hello-world │ │ │ └── cover.jpg │ │ ├── preview │ │ │ └── cover.jpg │ │ ├── self-modifying-code │ │ │ ├── agent-tools.png │ │ │ ├── architecture.png │ │ │ ├── build-failed.png │ │ │ ├── build-success.png │ │ │ ├── plan.png │ │ │ ├── pr-summary.png │ │ │ └── pr-todos.png │ │ └── tic-tac-toe │ │ │ ├── errors-by-model.png │ │ │ ├── errors-reasoning.png │ │ │ ├── errors-thinking-vs-not.png │ │ │ ├── perf-by-model.png │ │ │ ├── perf-reasoning.png │ │ │ └── perf-thinking-vs-not.png │ └── home │ │ ├── deploy.png │ │ ├── status.gif │ │ └── trace.png ├── favicon.ico ├── file.svg ├── globe.svg ├── logo-dark.svg ├── logo.svg ├── next.svg ├── vercel.svg ├── white-paper-texture.jpg └── window.svg ├── scripts ├── generate-llms-full-txt.ts └── generate-llms-txt.ts ├── tailwind.config.ts └── tsconfig.json /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig is awesome: https://EditorConfig.org 2 | 3 | # top-most EditorConfig file 4 | root = true 5 | 6 | # Unix-style newlines with a newline ending every file 7 | [*] 8 | end_of_line = lf 9 | insert_final_newline = true 10 | charset = utf-8 11 | indent_style = space 12 | indent_size = 2 13 | trim_trailing_whitespace = true 14 | 15 | [CHANGELOG.md] 16 | indent_size = unset 17 | indent_style = unset 18 | end_of_line = unset 19 | trim_trailing_whitespace = unset 20 | insert_final_newline = unset 21 | charset = unset 22 | -------------------------------------------------------------------------------- /.env.test: -------------------------------------------------------------------------------- 1 | ENABLE_EXPERIMENTAL_COREPACK=1 2 | NODE_ENV=test 3 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # Default owners for everything in the repo 2 | * @cortexclick/gensx 3 | 4 | # GitHub Actions workflow files 5 | .github/workflows/* @cortexclick/gensx 6 | .github/actions/* @cortexclick/gensx 7 | 8 | # Package files 9 | packages/gensx/* @cortexclick/gensx 10 | packages/gensx-openai/* @cortexclick/gensx 11 | 12 | # Critical configuration files 13 | package.json @cortexclick/gensx 14 | pnpm-lock.yaml @cortexclick/gensx 15 | turbo.json @cortexclick/gensx 16 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: "" 5 | labels: "kind/bug" 6 | assignees: "" 7 | --- 8 | 9 | # Prerequisites 10 | 11 | - [ ] I checked to make sure that this issue has not already been filed 12 | 13 | **Describe the bug** 14 | 15 | A clear and concise description of what the bug is. Include what is current behavior and what are you expecting. Add screenshots if needed and error details in JSON format so it can be easy to copy and paste. 16 | 17 | **To Reproduce** 18 | 19 | 1. Go to '...' 20 | 2. Click on '....' 21 | 3. Scroll down to '....' 22 | 4. See error 23 | 24 | **Context** 25 | 26 | Node Versions: 27 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: "" 5 | labels: "kind/feature" 6 | assignees: "" 7 | --- 8 | 9 | # Prerequisites 10 | 11 | - [ ] I checked the documentation and found no answer 12 | 13 | **Is your feature request related to a problem? Please describe.** 14 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 15 | 16 | **Describe the solution you'd like** 17 | A clear and concise description of what you want to happen. 18 | 19 | **Describe alternatives you've considered** 20 | A clear and concise description of any alternative solutions or features you've considered. 21 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ## Proposed changes 2 | 3 | Describe the big picture of your changes here to communicate to the maintainers why we should accept this pull request. If it fixes a bug or resolves a feature request, be sure to link to that issue. 4 | 5 | Does your title have a `feat:`, `fix:` or `chore:` prefix? 6 | -------------------------------------------------------------------------------- /.github/actions/setup-node/action.yml: -------------------------------------------------------------------------------- 1 | name: "⚙️ Setup node" 2 | 3 | description: "Setup node with project version and install dependencies" 4 | 5 | inputs: 6 | version: 7 | description: "Node version to use" 8 | required: false 9 | npm_token: 10 | description: "NPM Token" 11 | required: false 12 | default: "" 13 | 14 | runs: 15 | using: "composite" 16 | steps: 17 | - name: Authenticate npm 🔑 18 | shell: bash 19 | run: echo "//registry.npmjs.org/:_authToken=${{ inputs.npm_token }}" > ~/.npmrc 20 | - name: Install pnpm 📦 21 | uses: pnpm/action-setup@v4 22 | - name: Cache Dependencies ⌛️ 23 | uses: actions/cache@v4 24 | id: cache-node-modules 25 | with: 26 | path: | 27 | ~/.pnpm-store 28 | node_modules 29 | .turbo 30 | **/node_modules/.cache/turbo 31 | **/.turbo 32 | key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ hashFiles('.github/actions/setup-node/action.yml') }}-node-${{ hashFiles('.nvmrc') }}-${{ inputs.version }} 33 | - name: Setup Node ⚙️ 34 | uses: actions/setup-node@v4 35 | with: 36 | node-version: ${{ inputs.version }} 37 | node-version-file: ".nvmrc" 38 | cache: "pnpm" 39 | - name: Install dependencies 📥 40 | shell: bash 41 | run: pnpm install --frozen-lockfile 42 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | # Enable version updates for npm 4 | - package-ecosystem: "npm" 5 | directory: "/" 6 | schedule: 7 | interval: "weekly" 8 | commit-message: 9 | prefix: "chore" 10 | include: "scope" 11 | versioning-strategy: "increase" 12 | groups: 13 | dependencies: 14 | patterns: 15 | - "*" 16 | ignore: 17 | - dependency-name: "*" 18 | update-types: ["version-update:semver-major"] 19 | 20 | # Enable version updates for GitHub Actions 21 | - package-ecosystem: "github-actions" 22 | directory: "/" 23 | schedule: 24 | interval: "weekly" 25 | commit-message: 26 | prefix: "ci" 27 | include: "scope" 28 | groups: 29 | actions: 30 | patterns: 31 | - "*" 32 | -------------------------------------------------------------------------------- /.github/labels.yml: -------------------------------------------------------------------------------- 1 | - name: kind/feature 2 | description: New Feature 3 | color: 07D90A 4 | - name: kind/bug 5 | description: Bug/Regression 6 | color: F4D03F 7 | - name: kind/breaking-change 8 | description: Breaking change 9 | color: F1F800 10 | - name: "autorelease: tagged" 11 | description: Used by release-please to indicate a release has been tagged 12 | color: EDEDED 13 | - name: "autorelease: pending" 14 | description: Used by release-please to indicate a release is pending 15 | color: EDEDED 16 | - name: kind/todo 17 | description: Action we need to perform at some point 18 | color: 82FC28 19 | - name: area/source 20 | description: Indicates the scope is related to the library source code 21 | color: FDC720 22 | - name: area/build 23 | description: Indicates the change is related to the build and pipelines 24 | color: 0FD4DA 25 | - name: area/docs 26 | description: Indicates the change is related to the documentation 27 | color: 228AFF 28 | - name: kind/documentation 29 | description: Improvements or additions to documentation 30 | color: 228AFF 31 | - name: kind/duplicate 32 | description: This issue or pull request already exists 33 | color: 17202A 34 | - name: ignore-for-release 35 | description: Ignore pull request for a new release 36 | color: 9C28FC 37 | -------------------------------------------------------------------------------- /.github/pr-scope-labeler.yml: -------------------------------------------------------------------------------- 1 | core: 2 | - changed-files: 3 | - any-glob-to-any-file: 4 | - packages/gensx-core/** 5 | 6 | package: 7 | - changed-files: 8 | - any-glob-to-any-file: 9 | - packages/gensx-*/** 10 | 11 | cli: 12 | - changed-files: 13 | - any-glob-to-any-file: 14 | - packages/gensx/** 15 | 16 | docs: 17 | - changed-files: 18 | - any-glob-to-any-file: 19 | - website/docs/** 20 | 21 | homepage: 22 | - changed-files: 23 | - any-glob-to-any-file: 24 | - website/home/** 25 | 26 | examples: 27 | - changed-files: 28 | - any-glob-to-any-file: 29 | - examples/** 30 | -------------------------------------------------------------------------------- /.github/settings.yml: -------------------------------------------------------------------------------- 1 | repository: 2 | name: gensx 3 | description: The AI framework for TypeScript developers. Lightning fast dev loop. Easy to learn. Easy to extend. 4 | homepage: github.com/gensx-inc/gensx 5 | topics: llms, generative-ai, llm-framework, workflow,nodejs, template, typescript, typescript-library, jsx 6 | has_wiki: false 7 | private: false 8 | has_issues: true 9 | has_projects: false 10 | default_branch: main 11 | allow_squash_merge: true 12 | allow_merge_commit: false 13 | allow_rebase_merge: false 14 | delete_branch_on_merge: true 15 | enable_automated_security_fixes: true 16 | enable_vulnerability_alerts: true 17 | branches: 18 | - name: main 19 | protection: 20 | required_pull_request_reviews: 21 | required_approving_review_count: 1 22 | dismiss_stale_reviews: true 23 | require_code_owner_reviews: true 24 | required_status_checks: 25 | strict: true 26 | contexts: [] 27 | enforce_admins: false 28 | required_linear_history: true 29 | restrictions: null 30 | -------------------------------------------------------------------------------- /.github/workflows/build-containers.yml: -------------------------------------------------------------------------------- 1 | name: "🐳 Build Containers" 2 | 3 | on: 4 | pull_request: 5 | branches: [main] 6 | paths: 7 | - "containers/**/*" 8 | push: 9 | branches: [main] 10 | paths: 11 | - "containers/**/*" 12 | 13 | permissions: 14 | contents: read 15 | checks: write 16 | pull-requests: write 17 | 18 | concurrency: 19 | group: ${{ github.workflow }}-${{ github.ref }} 20 | cancel-in-progress: true 21 | 22 | jobs: 23 | build: 24 | runs-on: ubuntu-latest 25 | 26 | steps: 27 | - name: Checkout 🛬 28 | uses: actions/checkout@v4 29 | 30 | - name: GenSX Builder 🛠️ 31 | env: 32 | # Only publish the container on push to main 33 | PUBLISH_LATEST: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} 34 | DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} 35 | DOCKER_ACCESS_TOKEN: ${{ secrets.DOCKER_ACCESS_TOKEN }} 36 | GIT_SHA: ${{ github.sha }} 37 | run: ./build_container.sh 38 | working-directory: containers/builder 39 | -------------------------------------------------------------------------------- /.github/workflows/lint.yml: -------------------------------------------------------------------------------- 1 | name: "💅 Lint and Format" 2 | 3 | on: 4 | pull_request: 5 | push: 6 | branches: [main] 7 | 8 | permissions: 9 | contents: read 10 | checks: write 11 | pull-requests: write 12 | 13 | concurrency: 14 | group: ${{ github.workflow }}-${{ github.ref }} 15 | cancel-in-progress: true 16 | 17 | jobs: 18 | lint: 19 | runs-on: ubuntu-latest 20 | 21 | steps: 22 | - name: Checkout 🛬 23 | uses: actions/checkout@v4 24 | - name: Setup Node ⚙️ 25 | uses: ./.github/actions/setup-node 26 | with: 27 | version: 20.x 28 | 29 | - name: Lint code 💅 30 | run: pnpm lint:all 31 | - name: Format code 📝 32 | run: pnpm format:check 33 | -------------------------------------------------------------------------------- /.github/workflows/pr-scope-label.yml: -------------------------------------------------------------------------------- 1 | name: '🏷️ PR Scope label' 2 | 3 | on: 4 | pull_request_target: 5 | types: [opened, synchronize, reopened] 6 | 7 | jobs: 8 | labeler: 9 | permissions: 10 | contents: read 11 | pull-requests: write 12 | runs-on: ubuntu-latest 13 | steps: 14 | - uses: actions/labeler@v5 15 | with: 16 | configuration-path: .github/pr-scope-labeler.yml 17 | sync-labels: true 18 | -------------------------------------------------------------------------------- /.github/workflows/sync-labels.yml: -------------------------------------------------------------------------------- 1 | name: '🔄 Sync labels' 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | 8 | jobs: 9 | build: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: actions/checkout@v4 13 | - uses: micnncim/action-label-syncer@v1 14 | env: 15 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 16 | -------------------------------------------------------------------------------- /.github/workflows/test-examples.yml: -------------------------------------------------------------------------------- 1 | name: "🐢 Build and Test Examples" 2 | 3 | on: 4 | pull_request: 5 | paths: 6 | - "examples/**/*" 7 | - "packages/**/*" 8 | push: 9 | branches: [main] 10 | paths: 11 | - "examples/**/*" 12 | - "packages/**/*" 13 | 14 | permissions: 15 | contents: read 16 | checks: write 17 | pull-requests: write 18 | 19 | concurrency: 20 | group: ${{ github.workflow }}-${{ github.ref }} 21 | cancel-in-progress: true 22 | 23 | jobs: 24 | build: 25 | runs-on: ubuntu-latest 26 | if: github.event_name == 'push' || github.event_name == 'pull_request' 27 | strategy: 28 | fail-fast: false 29 | matrix: 30 | node-version: [22.x, 20.x, 18.x] 31 | 32 | steps: 33 | - name: Checkout code 🛬 34 | uses: actions/checkout@v4 35 | with: 36 | fetch-depth: 0 37 | - name: Setup Node ⚙️ 38 | uses: ./.github/actions/setup-node 39 | with: 40 | version: ${{ matrix.node-version }} 41 | - name: Clean build artifacts 🧹 42 | run: | 43 | rm -rf examples/**/dist 44 | rm -rf examples/**/.turbo 45 | - name: Build 📦 46 | run: pnpm build:examples 47 | 48 | - name: Test 🧪 49 | run: pnpm test:examples 50 | env: 51 | OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} 52 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | dist/ 3 | .tmp 4 | .idea 5 | .env 6 | coverage/ 7 | .turbo 8 | .tsbuildinfo 9 | .DS_Store 10 | .gensx/ 11 | -------------------------------------------------------------------------------- /.husky/.gitignore: -------------------------------------------------------------------------------- 1 | _ 2 | -------------------------------------------------------------------------------- /.husky/install.mjs: -------------------------------------------------------------------------------- 1 | if (process.env.NODE_ENV === 'production' || process.env.CI === 'true') { 2 | process.exit(0) 3 | } 4 | const husky = (await import('husky')).default 5 | console.log(husky()) 6 | -------------------------------------------------------------------------------- /.nvmrc: -------------------------------------------------------------------------------- 1 | 20 2 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | dist/ 2 | coverage/ 3 | node_modules/ 4 | CHANGELOG.md 5 | .astro 6 | .turbo 7 | .wrangler 8 | .next/ -------------------------------------------------------------------------------- /.release-please-manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "packages/create-gensx": "0.1.47", 3 | "packages/gensx-anthropic": "0.2.2", 4 | "packages/gensx-cloud-mcp": "0.0.11", 5 | "packages/gensx-openai": "0.2.2", 6 | "packages/gensx-vercel-ai-sdk": "0.1.17", 7 | "packages/gensx": "0.3.35", 8 | "packages/gensx-core": "0.4.2", 9 | "packages/gensx-claude-md": "0.1.8", 10 | "packages/gensx-cline-rules": "0.1.8", 11 | "packages/gensx-cursor-rules": "0.1.8", 12 | "packages/gensx-windsurf-rules": "0.1.8", 13 | "packages/gensx-storage": "0.1.3", 14 | "packages/gensx-vercel-ai": "0.2.2" 15 | } 16 | -------------------------------------------------------------------------------- /.vercelignore: -------------------------------------------------------------------------------- 1 | .release-please-manifest.json 2 | release-please-config.json 3 | -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "dbaeumer.vscode-eslint", 4 | "streetsidesoftware.code-spell-checker", 5 | "vitest.explorer", 6 | "esbenp.prettier-vscode", 7 | "editorconfig.editorconfig", 8 | "astro-build.astro-vscode" 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "editor.formatOnSave": true, 3 | "editor.defaultFormatter": "esbenp.prettier-vscode", 4 | "editor.codeActionsOnSave": { 5 | "source.fixAll.eslint": "explicit", 6 | "source.removeUnusedImports": "always" 7 | }, 8 | "eslint.validate": [ 9 | "javascript", 10 | "typescript", 11 | "javascriptreact", 12 | "typescriptreact" 13 | ], 14 | "cSpell.words": [ 15 | "Firecrawl", 16 | "gensx", 17 | "jsxs", 18 | "libsql", 19 | "Kysely", 20 | "modelcontextprotocol", 21 | "Streamable", 22 | "turbopuffer" 23 | ], 24 | "[jsonc]": { 25 | "editor.defaultFormatter": "esbenp.prettier-vscode" 26 | }, 27 | "files.associations": { 28 | "*.tsx.template": "typescriptreact", 29 | "*.ts.template": "typescript", 30 | "*.js.template": "javascript", 31 | "*.json.template": "json", 32 | "*.md.template": "markdown" 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "label": "build-packages", 6 | "type": "shell", 7 | "command": "pnpm", 8 | "args": ["build"], 9 | "group": { 10 | "kind": "build", 11 | "isDefault": true 12 | }, 13 | "presentation": { 14 | "reveal": "silent", 15 | "panel": "shared", 16 | "showReuseMessage": false, 17 | "clear": true 18 | }, 19 | "problemMatcher": ["$tsc"] 20 | } 21 | ] 22 | } 23 | -------------------------------------------------------------------------------- /containers/builder/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:20-slim 2 | 3 | RUN npm install -g @vercel/ncc 4 | 5 | COPY ./build.sh /build.sh 6 | RUN chmod +x /build.sh 7 | 8 | ENTRYPOINT ["/bin/bash"] 9 | 10 | CMD ["/build.sh"] 11 | -------------------------------------------------------------------------------- /containers/builder/build.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | set -e 4 | 5 | rm -rf /out/* 6 | 7 | # TODO: Persist cache for ncc on disk between builds 8 | 9 | cd /app 10 | 11 | mkdir -p /tmp/project 12 | 13 | for file in * .*; do 14 | [[ "$file" == "." || "$file" == ".." ]] && continue 15 | [[ "$file" == "node_modules" || "$file" == "dist" || "$file" == "dist.tar.gz" || "$file" == ".gensx" ]] && continue 16 | cp -r "$file" /tmp/project/ 17 | done 18 | 19 | cd /tmp/project 20 | 21 | # Install required dependencies 22 | npm install 23 | 24 | WORKFLOW_PATH=${WORKFLOW_PATH:-"workflows.tsx"} 25 | 26 | # Build with ncc - this should bundle all dependencies 27 | ncc build ./${WORKFLOW_PATH} -o /out/dist --target es2022 -e "@libsql/client" 28 | 29 | cd /out/dist 30 | 31 | # Work around an issue with @libsql/client and bundlers 32 | # https://github.com/tursodatabase/libsql-client-ts/issues/112 33 | sed -i 's/@libsql\/linux-arm64-gnu/@libsql\/linux-x64-gnu/g' index.js 34 | 35 | npm install @libsql/client 36 | 37 | # tar the dist directory 38 | tar -czvf ../dist.tar.gz * 39 | -------------------------------------------------------------------------------- /containers/builder/build_container.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | echo "Publishing..." 6 | 7 | docker login -u $DOCKER_USERNAME -p $DOCKER_ACCESS_TOKEN 8 | 9 | docker build -t gensx/builder:$GIT_SHA . 10 | 11 | docker push gensx/builder:$GIT_SHA 12 | 13 | if [ "$PUBLISH_LATEST" = "true" ]; then 14 | docker image tag gensx/builder:$GIT_SHA gensx/builder:latest 15 | docker push gensx/builder:latest 16 | fi 17 | 18 | echo "Done!" 19 | -------------------------------------------------------------------------------- /examples/all-models-metadata/eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import rootConfig from "../../eslint.config.mjs"; 2 | import examplesConfig from "../eslint.config.mjs"; 3 | 4 | export default [ 5 | ...rootConfig, 6 | ...examplesConfig, 7 | { 8 | files: ["**/*.{js,mjs,cjs,jsx,ts,tsx}"], 9 | languageOptions: { 10 | parserOptions: { 11 | tsconfigRootDir: import.meta.dirname, 12 | project: "./tsconfig.json", 13 | }, 14 | }, 15 | }, 16 | ]; 17 | -------------------------------------------------------------------------------- /examples/all-models-metadata/gensx.yaml: -------------------------------------------------------------------------------- 1 | projectName: all-models-metadata -------------------------------------------------------------------------------- /examples/all-models-metadata/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@examples/all-models-metadata", 3 | "private": true, 4 | "version": "0.0.1", 5 | "type": "module", 6 | "engines": { 7 | "node": ">=18.0.0" 8 | }, 9 | "scripts": { 10 | "dev": "tsx ./src/index.ts", 11 | "start": "npx gensx start ./src/workflows.ts", 12 | "build": "tsc", 13 | "deploy": "npx gensx deploy -e OPENROUTER_API_KEY ./src/workflows.ts", 14 | "lint": "eslint .", 15 | "lint:fix": "eslint . --fix" 16 | }, 17 | "description": "Use OpenRouter to list all models and their pricing", 18 | "main": "index.js", 19 | "keywords": [], 20 | "author": "", 21 | "license": "ISC", 22 | "dependencies": { 23 | "@gensx/core": "^0.4.0", 24 | "@gensx/openai": "^0.2.0" 25 | }, 26 | "devDependencies": { 27 | "@types/node": "^22", 28 | "tsx": "^4.19.2", 29 | "typescript": "^5.7.2" 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /examples/all-models-metadata/src/index.ts: -------------------------------------------------------------------------------- 1 | import { GetAllOpenRouterModelPricing } from "./workflows.js"; 2 | 3 | async function main() { 4 | try { 5 | const pricing = await GetAllOpenRouterModelPricing({}); 6 | console.log("OpenRouter Model Pricing:"); 7 | console.log(JSON.stringify(pricing, null, 2)); 8 | } catch (error) { 9 | console.error("Error fetching model pricing:", error); 10 | process.exit(1); 11 | } 12 | } 13 | 14 | void main(); 15 | -------------------------------------------------------------------------------- /examples/all-models-metadata/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ESNext", 4 | "module": "NodeNext", 5 | "lib": ["ESNext", "DOM"], 6 | "strict": true, 7 | "esModuleInterop": true, 8 | "skipLibCheck": true, 9 | "forceConsistentCasingInFileNames": true, 10 | "moduleResolution": "NodeNext", 11 | "resolveJsonModule": true, 12 | "isolatedModules": true, 13 | "outDir": "./dist" 14 | }, 15 | "include": ["./src/**/*.ts"], 16 | "exclude": ["node_modules"] 17 | } 18 | -------------------------------------------------------------------------------- /examples/anthropic-examples/eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import rootConfig from "../../eslint.config.mjs"; 2 | import examplesConfig from "../eslint.config.mjs"; 3 | 4 | export default [ 5 | ...rootConfig, 6 | ...examplesConfig, 7 | { 8 | files: ["**/*.{js,mjs,cjs,jsx,ts,tsx}"], 9 | languageOptions: { 10 | parserOptions: { 11 | tsconfigRootDir: import.meta.dirname, 12 | project: "./tsconfig.json", 13 | }, 14 | }, 15 | }, 16 | ]; 17 | -------------------------------------------------------------------------------- /examples/anthropic-examples/gensx.yaml: -------------------------------------------------------------------------------- 1 | projectName: anthropic-examples 2 | -------------------------------------------------------------------------------- /examples/anthropic-examples/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@examples/gensx-anthropic", 3 | "private": true, 4 | "version": "0.0.0", 5 | "type": "module", 6 | "engines": { 7 | "node": ">=18.0.0" 8 | }, 9 | "scripts": { 10 | "dev": "tsx ./src/index.ts", 11 | "start": "npx gensx start ./src/workflows.ts", 12 | "build": "tsc", 13 | "deploy": "npx gensx deploy -e OPENAI_API_KEY ./src/workflows.ts", 14 | "lint": "eslint .", 15 | "lint:fix": "eslint . --fix" 16 | }, 17 | "dependencies": { 18 | "@gensx/core": "^0.4.0", 19 | "@gensx/anthropic": "^0.2.0", 20 | "zod": "^3.24.2" 21 | }, 22 | "devDependencies": { 23 | "@types/node": "^22", 24 | "tsx": "^4.19.2", 25 | "typescript": "^5.7.2" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /examples/anthropic-examples/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ESNext", 4 | "module": "NodeNext", 5 | "lib": ["ESNext", "DOM"], 6 | "strict": true, 7 | "esModuleInterop": true, 8 | "skipLibCheck": true, 9 | "forceConsistentCasingInFileNames": true, 10 | "moduleResolution": "NodeNext", 11 | "resolveJsonModule": true, 12 | "isolatedModules": true, 13 | "outDir": "./dist" 14 | }, 15 | "include": ["./src/**/*.ts"], 16 | "exclude": ["node_modules"] 17 | } 18 | -------------------------------------------------------------------------------- /examples/blog-writer/eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import rootConfig from "../../eslint.config.mjs"; 2 | import examplesConfig from "../eslint.config.mjs"; 3 | 4 | export default [ 5 | ...rootConfig, 6 | ...examplesConfig, 7 | { 8 | files: ["**/*.{js,mjs,cjs,jsx,ts,tsx}"], 9 | languageOptions: { 10 | parserOptions: { 11 | tsconfigRootDir: import.meta.dirname, 12 | project: "./tsconfig.json", 13 | }, 14 | }, 15 | }, 16 | ]; 17 | -------------------------------------------------------------------------------- /examples/blog-writer/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@examples/blog-writer", 3 | "private": true, 4 | "version": "0.0.0", 5 | "type": "module", 6 | "engines": { 7 | "node": ">=18.0.0" 8 | }, 9 | "scripts": { 10 | "dev": "tsx ./src/index.ts", 11 | "start": "npx gensx start ./src/workflows.ts", 12 | "build": "tsc", 13 | "deploy": "npx gensx deploy -e OPENAI_API_KEY ./src/workflows.ts", 14 | "lint": "eslint .", 15 | "lint:fix": "eslint . --fix" 16 | }, 17 | "dependencies": { 18 | "@gensx/core": "^0.4.0", 19 | "@gensx/openai": "^0.2.0", 20 | "openai": "^4.0.0", 21 | "zod": "^3.24.2" 22 | }, 23 | "devDependencies": { 24 | "@types/node": "^22", 25 | "tsx": "^4.19.2", 26 | "typescript": "^5.7.2" 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /examples/blog-writer/src/index.ts: -------------------------------------------------------------------------------- 1 | import { WriteBlogWorkflow } from "./workflows.js"; 2 | 3 | const prompt = process.argv[2] || "Write a blog post about the future of AI"; 4 | 5 | async function main() { 6 | console.log("\n🚀 Starting blog writing workflow"); 7 | console.log(`Prompt: ${prompt}`); 8 | 9 | const stream = await WriteBlogWorkflow({ prompt }); 10 | for await (const chunk of stream) { 11 | process.stdout.write(chunk); 12 | } 13 | console.log("\n✅ Blog writing complete"); 14 | } 15 | 16 | main().catch(console.error); 17 | -------------------------------------------------------------------------------- /examples/blog-writer/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ESNext", 4 | "module": "NodeNext", 5 | "lib": ["ESNext", "DOM"], 6 | "strict": true, 7 | "esModuleInterop": true, 8 | "skipLibCheck": true, 9 | "forceConsistentCasingInFileNames": true, 10 | "moduleResolution": "NodeNext", 11 | "resolveJsonModule": true, 12 | "isolatedModules": true, 13 | "outDir": "./dist" 14 | }, 15 | "include": ["./src/**/*.ts"], 16 | "exclude": ["node_modules"] 17 | } 18 | -------------------------------------------------------------------------------- /examples/chat-memory/.gitignore: -------------------------------------------------------------------------------- 1 | chat-memory -------------------------------------------------------------------------------- /examples/chat-memory/eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import rootConfig from "../../eslint.config.mjs"; 2 | import examplesConfig from "../eslint.config.mjs"; 3 | 4 | export default [ 5 | ...rootConfig, 6 | ...examplesConfig, 7 | { 8 | files: ["**/*.{js,mjs,cjs,jsx,ts,tsx}"], 9 | languageOptions: { 10 | parserOptions: { 11 | tsconfigRootDir: import.meta.dirname, 12 | project: "./tsconfig.json", 13 | }, 14 | }, 15 | }, 16 | ]; 17 | -------------------------------------------------------------------------------- /examples/chat-memory/gensx.yaml: -------------------------------------------------------------------------------- 1 | projectName: chat-memory 2 | -------------------------------------------------------------------------------- /examples/chat-memory/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@examples/chat-memory", 3 | "private": true, 4 | "version": "0.0.0", 5 | "type": "module", 6 | "engines": { 7 | "node": ">=18.0.0" 8 | }, 9 | "description": "Use GenSX to create a chat completion", 10 | "scripts": { 11 | "dev": "tsx ./src/index.ts", 12 | "start": "npx gensx start ./src/workflows.ts", 13 | "build": "tsc", 14 | "deploy": "npx gensx deploy -e OPENAI_API_KEY ./src/workflows.ts", 15 | "lint": "eslint .", 16 | "lint:fix": "eslint . --fix" 17 | }, 18 | "dependencies": { 19 | "@ai-sdk/openai": "^1.3.22", 20 | "@gensx/core": "^0.4.0", 21 | "@gensx/storage": "^0.1.1", 22 | "@gensx/vercel-ai": "^0.2.0", 23 | "ai": "^4.2.10", 24 | "openai": "^4.87.4", 25 | "zod": "^3.24.2" 26 | }, 27 | "devDependencies": { 28 | "@types/node": "^22", 29 | "tsx": "^4.19.2", 30 | "typescript": "^5.7.2" 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /examples/chat-memory/request.json: -------------------------------------------------------------------------------- 1 | { 2 | "threadId": "thread-1", 3 | "userInput": "What is the capital of paris?" 4 | } 5 | -------------------------------------------------------------------------------- /examples/chat-memory/src/index.ts: -------------------------------------------------------------------------------- 1 | import { ChatMemoryWorkflow } from "./workflows.js"; 2 | 3 | // Run the workflow with a specific thread ID 4 | const threadId = process.argv[2] || "default-thread"; 5 | const userInput = 6 | process.argv[3] || "Hi there! Tell me something interesting about my thread."; 7 | 8 | console.log(`Using thread: ${threadId}`); 9 | console.log(`User input: ${userInput}`); 10 | 11 | const result = await ChatMemoryWorkflow({ 12 | userInput, 13 | threadId, 14 | }); 15 | 16 | console.log("\nAssistant response:"); 17 | console.log(result); 18 | -------------------------------------------------------------------------------- /examples/chat-memory/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ESNext", 4 | "module": "NodeNext", 5 | "lib": ["ESNext", "DOM"], 6 | "strict": true, 7 | "esModuleInterop": true, 8 | "skipLibCheck": true, 9 | "forceConsistentCasingInFileNames": true, 10 | "moduleResolution": "NodeNext", 11 | "resolveJsonModule": true, 12 | "isolatedModules": true, 13 | "outDir": "./dist" 14 | }, 15 | "include": ["./src/**/*.ts"], 16 | "exclude": ["node_modules"] 17 | } 18 | -------------------------------------------------------------------------------- /examples/commonjs-compatibility/README.md: -------------------------------------------------------------------------------- 1 | # CommonJS Compatibility Example 2 | 3 | This example demonstrates how to use GenSX packages with CommonJS modules. It shows that GenSX packages support both ESM (the default) and CommonJS format. 4 | 5 | ## The Example 6 | 7 | This example has typescript configured with `moduleResolution: "Node"` and `module: "esnext"`. It also has a `js` file that uses the `require` syntax to import the GenSX packages. 8 | 9 | This demonstrates usage of the GenSX packages in a CommonJS environment. 10 | 11 | ## Running the typescript example 12 | 13 | ```bash 14 | pnpm start:ts 15 | ``` 16 | 17 | ## Running the pure CommonJS example 18 | 19 | ```bash 20 | pnpm start:pure 21 | ``` 22 | -------------------------------------------------------------------------------- /examples/commonjs-compatibility/cjs-jsx.tsx: -------------------------------------------------------------------------------- 1 | // JSX example that will be compiled to CommonJS 2 | import { Component, Workflow } from "@gensx/core"; 3 | 4 | // Confirm we're using CommonJS at runtime 5 | console.log("Module type: CommonJS"); 6 | 7 | // Create a simple component that uses props 8 | const Greeter = Component<{ name: string }, string>("Greeter", (props) => { 9 | return `Hello, ${props.name}! This message was generated using CommonJS + JSX.`; 10 | }); 11 | 12 | // Create a component that composes other components using JSX 13 | const App = Component, string[]>("App", async () => { 14 | return [ 15 | await Greeter.run({ name: "World" }), 16 | await Greeter.run({ name: "CommonJS" }), 17 | ]; 18 | }); 19 | 20 | // Run the example 21 | async function main() { 22 | console.log("Running workflow..."); 23 | const workflow = Workflow("CommonJSWorkflow", App); 24 | const results = await workflow.run({}); 25 | console.log("Results:", results); 26 | return results; 27 | } 28 | 29 | // Export for testing 30 | module.exports = main; 31 | -------------------------------------------------------------------------------- /examples/commonjs-compatibility/eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import rootConfig from "../../eslint.config.mjs"; 2 | import examplesConfig from "../eslint.config.mjs"; 3 | 4 | export default [ 5 | ...rootConfig, 6 | ...examplesConfig, 7 | { 8 | files: ["**/*.{js,mjs,cjs,jsx,ts,tsx}"], 9 | languageOptions: { 10 | parserOptions: { 11 | tsconfigRootDir: import.meta.dirname, 12 | project: "./tsconfig.json", 13 | }, 14 | }, 15 | rules: { 16 | "no-console": "off", 17 | }, 18 | }, 19 | ]; 20 | -------------------------------------------------------------------------------- /examples/commonjs-compatibility/index.tsx: -------------------------------------------------------------------------------- 1 | import * as gensx from "@gensx/core"; 2 | 3 | const RespondToInput = gensx.Component<{ input: string }, string>( 4 | "RespondToInput", 5 | ({ input }) => { 6 | return input.toUpperCase(); 7 | }, 8 | ); 9 | 10 | const workflow = gensx.Workflow("RespondToInputWorkflow", RespondToInput); 11 | 12 | // Main function to run examples 13 | async function main() { 14 | const result = await workflow.run({ input: "Hello, world!" }); 15 | console.log(result); 16 | } 17 | 18 | main().catch(console.error); 19 | -------------------------------------------------------------------------------- /examples/commonjs-compatibility/nodemon.json: -------------------------------------------------------------------------------- 1 | { 2 | "watch": ["*.ts", "*.tsx"], 3 | "exec": "tsx ./index.tsx", 4 | "ext": "ts,tsx,json" 5 | } 6 | -------------------------------------------------------------------------------- /examples/commonjs-compatibility/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@examples/commonjs-compatibility", 3 | "private": true, 4 | "version": "0.0.0", 5 | "engines": { 6 | "node": ">=18.0.0" 7 | }, 8 | "type": "commonjs", 9 | "scripts": { 10 | "dev": "nodemon", 11 | "start:ts": "tsx index.tsx", 12 | "start": "node ./dist/index.js", 13 | "start:pure": "node ./pure-commonjs.js", 14 | "build": "tsc", 15 | "build:jsx": "tsc cjs-jsx.tsx --outDir dist --module commonjs --jsx react-jsx --jsxImportSource @gensx/core --moduleResolution node --target es2022", 16 | "start:jsx": "node dist/cjs-jsx.js", 17 | "test": "pnpm run build:jsx && node test/verify-commonjs.js", 18 | "lint": "eslint .", 19 | "lint:fix": "eslint . --fix" 20 | }, 21 | "dependencies": { 22 | "@gensx/core": "0.3.13", 23 | "zod": "catalog:" 24 | }, 25 | "devDependencies": { 26 | "@types/node": "catalog:examples", 27 | "nodemon": "catalog:", 28 | "tsx": "catalog:", 29 | "typescript": "catalog:" 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /examples/commonjs-compatibility/test/verify-commonjs.js: -------------------------------------------------------------------------------- 1 | // Test script to verify CommonJS compatibility 2 | const assert = require("assert"); 3 | 4 | // Import the main function from our CommonJS example 5 | const main = require("../dist/cjs-jsx.js"); 6 | 7 | async function runTest() { 8 | try { 9 | // Expected results from our workflow 10 | const expectedResults = [ 11 | "Hello, World! This message was generated using CommonJS + JSX.", 12 | "Hello, CommonJS! This message was generated using CommonJS + JSX.", 13 | ]; 14 | 15 | // Run the workflow and get results directly 16 | const actualResults = await main(); 17 | 18 | // Verify the results match exactly 19 | assert.deepStrictEqual( 20 | actualResults, 21 | expectedResults, 22 | "Results do not match expected output", 23 | ); 24 | 25 | console.log("✓ CommonJS compatibility test passed"); 26 | } catch (err) { 27 | console.error("Test failed:", err); 28 | throw err; 29 | } 30 | } 31 | 32 | // Run the test 33 | runTest(); 34 | -------------------------------------------------------------------------------- /examples/commonjs-compatibility/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.base.json", 3 | "compilerOptions": { 4 | "moduleResolution": "node", 5 | "module": "commonjs", 6 | "jsx": "react-jsx", 7 | "jsxImportSource": "@gensx/core", 8 | "outDir": "./dist", 9 | "baseUrl": ".", 10 | "paths": { 11 | "@gensx/core/jsx-runtime": [ 12 | "./node_modules/@gensx/core/dist/cjs/jsx-runtime" 13 | ] 14 | } 15 | }, 16 | "include": ["*.tsx", "*.ts"], 17 | "exclude": ["node_modules", "dist"] 18 | } 19 | -------------------------------------------------------------------------------- /examples/deep-research/eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import rootConfig from "../../eslint.config.mjs"; 2 | import examplesConfig from "../eslint.config.mjs"; 3 | 4 | export default [ 5 | ...rootConfig, 6 | ...examplesConfig, 7 | { 8 | files: ["**/*.{js,mjs,cjs,jsx,ts,tsx}"], 9 | languageOptions: { 10 | parserOptions: { 11 | tsconfigRootDir: import.meta.dirname, 12 | project: "./tsconfig.json", 13 | }, 14 | }, 15 | }, 16 | ]; 17 | -------------------------------------------------------------------------------- /examples/deep-research/gensx.yaml: -------------------------------------------------------------------------------- 1 | projectName: deep-research -------------------------------------------------------------------------------- /examples/deep-research/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@examples/deep-research", 3 | "private": true, 4 | "version": "0.0.0", 5 | "type": "module", 6 | "engines": { 7 | "node": ">=18.0.0" 8 | }, 9 | "scripts": { 10 | "dev": "tsx ./src/index.ts", 11 | "start": "npx gensx start ./src/workflows.ts", 12 | "build": "tsc", 13 | "deploy": "npx gensx deploy -e OPENAI_API_KEY -e FIRECRAWL_API_KEY ./src/workflows.ts", 14 | "lint": "eslint .", 15 | "lint:fix": "eslint . --fix" 16 | }, 17 | "dependencies": { 18 | "@ai-sdk/openai": "^1.3.22", 19 | "@gensx/core": "^0.4.0", 20 | "@gensx/vercel-ai": "^0.2.0", 21 | "@mendable/firecrawl-js": "^1.21.0", 22 | "ai": "^4.2.10", 23 | "openai": "^4.87.4", 24 | "node-fetch": "^3.3.2", 25 | "xml2js": "^0.6.2", 26 | "zod": "^3.24.2" 27 | }, 28 | "devDependencies": { 29 | "@types/node": "^22", 30 | "@types/xml2js": "^0.4.14", 31 | "tsx": "^4.19.2", 32 | "typescript": "^5.7.2" 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /examples/deep-research/src/firecrawl.ts: -------------------------------------------------------------------------------- 1 | import * as gensx from "@gensx/core"; 2 | import FirecrawlApp from "@mendable/firecrawl-js"; 3 | 4 | interface ScrapePageProps { 5 | url: string; 6 | } 7 | 8 | export const ScrapePage = gensx.Component( 9 | "ScrapePage", 10 | async ({ url }: ScrapePageProps): Promise => { 11 | const client = new FirecrawlApp({ 12 | apiKey: process.env.FIRECRAWL_API_KEY, 13 | }); 14 | 15 | const result = await client.scrapeUrl(url, { 16 | formats: ["markdown"], 17 | timeout: 40000, 18 | }); 19 | 20 | if (!result.success || !result.markdown) { 21 | throw new Error(`Failed to scrape url: ${url}`); 22 | } 23 | 24 | return result.markdown; 25 | }, 26 | ); 27 | -------------------------------------------------------------------------------- /examples/deep-research/src/index.ts: -------------------------------------------------------------------------------- 1 | import { DeepResearch } from "./workflows.js"; 2 | 3 | async function main() { 4 | const prompt = 5 | process.argv[2] || 6 | "find research comparing the writing style of humans and LLMs. We want to figure out how to quantify the differences."; 7 | console.log("\n🚀 Starting deep research workflow with prompt: ", prompt); 8 | const result = await DeepResearch({ prompt }); 9 | 10 | console.log("\n\n"); 11 | console.log("=".repeat(50)); 12 | console.log("Final Report"); 13 | console.log("=".repeat(50)); 14 | console.log(JSON.stringify(result, null, 2)); 15 | } 16 | 17 | main().catch(console.error); 18 | -------------------------------------------------------------------------------- /examples/deep-research/src/queryGenerator.ts: -------------------------------------------------------------------------------- 1 | import { openai } from "@ai-sdk/openai"; 2 | import * as gensx from "@gensx/core"; 3 | import { generateObject } from "@gensx/vercel-ai"; 4 | import { z } from "zod"; 5 | 6 | export interface GenerateQueriesProps { 7 | prompt: string; 8 | } 9 | 10 | export interface GenerateQueriesOutput { 11 | queries: string[]; 12 | } 13 | 14 | export const GenerateQueries = gensx.Component( 15 | "GenerateQueries", 16 | async ({ prompt }: GenerateQueriesProps): Promise => { 17 | const systemMessage = `You are a helpful research assistant. 18 | 19 | Instructions: 20 | - You will be given a prompt and your job is to return a list of arxiv search queries 21 | - Please write between 1 and 3 queries 22 | 23 | Output Format: 24 | Please return json with the following format: 25 | { 26 | "queries": ["query1", "query2", "query3"] 27 | }`; 28 | 29 | const response = await generateObject({ 30 | model: openai("gpt-4o-mini"), 31 | messages: [ 32 | { 33 | role: "system", 34 | content: systemMessage, 35 | }, 36 | { role: "user", content: prompt }, 37 | ], 38 | schema: z.object({ 39 | queries: z.array(z.string()), 40 | }), 41 | }); 42 | 43 | return { queries: response.object.queries }; 44 | }, 45 | ); 46 | -------------------------------------------------------------------------------- /examples/deep-research/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ESNext", 4 | "module": "NodeNext", 5 | "lib": ["ESNext", "DOM"], 6 | "strict": true, 7 | "esModuleInterop": true, 8 | "skipLibCheck": true, 9 | "forceConsistentCasingInFileNames": true, 10 | "moduleResolution": "NodeNext", 11 | "resolveJsonModule": true, 12 | "isolatedModules": true, 13 | "outDir": "./dist" 14 | }, 15 | "include": ["./src/**/*.ts"], 16 | "exclude": ["node_modules"] 17 | } 18 | -------------------------------------------------------------------------------- /examples/eslint.config.mjs: -------------------------------------------------------------------------------- 1 | export default [ 2 | { 3 | files: ["**/*.ts", "**/*.tsx"], 4 | rules: { 5 | "@typescript-eslint/no-empty-object-type": "off", 6 | "@typescript-eslint/no-unsafe-argument": "off", 7 | "@typescript-eslint/no-unsafe-assignment": "off", 8 | "@typescript-eslint/no-unsafe-call": "off", 9 | "@typescript-eslint/no-unsafe-member-access": "off", 10 | "@typescript-eslint/no-unsafe-return": "off", 11 | "no-console": "off", 12 | "node/no-unsupported-features/es-syntax": "off", 13 | }, 14 | }, 15 | ]; 16 | -------------------------------------------------------------------------------- /examples/groq-deepseek/eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import rootConfig from "../../eslint.config.mjs"; 2 | import examplesConfig from "../eslint.config.mjs"; 3 | 4 | export default [ 5 | ...rootConfig, 6 | ...examplesConfig, 7 | { 8 | files: ["**/*.{js,mjs,cjs,jsx,ts,tsx}"], 9 | languageOptions: { 10 | parserOptions: { 11 | tsconfigRootDir: import.meta.dirname, 12 | project: "./tsconfig.json", 13 | }, 14 | }, 15 | }, 16 | ]; 17 | -------------------------------------------------------------------------------- /examples/groq-deepseek/gensx.yaml: -------------------------------------------------------------------------------- 1 | projectName: groq-deepseek -------------------------------------------------------------------------------- /examples/groq-deepseek/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@examples/groq-deepseek", 3 | "private": true, 4 | "version": "0.0.0", 5 | "type": "module", 6 | "engines": { 7 | "node": ">=18.0.0" 8 | }, 9 | "description": "Use Groq DeepSeek R1 Distilled to write a blog post", 10 | "scripts": { 11 | "dev": "tsx ./src/index.ts", 12 | "start": "npx gensx start ./src/workflows.ts", 13 | "build": "tsc", 14 | "deploy": "npx gensx deploy -e GROQ_API_KEY ./src/workflows.ts", 15 | "lint": "eslint .", 16 | "lint:fix": "eslint . --fix" 17 | }, 18 | "dependencies": { 19 | "@gensx/core": "^0.4.0", 20 | "@gensx/openai": "^0.2.0" 21 | }, 22 | "devDependencies": { 23 | "@types/node": "^22", 24 | "tsx": "^4.19.2", 25 | "typescript": "^5.7.2" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /examples/groq-deepseek/src/index.ts: -------------------------------------------------------------------------------- 1 | import { GroqDeepSeekR1Completion } from "./workflows.js"; 2 | 3 | const result = await GroqDeepSeekR1Completion({ 4 | prompt: "Write me a blog post about the future of AI.", 5 | }); 6 | 7 | console.log("\n🧠 === THINKING PROCESS === 🧠\n"); 8 | console.log(result.thinking); 9 | console.log("\n🚀 === FINAL OUTPUT === 🚀\n"); 10 | console.log(result.completion); 11 | -------------------------------------------------------------------------------- /examples/groq-deepseek/src/workflows.ts: -------------------------------------------------------------------------------- 1 | import * as gensx from "@gensx/core"; 2 | import { OpenAI } from "@gensx/openai"; 3 | 4 | const apiKey = process.env.GROQ_API_KEY; 5 | if (!apiKey) { 6 | throw new Error("GROQ_API_KEY environment variable is not set"); 7 | } 8 | 9 | const openai = new OpenAI({ 10 | apiKey, 11 | baseURL: "https://api.groq.com/openai/v1", 12 | }); 13 | 14 | export interface GroqDeepSeekR1CompletionProps { 15 | prompt: string; 16 | } 17 | 18 | export interface GroqDeepSeekR1CompletionOutput { 19 | thinking: string; 20 | completion: string; 21 | } 22 | 23 | export const GroqDeepSeekR1Completion = gensx.Workflow( 24 | "GroqDeepSeekR1Completion", 25 | async ({ 26 | prompt, 27 | }: GroqDeepSeekR1CompletionProps): Promise => { 28 | const response = await openai.chat.completions.create({ 29 | model: "deepseek-r1-distill-llama-70b", 30 | messages: [{ role: "user", content: prompt }], 31 | stream: false, 32 | }); 33 | 34 | const content = response.choices[0].message.content ?? ""; 35 | const thinkRegex = /(.*?)<\/think>/s; 36 | const thinkExec = thinkRegex.exec(content); 37 | const thinking = thinkExec ? thinkExec[1].trim() : ""; 38 | const completion = content.replace(thinkRegex, "").trim(); 39 | 40 | return { 41 | thinking, 42 | completion, 43 | }; 44 | }, 45 | ); 46 | -------------------------------------------------------------------------------- /examples/groq-deepseek/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ESNext", 4 | "module": "NodeNext", 5 | "lib": ["ESNext", "DOM"], 6 | "strict": true, 7 | "esModuleInterop": true, 8 | "skipLibCheck": true, 9 | "forceConsistentCasingInFileNames": true, 10 | "moduleResolution": "NodeNext", 11 | "resolveJsonModule": true, 12 | "isolatedModules": true, 13 | "rootDir": "./src", 14 | "outDir": "./dist", 15 | "plugins": [ 16 | { 17 | "name": "ts-function-decorator-ls" 18 | } 19 | ] 20 | }, 21 | "include": ["./*.ts", "./**/*.ts"], 22 | "exclude": ["node_modules", "dist"] 23 | } 24 | -------------------------------------------------------------------------------- /examples/hacker-news-analyzer/.gitignore: -------------------------------------------------------------------------------- 1 | hn_analysis_report.md 2 | hn_analysis_tweet.txt 3 | -------------------------------------------------------------------------------- /examples/hacker-news-analyzer/eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import rootConfig from "../../eslint.config.mjs"; 2 | import examplesConfig from "../eslint.config.mjs"; 3 | 4 | export default [ 5 | ...rootConfig, 6 | ...examplesConfig, 7 | { 8 | files: ["**/*.{js,mjs,cjs,jsx,ts,tsx}"], 9 | languageOptions: { 10 | parserOptions: { 11 | tsconfigRootDir: import.meta.dirname, 12 | project: "./tsconfig.json", 13 | }, 14 | }, 15 | }, 16 | ]; 17 | -------------------------------------------------------------------------------- /examples/hacker-news-analyzer/gensx.yaml: -------------------------------------------------------------------------------- 1 | projectName: hacker-news-analyzer 2 | -------------------------------------------------------------------------------- /examples/hacker-news-analyzer/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@examples/hacker-news-analyzer", 3 | "private": true, 4 | "version": "0.0.0", 5 | "type": "module", 6 | "engines": { 7 | "node": ">=18.0.0" 8 | }, 9 | "scripts": { 10 | "dev": "tsx ./src/index.ts", 11 | "start": "npx gensx start ./src/workflows.ts", 12 | "build": "tsc", 13 | "deploy": "npx gensx deploy -e OPENAI_API_KEY ./src/workflows.ts", 14 | "lint": "eslint .", 15 | "lint:fix": "eslint . --fix" 16 | }, 17 | "dependencies": { 18 | "@gensx/core": "^0.4.0", 19 | "@gensx/openai": "^0.2.0" 20 | }, 21 | "devDependencies": { 22 | "@types/node": "^20", 23 | "tsx": "^4.19.2", 24 | "typescript": "^5.8" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /examples/hacker-news-analyzer/src/index.ts: -------------------------------------------------------------------------------- 1 | import fs from "fs/promises"; 2 | 3 | import { AnalyzeHackerNewsTrends } from "./workflows.js"; 4 | 5 | async function main() { 6 | console.log("\n🚀 Starting HN analysis workflow..."); 7 | 8 | // Directly await the decorated workflow function 9 | const { report, tweet } = await AnalyzeHackerNewsTrends({ 10 | postCount: 500, 11 | }); 12 | 13 | // Write outputs to files 14 | await fs.writeFile("hn_analysis_report.md", report); 15 | await fs.writeFile("hn_analysis_tweet.txt", tweet); 16 | console.log( 17 | "✅ Analysis complete! Check hn_analysis_report.md and hn_analysis_tweet.txt", 18 | ); 19 | } 20 | 21 | await main().catch(console.error); 22 | -------------------------------------------------------------------------------- /examples/hacker-news-analyzer/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ESNext", 4 | "module": "NodeNext", 5 | "lib": ["ESNext", "DOM"], 6 | "strict": true, 7 | "esModuleInterop": true, 8 | "skipLibCheck": true, 9 | "forceConsistentCasingInFileNames": true, 10 | "moduleResolution": "NodeNext", 11 | "resolveJsonModule": true, 12 | "isolatedModules": true, 13 | "outDir": "./dist" 14 | }, 15 | "include": ["./src/**/*.ts"], 16 | "exclude": ["node_modules"] 17 | } 18 | -------------------------------------------------------------------------------- /examples/llm-games/README.md: -------------------------------------------------------------------------------- 1 | # LLM Games - Tic-Tac-Toe 2 | 3 | This example allows you to run a Tic-Tac-Toe tournament between two LLMs or an LLM and a computer. You can see the full results of our tournament runs in [this blog post](https://gensx.com/blog/llm-tic-tac-toe). 4 | 5 | ## Usage 6 | 7 | ### Running the example 8 | 9 | ```bash 10 | # Install dependencies 11 | pnpm install 12 | 13 | # Set your OpenAI API key or any relevant key 14 | export OPENAI_API_KEY= 15 | 16 | # Run the example 17 | pnpm run start 18 | ``` 19 | 20 | ### Updating the tournament 21 | 22 | By default, the tournament will run 10 games between `gpt-4o-mini` and the `basic` computer strategy in index.tsx. 23 | 24 | #### Players 25 | 26 | You can also change the different players in the `index.tsx` file. 27 | 28 | There are two computer strategies supported: "random" and "basic". 29 | 30 | ```tsx 31 | const player2: Player = new Player({ 32 | type: "basic", 33 | }); 34 | ``` 35 | 36 | You can use any anthropic model or any openai compatible model. 37 | 38 | ```tsx 39 | const player1: Player = new Player({ 40 | model: "claude-3-5-haiku-latest", 41 | type: "llm", 42 | strategy: "basic", 43 | provider: { 44 | apiKey: process.env.ANTHROPIC_API_KEY!, 45 | type: "anthropic", 46 | }, 47 | }); 48 | ``` 49 | -------------------------------------------------------------------------------- /examples/llm-games/eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import rootConfig from "../../eslint.config.mjs"; 2 | import examplesConfig from "../eslint.config.mjs"; 3 | 4 | export default [ 5 | ...rootConfig, 6 | ...examplesConfig, 7 | { 8 | files: ["**/*.{js,mjs,cjs,jsx,ts,tsx}"], 9 | languageOptions: { 10 | parserOptions: { 11 | tsconfigRootDir: import.meta.dirname, 12 | project: "./tsconfig.json", 13 | }, 14 | }, 15 | }, 16 | ]; 17 | -------------------------------------------------------------------------------- /examples/llm-games/nodemon.json: -------------------------------------------------------------------------------- 1 | { 2 | "watch": [".", ".env", "../../packages/**/dist/**"], 3 | "exec": "tsx ./index.tsx", 4 | "ext": "ts, tsx, js, json" 5 | } 6 | -------------------------------------------------------------------------------- /examples/llm-games/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@examples/llm-games", 3 | "private": true, 4 | "version": "0.0.0", 5 | "type": "module", 6 | "engines": { 7 | "node": ">=18.0.0" 8 | }, 9 | "description": "Use GenSX to enable models to play LLM against each other", 10 | "scripts": { 11 | "dev": "nodemon", 12 | "start": "tsx ./index.tsx", 13 | "build": "tsc", 14 | "lint": "eslint .", 15 | "lint:fix": "eslint . --fix" 16 | }, 17 | "dependencies": { 18 | "@gensx/anthropic": "0.1.17", 19 | "@gensx/openai": "0.1.28", 20 | "@gensx/core": "0.3.13", 21 | "zod": "catalog:" 22 | }, 23 | "devDependencies": { 24 | "@types/node": "catalog:examples", 25 | "nodemon": "catalog:", 26 | "tsx": "catalog:", 27 | "typescript": "catalog:" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /examples/llm-games/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.base.json", 3 | "compilerOptions": { 4 | "outDir": "./dist" 5 | }, 6 | "include": ["./*.ts", "./*.tsx", "./**/*.ts", "./**/*.tsx"], 7 | "exclude": ["node_modules"] 8 | } 9 | -------------------------------------------------------------------------------- /examples/nextjs-ai-chatbot-template/README.md: -------------------------------------------------------------------------------- 1 | # Next.js AI Chatbot with GenSX 2 | 3 | ![Screenshot](https://github.com/user-attachments/assets/1d56768b-ecc1-4949-bcf3-f9290bc8e9f5) 4 | 5 | This example demonstrates how to build an AI-powered chatbot using Next.js, the Vercel AI SDK, and GenSX. It showcases how to integrate GenSX workflows into a full-featured chat application. 6 | 7 | ## What it demonstrates 8 | 9 | - Integration of GenSX workflows into a Next.js application 10 | - Creating and using custom tools with GenSX workflows 11 | 12 | ## Full Example 13 | 14 | To work with the example fork the github repo: https://github.com/gensx-inc/nextjs-ai-chatbot-gensx. It has full instructions on how to run and update it to use new workflows and tools. 15 | 16 | This is an lightly updated version of ai-chatbot template from Vercel: [Next.js AI Chatbot Template repository](https://github.com/vercel/ai-chatbot). 17 | -------------------------------------------------------------------------------- /examples/open-router/eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import rootConfig from "../../eslint.config.mjs"; 2 | import examplesConfig from "../eslint.config.mjs"; 3 | 4 | export default [ 5 | ...rootConfig, 6 | ...examplesConfig, 7 | { 8 | files: ["**/*.{js,mjs,cjs,jsx,ts,tsx}"], 9 | languageOptions: { 10 | parserOptions: { 11 | tsconfigRootDir: import.meta.dirname, 12 | project: "./tsconfig.json", 13 | }, 14 | }, 15 | }, 16 | ]; 17 | -------------------------------------------------------------------------------- /examples/open-router/gensx.yaml: -------------------------------------------------------------------------------- 1 | projectName: open-router -------------------------------------------------------------------------------- /examples/open-router/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@examples/open-router", 3 | "private": true, 4 | "version": "0.0.1", 5 | "type": "module", 6 | "engines": { 7 | "node": ">=18.0.0" 8 | }, 9 | "description": "Example project leveraging OpenRouter for LLM inference.", 10 | "scripts": { 11 | "dev": "tsx ./src/index.ts", 12 | "start": "npx gensx start ./src/workflows.ts", 13 | "build": "tsc", 14 | "deploy": "npx gensx deploy -e OPENROUTER_API_KEY ./src/workflows.ts", 15 | "lint": "eslint .", 16 | "lint:fix": "eslint . --fix" 17 | }, 18 | "dependencies": { 19 | "@gensx/openai": "^0.2.0", 20 | "@gensx/core": "^0.4.0" 21 | }, 22 | "devDependencies": { 23 | "@types/node": "^22", 24 | "tsx": "^4.19.2", 25 | "typescript": "^5.7.2" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /examples/open-router/src/index.ts: -------------------------------------------------------------------------------- 1 | import { OpenRouterCompletion } from "./workflows.js"; 2 | 3 | const result = await OpenRouterCompletion({ 4 | userInput: "Write a short story about a cat that can fly.", 5 | }); 6 | 7 | console.log("\n🚀 === AI RESPONSE === 🚀\n"); 8 | console.log(result.response); 9 | -------------------------------------------------------------------------------- /examples/open-router/src/workflows.ts: -------------------------------------------------------------------------------- 1 | import * as gensx from "@gensx/core"; 2 | import { OpenAI } from "@gensx/openai"; 3 | 4 | const apiKey = process.env.OPENROUTER_API_KEY; 5 | if (!apiKey) { 6 | throw new Error("OPENROUTER_API_KEY environment variable is not set"); 7 | } 8 | 9 | const openai = new OpenAI({ 10 | apiKey, 11 | baseURL: "https://openrouter.ai/api/v1", 12 | }); 13 | 14 | export interface OpenRouterCompletionProps { 15 | userInput: string; 16 | } 17 | 18 | export interface OpenRouterCompletionOutput { 19 | response: string; 20 | } 21 | 22 | export const OpenRouterCompletion = gensx.Workflow( 23 | "OpenRouterCompletion", 24 | async ({ 25 | userInput, 26 | }: OpenRouterCompletionProps): Promise => { 27 | const response = await openai.chat.completions.create({ 28 | model: "anthropic/claude-3.7-sonnet", 29 | messages: [ 30 | { 31 | role: "system", 32 | content: "You are a helpful assistant. Respond to the user's input.", 33 | }, 34 | { role: "user", content: userInput }, 35 | ], 36 | stream: false, 37 | }); 38 | 39 | return { 40 | response: response.choices[0].message.content ?? "", 41 | }; 42 | }, 43 | ); 44 | -------------------------------------------------------------------------------- /examples/open-router/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ESNext", 4 | "module": "NodeNext", 5 | "lib": ["ESNext", "DOM"], 6 | "strict": true, 7 | "esModuleInterop": true, 8 | "skipLibCheck": true, 9 | "forceConsistentCasingInFileNames": true, 10 | "moduleResolution": "NodeNext", 11 | "resolveJsonModule": true, 12 | "isolatedModules": true, 13 | "outDir": "./dist" 14 | }, 15 | "include": ["./src/**/*.ts"], 16 | "exclude": ["node_modules"] 17 | } 18 | -------------------------------------------------------------------------------- /examples/openai-computer-use/README.md: -------------------------------------------------------------------------------- 1 | # OpenAI Computer Use Tool Example 2 | 3 | This example demonstrates how to use the OpenAI [computer use tool](https://platform.openai.com/docs/guides/tools-computer-use) with the [Responses API](https://platform.openai.com/docs/api-reference/responses) and GenSX. 4 | 5 | ## Setup 6 | 7 | You'll need to install Playwright to run this example. The model will interact with a chromium browser powered by Playwright to accomplish the task. 8 | 9 | ```bash 10 | # Install dependencies 11 | pnpm install 12 | 13 | # Build the example 14 | pnpm build 15 | 16 | # Install Playwright 17 | npx playwright install 18 | ``` 19 | 20 | ## Usage 21 | 22 | You can update the prompt in the `index.tsx` file to try out different tasks. 23 | 24 | ```bash 25 | # Set your OpenAI API key 26 | export OPENAI_API_KEY= 27 | 28 | # Run the example 29 | pnpm run start 30 | ``` 31 | -------------------------------------------------------------------------------- /examples/openai-computer-use/browserContext.tsx: -------------------------------------------------------------------------------- 1 | import * as gensx from "@gensx/core"; 2 | import { chromium, Page } from "playwright"; 3 | 4 | interface Browser { 5 | page?: Page; 6 | } 7 | 8 | // Create a context with a default value 9 | export const BrowserContext = gensx.createContext({ 10 | page: undefined, 11 | }); 12 | 13 | interface BrowserProviderProps { 14 | initialUrl: string; 15 | } 16 | 17 | // Export the provider component 18 | export const BrowserProvider = gensx.Component( 19 | "BrowserProvider", 20 | async ({ initialUrl }) => { 21 | const browser = await chromium.launch({ 22 | headless: false, 23 | chromiumSandbox: true, 24 | env: {}, 25 | args: ["--disable-extensions", "--disable-file-system"], 26 | }); 27 | const page = await browser.newPage(); 28 | await page.setViewportSize({ width: 1024, height: 768 }); 29 | await page.goto(initialUrl); 30 | 31 | return ; 32 | }, 33 | ); 34 | 35 | // Export a hook-like function to use the browser context 36 | export const useBrowser = () => gensx.useContext(BrowserContext); 37 | -------------------------------------------------------------------------------- /examples/openai-computer-use/eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import rootConfig from "../../eslint.config.mjs"; 2 | import examplesConfig from "../eslint.config.mjs"; 3 | 4 | export default [ 5 | ...rootConfig, 6 | ...examplesConfig, 7 | { 8 | files: ["**/*.{js,mjs,cjs,jsx,ts,tsx}"], 9 | languageOptions: { 10 | parserOptions: { 11 | tsconfigRootDir: import.meta.dirname, 12 | project: "./tsconfig.json", 13 | }, 14 | }, 15 | }, 16 | ]; 17 | -------------------------------------------------------------------------------- /examples/openai-computer-use/nodemon.json: -------------------------------------------------------------------------------- 1 | { 2 | "watch": [".", ".env", "../../packages/**/dist/**"], 3 | "exec": "tsx ./index.tsx", 4 | "ext": "ts, tsx, js, json" 5 | } 6 | -------------------------------------------------------------------------------- /examples/openai-computer-use/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@examples/openai-computer-use", 3 | "private": true, 4 | "version": "0.0.0", 5 | "type": "module", 6 | "engines": { 7 | "node": ">=18.0.0" 8 | }, 9 | "scripts": { 10 | "dev": "nodemon", 11 | "start": "tsx ./index.tsx", 12 | "build": "tsc", 13 | "lint": "eslint .", 14 | "lint:fix": "eslint . --fix" 15 | }, 16 | "dependencies": { 17 | "@gensx/core": "0.3.13", 18 | "@gensx/openai": "0.1.28", 19 | "openai": "catalog:", 20 | "playwright": "^1.51.1", 21 | "zod": "catalog:" 22 | }, 23 | "devDependencies": { 24 | "@types/node": "catalog:examples", 25 | "nodemon": "catalog:", 26 | "tsx": "catalog:", 27 | "typescript": "catalog:" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /examples/openai-computer-use/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.base.json", 3 | "compilerOptions": { 4 | "outDir": "./dist" 5 | }, 6 | "include": ["./*.ts", "./*.tsx", "./**/*.ts", "./**/*.tsx"], 7 | "exclude": ["node_modules"] 8 | } 9 | -------------------------------------------------------------------------------- /examples/openai-examples/eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import rootConfig from "../../eslint.config.mjs"; 2 | import examplesConfig from "../eslint.config.mjs"; 3 | 4 | export default [ 5 | ...rootConfig, 6 | ...examplesConfig, 7 | { 8 | files: ["**/*.{js,mjs,cjs,jsx,ts,tsx}"], 9 | languageOptions: { 10 | parserOptions: { 11 | tsconfigRootDir: import.meta.dirname, 12 | project: "./tsconfig.json", 13 | }, 14 | }, 15 | }, 16 | ]; 17 | -------------------------------------------------------------------------------- /examples/openai-examples/gensx.yaml: -------------------------------------------------------------------------------- 1 | projectName: openai-examples -------------------------------------------------------------------------------- /examples/openai-examples/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@examples/openai-examples", 3 | "private": true, 4 | "version": "0.0.0", 5 | "type": "module", 6 | "engines": { 7 | "node": ">=18.0.0" 8 | }, 9 | "description": "Use GenSX to create a chat completion", 10 | "scripts": { 11 | "dev": "tsx ./src/index.ts", 12 | "start": "npx gensx start ./src/workflows.ts", 13 | "build": "tsc", 14 | "deploy": "npx gensx deploy -e OPENAI_API_KEY ./src/workflows.ts", 15 | "lint": "eslint .", 16 | "lint:fix": "eslint . --fix" 17 | }, 18 | "dependencies": { 19 | "@gensx/openai": "^0.2.0", 20 | "@gensx/core": "^0.4.0", 21 | "openai": "^4.0.0", 22 | "zod": "^3.24.2" 23 | }, 24 | "devDependencies": { 25 | "@types/node": "^22", 26 | "tsx": "^4.19.2", 27 | "typescript": "^5.7.2" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /examples/openai-examples/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ESNext", 4 | "module": "NodeNext", 5 | "lib": ["ESNext", "DOM"], 6 | "strict": true, 7 | "esModuleInterop": true, 8 | "skipLibCheck": true, 9 | "forceConsistentCasingInFileNames": true, 10 | "moduleResolution": "NodeNext", 11 | "resolveJsonModule": true, 12 | "isolatedModules": true, 13 | "outDir": "./dist" 14 | }, 15 | "include": ["./src/**/*.ts"], 16 | "exclude": ["node_modules"] 17 | } 18 | -------------------------------------------------------------------------------- /examples/rag/eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import rootConfig from "../../eslint.config.mjs"; 2 | import examplesConfig from "../eslint.config.mjs"; 3 | 4 | export default [ 5 | ...rootConfig, 6 | ...examplesConfig, 7 | { 8 | files: ["**/*.{js,mjs,cjs,jsx,ts,tsx}"], 9 | languageOptions: { 10 | parserOptions: { 11 | tsconfigRootDir: import.meta.dirname, 12 | project: "./tsconfig.json", 13 | }, 14 | }, 15 | }, 16 | ]; 17 | -------------------------------------------------------------------------------- /examples/rag/gensx.yaml: -------------------------------------------------------------------------------- 1 | projectName: rag 2 | -------------------------------------------------------------------------------- /examples/rag/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@examples/rag", 3 | "private": true, 4 | "version": "0.0.0", 5 | "type": "module", 6 | "engines": { 7 | "node": ">=18.0.0" 8 | }, 9 | "description": "Retrieval Augmented Generation with GenSX and the useSearch hook", 10 | "scripts": { 11 | "dev": "tsx ./src/index.ts", 12 | "start": "npx gensx start ./src/workflows.ts", 13 | "build": "tsc", 14 | "deploy": "npx gensx deploy -e OPENAI_API_KEY ./src/workflows.ts", 15 | "lint": "eslint .", 16 | "lint:fix": "eslint . --fix" 17 | }, 18 | "dependencies": { 19 | "@ai-sdk/openai": "^1.3.22", 20 | "@gensx/core": "^0.4.0", 21 | "@gensx/storage": "^0.1.1", 22 | "@gensx/vercel-ai": "^0.2.0", 23 | "ai": "^4.2.10", 24 | "openai": "^4.87.4", 25 | "zod": "^3.24.2" 26 | }, 27 | "devDependencies": { 28 | "@types/node": "^22", 29 | "tsx": "^4.19.2", 30 | "typescript": "^5.7.2" 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /examples/rag/src/index.ts: -------------------------------------------------------------------------------- 1 | import { InitializeSearch, RagWorkflow } from "./workflows.js"; 2 | 3 | // Get the question from command line arguments 4 | const question = process.argv[2]; 5 | 6 | if (!question) { 7 | console.error("Please provide a question as a command line argument"); 8 | console.error('Example: pnpm start "Who has the highest batting average?"'); 9 | process.exit(1); 10 | } 11 | 12 | // First, initialize the database 13 | console.log("Initializing database..."); 14 | const initMessage = await InitializeSearch({}); 15 | console.log(initMessage); 16 | 17 | // Then run the query 18 | console.log("Processing your question..."); 19 | const result = await RagWorkflow({ 20 | question, 21 | }); 22 | 23 | console.log("Response:"); 24 | console.log(result); 25 | -------------------------------------------------------------------------------- /examples/rag/src/initialize.ts: -------------------------------------------------------------------------------- 1 | import { openai } from "@ai-sdk/openai"; 2 | import * as gensx from "@gensx/core"; 3 | import { useSearch } from "@gensx/storage"; 4 | import { embedMany } from "@gensx/vercel-ai"; 5 | 6 | const embeddingModel = openai.embedding("text-embedding-3-small"); 7 | 8 | export const InitializeSearch = gensx.Workflow("InitializeSearch", async () => { 9 | // useSearch will create the namespace automatically if it doesn't exist. 10 | const namespace = await useSearch("baseball"); 11 | 12 | const documents = [ 13 | { 14 | id: "1", 15 | text: "Marcus Bennett is a 1B for the Portland Pioneers", 16 | }, 17 | { 18 | id: "2", 19 | text: "Ethan Carter is a SS for the San Antonio Stallions", 20 | }, 21 | { 22 | id: "3", 23 | text: "Lucas Rivera is a OF for the Charlotte Cougars", 24 | }, 25 | ]; 26 | 27 | const embeddings = await embedMany({ 28 | model: embeddingModel, 29 | values: documents.map((doc) => doc.text), 30 | }); 31 | 32 | await namespace.write({ 33 | upsertRows: documents.map((doc, index) => ({ 34 | id: doc.id, 35 | vector: embeddings.embeddings[index], 36 | text: doc.text, 37 | })), 38 | distanceMetric: "cosine_distance", 39 | }); 40 | 41 | return "Search namespace initialized"; 42 | }); 43 | -------------------------------------------------------------------------------- /examples/rag/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ESNext", 4 | "module": "NodeNext", 5 | "lib": ["ESNext", "DOM"], 6 | "strict": true, 7 | "esModuleInterop": true, 8 | "skipLibCheck": true, 9 | "forceConsistentCasingInFileNames": true, 10 | "moduleResolution": "NodeNext", 11 | "resolveJsonModule": true, 12 | "isolatedModules": true, 13 | "outDir": "./dist" 14 | }, 15 | "include": ["./src/**/*.ts"], 16 | "exclude": ["node_modules"] 17 | } 18 | -------------------------------------------------------------------------------- /examples/reflection/eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import rootConfig from "../../eslint.config.mjs"; 2 | import examplesConfig from "../eslint.config.mjs"; 3 | 4 | export default [ 5 | ...rootConfig, 6 | ...examplesConfig, 7 | { 8 | files: ["**/*.{js,mjs,cjs,jsx,ts,tsx}"], 9 | languageOptions: { 10 | parserOptions: { 11 | tsconfigRootDir: import.meta.dirname, 12 | project: "./tsconfig.json", 13 | }, 14 | }, 15 | }, 16 | ]; 17 | -------------------------------------------------------------------------------- /examples/reflection/gensx.yaml: -------------------------------------------------------------------------------- 1 | projectName: reflection -------------------------------------------------------------------------------- /examples/reflection/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@examples/reflection", 3 | "private": true, 4 | "version": "0.0.0", 5 | "type": "module", 6 | "engines": { 7 | "node": ">=18.0.0" 8 | }, 9 | "scripts": { 10 | "dev": "tsx ./src/index.ts", 11 | "start": "npx gensx start ./src/workflows.ts", 12 | "build": "tsc", 13 | "deploy": "npx gensx deploy -e OPENAI_API_KEY ./src/workflows.ts", 14 | "lint": "eslint .", 15 | "lint:fix": "eslint . --fix" 16 | }, 17 | "dependencies": { 18 | "@ai-sdk/openai": "^1.3.22", 19 | "@gensx/core": "^0.4.0", 20 | "@gensx/vercel-ai": "^0.2.0", 21 | "zod": "^3.24.2", 22 | "ai": "^4.2.10" 23 | }, 24 | "devDependencies": { 25 | "@types/node": "^22", 26 | "tsx": "^4.19.2", 27 | "typescript": "^5.7.2" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /examples/reflection/src/index.ts: -------------------------------------------------------------------------------- 1 | import { ImproveTextWithReflection } from "./workflows.js"; 2 | 3 | async function main() { 4 | // Get text from command line arguments or use default text 5 | const userText = process.argv[2]; 6 | const defaultText = `We are a cutting-edge technology company leveraging bleeding-edge AI solutions to deliver best-in-class products to our customers. Our agile development methodology ensures we stay ahead of the curve with paradigm-shifting innovations. 7 | 8 | Our mission-critical systems utilize cloud-native architectures and next-generation frameworks to create synergistic solutions that drive digital transformation. By thinking outside the box, we empower stakeholders with scalable and future-proof applications that maximize ROI. 9 | 10 | Through our holistic approach to disruptive innovation, we create game-changing solutions that move the needle and generate impactful results. Our best-of-breed technology stack combined with our customer-centric focus allows us to ideate and iterate rapidly in this fast-paced market.`; 11 | 12 | const text = userText || defaultText; 13 | console.log("📝 Input text:\n", text); 14 | console.log("=".repeat(50)); 15 | 16 | const improvedText = await ImproveTextWithReflection({ text }); 17 | console.log("🎯 Final text:\n", improvedText); 18 | } 19 | 20 | main().catch(console.error); 21 | -------------------------------------------------------------------------------- /examples/reflection/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ESNext", 4 | "module": "NodeNext", 5 | "lib": ["ESNext", "DOM"], 6 | "strict": true, 7 | "esModuleInterop": true, 8 | "skipLibCheck": true, 9 | "forceConsistentCasingInFileNames": true, 10 | "moduleResolution": "NodeNext", 11 | "resolveJsonModule": true, 12 | "isolatedModules": true, 13 | "outDir": "./dist" 14 | }, 15 | "include": ["./src/**/*.ts"], 16 | "exclude": ["node_modules"] 17 | } 18 | -------------------------------------------------------------------------------- /examples/salty-ocean-model-comparison/README.md: -------------------------------------------------------------------------------- 1 | # Model Comparison - Why is the Ocean Salty? 2 | 3 | This example demonstrates how to use [GenSX](https://gensx.com) to compare responses from different AI models and providers to the same prompt. 4 | 5 | ## What This Example Does 6 | 7 | This application: 8 | 9 | 1. Takes the prompt "Why is the ocean salty?" 10 | 2. Sends it to multiple AI providers (OpenAI and Groq) 11 | 3. For each provider, gets responses from all available text generation models 12 | 4. Displays the results for comparison 13 | 14 | ## Prerequisites 15 | 16 | - Node.js 18 or higher 17 | - API keys for the providers you want to use: 18 | - OpenAI API key 19 | - Groq API key 20 | 21 | ## Getting Started 22 | 23 | 1. Install dependencies: 24 | 25 | ```bash 26 | npm install 27 | ``` 28 | 29 | 2. Set up your environment variables: 30 | 31 | Create a `.env` file with your API keys: 32 | 33 | ``` 34 | OPENAI_API_KEY=your_openai_api_key 35 | GROQ_API_KEY=your_groq_api_key 36 | ``` 37 | 38 | 3. Start the development server: 39 | 40 | ```bash 41 | npm run dev 42 | ``` 43 | 44 | 4. The application will run the workflow and display the model comparison results in the console. 45 | 46 | ## Customization 47 | 48 | You can modify `src/index.tsx` to: 49 | 50 | - Change the prompt 51 | - Add or remove providers 52 | - Adjust model filtering criteria 53 | - Change the output format 54 | -------------------------------------------------------------------------------- /examples/salty-ocean-model-comparison/eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import rootConfig from "../../eslint.config.mjs"; 2 | import examplesConfig from "../eslint.config.mjs"; 3 | 4 | export default [ 5 | ...rootConfig, 6 | ...examplesConfig, 7 | { 8 | files: ["**/*.{js,mjs,cjs,jsx,ts,tsx}"], 9 | languageOptions: { 10 | parserOptions: { 11 | tsconfigRootDir: import.meta.dirname, 12 | project: "./tsconfig.json", 13 | }, 14 | }, 15 | }, 16 | ]; 17 | -------------------------------------------------------------------------------- /examples/salty-ocean-model-comparison/nodemon.json: -------------------------------------------------------------------------------- 1 | { 2 | "watch": [".", ".env", "../../packages/**/dist/**"], 3 | "exec": "tsx ./src/index.tsx", 4 | "ext": "ts, tsx, js, json" 5 | } 6 | -------------------------------------------------------------------------------- /examples/salty-ocean-model-comparison/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@examples/salty-ocean-model-comparison", 3 | "private": true, 4 | "version": "0.0.1", 5 | "type": "module", 6 | "engines": { 7 | "node": ">=18.0.0" 8 | }, 9 | "scripts": { 10 | "dev": "nodemon", 11 | "start": "tsx ./src/index.tsx", 12 | "build": "tsc", 13 | "lint": "eslint .", 14 | "lint:fix": "eslint . --fix" 15 | }, 16 | "description": "Compare the performance of different models by asking them why the ocean is salty", 17 | "main": "index.js", 18 | "keywords": [], 19 | "author": "", 20 | "license": "ISC", 21 | "dependencies": { 22 | "@ai-sdk/openai": "^1.3.6", 23 | "@gensx/openai": "0.1.28", 24 | "@gensx/vercel-ai-sdk": "0.1.17", 25 | "@gensx/core": "0.3.13", 26 | "openai": "catalog:" 27 | }, 28 | "devDependencies": { 29 | "@types/node": "catalog:examples", 30 | "nodemon": "catalog:", 31 | "tsx": "catalog:", 32 | "typescript": "catalog:" 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /examples/salty-ocean-model-comparison/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.base.json", 3 | "compilerOptions": { 4 | "outDir": "./dist" 5 | }, 6 | "include": ["./*.ts", "./*.tsx", "./**/*.ts", "./**/*.tsx"], 7 | "exclude": ["node_modules"] 8 | } 9 | -------------------------------------------------------------------------------- /examples/self-modifying-code/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gensx-inc/gensx/1bc9c059cd7418c19fbe44ef85eb453fb9f74df5/examples/self-modifying-code/.gitignore -------------------------------------------------------------------------------- /examples/self-modifying-code/agent/tools/buildTool.tsx: -------------------------------------------------------------------------------- 1 | import { GSXTool } from "@gensx/anthropic"; 2 | import { serializeError } from "serialize-error"; 3 | import { z } from "zod"; 4 | 5 | import { validateBuild, type Workspace } from "../../workspace.js"; 6 | 7 | // Empty schema since we don't need any parameters 8 | const buildToolSchema = z.object({}); 9 | 10 | type BuildToolParams = z.infer; 11 | 12 | export function getBuildTool(workspace: Workspace) { 13 | return new GSXTool({ 14 | name: "build", 15 | description: 16 | "Build the project using pnpm build. Returns build output or error messages.", 17 | schema: buildToolSchema, 18 | run: async (_params: BuildToolParams) => { 19 | try { 20 | const output = await validateBuild(workspace); 21 | return output; 22 | } catch (error) { 23 | return { 24 | success: false, 25 | output: serializeError(error), 26 | }; 27 | } 28 | }, 29 | }); 30 | } 31 | -------------------------------------------------------------------------------- /examples/self-modifying-code/agent_context.json: -------------------------------------------------------------------------------- 1 | { 2 | "goalState": "Modify this codebase to improve your own capabilities so that you can make changes more rapidly and consistently. You should be moving towards a point where you can make changes to your own source code quickly and without mistakes.", 3 | "history": [] 4 | } 5 | -------------------------------------------------------------------------------- /examples/self-modifying-code/eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import rootConfig from "../../eslint.config.mjs"; 2 | import examplesConfig from "../eslint.config.mjs"; 3 | 4 | export default [ 5 | ...rootConfig, 6 | ...examplesConfig, 7 | { 8 | files: ["**/*.{js,mjs,cjs,jsx,ts,tsx}"], 9 | languageOptions: { 10 | parserOptions: { 11 | tsconfigRootDir: import.meta.dirname, 12 | project: "./tsconfig.json", 13 | }, 14 | }, 15 | }, 16 | ]; 17 | -------------------------------------------------------------------------------- /examples/self-modifying-code/nodemon.json: -------------------------------------------------------------------------------- 1 | { 2 | "watch": [".", ".env", "../../packages/**/dist/**"], 3 | "exec": "tsx ./index.tsx", 4 | "ext": "ts, tsx, js, json" 5 | } 6 | -------------------------------------------------------------------------------- /examples/self-modifying-code/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@examples/self-modifying-code", 3 | "private": true, 4 | "version": "0.0.0", 5 | "type": "module", 6 | "engines": { 7 | "node": ">=18.0.0", 8 | "pnpm": ">=9.0.0" 9 | }, 10 | "description": "Use GenSX to build a program that is capable of modifying itself", 11 | "scripts": { 12 | "dev": "nodemon", 13 | "start": "tsx ./index.tsx", 14 | "build": "tsc", 15 | "lint": "eslint .", 16 | "lint:fix": "eslint . --fix" 17 | }, 18 | "dependencies": { 19 | "@anthropic-ai/sdk": "^0.39.0", 20 | "@gensx/anthropic": "0.1.17", 21 | "@mendable/firecrawl-js": "^1.21.0", 22 | "@gensx/core": "0.3.13", 23 | "serialize-error": "^12.0.0", 24 | "zod": "catalog:" 25 | }, 26 | "devDependencies": { 27 | "@types/node": "catalog:examples", 28 | "nodemon": "catalog:", 29 | "tsx": "catalog:", 30 | "typescript": "catalog:" 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /examples/self-modifying-code/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.base.json", 3 | "compilerOptions": { 4 | "outDir": "./dist" 5 | }, 6 | "include": ["./*.ts", "./*.tsx", "./**/*.ts", "./**/*.tsx"], 7 | "exclude": ["node_modules"] 8 | } 9 | -------------------------------------------------------------------------------- /examples/text-to-sql/eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import rootConfig from "../../eslint.config.mjs"; 2 | import examplesConfig from "../eslint.config.mjs"; 3 | 4 | export default [ 5 | ...rootConfig, 6 | ...examplesConfig, 7 | { 8 | files: ["**/*.{js,mjs,cjs,jsx,ts,tsx}"], 9 | languageOptions: { 10 | parserOptions: { 11 | tsconfigRootDir: import.meta.dirname, 12 | project: "./tsconfig.json", 13 | }, 14 | }, 15 | }, 16 | ]; 17 | -------------------------------------------------------------------------------- /examples/text-to-sql/gensx.yaml: -------------------------------------------------------------------------------- 1 | projectName: text-to-sql 2 | -------------------------------------------------------------------------------- /examples/text-to-sql/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@examples/text-to-sql", 3 | "private": true, 4 | "version": "0.0.0", 5 | "type": "module", 6 | "engines": { 7 | "node": ">=18.0.0" 8 | }, 9 | "description": "Text to SQL with GenSX and the useDatabase hook", 10 | "scripts": { 11 | "dev": "tsx ./src/index.ts", 12 | "start": "npx gensx start ./src/workflows.ts", 13 | "build": "tsc", 14 | "deploy": "npx gensx deploy -e OPENAI_API_KEY ./src/workflows.ts", 15 | "lint": "eslint .", 16 | "lint:fix": "eslint . --fix" 17 | }, 18 | "dependencies": { 19 | "@ai-sdk/openai": "^1.3.22", 20 | "@gensx/core": "^0.4.0", 21 | "@gensx/storage": "^0.1.1", 22 | "@gensx/vercel-ai": "^0.2.0", 23 | "ai": "^4.2.10", 24 | "openai": "^4.87.4", 25 | "zod": "^3.24.2" 26 | }, 27 | "devDependencies": { 28 | "@types/node": "^22", 29 | "tsx": "^4.19.2", 30 | "typescript": "^5.7.2" 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /examples/text-to-sql/src/index.ts: -------------------------------------------------------------------------------- 1 | import { InitializeDatabase, TextToSqlWorkflow } from "./workflows.js"; 2 | 3 | // Get the question from command line arguments 4 | const question = process.argv[2]; 5 | 6 | if (!question) { 7 | console.error("Please provide a question as a command line argument"); 8 | console.error('Example: pnpm dev "Who has the highest batting average?"'); 9 | process.exit(1); 10 | } 11 | 12 | // First, initialize the database 13 | console.log("Initializing database..."); 14 | const initMessage = await InitializeDatabase(); 15 | console.log(initMessage); 16 | 17 | // Then run the query 18 | console.log("Processing your question..."); 19 | const result = await TextToSqlWorkflow({ 20 | question, 21 | }); 22 | 23 | console.log("Response:"); 24 | console.log(result); 25 | -------------------------------------------------------------------------------- /examples/text-to-sql/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ESNext", 4 | "module": "NodeNext", 5 | "lib": ["ESNext", "DOM"], 6 | "strict": true, 7 | "esModuleInterop": true, 8 | "skipLibCheck": true, 9 | "forceConsistentCasingInFileNames": true, 10 | "moduleResolution": "NodeNext", 11 | "resolveJsonModule": true, 12 | "isolatedModules": true, 13 | "outDir": "./dist", 14 | "rootDir": "./src" 15 | }, 16 | "include": ["./src/**/*.ts"], 17 | "exclude": ["node_modules"] 18 | } 19 | -------------------------------------------------------------------------------- /examples/tsconfig.base.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ESNext", 4 | "module": "NodeNext", 5 | "lib": ["ESNext", "DOM"], 6 | "strict": true, 7 | "esModuleInterop": true, 8 | "skipLibCheck": true, 9 | "forceConsistentCasingInFileNames": true, 10 | "moduleResolution": "NodeNext", 11 | "resolveJsonModule": true, 12 | "isolatedModules": true, 13 | "jsx": "react-jsx", 14 | "jsxImportSource": "@gensx/core" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /examples/typescript-compatibility/README.md: -------------------------------------------------------------------------------- 1 | # Typescript Compatibility Example 2 | 3 | This example demonstrates how to use GenSX packages with an older configuration of Typescript that uses `moduleResolution: "Node"` and `target: "es5"`. 4 | 5 | ## The Example 6 | 7 | This example has typescript configured with `moduleResolution: "Node"` and `target: "es5"`. 8 | 9 | ## Running the typescript example 10 | 11 | ```bash 12 | pnpm start 13 | ``` 14 | -------------------------------------------------------------------------------- /examples/typescript-compatibility/eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import rootConfig from "../../eslint.config.mjs"; 2 | import examplesConfig from "../eslint.config.mjs"; 3 | 4 | export default [ 5 | ...rootConfig, 6 | ...examplesConfig, 7 | { 8 | files: ["**/*.{js,mjs,cjs,jsx,ts,tsx}"], 9 | languageOptions: { 10 | parserOptions: { 11 | tsconfigRootDir: import.meta.dirname, 12 | project: "./tsconfig.json", 13 | }, 14 | }, 15 | }, 16 | ]; 17 | -------------------------------------------------------------------------------- /examples/typescript-compatibility/index.tsx: -------------------------------------------------------------------------------- 1 | /** @jsxRuntime automatic */ 2 | /** @jsxImportSource @gensx/core */ 3 | 4 | import * as gensx from "@gensx/core"; 5 | import { GSXChatCompletion, OpenAIProvider } from "@gensx/openai"; 6 | 7 | const RespondToInput = gensx.Component<{ input: string }, string>( 8 | "RespondToInput", 9 | ({ input }) => { 10 | return ( 11 | 25 | {(response) => response.choices[0].message.content ?? ""} 26 | 27 | ); 28 | }, 29 | ); 30 | 31 | const Wrapper = gensx.Component<{ input: string }, string>( 32 | "Wrapper", 33 | ({ input }) => ( 34 | 35 | 36 | 37 | ), 38 | ); 39 | 40 | const workflow = gensx.Workflow("RespondToInputWorkflow", Wrapper); 41 | 42 | // Main function to run examples 43 | async function main() { 44 | const result = await workflow.run({ input: "Tell me a joke." }); 45 | console.log(result); 46 | } 47 | 48 | main().catch(console.error); 49 | -------------------------------------------------------------------------------- /examples/typescript-compatibility/nodemon.json: -------------------------------------------------------------------------------- 1 | { 2 | "watch": ["*.ts", "*.tsx"], 3 | "exec": "tsx ./index.tsx", 4 | "ext": "ts,tsx,json" 5 | } 6 | -------------------------------------------------------------------------------- /examples/typescript-compatibility/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@examples/typescript-compatibility", 3 | "private": true, 4 | "version": "0.0.0", 5 | "engines": { 6 | "node": ">=18.0.0" 7 | }, 8 | "type": "commonjs", 9 | "scripts": { 10 | "dev": "nodemon", 11 | "start": "tsx index.tsx", 12 | "build": "tsc", 13 | "test": "pnpm run build && node dist/index.js", 14 | "lint": "eslint .", 15 | "lint:fix": "eslint . --fix" 16 | }, 17 | "dependencies": { 18 | "@gensx/core": "0.3.13", 19 | "@gensx/openai": "0.1.28" 20 | }, 21 | "devDependencies": { 22 | "@types/node": "catalog:examples", 23 | "nodemon": "catalog:", 24 | "tsx": "catalog:", 25 | "typescript": "5.1" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /examples/typescript-compatibility/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "module": "commonjs", 5 | "rootDir": ".", 6 | "outDir": "dist", 7 | "jsx": "react-jsx", 8 | "jsxImportSource": "@gensx/core", 9 | "strict": true, 10 | "skipLibCheck": true, 11 | "downlevelIteration": true, 12 | "types": ["@gensx/core", "node"], 13 | "baseUrl": ".", 14 | "paths": { 15 | "@gensx/core/jsx-runtime": [ 16 | "./node_modules/@gensx/core/dist/cjs/jsx-runtime" 17 | ] 18 | } 19 | }, 20 | "include": ["*.ts", "*.tsx"], 21 | "exclude": ["node_modules", "dist"] 22 | } 23 | -------------------------------------------------------------------------------- /examples/vercel-ai/eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import rootConfig from "../../eslint.config.mjs"; 2 | import examplesConfig from "../eslint.config.mjs"; 3 | 4 | export default [ 5 | ...rootConfig, 6 | ...examplesConfig, 7 | { 8 | files: ["**/*.{js,mjs,cjs,jsx,ts,tsx}"], 9 | languageOptions: { 10 | parserOptions: { 11 | tsconfigRootDir: import.meta.dirname, 12 | project: "./tsconfig.json", 13 | }, 14 | }, 15 | }, 16 | ]; 17 | -------------------------------------------------------------------------------- /examples/vercel-ai/gensx.yaml: -------------------------------------------------------------------------------- 1 | projectName: vercel-ai 2 | -------------------------------------------------------------------------------- /examples/vercel-ai/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@examples/vercel-ai", 3 | "private": true, 4 | "version": "0.0.0", 5 | "type": "module", 6 | "engines": { 7 | "node": ">=18.0.0" 8 | }, 9 | "description": "Example of using GenSX with the Vercel AI SDK", 10 | "scripts": { 11 | "dev": "tsx ./src/index.ts", 12 | "start": "npx gensx start ./src/workflows.ts", 13 | "build": "tsc", 14 | "deploy": "npx gensx deploy -e OPENAI_API_KEY ./src/workflows.ts", 15 | "lint": "eslint .", 16 | "lint:fix": "eslint . --fix" 17 | }, 18 | "dependencies": { 19 | "@ai-sdk/openai": "^1.3.22", 20 | "@gensx/core": "^0.4.0", 21 | "@gensx/vercel-ai": "^0.2.0", 22 | "ai": "^4.3.16", 23 | "zod": "^3.24.2" 24 | }, 25 | "devDependencies": { 26 | "@types/node": "^22", 27 | "tsx": "^4.19.2", 28 | "typescript": "^5.7.2" 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /examples/vercel-ai/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ESNext", 4 | "module": "NodeNext", 5 | "lib": ["ESNext", "DOM"], 6 | "strict": true, 7 | "esModuleInterop": true, 8 | "skipLibCheck": true, 9 | "forceConsistentCasingInFileNames": true, 10 | "moduleResolution": "NodeNext", 11 | "resolveJsonModule": true, 12 | "isolatedModules": true, 13 | "outDir": "./dist" 14 | }, 15 | "include": ["./src/**/*.ts"], 16 | "exclude": ["node_modules"] 17 | } 18 | -------------------------------------------------------------------------------- /packages/create-gensx/README.md: -------------------------------------------------------------------------------- 1 | # create-gensx 2 | 3 | Create a new [GenSX](https://gensx.com) project with one command. 4 | 5 | ## Usage 6 | 7 | ```bash 8 | # Using npm 9 | npm create gensx@latest my-app 10 | 11 | # Using npx 12 | npx create-gensx@latest my-app 13 | 14 | # Using yarn 15 | yarn create gensx my-app 16 | 17 | # Using pnpm 18 | pnpm create gensx my-app 19 | ``` 20 | 21 | ### Options 22 | 23 | ```bash 24 | # Use a specific template (default: ts) 25 | npm create gensx@latest my-app --template ts 26 | 27 | # Force creation in non-empty directory 28 | npm create gensx@latest my-app --force 29 | ``` 30 | 31 | ## Templates 32 | 33 | ### TypeScript (ts) 34 | 35 | A TypeScript-based project configured with: 36 | 37 | - TypeScript configuration for GenSX 38 | - Basic project structure 39 | - Development server with hot reload 40 | - Build setup 41 | 42 | ## Development 43 | 44 | ```bash 45 | # Build the package 46 | pnpm run build 47 | 48 | # Run tests 49 | pnpm test 50 | ``` 51 | -------------------------------------------------------------------------------- /packages/create-gensx/eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import rootConfig from "../../eslint.config.mjs"; 2 | 3 | export default [ 4 | ...rootConfig, 5 | { 6 | files: ["**/*.{js,mjs,cjs,jsx,ts,tsx}"], 7 | languageOptions: { 8 | parserOptions: { 9 | tsconfigRootDir: import.meta.dirname, 10 | project: "./tsconfig.json", 11 | }, 12 | }, 13 | }, 14 | ]; 15 | -------------------------------------------------------------------------------- /packages/create-gensx/src/cli.ts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | import { Command } from "commander"; 4 | 5 | import { createGensxProject, NewCommandOptions } from "./index.js"; 6 | 7 | export async function runCLI() { 8 | const program = new Command(); 9 | 10 | program 11 | .name("create-gensx") 12 | .description("Create a new GenSX project") 13 | .argument("", "Directory to create the project in") 14 | .option("-t, --template ", "Template to use", "ts") 15 | .option("-f, --force", "Overwrite existing files", false) 16 | .option("-s, --skip-login", "Skip check for login to GenSX", false) 17 | .option("--skip-ide-rules", "Skip IDE rules selection", false) 18 | .option( 19 | "--ide-rules ", 20 | "Comma-separated list of IDE rules to install (cline,windsurf,claude,cursor)", 21 | ) 22 | .option("-d, --description ", "Description of the project") 23 | .action(async (projectPath: string, options: NewCommandOptions) => { 24 | try { 25 | await createGensxProject(projectPath, options); 26 | } catch (error) { 27 | console.error("Error:", (error as Error).message); 28 | process.exit(1); 29 | } 30 | }); 31 | 32 | await program.parseAsync(); 33 | } 34 | 35 | runCLI().catch((error: unknown) => { 36 | console.error("Error:", (error as Error).message); 37 | process.exit(1); 38 | }); 39 | -------------------------------------------------------------------------------- /packages/create-gensx/src/index.ts: -------------------------------------------------------------------------------- 1 | import { NewCommandOptions, NewProjectUI } from "gensx"; 2 | import { render } from "ink"; 3 | import React from "react"; 4 | 5 | export type { NewCommandOptions }; 6 | 7 | export interface CreateOptions { 8 | template?: string; 9 | force: boolean; 10 | } 11 | 12 | export async function createGensxProject( 13 | projectPath: string, 14 | options: NewCommandOptions, 15 | ): Promise { 16 | return new Promise((resolve, reject) => { 17 | const { waitUntilExit } = render( 18 | React.createElement(NewProjectUI, { projectPath, options }), 19 | ); 20 | waitUntilExit().then(resolve).catch(reject); 21 | }); 22 | } 23 | -------------------------------------------------------------------------------- /packages/create-gensx/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "./dist", 5 | "sourceMap": true, 6 | "declaration": true, 7 | "declarationMap": true, 8 | "incremental": false, 9 | "rootDir": "./src" 10 | }, 11 | "include": ["src/**/*"] 12 | } 13 | -------------------------------------------------------------------------------- /packages/create-gensx/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.base.json", 3 | "compilerOptions": { 4 | "tsBuildInfoFile": ".tsbuildinfo", 5 | "outDir": "./dist", 6 | "jsxImportSource": "react" 7 | }, 8 | "include": ["src/**/*", "tests/**/*", "vitest.config.ts"], 9 | "exclude": ["node_modules", "dist"] 10 | } 11 | -------------------------------------------------------------------------------- /packages/create-gensx/vitest.config.ts: -------------------------------------------------------------------------------- 1 | // import swc from "unplugin-swc"; 2 | import * as path from "path"; 3 | 4 | import { loadEnv } from "vite"; 5 | import { defineConfig } from "vitest/config"; 6 | 7 | export default defineConfig({ 8 | test: { 9 | forceRerunTriggers: ["**/*.ts", "**/*.template"], 10 | root: path.resolve(__dirname, "./"), 11 | globals: true, 12 | isolate: false, 13 | passWithNoTests: false, 14 | include: ["./tests/**/*.test.ts"], 15 | env: loadEnv("test", process.cwd(), ""), 16 | coverage: { 17 | provider: "istanbul", 18 | reporter: ["text-summary", "json-summary", "json"], 19 | reportsDirectory: "coverage", 20 | include: ["./src/**/*.ts"], 21 | exclude: [ 22 | "node_modules/**", 23 | "dist/**", 24 | "coverage/**", 25 | "tests/**", 26 | "**/*.d.ts", 27 | ], 28 | all: true, 29 | enabled: true, 30 | clean: true, 31 | cleanOnRerun: true, 32 | reportOnFailure: true, 33 | skipFull: false, 34 | extension: [".ts"], 35 | }, 36 | }, 37 | // TODO: Get swc working to speed things up 38 | // plugins: [ 39 | // swc.vite({ 40 | // module: { type: "es6" }, 41 | // tsconfigFile: "./tsconfig.json", 42 | // }), 43 | // ], 44 | }); 45 | -------------------------------------------------------------------------------- /packages/gensx-anthropic/.gitignore: -------------------------------------------------------------------------------- 1 | .tsbuildinfo 2 | -------------------------------------------------------------------------------- /packages/gensx-anthropic/eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import rootConfig from "../../eslint.config.mjs"; 2 | 3 | export default [ 4 | ...rootConfig, 5 | { 6 | files: ["**/*.{js,mjs,cjs,jsx,ts,tsx}"], 7 | languageOptions: { 8 | parserOptions: { 9 | tsconfigRootDir: import.meta.dirname, 10 | project: "./tsconfig.json", 11 | }, 12 | }, 13 | }, 14 | { 15 | rules: { 16 | "@typescript-eslint/no-empty-object-type": "off", 17 | }, 18 | }, 19 | ]; 20 | -------------------------------------------------------------------------------- /packages/gensx-anthropic/rollup.config.js: -------------------------------------------------------------------------------- 1 | import { createConfigs } from "../../create-rollup-config.js"; 2 | import packageJson from "./package.json" with { type: "json" }; 3 | 4 | const external = [ 5 | ...Object.keys(packageJson.dependencies), 6 | ...(packageJson.peerDependencies 7 | ? Object.keys(packageJson.peerDependencies) 8 | : []), 9 | ]; 10 | 11 | export default createConfigs("src/index.ts", "@gensx/anthropic", external); 12 | -------------------------------------------------------------------------------- /packages/gensx-anthropic/src/anthropic.ts: -------------------------------------------------------------------------------- 1 | import { 2 | Anthropic as OriginalAnthropic, 3 | ClientOptions, 4 | } from "@anthropic-ai/sdk"; 5 | import { wrap } from "@gensx/core"; 6 | 7 | export class Anthropic extends OriginalAnthropic { 8 | constructor(options: ClientOptions) { 9 | super(options); 10 | return wrapAnthropic(this); 11 | } 12 | } 13 | 14 | // TODO: Deeper wrapping 15 | export const wrapAnthropic = wrap; 16 | -------------------------------------------------------------------------------- /packages/gensx-anthropic/src/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./anthropic.js"; 2 | -------------------------------------------------------------------------------- /packages/gensx-anthropic/tests/setup.ts: -------------------------------------------------------------------------------- 1 | import { afterEach, beforeEach, vi } from "vitest"; 2 | 3 | afterEach(() => { 4 | vi.clearAllMocks(); 5 | }); 6 | 7 | beforeEach(() => { 8 | vi.resetModules(); 9 | }); 10 | -------------------------------------------------------------------------------- /packages/gensx-anthropic/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "./dist", 5 | "sourceMap": true, 6 | "declaration": true, 7 | "declarationMap": true, 8 | "incremental": false, 9 | "rootDir": "./src" 10 | }, 11 | "include": ["src/**/*"] 12 | } 13 | -------------------------------------------------------------------------------- /packages/gensx-anthropic/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.base.json", 3 | "compilerOptions": { 4 | "tsBuildInfoFile": ".tsbuildinfo", 5 | "outDir": "./dist", 6 | "baseUrl": "." 7 | }, 8 | "include": [ 9 | "src/**/*.ts", 10 | "vitest.config.ts", 11 | "tests/**/*", 12 | "rollup.config.js" 13 | ], 14 | "exclude": ["node_modules", "dist"] 15 | } 16 | -------------------------------------------------------------------------------- /packages/gensx-anthropic/vitest.config.ts: -------------------------------------------------------------------------------- 1 | // import swc from "unplugin-swc"; 2 | import * as path from "path"; 3 | 4 | import { loadEnv } from "vite"; 5 | import { defineConfig } from "vitest/config"; 6 | 7 | export default defineConfig({ 8 | test: { 9 | root: path.resolve(__dirname, "./"), 10 | globals: true, 11 | isolate: false, 12 | passWithNoTests: false, 13 | include: ["./tests/**/*.test.ts", "./tests/**/*.test.tsx"], 14 | env: loadEnv("test", process.cwd(), ""), 15 | silent: "passed-only", 16 | setupFiles: ["./tests/setup.ts"], 17 | coverage: { 18 | provider: "istanbul", 19 | reporter: ["text-summary", "json-summary", "json"], 20 | reportsDirectory: "coverage", 21 | include: ["./src/**/*.ts", "./src/**/*.tsx"], 22 | exclude: [ 23 | "node_modules/**", 24 | "dist/**", 25 | "coverage/**", 26 | "tests/**", 27 | "**/*.d.ts", 28 | ], 29 | all: true, 30 | enabled: true, 31 | clean: true, 32 | cleanOnRerun: true, 33 | reportOnFailure: true, 34 | skipFull: false, 35 | extension: [".ts", ".tsx"], 36 | }, 37 | }, 38 | // TODO: Get swc working to speed things up 39 | // plugins: [ 40 | // swc.vite({ 41 | // module: { type: "es6" }, 42 | // tsconfigFile: "./tsconfig.json", 43 | // }), 44 | // ], 45 | }); 46 | -------------------------------------------------------------------------------- /packages/gensx-claude-md/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated files 2 | CLAUDE.md 3 | -------------------------------------------------------------------------------- /packages/gensx-claude-md/eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import baseConfig from "../../eslint.config.mjs"; 2 | 3 | export default [ 4 | ...baseConfig, 5 | { 6 | files: ["src/**/*.ts", "tests/**/*.ts", "*.ts"], 7 | languageOptions: { 8 | parserOptions: { 9 | project: "./tsconfig.json", 10 | }, 11 | }, 12 | rules: { 13 | "no-console": ["error", { allow: ["info", "error", "warn", "log"] }], 14 | "n/no-process-exit": "off", 15 | "n/shebang": "off", 16 | }, 17 | }, 18 | ]; 19 | -------------------------------------------------------------------------------- /packages/gensx-claude-md/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@gensx/claude-md", 3 | "version": "0.1.8", 4 | "license": "Apache-2.0", 5 | "engines": { 6 | "node": ">=18.0.0", 7 | "pnpm": ">=9.0.0" 8 | }, 9 | "type": "module", 10 | "description": "CLAUDE.md templates for GenSX projects.", 11 | "repository": { 12 | "type": "git", 13 | "url": "https://github.com/gensx-inc/gensx.git", 14 | "directory": "packages/gensx-claude-md" 15 | }, 16 | "bin": { 17 | "gensx-claude-md": "./dist/cli.js" 18 | }, 19 | "files": [ 20 | "templates", 21 | "dist" 22 | ], 23 | "scripts": { 24 | "build": "tsc -p tsconfig.build.json && chmod +x dist/cli.js", 25 | "clean": "rm -rf dist", 26 | "lint": "eslint .", 27 | "lint:fix": "eslint . --fix", 28 | "test": "vitest run", 29 | "test:watch": "vitest watch", 30 | "test:types": "tsc --noEmit" 31 | }, 32 | "devDependencies": { 33 | "@types/node": "catalog:packages", 34 | "typescript": "catalog:", 35 | "vite": "catalog:", 36 | "vitest": "catalog:" 37 | }, 38 | "publishConfig": { 39 | "access": "public" 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /packages/gensx-claude-md/tests/cli.test.ts: -------------------------------------------------------------------------------- 1 | import { exec } from "node:child_process"; 2 | import fs from "node:fs"; 3 | import os from "node:os"; 4 | import path from "node:path"; 5 | 6 | import { expect, suite, test } from "vitest"; 7 | 8 | suite("Gensx Claude MD", () => { 9 | test("should create the template", async () => { 10 | const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "gensx-claude-md-")); 11 | 12 | const cwd = process.cwd(); 13 | 14 | // execute the cli.js file 15 | await new Promise((resolve, reject) => { 16 | exec( 17 | `${cwd}/dist/cli.js`, 18 | { 19 | cwd: tmpDir, 20 | }, 21 | (error, stdout, stderr) => { 22 | if (error) reject(error); 23 | resolve({ stdout, stderr }); 24 | }, 25 | ); 26 | }); 27 | 28 | // check if the CLAUDE.md file was created 29 | const ruleFile = path.join(tmpDir, "CLAUDE.md"); 30 | expect(fs.existsSync(ruleFile)).toBe(true); 31 | expect(fs.readFileSync(ruleFile, "utf8")).toContain( 32 | "GenSX Project Claude Memory", 33 | ); 34 | }); 35 | }); 36 | -------------------------------------------------------------------------------- /packages/gensx-claude-md/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "rootDir": "./src", 5 | "outDir": "./dist", 6 | "noEmit": false 7 | }, 8 | "include": ["src/**/*"] 9 | } 10 | -------------------------------------------------------------------------------- /packages/gensx-claude-md/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.base.json", 3 | "compilerOptions": { 4 | "module": "NodeNext", 5 | "moduleResolution": "NodeNext", 6 | "target": "esnext", 7 | "tsBuildInfoFile": ".tsbuildinfo", 8 | "outDir": "./dist", 9 | "baseUrl": ".", 10 | "types": ["@types/node"], 11 | "emitDeclarationOnly": false 12 | }, 13 | "include": ["src/**/*", "vitest.config.ts", "tests/**/*", "vitest.config.ts"] 14 | } 15 | -------------------------------------------------------------------------------- /packages/gensx-claude-md/vitest.config.ts: -------------------------------------------------------------------------------- 1 | import * as path from "path"; 2 | 3 | import { defineConfig } from "vitest/config"; 4 | 5 | export default defineConfig({ 6 | test: { 7 | root: path.resolve(__dirname, "./"), 8 | globals: true, 9 | isolate: false, 10 | passWithNoTests: false, 11 | include: ["./tests/**/*.test.ts"], 12 | silent: "passed-only", 13 | }, 14 | }); 15 | -------------------------------------------------------------------------------- /packages/gensx-cli/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled binaries 2 | gensx-cli-* 3 | 4 | # Deno specific 5 | .deno_compile_node_modules/ 6 | -------------------------------------------------------------------------------- /packages/gensx-cli/eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import rootConfig from "../../eslint.config.mjs"; 2 | 3 | export default [ 4 | ...rootConfig, 5 | { 6 | files: ["**/*.{js,mjs,cjs,jsx,ts,tsx}"], 7 | languageOptions: { 8 | parserOptions: { 9 | tsconfigRootDir: import.meta.dirname, 10 | project: "./tsconfig.json", 11 | }, 12 | }, 13 | }, 14 | { 15 | rules: { 16 | "@typescript-eslint/no-empty-object-type": "off", 17 | }, 18 | }, 19 | ]; 20 | -------------------------------------------------------------------------------- /packages/gensx-cli/main.ts: -------------------------------------------------------------------------------- 1 | import { runCLI } from "../gensx/dist/index.js"; 2 | 3 | Deno.env.set("DENO_BINARY", "true"); 4 | 5 | await runCLI(); 6 | Deno.exit(0); 7 | -------------------------------------------------------------------------------- /packages/gensx-cli/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "gensx-cli", 3 | "version": "1.0.0", 4 | "type": "module", 5 | "description": "This package is not published to npm. It is just a container of scripts to build the CLI binary.", 6 | "private": true, 7 | "scripts": { 8 | "#test-comment": "this hangs locally for some reason, so only run in CI", 9 | "test": "if [ \"$CI\" = \"true\" ]; then deno task compile:macos-x64; fi", 10 | "test:local": "deno task compile:macos-x64" 11 | }, 12 | "keywords": [], 13 | "author": "", 14 | "license": "ISC", 15 | "dependencies": { 16 | "deno": "^2.2.13" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /packages/gensx-cli/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "allowJs": true, 4 | "lib": ["deno.window", "deno.unstable", "dom"], 5 | "strict": true, 6 | "target": "ESNext", 7 | "module": "ESNext", 8 | "moduleResolution": "node", 9 | "types": ["npm:@types/node"] 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /packages/gensx-cline-rules/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated files 2 | .clinerules 3 | -------------------------------------------------------------------------------- /packages/gensx-cline-rules/eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import rootConfig from "../../eslint.config.mjs"; 2 | 3 | export default [ 4 | ...rootConfig, 5 | { 6 | files: ["src/**/*.ts", "tests/**/*.ts", "*.ts"], 7 | languageOptions: { 8 | parserOptions: { 9 | project: "./tsconfig.json", 10 | }, 11 | }, 12 | rules: { 13 | "no-console": ["error", { allow: ["info", "error", "warn", "log"] }], 14 | "n/no-process-exit": "off", 15 | "n/shebang": "off", 16 | }, 17 | }, 18 | ]; 19 | -------------------------------------------------------------------------------- /packages/gensx-cline-rules/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@gensx/cline-rules", 3 | "version": "0.1.8", 4 | "license": "Apache-2.0", 5 | "engines": { 6 | "node": ">=18.0.0", 7 | "pnpm": ">=9.0.0" 8 | }, 9 | "description": "Cline rules for GenSX projects.", 10 | "repository": { 11 | "type": "git", 12 | "url": "https://github.com/gensx-inc/gensx.git", 13 | "directory": "packages/gensx-cline-rules" 14 | }, 15 | "type": "module", 16 | "bin": { 17 | "gensx-cline-rules": "./dist/cli.js" 18 | }, 19 | "files": [ 20 | "dist", 21 | "templates" 22 | ], 23 | "scripts": { 24 | "build": "tsc -p tsconfig.build.json && chmod +x dist/cli.js", 25 | "clean": "rm -rf dist", 26 | "lint": "eslint .", 27 | "lint:fix": "eslint . --fix", 28 | "test": "vitest run", 29 | "test:watch": "vitest watch", 30 | "test:types": "tsc --noEmit" 31 | }, 32 | "publishConfig": { 33 | "access": "public" 34 | }, 35 | "devDependencies": { 36 | "@types/node": "catalog:packages", 37 | "typescript": "catalog:", 38 | "vite": "catalog:", 39 | "vitest": "catalog:" 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /packages/gensx-cline-rules/tests/cli.test.ts: -------------------------------------------------------------------------------- 1 | import { exec } from "node:child_process"; 2 | import fs from "node:fs"; 3 | import os from "node:os"; 4 | import path from "node:path"; 5 | 6 | import { expect, suite, test } from "vitest"; 7 | 8 | suite("Gensx Cline Rules", () => { 9 | test("should create the rules", async () => { 10 | const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "gensx-cline-rules-")); 11 | 12 | const cwd = process.cwd(); 13 | 14 | // execute the cli.js file 15 | await new Promise((resolve, reject) => { 16 | exec( 17 | `${cwd}/dist/cli.js`, 18 | { 19 | cwd: tmpDir, 20 | }, 21 | (error, stdout, stderr) => { 22 | if (error) reject(error); 23 | resolve({ stdout, stderr }); 24 | }, 25 | ); 26 | }); 27 | 28 | // check if the .clinerules file was created 29 | const ruleFile = path.join(tmpDir, ".clinerules"); 30 | expect(fs.existsSync(ruleFile)).toBe(true); 31 | expect(fs.readFileSync(ruleFile, "utf8")).toContain( 32 | "GenSX Project Guidelines", 33 | ); 34 | }); 35 | }); 36 | -------------------------------------------------------------------------------- /packages/gensx-cline-rules/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "rootDir": "./src", 5 | "outDir": "./dist", 6 | "noEmit": false 7 | }, 8 | "include": ["src/**/*"], 9 | "exclude": ["node_modules", "tests", "**/*.test.ts", "**/*.spec.ts"] 10 | } 11 | -------------------------------------------------------------------------------- /packages/gensx-cline-rules/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.base.json", 3 | "compilerOptions": { 4 | "module": "NodeNext", 5 | "moduleResolution": "NodeNext", 6 | "target": "esnext", 7 | "tsBuildInfoFile": ".tsbuildinfo", 8 | "outDir": "./dist", 9 | "baseUrl": ".", 10 | "types": ["@types/node"], 11 | "emitDeclarationOnly": false 12 | }, 13 | "include": ["src/**/*", "vitest.config.ts", "tests/**/*"], 14 | "exclude": ["node_modules", "dist"] 15 | } 16 | -------------------------------------------------------------------------------- /packages/gensx-cline-rules/vitest.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from "vitest/config"; 2 | 3 | export default defineConfig({ 4 | test: { 5 | include: ["tests/**/*.test.ts"], 6 | globals: true, 7 | isolate: false, 8 | passWithNoTests: false, 9 | silent: "passed-only", 10 | }, 11 | }); 12 | -------------------------------------------------------------------------------- /packages/gensx-cloud-mcp/.gitignore: -------------------------------------------------------------------------------- 1 | .tsbuildinfo 2 | -------------------------------------------------------------------------------- /packages/gensx-cloud-mcp/claude-desktop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gensx-inc/gensx/1bc9c059cd7418c19fbe44ef85eb453fb9f74df5/packages/gensx-cloud-mcp/claude-desktop.png -------------------------------------------------------------------------------- /packages/gensx-cloud-mcp/eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import rootConfig from "../../eslint.config.mjs"; 2 | 3 | export default [ 4 | ...rootConfig, 5 | { 6 | files: ["**/*.{js,mjs,cjs,jsx,ts,tsx}"], 7 | languageOptions: { 8 | parserOptions: { 9 | tsconfigRootDir: import.meta.dirname, 10 | project: "./tsconfig.json", 11 | }, 12 | }, 13 | }, 14 | { 15 | rules: { 16 | "@typescript-eslint/no-empty-object-type": "off", 17 | }, 18 | }, 19 | ]; 20 | -------------------------------------------------------------------------------- /packages/gensx-cloud-mcp/src/utils/user-agent.ts: -------------------------------------------------------------------------------- 1 | import { existsSync, readFileSync } from "node:fs"; 2 | import path from "node:path"; 3 | import { fileURLToPath } from "node:url"; 4 | 5 | let version = ""; 6 | const dirname = path.dirname(fileURLToPath(import.meta.url)); 7 | 8 | let rootDir = path.resolve(dirname, "..", "..", ".."); 9 | let packageJsonPath = path.join(rootDir, "package.json"); 10 | if (existsSync(packageJsonPath)) { 11 | const localPackageJson = JSON.parse( 12 | readFileSync(packageJsonPath, "utf8"), 13 | ) as { version: string }; 14 | version = localPackageJson.version; 15 | } else { 16 | // if the first check fails, try two levels up instead of three 17 | rootDir = path.resolve(dirname, "..", ".."); 18 | packageJsonPath = path.join(rootDir, "package.json"); 19 | if (existsSync(packageJsonPath)) { 20 | const localPackageJson = JSON.parse( 21 | readFileSync(packageJsonPath, "utf8"), 22 | ) as { version: string }; 23 | version = localPackageJson.version; 24 | } else { 25 | console.error("Error trying to get version from package.json"); 26 | } 27 | } 28 | 29 | export const VERSION = version; 30 | export const USER_AGENT = `@gensx/gensx-cloud-mcp v${VERSION}`; 31 | -------------------------------------------------------------------------------- /packages/gensx-cloud-mcp/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "./dist", 5 | "sourceMap": true, 6 | "declaration": true, 7 | "declarationMap": true, 8 | "incremental": false 9 | }, 10 | "include": ["src/**/*.ts"] 11 | } 12 | -------------------------------------------------------------------------------- /packages/gensx-cloud-mcp/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.base.json", 3 | "compilerOptions": { 4 | "target": "ESNext", 5 | "module": "NodeNext", 6 | "moduleResolution": "NodeNext", 7 | "tsBuildInfoFile": ".tsbuildinfo", 8 | "outDir": "./dist", 9 | "baseUrl": ".", 10 | "emitDeclarationOnly": false 11 | }, 12 | "include": ["src/**/*.ts"], 13 | "exclude": ["node_modules", "dist"] 14 | } 15 | -------------------------------------------------------------------------------- /packages/gensx-core/.npmignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | dist/ 3 | .tmp 4 | .idea 5 | .env 6 | coverage/ 7 | .npm 8 | .vscode 9 | -------------------------------------------------------------------------------- /packages/gensx-core/.npmrc: -------------------------------------------------------------------------------- 1 | engine-strict=true 2 | -------------------------------------------------------------------------------- /packages/gensx-core/eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import rootConfig from "../../eslint.config.mjs"; 2 | 3 | export default [ 4 | { 5 | ignores: ["**/coverage/**"], 6 | }, 7 | ...rootConfig, 8 | { 9 | files: ["**/*.{js,mjs,cjs,jsx,ts,tsx}"], 10 | languageOptions: { 11 | parserOptions: { 12 | project: "./tsconfig.json", 13 | tsconfigRootDir: import.meta.dirname, 14 | }, 15 | }, 16 | }, 17 | { 18 | rules: { 19 | "@typescript-eslint/no-empty-object-type": "off", 20 | }, 21 | }, 22 | ]; 23 | -------------------------------------------------------------------------------- /packages/gensx-core/rollup.config.js: -------------------------------------------------------------------------------- 1 | import { createConfigs } from "../../create-rollup-config.js"; 2 | import packageJson from "./package.json" with { type: "json" }; 3 | 4 | const external = [ 5 | ...Object.keys(packageJson.dependencies), 6 | ...(packageJson.peerDependencies 7 | ? Object.keys(packageJson.peerDependencies) 8 | : []), 9 | ]; 10 | 11 | export default createConfigs(["src/index.ts"], "@gensx/core", external); 12 | -------------------------------------------------------------------------------- /packages/gensx-core/src/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./component.js"; 2 | export * from "./types.js"; 3 | export { emitProgress, withContext, getCurrentContext } from "./context.js"; 4 | export * from "./wrap.js"; 5 | 6 | export { Component, Workflow } from "./component.js"; 7 | 8 | export { readConfig } from "./utils/config.js"; 9 | export { getSelectedEnvironment } from "./utils/env-config.js"; 10 | export { readProjectConfig } from "./utils/project-config.js"; 11 | -------------------------------------------------------------------------------- /packages/gensx-core/src/utils/user-agent.ts: -------------------------------------------------------------------------------- 1 | import { existsSync, readFileSync } from "node:fs"; 2 | import path from "node:path"; 3 | import { fileURLToPath } from "node:url"; 4 | 5 | let version = ""; 6 | const dirname = path.dirname(fileURLToPath(import.meta.url)); 7 | 8 | let rootDir = path.resolve(dirname, "..", "..", ".."); 9 | let packageJsonPath = path.join(rootDir, "package.json"); 10 | if (existsSync(packageJsonPath)) { 11 | const localPackageJson = JSON.parse( 12 | readFileSync(packageJsonPath, "utf8"), 13 | ) as { version: string }; 14 | version = localPackageJson.version; 15 | } else { 16 | // if the first check fails, try two levels up instead of three 17 | rootDir = path.resolve(dirname, "..", ".."); 18 | packageJsonPath = path.join(rootDir, "package.json"); 19 | if (existsSync(packageJsonPath)) { 20 | const localPackageJson = JSON.parse( 21 | readFileSync(packageJsonPath, "utf8"), 22 | ) as { version: string }; 23 | version = localPackageJson.version; 24 | } else { 25 | console.error("Error trying to get version from package.json"); 26 | } 27 | } 28 | 29 | export const VERSION = version; 30 | export const USER_AGENT = `@gensx/core v${VERSION}`; 31 | -------------------------------------------------------------------------------- /packages/gensx-core/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "sourceMap": true, 5 | "declaration": true, 6 | "declarationMap": true, 7 | "incremental": false, 8 | "rootDir": "./src" 9 | }, 10 | "include": ["src/**/*"] 11 | } 12 | -------------------------------------------------------------------------------- /packages/gensx-core/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.base.json", 3 | "compilerOptions": { 4 | "tsBuildInfoFile": ".tsbuildinfo", 5 | "outDir": "./dist", 6 | "baseUrl": ".", 7 | "rootDir": "." 8 | }, 9 | "include": ["src/**/*", "vitest.config.ts", "tests/**/*"], 10 | "exclude": ["node_modules", "dist"] 11 | } 12 | -------------------------------------------------------------------------------- /packages/gensx-core/vitest.config.ts: -------------------------------------------------------------------------------- 1 | // import swc from "unplugin-swc"; 2 | import * as path from "path"; 3 | 4 | import { loadEnv } from "vite"; 5 | import { defineConfig } from "vitest/config"; 6 | 7 | export default defineConfig({ 8 | test: { 9 | root: path.resolve(__dirname, "./"), 10 | globals: true, 11 | isolate: false, 12 | passWithNoTests: false, 13 | include: ["./tests/**/*.test.ts"], 14 | env: loadEnv("test", process.cwd(), ""), 15 | silent: "passed-only", 16 | coverage: { 17 | provider: "istanbul", 18 | reporter: ["text-summary", "json-summary", "json"], 19 | reportsDirectory: "coverage", 20 | include: ["./src/**/*.ts", "./src/**/*.tsx"], 21 | exclude: [ 22 | "node_modules/**", 23 | "dist/**", 24 | "coverage/**", 25 | "tests/**", 26 | "**/*.d.ts", 27 | ], 28 | all: true, 29 | enabled: true, 30 | clean: true, 31 | cleanOnRerun: true, 32 | reportOnFailure: true, 33 | skipFull: false, 34 | extension: [".ts", ".tsx"], 35 | }, 36 | }, 37 | // TODO: Get swc working to speed things up 38 | // plugins: [ 39 | // swc.vite({ 40 | // module: { type: "es6" }, 41 | // tsconfigFile: "./tsconfig.json", 42 | // }), 43 | // ], 44 | }); 45 | -------------------------------------------------------------------------------- /packages/gensx-cursor-rules/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated files 2 | .cursor/ 3 | -------------------------------------------------------------------------------- /packages/gensx-cursor-rules/eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import baseConfig from "../../eslint.config.mjs"; 2 | 3 | export default [ 4 | ...baseConfig, 5 | { 6 | files: ["src/**/*.ts", "tests/**/*.ts", "*.ts"], 7 | languageOptions: { 8 | parserOptions: { 9 | project: "./tsconfig.json", 10 | }, 11 | }, 12 | rules: { 13 | "no-console": ["error", { allow: ["info", "error", "warn", "log"] }], 14 | "n/no-process-exit": "off", 15 | "n/shebang": "off", 16 | }, 17 | }, 18 | ]; 19 | -------------------------------------------------------------------------------- /packages/gensx-cursor-rules/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@gensx/cursor-rules", 3 | "version": "0.1.8", 4 | "license": "Apache-2.0", 5 | "engines": { 6 | "node": ">=18.0.0", 7 | "pnpm": ">=9.0.0" 8 | }, 9 | "description": "Cursor rules for GenSX projects.", 10 | "repository": { 11 | "type": "git", 12 | "url": "https://github.com/gensx-inc/gensx.git", 13 | "directory": "packages/gensx-cursor-rules" 14 | }, 15 | "type": "module", 16 | "bin": { 17 | "gensx-cursor-rules": "./dist/cli.js" 18 | }, 19 | "files": [ 20 | "dist", 21 | "rules" 22 | ], 23 | "scripts": { 24 | "build": "tsc -p tsconfig.build.json && chmod +x dist/cli.js", 25 | "clean": "rm -rf dist", 26 | "lint": "eslint .", 27 | "lint:fix": "eslint . --fix", 28 | "test": "vitest run", 29 | "test:watch": "vitest watch", 30 | "test:types": "tsc --noEmit" 31 | }, 32 | "publishConfig": { 33 | "access": "public" 34 | }, 35 | "devDependencies": { 36 | "@types/node": "catalog:packages", 37 | "typescript": "catalog:", 38 | "vite": "catalog:", 39 | "vitest": "catalog:" 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /packages/gensx-cursor-rules/tests/cli.test.ts: -------------------------------------------------------------------------------- 1 | import { exec } from "node:child_process"; 2 | import fs from "node:fs"; 3 | import os from "node:os"; 4 | import path from "node:path"; 5 | 6 | import { expect, suite, test } from "vitest"; 7 | 8 | suite("Gensx Cursor Rules", () => { 9 | test("should create the rules", async () => { 10 | const tmpDir = fs.mkdtempSync( 11 | path.join(os.tmpdir(), "gensx-cursor-rules-"), 12 | ); 13 | 14 | const cwd = process.cwd(); 15 | 16 | // execute the cli.js file 17 | await new Promise((resolve, reject) => { 18 | exec( 19 | `${cwd}/dist/cli.js`, 20 | { 21 | cwd: tmpDir, 22 | }, 23 | (error, stdout, stderr) => { 24 | if (error) reject(error); 25 | resolve({ stdout, stderr }); 26 | }, 27 | ); 28 | }); 29 | 30 | // check if the .cursor directory was created 31 | const cursorDir = path.join(tmpDir, ".cursor"); 32 | expect(fs.existsSync(cursorDir)).toBe(true); 33 | 34 | // Ensure it contains all the files from ./rules 35 | const ruleFiles = fs.readdirSync(path.join(cwd, "rules")); 36 | ruleFiles.forEach((file) => { 37 | expect(fs.existsSync(path.join(cursorDir, file))).toBe(true); 38 | }); 39 | }); 40 | }); 41 | -------------------------------------------------------------------------------- /packages/gensx-cursor-rules/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "rootDir": "./src", 5 | "outDir": "./dist", 6 | "noEmit": false 7 | }, 8 | "include": ["src/**/*"] 9 | } 10 | -------------------------------------------------------------------------------- /packages/gensx-cursor-rules/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.base.json", 3 | "compilerOptions": { 4 | "module": "NodeNext", 5 | "moduleResolution": "NodeNext", 6 | "target": "esnext", 7 | "tsBuildInfoFile": ".tsbuildinfo", 8 | "outDir": "./dist", 9 | "baseUrl": ".", 10 | "types": ["@types/node"], 11 | "emitDeclarationOnly": false 12 | }, 13 | "include": ["src/**/*", "vitest.config.ts", "tests/**/*", "vitest.config.ts"] 14 | } 15 | -------------------------------------------------------------------------------- /packages/gensx-cursor-rules/vitest.config.ts: -------------------------------------------------------------------------------- 1 | import * as path from "path"; 2 | 3 | import { defineConfig } from "vitest/config"; 4 | 5 | export default defineConfig({ 6 | test: { 7 | root: path.resolve(__dirname, "./"), 8 | globals: true, 9 | isolate: false, 10 | passWithNoTests: false, 11 | include: ["./tests/**/*.test.ts"], 12 | silent: "passed-only", 13 | }, 14 | }); 15 | -------------------------------------------------------------------------------- /packages/gensx-openai/.gitignore: -------------------------------------------------------------------------------- 1 | .tsbuildinfo 2 | -------------------------------------------------------------------------------- /packages/gensx-openai/eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import rootConfig from "../../eslint.config.mjs"; 2 | 3 | export default [ 4 | ...rootConfig, 5 | { 6 | files: ["**/*.{js,mjs,cjs,jsx,ts,tsx}"], 7 | languageOptions: { 8 | parserOptions: { 9 | tsconfigRootDir: import.meta.dirname, 10 | project: "./tsconfig.json", 11 | }, 12 | }, 13 | }, 14 | { 15 | rules: { 16 | "@typescript-eslint/no-empty-object-type": "off", 17 | }, 18 | }, 19 | ]; 20 | -------------------------------------------------------------------------------- /packages/gensx-openai/rollup.config.js: -------------------------------------------------------------------------------- 1 | import { createConfigs } from "../../create-rollup-config.js"; 2 | import packageJson from "./package.json" with { type: "json" }; 3 | 4 | const external = [ 5 | ...Object.keys(packageJson.dependencies), 6 | ...(packageJson.peerDependencies 7 | ? Object.keys(packageJson.peerDependencies) 8 | : []), 9 | ]; 10 | 11 | export default createConfigs("src/index.ts", "@gensx/openai", external); 12 | -------------------------------------------------------------------------------- /packages/gensx-openai/src/index.ts: -------------------------------------------------------------------------------- 1 | export { OpenAI, wrapOpenAI } from "./openai.js"; 2 | -------------------------------------------------------------------------------- /packages/gensx-openai/tests/setup.ts: -------------------------------------------------------------------------------- 1 | import { afterEach, beforeEach, vi } from "vitest"; 2 | 3 | import { mockCreateMethod } from "../__mocks__/openai.js"; 4 | 5 | afterEach(() => { 6 | vi.clearAllMocks(); 7 | }); 8 | 9 | beforeEach(() => { 10 | vi.resetModules(); 11 | }); 12 | 13 | // Use vi.mock to automatically use the implementation in __mocks__/openai.ts 14 | vi.mock("openai"); 15 | 16 | // Export the mock method for spying in tests 17 | export const openAISpy = mockCreateMethod; 18 | -------------------------------------------------------------------------------- /packages/gensx-openai/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "sourceMap": true, 5 | "declaration": true, 6 | "declarationMap": true, 7 | "incremental": false, 8 | "rootDir": "./src" 9 | }, 10 | "include": ["src/**/*"] 11 | } 12 | -------------------------------------------------------------------------------- /packages/gensx-openai/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.base.json", 3 | "compilerOptions": { 4 | "tsBuildInfoFile": ".tsbuildinfo", 5 | "outDir": "./dist", 6 | "baseUrl": "." 7 | }, 8 | "include": [ 9 | "src/**/*", 10 | "vitest.config.ts", 11 | "tests/**/*", 12 | "__mocks__/**/*", 13 | "rollup.config.js" 14 | ], 15 | "exclude": ["node_modules", "dist"] 16 | } 17 | -------------------------------------------------------------------------------- /packages/gensx-openai/vitest.config.ts: -------------------------------------------------------------------------------- 1 | // import swc from "unplugin-swc"; 2 | import * as path from "path"; 3 | 4 | import { loadEnv } from "vite"; 5 | import { defineConfig } from "vitest/config"; 6 | 7 | export default defineConfig({ 8 | test: { 9 | root: path.resolve(__dirname, "./"), 10 | globals: true, 11 | isolate: false, 12 | passWithNoTests: false, 13 | include: ["./tests/**/*.test.ts", "./tests/**/*.test.tsx"], 14 | env: loadEnv("test", process.cwd(), ""), 15 | silent: "passed-only", 16 | setupFiles: ["./tests/setup.ts"], 17 | coverage: { 18 | provider: "istanbul", 19 | reporter: ["text-summary", "json-summary", "json"], 20 | reportsDirectory: "coverage", 21 | include: ["./src/**/*.ts", "./src/**/*.tsx"], 22 | exclude: [ 23 | "node_modules/**", 24 | "dist/**", 25 | "coverage/**", 26 | "tests/**", 27 | "**/*.d.ts", 28 | ], 29 | all: true, 30 | enabled: true, 31 | clean: true, 32 | cleanOnRerun: true, 33 | reportOnFailure: true, 34 | skipFull: false, 35 | extension: [".ts", ".tsx"], 36 | }, 37 | }, 38 | // TODO: Get swc working to speed things up 39 | // plugins: [ 40 | // swc.vite({ 41 | // module: { type: "es6" }, 42 | // tsconfigFile: "./tsconfig.json", 43 | // }), 44 | // ], 45 | }); 46 | -------------------------------------------------------------------------------- /packages/gensx-storage/.gitignore: -------------------------------------------------------------------------------- 1 | .tsbuildinfo 2 | -------------------------------------------------------------------------------- /packages/gensx-storage/eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import rootConfig from "../../eslint.config.mjs"; 2 | 3 | export default [ 4 | ...rootConfig, 5 | { 6 | files: ["**/*.{js,mjs,cjs,jsx,ts,tsx}"], 7 | languageOptions: { 8 | parserOptions: { 9 | tsconfigRootDir: import.meta.dirname, 10 | project: "./tsconfig.json", 11 | }, 12 | }, 13 | }, 14 | { 15 | rules: { 16 | "@typescript-eslint/no-empty-object-type": "off", 17 | }, 18 | }, 19 | ]; 20 | -------------------------------------------------------------------------------- /packages/gensx-storage/rollup.config.js: -------------------------------------------------------------------------------- 1 | import { createConfigs } from "../../create-rollup-config.js"; 2 | import packageJson from "./package.json" with { type: "json" }; 3 | 4 | const external = [ 5 | ...Object.keys(packageJson.dependencies), 6 | ...(packageJson.peerDependencies 7 | ? Object.keys(packageJson.peerDependencies) 8 | : []), 9 | ]; 10 | 11 | export default createConfigs("src/index.ts", "@gensx/storage", external); 12 | -------------------------------------------------------------------------------- /packages/gensx-storage/src/blob/useBlob.ts: -------------------------------------------------------------------------------- 1 | import { BlobClient } from "./blobClient.js"; 2 | import { BlobStorageOptions } from "./types.js"; 3 | 4 | /** 5 | * Hook to access a blob 6 | * @param key The name of the blob to access 7 | * @param options Optional configuration properties for the blob 8 | * @returns A blob object for the given key 9 | */ 10 | export function useBlob( 11 | key: string, 12 | options: BlobStorageOptions = {}, 13 | ) { 14 | const client = new BlobClient(options); 15 | return client.getBlob(key); 16 | } 17 | -------------------------------------------------------------------------------- /packages/gensx-storage/src/database/useDatabase.ts: -------------------------------------------------------------------------------- 1 | import { DatabaseClient } from "./databaseClient.js"; 2 | import { Database, DatabaseStorageOptions } from "./types.js"; 3 | 4 | /** 5 | * Hook to access a database 6 | * @param name The name of the database to access 7 | * @param options Optional configuration properties for the database 8 | * @returns A promise that resolves to a database object for the given name 9 | */ 10 | export async function useDatabase( 11 | name: string, 12 | options: DatabaseStorageOptions = {}, 13 | ): Promise { 14 | const client = new DatabaseClient(options); 15 | const db = await client.getDatabase(name); 16 | return db; 17 | } 18 | -------------------------------------------------------------------------------- /packages/gensx-storage/src/index.ts: -------------------------------------------------------------------------------- 1 | // Export the blob storage types and interfaces 2 | export * from "./blob/types.js"; 3 | export { useBlob } from "./blob/useBlob.js"; 4 | export { BlobClient } from "./blob/blobClient.js"; 5 | 6 | // Export the database types and interfaces 7 | export * from "./database/types.js"; 8 | export { useDatabase } from "./database/useDatabase.js"; 9 | export { DatabaseClient } from "./database/databaseClient.js"; 10 | 11 | // Export the search types and interfaces 12 | export * from "./search/types.js"; 13 | export { useSearch } from "./search/useSearch.js"; 14 | export { SearchClient } from "./search/searchClient.js"; 15 | -------------------------------------------------------------------------------- /packages/gensx-storage/src/search/useSearch.ts: -------------------------------------------------------------------------------- 1 | import { SearchClient } from "./searchClient.js"; 2 | import { Namespace, SearchStorageOptions } from "./types.js"; 3 | 4 | /** 5 | * Hook to access a search namespace 6 | * @param name The name of the namespace to access 7 | * @param options Optional configuration properties for the search namespace 8 | * @returns A promise that resolves to a namespace object for the given name 9 | */ 10 | export async function useSearch( 11 | name: string, 12 | options: SearchStorageOptions = {}, 13 | ): Promise { 14 | const client = new SearchClient(options); 15 | const namespace = await client.getNamespace(name); 16 | return namespace; 17 | } 18 | -------------------------------------------------------------------------------- /packages/gensx-storage/src/utils/base64.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Convert string to URL-safe base64 3 | * @param str The string to encode 4 | * @returns URL-safe base64 encoded string 5 | */ 6 | export function toBase64UrlSafe(str: string): string { 7 | return Buffer.from(str).toString("base64url"); 8 | } 9 | 10 | /** 11 | * Convert URL-safe base64 to string 12 | * @param base64 The URL-safe base64 string to decode 13 | * @returns Decoded string 14 | */ 15 | export function fromBase64UrlSafe(base64: string): string { 16 | return Buffer.from(base64, "base64url").toString("utf-8"); 17 | } 18 | -------------------------------------------------------------------------------- /packages/gensx-storage/src/utils/config.ts: -------------------------------------------------------------------------------- 1 | import { getSelectedEnvironment, readProjectConfig } from "@gensx/core"; 2 | 3 | interface ProjectEnvConfig { 4 | project: string; 5 | environment: string; 6 | } 7 | 8 | export function getProjectAndEnvironment(props: { 9 | project?: string; 10 | environment?: string; 11 | }): ProjectEnvConfig { 12 | const projectConfig = readProjectConfig(process.cwd()) as 13 | | { projectName: string } 14 | | undefined; 15 | 16 | const project = 17 | props.project ?? 18 | process.env.GENSX_PROJECT ?? 19 | projectConfig?.projectName ?? 20 | ""; 21 | 22 | if (!project) { 23 | throw new Error( 24 | "Project must be provided via props, a gensx.yaml file, or the GENSX_PROJECT environment variable", 25 | ); 26 | } 27 | 28 | const selectedEnvironment = getSelectedEnvironment(project) as 29 | | string 30 | | undefined; 31 | 32 | let environment = 33 | props.environment ?? process.env.GENSX_ENV ?? selectedEnvironment ?? ""; 34 | 35 | if (!environment) { 36 | throw new Error( 37 | "Environment must be provided via props, set in the CLI via `gensx env select`, or the GENSX_ENV environment variable", 38 | ); 39 | } 40 | 41 | return { project, environment }; 42 | } 43 | -------------------------------------------------------------------------------- /packages/gensx-storage/src/utils/user-agent.ts: -------------------------------------------------------------------------------- 1 | import { existsSync, readFileSync } from "node:fs"; 2 | import path from "node:path"; 3 | import { fileURLToPath } from "node:url"; 4 | 5 | let version = ""; 6 | const dirname = path.dirname(fileURLToPath(import.meta.url)); 7 | 8 | let rootDir = path.resolve(dirname, "..", "..", ".."); 9 | let packageJsonPath = path.join(rootDir, "package.json"); 10 | if (existsSync(packageJsonPath)) { 11 | const localPackageJson = JSON.parse( 12 | readFileSync(packageJsonPath, "utf8"), 13 | ) as { version: string }; 14 | version = localPackageJson.version; 15 | } else { 16 | // if the first check fails, try two levels up instead of three 17 | rootDir = path.resolve(dirname, "..", ".."); 18 | packageJsonPath = path.join(rootDir, "package.json"); 19 | if (existsSync(packageJsonPath)) { 20 | const localPackageJson = JSON.parse( 21 | readFileSync(packageJsonPath, "utf8"), 22 | ) as { version: string }; 23 | version = localPackageJson.version; 24 | } else { 25 | console.error("Error trying to get version from package.json"); 26 | } 27 | } 28 | 29 | export const VERSION = version; 30 | export const USER_AGENT = `@gensx/storage v${VERSION}`; 31 | -------------------------------------------------------------------------------- /packages/gensx-storage/tests/setup.ts: -------------------------------------------------------------------------------- 1 | import { afterEach, beforeEach, vi } from "vitest"; 2 | 3 | afterEach(() => { 4 | vi.clearAllMocks(); 5 | }); 6 | 7 | beforeEach(() => { 8 | vi.resetModules(); 9 | }); 10 | -------------------------------------------------------------------------------- /packages/gensx-storage/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "sourceMap": true, 5 | "declaration": true, 6 | "declarationMap": true, 7 | "incremental": false, 8 | "rootDir": "./src" 9 | }, 10 | "include": ["src/**/*"] 11 | } 12 | -------------------------------------------------------------------------------- /packages/gensx-storage/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.base.json", 3 | "compilerOptions": { 4 | "tsBuildInfoFile": ".tsbuildinfo", 5 | "outDir": "./dist", 6 | "baseUrl": "." 7 | }, 8 | "include": ["src/**/*", "vitest.config.ts", "tests/**/*", "__mocks__/**/*"], 9 | "exclude": ["node_modules", "dist"] 10 | } 11 | -------------------------------------------------------------------------------- /packages/gensx-storage/vitest.config.ts: -------------------------------------------------------------------------------- 1 | // import swc from "unplugin-swc"; 2 | import * as path from "path"; 3 | 4 | import { loadEnv } from "vite"; 5 | import { defineConfig } from "vitest/config"; 6 | 7 | export default defineConfig({ 8 | test: { 9 | root: path.resolve(__dirname, "./"), 10 | globals: true, 11 | isolate: false, 12 | passWithNoTests: false, 13 | include: ["./tests/**/*.test.ts", "./tests/**/*.test.tsx"], 14 | env: loadEnv("test", process.cwd(), ""), 15 | setupFiles: ["./tests/setup.ts"], 16 | coverage: { 17 | provider: "istanbul", 18 | reporter: ["text-summary", "json-summary", "json"], 19 | reportsDirectory: "coverage", 20 | include: ["./src/**/*.ts", "./src/**/*.tsx"], 21 | exclude: [ 22 | "node_modules/**", 23 | "dist/**", 24 | "coverage/**", 25 | "tests/**", 26 | "**/*.d.ts", 27 | ], 28 | all: true, 29 | enabled: true, 30 | clean: true, 31 | cleanOnRerun: true, 32 | reportOnFailure: true, 33 | skipFull: false, 34 | extension: [".ts", ".tsx"], 35 | }, 36 | }, 37 | // TODO: Get swc working to speed things up 38 | // plugins: [ 39 | // swc.vite({ 40 | // module: { type: "es6" }, 41 | // tsconfigFile: "./tsconfig.json", 42 | // }), 43 | // ], 44 | }); 45 | -------------------------------------------------------------------------------- /packages/gensx-vercel-ai/.gitignore: -------------------------------------------------------------------------------- 1 | .tsbuildinfo 2 | -------------------------------------------------------------------------------- /packages/gensx-vercel-ai/README.md: -------------------------------------------------------------------------------- 1 | # @gensx/vercel-ai 2 | 3 | Vercel AI SDK for [GenSX](https://github.com/gensx-inc/gensx/packages/gensx-vercel-ai) 4 | 5 | ## Installation 6 | 7 | ```bash 8 | npm install @gensx/vercel-ai 9 | ``` 10 | 11 | ### Requires `@gensx/core` 12 | 13 | This package requires `@gensx/core` to be installed as a peer dependency. 14 | 15 | ```bash 16 | npm install @gensx/core 17 | ``` 18 | 19 | ## Usage 20 | 21 | ```tsx 22 | import * as gensx from "@gensx/core"; 23 | import { generateText, streamText } from "@gensx/vercel-ai"; 24 | 25 | @Component() 26 | async function ChatBot({ userInput }: { userInput: string }): Promise { 27 | const result = await generateText({ 28 | messages: [ 29 | { role: "system", content: "You are a helpful assistant." }, 30 | { role: "user", content: userInput }, 31 | ], 32 | model: "gpt-4o", 33 | temperature: 0.7, 34 | }); 35 | return result.text; 36 | } 37 | ``` 38 | -------------------------------------------------------------------------------- /packages/gensx-vercel-ai/eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import rootConfig from "../../eslint.config.mjs"; 2 | 3 | export default [ 4 | ...rootConfig, 5 | { 6 | files: ["**/*.{js,mjs,cjs,jsx,ts,tsx}"], 7 | languageOptions: { 8 | parserOptions: { 9 | tsconfigRootDir: import.meta.dirname, 10 | project: "./tsconfig.json", 11 | }, 12 | }, 13 | }, 14 | { 15 | rules: { 16 | "@typescript-eslint/no-empty-object-type": "off", 17 | }, 18 | }, 19 | ]; 20 | -------------------------------------------------------------------------------- /packages/gensx-vercel-ai/rollup.config.js: -------------------------------------------------------------------------------- 1 | import { createConfigs } from "../../create-rollup-config.js"; 2 | import packageJson from "./package.json" with { type: "json" }; 3 | 4 | const external = [ 5 | ...Object.keys(packageJson.dependencies), 6 | ...(packageJson.peerDependencies 7 | ? Object.keys(packageJson.peerDependencies) 8 | : []), 9 | ]; 10 | 11 | export default createConfigs("src/index.ts", "@gensx/vercel-ai", external); 12 | -------------------------------------------------------------------------------- /packages/gensx-vercel-ai/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "sourceMap": true, 5 | "declaration": true, 6 | "declarationMap": true, 7 | "incremental": false, 8 | "rootDir": "./src" 9 | }, 10 | "include": ["src/**/*"] 11 | } 12 | -------------------------------------------------------------------------------- /packages/gensx-vercel-ai/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.base.json", 3 | "compilerOptions": { 4 | "outDir": "./dist", 5 | "baseUrl": ".", 6 | "tsBuildInfoFile": ".tsbuildinfo" 7 | }, 8 | "include": ["src/**/*", "vitest.config.ts", "tests/**/*", "rollup.config.js"], 9 | "exclude": ["node_modules", "dist"] 10 | } 11 | -------------------------------------------------------------------------------- /packages/gensx-vercel-ai/vitest.config.ts: -------------------------------------------------------------------------------- 1 | // import swc from "unplugin-swc"; 2 | import * as path from "path"; 3 | 4 | import { loadEnv } from "vite"; 5 | import { defineConfig } from "vitest/config"; 6 | 7 | export default defineConfig({ 8 | test: { 9 | root: path.resolve(__dirname, "./"), 10 | globals: true, 11 | isolate: false, 12 | passWithNoTests: false, 13 | include: ["./tests/**/*.test.ts", "./tests/**/*.test.tsx"], 14 | silent: false, 15 | env: loadEnv("test", process.cwd(), ""), 16 | coverage: { 17 | provider: "istanbul", 18 | reporter: ["text-summary", "json-summary", "json"], 19 | reportsDirectory: "coverage", 20 | include: ["./src/**/*.ts", "./src/**/*.tsx"], 21 | exclude: [ 22 | "node_modules/**", 23 | "dist/**", 24 | "coverage/**", 25 | "tests/**", 26 | "**/*.d.ts", 27 | ], 28 | all: true, 29 | enabled: true, 30 | clean: true, 31 | cleanOnRerun: true, 32 | reportOnFailure: true, 33 | skipFull: false, 34 | extension: [".ts", ".tsx"], 35 | }, 36 | }, 37 | // TODO: Get swc working to speed things up 38 | // plugins: [ 39 | // swc.vite({ 40 | // module: { type: "es6" }, 41 | // tsconfigFile: "./tsconfig.json", 42 | // }), 43 | // ], 44 | }); 45 | -------------------------------------------------------------------------------- /packages/gensx-windsurf-rules/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated files 2 | .windsurfrules 3 | -------------------------------------------------------------------------------- /packages/gensx-windsurf-rules/eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import baseConfig from "../../eslint.config.mjs"; 2 | 3 | export default [ 4 | ...baseConfig, 5 | { 6 | files: ["src/**/*.ts", "tests/**/*.ts", "*.ts"], 7 | languageOptions: { 8 | parserOptions: { 9 | project: "./tsconfig.json", 10 | }, 11 | }, 12 | rules: { 13 | "no-console": ["error", { allow: ["info", "error", "warn", "log"] }], 14 | "n/no-process-exit": "off", 15 | "n/shebang": "off", 16 | }, 17 | }, 18 | ]; 19 | -------------------------------------------------------------------------------- /packages/gensx-windsurf-rules/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@gensx/windsurf-rules", 3 | "version": "0.1.8", 4 | "description": "Windsurf rules for GenSX projects", 5 | "bin": { 6 | "gensx-windsurf-rules": "./dist/cli.js" 7 | }, 8 | "type": "module", 9 | "scripts": { 10 | "build": "tsc -p tsconfig.build.json && chmod +x dist/cli.js", 11 | "clean": "rm -rf dist", 12 | "lint": "eslint .", 13 | "lint:fix": "eslint . --fix", 14 | "test": "vitest run", 15 | "test:watch": "vitest watch", 16 | "test:types": "tsc --noEmit" 17 | }, 18 | "repository": { 19 | "type": "git", 20 | "url": "https://github.com/gensx-inc/gensx.git", 21 | "directory": "packages/gensx-windsurf-rules" 22 | }, 23 | "keywords": [ 24 | "gensx", 25 | "windsurf", 26 | "rules" 27 | ], 28 | "files": [ 29 | "templates", 30 | "dist" 31 | ], 32 | "publishConfig": { 33 | "access": "public" 34 | }, 35 | "author": "GenSX Inc.", 36 | "license": "Apache-2.0", 37 | "devDependencies": { 38 | "@types/node": "catalog:packages", 39 | "typescript": "catalog:", 40 | "vite": "catalog:", 41 | "vitest": "catalog:" 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /packages/gensx-windsurf-rules/tests/cli.test.ts: -------------------------------------------------------------------------------- 1 | import { exec } from "node:child_process"; 2 | import fs from "node:fs"; 3 | import os from "node:os"; 4 | import path from "node:path"; 5 | 6 | import { expect, suite, test } from "vitest"; 7 | 8 | suite("Gensx Windsurf Rules", () => { 9 | test("should create the rules", async () => { 10 | const tmpDir = fs.mkdtempSync( 11 | path.join(os.tmpdir(), "gensx-windsurf-rules-"), 12 | ); 13 | 14 | const cwd = process.cwd(); 15 | 16 | // execute the cli.js file 17 | await new Promise((resolve, reject) => { 18 | exec( 19 | `${cwd}/dist/cli.js`, 20 | { 21 | cwd: tmpDir, 22 | }, 23 | (error, stdout, stderr) => { 24 | if (error) reject(error); 25 | resolve({ stdout, stderr }); 26 | }, 27 | ); 28 | }); 29 | 30 | // check if the .windsurfrules file was created 31 | const ruleFile = path.join(tmpDir, ".windsurfrules"); 32 | expect(fs.existsSync(ruleFile)).toBe(true); 33 | expect(fs.readFileSync(ruleFile, "utf8")).toContain( 34 | "GenSX Project Guidelines", 35 | ); 36 | }); 37 | }); 38 | -------------------------------------------------------------------------------- /packages/gensx-windsurf-rules/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "rootDir": "./src", 5 | "outDir": "./dist", 6 | "noEmit": false 7 | }, 8 | "include": ["src/**/*"] 9 | } 10 | -------------------------------------------------------------------------------- /packages/gensx-windsurf-rules/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.base.json", 3 | "compilerOptions": { 4 | "module": "NodeNext", 5 | "moduleResolution": "NodeNext", 6 | "target": "esnext", 7 | "tsBuildInfoFile": ".tsbuildinfo", 8 | "outDir": "./dist", 9 | "baseUrl": ".", 10 | "types": ["@types/node"], 11 | "emitDeclarationOnly": false 12 | }, 13 | "include": ["src/**/*", "vitest.config.ts", "tests/**/*", "vitest.config.ts"] 14 | } 15 | -------------------------------------------------------------------------------- /packages/gensx-windsurf-rules/vitest.config.ts: -------------------------------------------------------------------------------- 1 | import * as path from "path"; 2 | 3 | import { defineConfig } from "vitest/config"; 4 | 5 | export default defineConfig({ 6 | test: { 7 | root: path.resolve(__dirname, "./"), 8 | globals: true, 9 | isolate: false, 10 | passWithNoTests: false, 11 | include: ["./tests/**/*.test.ts"], 12 | silent: "passed-only", 13 | }, 14 | }); 15 | -------------------------------------------------------------------------------- /packages/gensx/.npmignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | dist/ 3 | .tmp 4 | .idea 5 | .env 6 | coverage/ 7 | .npm 8 | .vscode 9 | -------------------------------------------------------------------------------- /packages/gensx/.npmrc: -------------------------------------------------------------------------------- 1 | engine-strict=true 2 | -------------------------------------------------------------------------------- /packages/gensx/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # GenSX CLI 2 | 3 | ## Development 4 | 5 | 1. Install deps: 6 | 7 | ```bash 8 | pnpm install 9 | ``` 10 | 11 | 2. Build the CLI: 12 | 13 | ```bash 14 | pnpm build 15 | ``` 16 | 17 | 3. Install the CLI globally: 18 | 19 | ```bash 20 | pnpm link --global 21 | ``` 22 | 23 | 4. Watch for changes: 24 | 25 | ```bash 26 | pnpm dev 27 | ``` 28 | 29 | Now you can call `gensx` from the command line anywhere, and it will run the CLI with your most recent changes. 30 | -------------------------------------------------------------------------------- /packages/gensx/README.md: -------------------------------------------------------------------------------- 1 | # GenSX CLI 2 | 3 | ## Installation 4 | 5 | ```bash 6 | npm install -g gensx 7 | 8 | # or 9 | 10 | pnpm install -g gensx 11 | 12 | # or 13 | 14 | yarn global add gensx 15 | 16 | # or 17 | 18 | brew install gensx-inc/gensx/gensx 19 | ``` 20 | 21 | Or use without installing globally: 22 | 23 | ```bash 24 | npx gensx 25 | ``` 26 | 27 | ## Usage 28 | 29 | ### Login 30 | 31 | Login to GenSX to get started: 32 | 33 | ```bash 34 | gensx login 35 | ``` 36 | 37 | Now you will have an API key saved in your config file, and this will be used by default for any commands that require authentication, or when running a workflow locally. 38 | -------------------------------------------------------------------------------- /packages/gensx/eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import eslintPluginN from "eslint-plugin-n"; 2 | 3 | import rootConfig from "../../eslint.config.mjs"; 4 | 5 | export default [ 6 | { 7 | ignores: ["**/coverage/**"], 8 | }, 9 | ...rootConfig, 10 | { 11 | files: ["**/*.{js,mjs,cjs,jsx,ts,tsx}"], 12 | languageOptions: { 13 | parserOptions: { 14 | project: "./tsconfig.json", 15 | tsconfigRootDir: import.meta.dirname, 16 | }, 17 | }, 18 | }, 19 | { 20 | plugins: { 21 | n: eslintPluginN, 22 | }, 23 | rules: { 24 | "n/prefer-node-protocol": "error", 25 | }, 26 | }, 27 | ]; 28 | -------------------------------------------------------------------------------- /packages/gensx/src/components/ErrorMessage.tsx: -------------------------------------------------------------------------------- 1 | import { Box, Text } from "ink"; 2 | 3 | interface Props { 4 | message: string; 5 | title?: string; 6 | } 7 | 8 | export function ErrorMessage({ message, title = "Error" }: Props) { 9 | return ( 10 | 11 | 12 | 13 | {title}: {message} 14 | 15 | 16 | 17 | ); 18 | } 19 | -------------------------------------------------------------------------------- /packages/gensx/src/components/FirstTimeSetup.tsx: -------------------------------------------------------------------------------- 1 | import { Box, Text } from "ink"; 2 | import { useCallback, useEffect, useState } from "react"; 3 | 4 | import { LoginUI } from "../commands/login.js"; 5 | import { getState, saveState } from "../utils/config.js"; 6 | 7 | export function FirstTimeSetup() { 8 | const [isComplete, setIsComplete] = useState(false); 9 | const [isLoading, setIsLoading] = useState(true); 10 | 11 | const checkFirstTimeSetup = useCallback(async () => { 12 | try { 13 | const state = await getState(); 14 | if (!state.hasCompletedFirstTimeSetup) { 15 | // Ensure that we don't ask again. 16 | await saveState({ hasCompletedFirstTimeSetup: true }); 17 | setIsLoading(false); 18 | } else { 19 | setIsComplete(true); 20 | } 21 | } catch (_error) { 22 | setIsLoading(false); 23 | } 24 | }, []); 25 | 26 | useEffect(() => { 27 | void checkFirstTimeSetup(); 28 | }, [checkFirstTimeSetup]); 29 | 30 | if (isLoading) { 31 | return null; 32 | } 33 | 34 | if (isComplete) { 35 | return null; 36 | } 37 | 38 | return ( 39 | 40 | 41 | 42 | Welcome to GenSX! Let's get you set up first. 43 | 44 | 45 | 46 | 47 | ); 48 | } 49 | -------------------------------------------------------------------------------- /packages/gensx/src/components/LoadingSpinner.tsx: -------------------------------------------------------------------------------- 1 | import { Box, Text } from "ink"; 2 | import Spinner from "ink-spinner"; 3 | 4 | interface Props { 5 | message?: string; 6 | } 7 | 8 | // By default the message is empty, so just the spinner is shown 9 | export function LoadingSpinner({ message = "" }: Props) { 10 | return ( 11 | 12 | 13 | {message} 14 | 15 | 16 | ); 17 | } 18 | -------------------------------------------------------------------------------- /packages/gensx/src/run.ts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | import { runCLI } from "./index.js"; 4 | 5 | void runCLI(); 6 | -------------------------------------------------------------------------------- /packages/gensx/src/templates/projects/typescript/package.json.template: -------------------------------------------------------------------------------- 1 | { 2 | "name": "my-gensx-app", 3 | "private": true, 4 | "version": "0.0.1", 5 | "type": "module", 6 | "engines": { 7 | "node": ">=18.0.0" 8 | }, 9 | "scripts": { 10 | "dev": "tsx ./src/index.ts", 11 | "start": "npx gensx start ./src/workflows.ts", 12 | "build": "tsc", 13 | "deploy": "npx gensx deploy -e OPENAI_API_KEY ./src/workflows.ts" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /packages/gensx/src/templates/projects/typescript/src/index.ts.template: -------------------------------------------------------------------------------- 1 | import { ChatWorkflow } from "./workflows.js"; 2 | 3 | const result = await ChatWorkflow({ 4 | userMessage: "Hi there! Say 'Hello, World!' and nothing else.", 5 | }); 6 | 7 | console.log(result); 8 | -------------------------------------------------------------------------------- /packages/gensx/src/templates/projects/typescript/src/workflows.ts.template: -------------------------------------------------------------------------------- 1 | import * as gensx from "@gensx/core"; 2 | import { openai } from "@ai-sdk/openai"; 3 | import { generateText } from "@gensx/vercel-ai"; 4 | 5 | interface ChatProps { 6 | userMessage: string; 7 | } 8 | 9 | const Chat = gensx.Component("Chat", async ({ userMessage }: ChatProps) => { 10 | const result = await generateText({ 11 | model: openai("gpt-4.1-mini"), 12 | messages: [ 13 | { 14 | role: "system", 15 | content: "You are a helpful assistant.", 16 | }, 17 | { role: "user", content: userMessage }, 18 | ], 19 | }); 20 | return result.text; 21 | }); 22 | 23 | const ChatWorkflow = gensx.Workflow( 24 | "ChatWorkflow", 25 | async ({ userMessage }: ChatProps) => { 26 | return await Chat({ userMessage }); 27 | }, 28 | ); 29 | 30 | export { ChatWorkflow }; 31 | -------------------------------------------------------------------------------- /packages/gensx/src/templates/projects/typescript/template.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "typescript", 3 | "description": "A TypeScript-based GenSX project template", 4 | "dependencies": ["@gensx/core", "@gensx/vercel-ai", "@ai-sdk/openai"], 5 | "devDependencies": ["@types/node", "typescript@5.7.2", "tsx"], 6 | "runCommand": "OPENAI_API_KEY= npm run dev" 7 | } 8 | -------------------------------------------------------------------------------- /packages/gensx/src/templates/projects/typescript/tsconfig.json.template: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ESNext", 4 | "module": "NodeNext", 5 | "lib": [ 6 | "ESNext", 7 | "DOM" 8 | ], 9 | "strict": true, 10 | "esModuleInterop": true, 11 | "skipLibCheck": true, 12 | "forceConsistentCasingInFileNames": true, 13 | "moduleResolution": "NodeNext", 14 | "resolveJsonModule": true, 15 | "isolatedModules": true, 16 | "outDir": "./dist" 17 | }, 18 | "include": [ 19 | "./src/**/*.ts" 20 | ], 21 | "exclude": [ 22 | "node_modules" 23 | ] 24 | } 25 | -------------------------------------------------------------------------------- /packages/gensx/src/types/prompt.ts: -------------------------------------------------------------------------------- 1 | export interface PromptModule { 2 | prompt(options: unknown): Promise; 3 | } 4 | -------------------------------------------------------------------------------- /packages/gensx/src/utils/exec.ts: -------------------------------------------------------------------------------- 1 | import { exec as execCallback } from "node:child_process"; 2 | import { promisify } from "node:util"; 3 | 4 | export const exec = promisify(execCallback); 5 | -------------------------------------------------------------------------------- /packages/gensx/src/utils/user-agent.ts: -------------------------------------------------------------------------------- 1 | import { readFileSync } from "node:fs"; 2 | import path from "node:path"; 3 | import { fileURLToPath } from "node:url"; 4 | 5 | const dirname = path.dirname(fileURLToPath(import.meta.url)); 6 | 7 | let VERSION: string; 8 | try { 9 | const localPackageJson = JSON.parse( 10 | readFileSync(path.join(dirname, "..", "..", "package.json"), "utf8"), 11 | ) as { version: string }; 12 | VERSION = localPackageJson.version; 13 | } catch { 14 | VERSION = "unknown"; 15 | } 16 | 17 | export { VERSION }; 18 | export const USER_AGENT = `GenSX CLI${VERSION === "unknown" ? "" : ` v${VERSION}`}`; 19 | -------------------------------------------------------------------------------- /packages/gensx/tests/setup.ts: -------------------------------------------------------------------------------- 1 | import path from "node:path"; 2 | 3 | import { afterAll, afterEach, beforeAll, beforeEach, vi } from "vitest"; 4 | 5 | import { 6 | cleanupProjectFiles, 7 | cleanupTestEnvironment, 8 | setupTestEnvironment, 9 | } from "./test-helpers.js"; 10 | 11 | // Setup test variables that will be shared across tests 12 | export let tempDir: string; 13 | export let origCwd: typeof process.cwd; 14 | export let origConfigDir: string | undefined; 15 | 16 | // Set up and tear down the test environment 17 | beforeAll(async () => { 18 | const setup = await setupTestEnvironment("gensx-tests"); 19 | tempDir = setup.tempDir; 20 | origCwd = setup.origCwd; 21 | origConfigDir = setup.origConfigDir; 22 | }); 23 | 24 | afterAll(async () => { 25 | await cleanupTestEnvironment(tempDir, origCwd, origConfigDir); 26 | }); 27 | 28 | beforeEach(() => { 29 | // Set working directory to our test project 30 | process.cwd = vi.fn().mockReturnValue(path.join(tempDir, "project")); 31 | }); 32 | 33 | afterEach(async () => { 34 | vi.resetAllMocks(); 35 | await cleanupProjectFiles(tempDir); 36 | }); 37 | -------------------------------------------------------------------------------- /packages/gensx/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "./dist", 5 | "sourceMap": true, 6 | "declaration": true, 7 | "declarationMap": true, 8 | "incremental": false, 9 | "rootDir": "./src" 10 | }, 11 | "include": ["src/**/*"] 12 | } 13 | -------------------------------------------------------------------------------- /packages/gensx/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.base.json", 3 | "compilerOptions": { 4 | "tsBuildInfoFile": ".tsbuildinfo", 5 | "outDir": "./dist", 6 | "jsxImportSource": "react", 7 | "jsx": "react-jsx" 8 | }, 9 | "include": ["src/**/*", "tests/**/*", "vitest.config.ts"], 10 | "exclude": ["node_modules", "dist"] 11 | } 12 | -------------------------------------------------------------------------------- /packages/gensx/vitest.config.ts: -------------------------------------------------------------------------------- 1 | // import swc from "unplugin-swc"; 2 | import * as path from "node:path"; 3 | 4 | import { loadEnv } from "vite"; 5 | import { defineConfig } from "vitest/config"; 6 | 7 | export default defineConfig({ 8 | test: { 9 | forceRerunTriggers: ["**/*.ts", "**/*.template"], 10 | root: path.resolve(process.cwd(), "./"), 11 | globals: true, 12 | isolate: true, 13 | passWithNoTests: false, 14 | silent: "passed-only", 15 | include: ["./tests/**/*.test.ts"], 16 | env: loadEnv("test", process.cwd(), ""), 17 | setupFiles: ["./tests/setup.ts"], 18 | coverage: { 19 | provider: "istanbul", 20 | reporter: ["text-summary", "json-summary", "json"], 21 | reportsDirectory: "coverage", 22 | include: ["./src/**/*.ts"], 23 | exclude: [ 24 | "node_modules/**", 25 | "dist/**", 26 | "coverage/**", 27 | "tests/**", 28 | "**/*.d.ts", 29 | ], 30 | all: true, 31 | enabled: true, 32 | clean: true, 33 | cleanOnRerun: true, 34 | reportOnFailure: true, 35 | skipFull: false, 36 | extension: [".ts"], 37 | }, 38 | }, 39 | }); 40 | -------------------------------------------------------------------------------- /packages/tsconfig.base.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@tsconfig/node20/tsconfig.json", 3 | "compilerOptions": { 4 | "target": "esnext", 5 | "useDefineForClassFields": true, 6 | "module": "NodeNext", 7 | "lib": ["ESNext"], 8 | "incremental": true, 9 | "skipLibCheck": true, 10 | "moduleResolution": "NodeNext", 11 | "resolveJsonModule": true, 12 | "declaration": true, 13 | "declarationMap": true, 14 | "isolatedModules": true, 15 | "emitDeclarationOnly": false, 16 | "sourceMap": true, 17 | "inlineSources": true, 18 | "strict": true, 19 | "noUnusedLocals": true, 20 | "noUnusedParameters": true, 21 | "noFallthroughCasesInSwitch": true 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /pnpm-workspace.yaml: -------------------------------------------------------------------------------- 1 | packages: 2 | - "packages/*" 3 | - "examples/*" 4 | - "docs" 5 | - "website/docs" 6 | - "website/home" 7 | - "!**/dist" 8 | 9 | catalog: 10 | "@rollup/plugin-commonjs": "^25.0.7" 11 | "@rollup/plugin-node-resolve": "^15.2.3" 12 | "@rollup/plugin-typescript": "^11.1.6" 13 | "@types/glob": "^8.1.0" 14 | "@types/react": "^18.3.20" 15 | "@vitest/coverage-istanbul": "^3.1.3" 16 | "eslint-plugin-n": "^17.16.2" 17 | "glob": "^10.3.10" 18 | "gray-matter": "^4.0.3" 19 | "ink": "^5.2.1" 20 | "nodemon": "^3.1.9" 21 | "openai": "^4.87.4" 22 | "rollup": "^4.39.0" 23 | "tsx": "^4.19.2" 24 | "typescript": "^5.7.2" 25 | "vite": "^6.2.2" 26 | "vitest": "^3.1.3" 27 | "zod-to-json-schema": "^3.24.1" 28 | "zod": "^3.24.2" 29 | 30 | catalogs: 31 | examples: 32 | "@types/node": "^22" 33 | packages: 34 | "@types/node": "^18" 35 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json.schemastore.org/tsconfig", 3 | "compilerOptions": { 4 | "target": "esnext", 5 | "useDefineForClassFields": true, 6 | "module": "esnext", 7 | "lib": ["ESNext"], 8 | "tsBuildInfoFile": ".tsbuildinfo", 9 | "incremental": true, 10 | "skipLibCheck": true, 11 | "moduleResolution": "bundler", 12 | "resolveJsonModule": true, 13 | "isolatedModules": true, 14 | "emitDeclarationOnly": true, 15 | "declaration": true, 16 | "declarationMap": true, 17 | "outDir": "dist", 18 | "sourceMap": true, 19 | "inlineSources": true, 20 | "strict": true, 21 | "noUnusedLocals": true, 22 | "noUnusedParameters": true, 23 | "noFallthroughCasesInSwitch": true, 24 | "baseUrl": "." 25 | }, 26 | "include": ["vitest.workspace.ts"], 27 | "exclude": ["node_modules", "dist"] 28 | } 29 | -------------------------------------------------------------------------------- /vitest.workspace.ts: -------------------------------------------------------------------------------- 1 | import { defineWorkspace } from "vitest/config"; 2 | 3 | export default defineWorkspace(["packages/*/vitest.config.ts"]); 4 | -------------------------------------------------------------------------------- /website/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gensx-inc/gensx/1bc9c059cd7418c19fbe44ef85eb453fb9f74df5/website/.DS_Store -------------------------------------------------------------------------------- /website/docs/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | /public/_pagefind 4 | 5 | # dependencies 6 | /node_modules 7 | /.pnp 8 | .pnp.* 9 | .yarn/* 10 | !.yarn/patches 11 | !.yarn/plugins 12 | !.yarn/releases 13 | !.yarn/versions 14 | 15 | # testing 16 | /coverage 17 | 18 | # next.js 19 | /.next/ 20 | /out/ 21 | .next 22 | 23 | # production 24 | /build 25 | 26 | # misc 27 | .DS_Store 28 | *.pem 29 | 30 | # debug 31 | npm-debug.log* 32 | yarn-debug.log* 33 | yarn-error.log* 34 | .pnpm-debug.log* 35 | 36 | # env files (can opt-in for committing if needed) 37 | .env* 38 | 39 | # vercel 40 | .vercel 41 | 42 | # typescript 43 | *.tsbuildinfo 44 | next-env.d.ts 45 | 46 | public/docs/sitemap*.xml 47 | -------------------------------------------------------------------------------- /website/docs/.npmrc: -------------------------------------------------------------------------------- 1 | //.npmrc 2 | enable-pre-post-scripts=true 3 | -------------------------------------------------------------------------------- /website/docs/eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import { dirname } from "path"; 2 | import { fileURLToPath } from "url"; 3 | import { FlatCompat } from "@eslint/eslintrc"; 4 | 5 | const __filename = fileURLToPath(import.meta.url); 6 | const __dirname = dirname(__filename); 7 | 8 | const compat = new FlatCompat({ 9 | baseDirectory: __dirname, 10 | }); 11 | 12 | const eslintConfig = [ 13 | ...compat.extends("next/core-web-vitals", "next/typescript"), 14 | ]; 15 | 16 | export default eslintConfig; 17 | -------------------------------------------------------------------------------- /website/docs/mdx-components.js: -------------------------------------------------------------------------------- 1 | import { useMDXComponents as getDocsMDXComponents } from "nextra-theme-docs"; 2 | 3 | const docsComponents = getDocsMDXComponents(); 4 | 5 | export const useMDXComponents = (components) => ({ 6 | ...docsComponents, 7 | ...components, 8 | }); 9 | -------------------------------------------------------------------------------- /website/docs/next-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | 4 | // NOTE: This file should not be edited 5 | // see https://nextjs.org/docs/app/api-reference/config/typescript for more information. 6 | -------------------------------------------------------------------------------- /website/docs/next-sitemap.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('next-sitemap').IConfig} */ 2 | module.exports = { 3 | siteUrl: "https://gensx.com", 4 | outDir: "public/docs", 5 | generateRobotsTxt: false, 6 | generateIndexSitemap: false, 7 | }; 8 | -------------------------------------------------------------------------------- /website/docs/next.config.ts: -------------------------------------------------------------------------------- 1 | import nextra from "nextra"; 2 | 3 | const withNextra = nextra({ 4 | latex: true, 5 | search: { 6 | codeblocks: false, 7 | }, 8 | contentDirBasePath: "/docs", 9 | }); 10 | 11 | export default withNextra({ 12 | reactStrictMode: true, 13 | assetPrefix: "/docs-static", 14 | }); 15 | -------------------------------------------------------------------------------- /website/docs/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "gensx-docs", 3 | "license": "Apache-2.0", 4 | "private": true, 5 | "scripts": { 6 | "build": "next build", 7 | "dev": "next dev --turbopack -p 4000", 8 | "postbuild": "pagefind --site .next/server/app --output-path public/_pagefind && next-sitemap", 9 | "start": "next start", 10 | "lint": "next lint", 11 | "lint:fix": "next lint --fix", 12 | "format": "prettier --write ." 13 | }, 14 | "dependencies": { 15 | "@next/third-parties": "^15.2.4", 16 | "@tailwindcss/postcss": "^4.1.0", 17 | "@vercel/analytics": "^1.5.0", 18 | "next": "^15.2.4", 19 | "next-sitemap": "^4.2.3", 20 | "nextra": "^4.2.17", 21 | "nextra-theme-docs": "^4.2.17", 22 | "postcss": "^8", 23 | "react": "18.3.1", 24 | "react-dom": "18.3.1", 25 | "tailwindcss": "^4.0.6", 26 | "tailwindcss-animate": "^1.0.7" 27 | }, 28 | "devDependencies": { 29 | "@tailwindcss/typography": "^0.5.16", 30 | "@types/node": "^20.17.30", 31 | "@types/react": "^19", 32 | "pagefind": "^1.3.0", 33 | "typescript": "^5.8.2" 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /website/docs/postcss.config.mjs: -------------------------------------------------------------------------------- 1 | const config = { 2 | plugins: { 3 | "@tailwindcss/postcss": {}, 4 | }, 5 | }; 6 | export default config; 7 | -------------------------------------------------------------------------------- /website/docs/public/cloud/claude-desktop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gensx-inc/gensx/1bc9c059cd7418c19fbe44ef85eb453fb9f74df5/website/docs/public/cloud/claude-desktop.png -------------------------------------------------------------------------------- /website/docs/public/cloud/component-trace.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gensx-inc/gensx/1bc9c059cd7418c19fbe44ef85eb453fb9f74df5/website/docs/public/cloud/component-trace.png -------------------------------------------------------------------------------- /website/docs/public/cloud/console-playground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gensx-inc/gensx/1bc9c059cd7418c19fbe44ef85eb453fb9f74df5/website/docs/public/cloud/console-playground.png -------------------------------------------------------------------------------- /website/docs/public/cloud/console-workflow-docs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gensx-inc/gensx/1bc9c059cd7418c19fbe44ef85eb453fb9f74df5/website/docs/public/cloud/console-workflow-docs.png -------------------------------------------------------------------------------- /website/docs/public/cloud/console-workflows.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gensx-inc/gensx/1bc9c059cd7418c19fbe44ef85eb453fb9f74df5/website/docs/public/cloud/console-workflows.png -------------------------------------------------------------------------------- /website/docs/public/cloud/local-swagger-ui.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gensx-inc/gensx/1bc9c059cd7418c19fbe44ef85eb453fb9f74df5/website/docs/public/cloud/local-swagger-ui.png -------------------------------------------------------------------------------- /website/docs/public/cloud/project-structure.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gensx-inc/gensx/1bc9c059cd7418c19fbe44ef85eb453fb9f74df5/website/docs/public/cloud/project-structure.png -------------------------------------------------------------------------------- /website/docs/public/cloud/swagger-execute.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gensx-inc/gensx/1bc9c059cd7418c19fbe44ef85eb453fb9f74df5/website/docs/public/cloud/swagger-execute.png -------------------------------------------------------------------------------- /website/docs/public/cloud/trace.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gensx-inc/gensx/1bc9c059cd7418c19fbe44ef85eb453fb9f74df5/website/docs/public/cloud/trace.png -------------------------------------------------------------------------------- /website/docs/public/docs/computer-use-trace.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gensx-inc/gensx/1bc9c059cd7418c19fbe44ef85eb453fb9f74df5/website/docs/public/docs/computer-use-trace.png -------------------------------------------------------------------------------- /website/docs/public/docs/gensx-visualize-workflow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gensx-inc/gensx/1bc9c059cd7418c19fbe44ef85eb453fb9f74df5/website/docs/public/docs/gensx-visualize-workflow.png -------------------------------------------------------------------------------- /website/docs/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gensx-inc/gensx/1bc9c059cd7418c19fbe44ef85eb453fb9f74df5/website/docs/public/favicon.ico -------------------------------------------------------------------------------- /website/docs/public/quickstart/api-docs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gensx-inc/gensx/1bc9c059cd7418c19fbe44ef85eb453fb9f74df5/website/docs/public/quickstart/api-docs.png -------------------------------------------------------------------------------- /website/docs/public/quickstart/blog-trace.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gensx-inc/gensx/1bc9c059cd7418c19fbe44ef85eb453fb9f74df5/website/docs/public/quickstart/blog-trace.png -------------------------------------------------------------------------------- /website/docs/public/quickstart/run-console.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gensx-inc/gensx/1bc9c059cd7418c19fbe44ef85eb453fb9f74df5/website/docs/public/quickstart/run-console.png -------------------------------------------------------------------------------- /website/docs/public/quickstart/trace-rag.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gensx-inc/gensx/1bc9c059cd7418c19fbe44ef85eb453fb9f74df5/website/docs/public/quickstart/trace-rag.png -------------------------------------------------------------------------------- /website/docs/public/quickstart/trace.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gensx-inc/gensx/1bc9c059cd7418c19fbe44ef85eb453fb9f74df5/website/docs/public/quickstart/trace.png -------------------------------------------------------------------------------- /website/docs/public/quickstart/writer-trace.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gensx-inc/gensx/1bc9c059cd7418c19fbe44ef85eb453fb9f74df5/website/docs/public/quickstart/writer-trace.png -------------------------------------------------------------------------------- /website/docs/src/app/_ignored/_meta.js: -------------------------------------------------------------------------------- 1 | // This file will be NOT treated as `_meta` file, since directory starts with underscore 2 | const meta = {}; 3 | export default meta; 4 | -------------------------------------------------------------------------------- /website/docs/src/app/_ignored/page.mdx: -------------------------------------------------------------------------------- 1 | This file will be NOT treated as page, since directory starts with underscore 2 | -------------------------------------------------------------------------------- /website/docs/src/app/_meta.ts: -------------------------------------------------------------------------------- 1 | const meta = {}; 2 | export default meta; 3 | -------------------------------------------------------------------------------- /website/docs/src/app/components/Logo.tsx: -------------------------------------------------------------------------------- 1 | "use client"; 2 | 3 | import Image from "next/image"; 4 | import { useTheme } from "nextra-theme-docs"; 5 | import { useState, useEffect } from "react"; 6 | 7 | const Logo = () => { 8 | const { resolvedTheme } = useTheme(); 9 | const [logoSrc, setLogoSrc] = useState("/logo.svg"); 10 | 11 | useEffect(() => { 12 | setLogoSrc(resolvedTheme === "dark" ? "/logo-dark.svg" : "/logo.svg"); 13 | }, [resolvedTheme]); 14 | 15 | return ( 16 | GenSX Logo 23 | ); 24 | }; 25 | 26 | export default Logo; 27 | -------------------------------------------------------------------------------- /website/docs/src/app/docs/[[...mdxPath]]/page.tsx: -------------------------------------------------------------------------------- 1 | /* eslint-disable react-hooks/rules-of-hooks -- false positive, useMDXComponents isn't react hooks */ 2 | 3 | import { generateStaticParamsFor, importPage } from "nextra/pages"; 4 | import { useMDXComponents } from "../../../../mdx-components"; 5 | 6 | export const generateStaticParams = generateStaticParamsFor("mdxPath"); 7 | 8 | export async function generateMetadata(props) { 9 | const params = await props.params; 10 | const { metadata } = await importPage(params.mdxPath); 11 | return metadata; 12 | } 13 | 14 | const Wrapper = useMDXComponents().wrapper; 15 | 16 | export default async function Page(props) { 17 | const params = await props.params; 18 | const result = await importPage(params.mdxPath); 19 | const { default: MDXContent, toc, metadata } = result; 20 | return ( 21 | 22 | 23 | 24 | ); 25 | } 26 | -------------------------------------------------------------------------------- /website/docs/src/content/_meta.ts: -------------------------------------------------------------------------------- 1 | const meta = { 2 | index: "Overview", 3 | quickstart: "Quickstart", 4 | "basic-concepts": "Basic concepts", 5 | "why-components": "Why components?", 6 | cloud: "GenSX Cloud ", 7 | "component-reference": "Components reference", 8 | patterns: "Patterns", 9 | "cli-reference": "CLI reference", 10 | examples: "Examples", 11 | "typescript-compatibility": "Typescript compatibility", 12 | }; 13 | 14 | export default meta; 15 | -------------------------------------------------------------------------------- /website/docs/src/content/cli-reference/_meta.ts: -------------------------------------------------------------------------------- 1 | const meta = { 2 | index: "CLI overview", 3 | new: "gensx new", 4 | start: "gensx start", 5 | run: "gensx run", 6 | build: "gensx build", 7 | deploy: "gensx deploy", 8 | login: "gensx login", 9 | env: "gensx env", 10 | }; 11 | 12 | export default meta; 13 | -------------------------------------------------------------------------------- /website/docs/src/content/cli-reference/env/_meta.ts: -------------------------------------------------------------------------------- 1 | const meta = { 2 | show: "gensx env", 3 | create: "gensx env create", 4 | ls: "gensx env ls", 5 | select: "gensx env select", 6 | unselect: "gensx env unselect", 7 | }; 8 | 9 | export default meta; 10 | -------------------------------------------------------------------------------- /website/docs/src/content/cli-reference/env/ls.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | title: gensx env ls 3 | description: List all GenSX environments in a project 4 | --- 5 | 6 | # gensx env ls 7 | 8 | The `gensx env ls` command lists all environments in your GenSX project. 9 | 10 | ## Usage 11 | 12 | ```bash 13 | gensx env ls [options] 14 | ``` 15 | 16 | ## Options 17 | 18 | | Option | Description | 19 | | ----------------------- | ---------------------------------------------------------------------------- | 20 | | `-p, --project ` | Project name to list environments for. | 21 | | `-h, --help` | Display help for the command. | 22 | 23 | ## Examples 24 | 25 | ```bash 26 | # List all environments in the current project 27 | gensx env ls 28 | 29 | # List environments in a specific project 30 | gensx env ls --project my-app 31 | ``` 32 | 33 | ## Notes 34 | 35 | - You must be logged in to GenSX Cloud to list environments (`gensx login`) 36 | 37 | -------------------------------------------------------------------------------- /website/docs/src/content/cli-reference/env/show.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | title: gensx env 3 | description: Show current GenSX environment details 4 | --- 5 | 6 | # gensx env 7 | 8 | The `gensx env` command displays the name of the currently selected environment. 9 | 10 | ## Usage 11 | 12 | ```bash 13 | gensx env [options] 14 | ``` 15 | 16 | ## Options 17 | 18 | | Option | Description | 19 | | ----------------------- | ---------------------------------------------------------------------------- | 20 | | `-p, --project ` | Project name to show environment details for. | 21 | | `-h, --help` | Display help for the command. | 22 | 23 | 24 | ## Examples 25 | 26 | ```bash 27 | # Show the current environment 28 | gensx env 29 | 30 | # Show the current environment for a specific project 31 | gensx env --project my-app 32 | ``` 33 | 34 | ## Notes 35 | 36 | - You must be logged in to GenSX Cloud to show environment details (`gensx login`) 37 | - You can use this command to verify your current environment before running important operations 38 | - If no environment is selected, the command will indicate this 39 | -------------------------------------------------------------------------------- /website/docs/src/content/cli-reference/login.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | title: gensx login 3 | description: Log in to GenSX Cloud to deploy and run workflows 4 | --- 5 | 6 | # gensx login 7 | 8 | The `gensx login` command authenticates you with GenSX Cloud, allowing you to deploy and run workflows remotely. 9 | 10 | ## Usage 11 | 12 | ```bash 13 | gensx login 14 | ``` 15 | 16 | ## Description 17 | 18 | When you run this command, it will: 19 | 20 | 1. Open your default web browser to the GenSX authentication page 21 | 2. Prompt you to log in with your GenSX account or create a new one 22 | 3. Store your authentication credentials locally for future CLI commands 23 | 24 | After successful login, you can use other commands that require authentication, such as `deploy` and `run`. 25 | 26 | ## Examples 27 | 28 | ```bash 29 | # Log in to GenSX Cloud 30 | gensx login 31 | ``` 32 | 33 | ## Notes 34 | 35 | - Your authentication token is stored in your user directory (typically `~/.gensx/config.json`) 36 | - The token is valid until you log out or revoke it from the GenSX dashboard 37 | - If you're behind a corporate firewall or using strict network policies, ensure that outbound connections to `api.gensx.com` are allowed 38 | -------------------------------------------------------------------------------- /website/docs/src/content/cloud/_meta.ts: -------------------------------------------------------------------------------- 1 | const meta = { 2 | index: "Overview", 3 | "serverless-deployments": "Serverless deployments", 4 | storage: "Cloud storage", 5 | "local-development": "Local development", 6 | observability: "Observability & tracing", 7 | "mcp-server": "MCP server", 8 | "projects-environments": "Projects and environments", 9 | pricing: "Pricing & limits", 10 | }; 11 | 12 | export default meta; 13 | -------------------------------------------------------------------------------- /website/docs/src/content/cloud/storage/_meta.ts: -------------------------------------------------------------------------------- 1 | const meta = { 2 | "blob-storage": "Blob storage", 3 | "sql-database": "SQL databases", 4 | search: "Search", 5 | }; 6 | 7 | export default meta; 8 | -------------------------------------------------------------------------------- /website/docs/src/content/component-reference/_meta.ts: -------------------------------------------------------------------------------- 1 | const meta = { 2 | openai: "OpenAI", 3 | anthropic: "Anthropic", 4 | "vercel-ai": "Vercel AI SDK", 5 | "storage-components": "Cloud storage", 6 | openrouter: "OpenRouter", 7 | }; 8 | 9 | export default meta; 10 | -------------------------------------------------------------------------------- /website/docs/src/content/typescript-compatibility.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | title: TypeScript-ESM Compatibility 3 | description: Learn about TypeScript and ESM module compatibility in GenSX, including version requirements and configuration settings 4 | --- 5 | 6 | # TypeScript Compatibility 7 | 8 | GenSX is designed to be compatible with TypeScript. This page has some tips and tricks for using GenSX with TypeScript. 9 | 10 | ## Minimum TypeScript Version 11 | 12 | GenSX requires TypeScript version 5.1 or higher. 13 | 14 | ## TypeScript Configuration 15 | 16 | - `target` should be set to at least `es6` 17 | - `module` should be set to at least `es6` 18 | 19 | ## JavaScript Compatibility 20 | 21 | GenSX is bundled with builds for both CommonJS and ESM. This means that you can use GenSX in any environment that supports either of these module formats. 22 | -------------------------------------------------------------------------------- /website/docs/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2017", 4 | "lib": ["dom", "dom.iterable", "esnext"], 5 | "allowJs": true, 6 | "skipLibCheck": true, 7 | "strict": false, 8 | "noEmit": true, 9 | "incremental": true, 10 | "module": "esnext", 11 | "esModuleInterop": true, 12 | "moduleResolution": "bundler", 13 | "resolveJsonModule": true, 14 | "isolatedModules": true, 15 | "jsx": "preserve", 16 | "plugins": [ 17 | { 18 | "name": "next" 19 | } 20 | ] 21 | }, 22 | "include": [ 23 | "next-env.d.ts", 24 | ".next/types/**/*.ts", 25 | "**/*.ts", 26 | "**/*.tsx", 27 | "mdx-components.js" 28 | ], 29 | "exclude": ["node_modules"] 30 | } 31 | -------------------------------------------------------------------------------- /website/home/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.* 7 | .yarn/* 8 | !.yarn/patches 9 | !.yarn/plugins 10 | !.yarn/releases 11 | !.yarn/versions 12 | 13 | # testing 14 | /coverage 15 | 16 | # next.js 17 | /.next/ 18 | /out/ 19 | 20 | # production 21 | /build 22 | 23 | # misc 24 | .DS_Store 25 | *.pem 26 | 27 | # debug 28 | npm-debug.log* 29 | yarn-debug.log* 30 | yarn-error.log* 31 | .pnpm-debug.log* 32 | 33 | # env files (can opt-in for committing if needed) 34 | .env* 35 | 36 | # vercel 37 | .vercel 38 | 39 | # typescript 40 | *.tsbuildinfo 41 | next-env.d.ts 42 | 43 | public/sitemap*.xml 44 | public/robots.txt 45 | public/llms-full.txt 46 | public/llms.txt -------------------------------------------------------------------------------- /website/home/.npmrc: -------------------------------------------------------------------------------- 1 | //.npmrc 2 | enable-pre-post-scripts=true 3 | -------------------------------------------------------------------------------- /website/home/app/blog/layout.tsx: -------------------------------------------------------------------------------- 1 | import type { Metadata } from "next"; 2 | 3 | export const metadata: Metadata = { 4 | title: "GenSX Blog", 5 | description: "The GenSX Blog - Latest news and updates", 6 | }; 7 | 8 | export default function BlogLayout({ 9 | children, 10 | }: Readonly<{ 11 | children: React.ReactNode; 12 | }>) { 13 | return
{children}
; 14 | } 15 | -------------------------------------------------------------------------------- /website/home/app/layout.tsx: -------------------------------------------------------------------------------- 1 | import type { Metadata } from "next"; 2 | import { Figtree } from "next/font/google"; 3 | import "./globals.css"; 4 | import { GridPatternDemo } from "@/components/ui/grid-pattern"; 5 | import Nav from "@/components/nav"; 6 | import Footer from "@/components/footer"; 7 | import { Analytics } from "@vercel/analytics/react"; 8 | import { GoogleAnalytics } from "@next/third-parties/google"; 9 | 10 | const figtree = Figtree({ 11 | subsets: ["latin"], 12 | variable: "--font-figtree", 13 | }); 14 | 15 | export const metadata: Metadata = { 16 | title: "GenSX", 17 | description: "Build agents and workflows with with React-like components", 18 | }; 19 | 20 | export default function RootLayout({ 21 | children, 22 | }: Readonly<{ 23 | children: React.ReactNode; 24 | }>) { 25 | return ( 26 | 27 | 30 | 31 |