This commit is contained in:
geoffsee
2025-05-23 09:48:26 -04:00
commit 66d3c06230
84 changed files with 6529 additions and 0 deletions

View File

@@ -0,0 +1,175 @@
# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore
# Logs
logs
_.log
npm-debug.log_
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*
# Caches
.cache
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
# Runtime data
pids
_.pid
_.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
*.lcov
# nyc test coverage
.nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# Snowpack dependency directory (https://snowpack.dev/)
web_modules/
# TypeScript cache
*.tsbuildinfo
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Optional stylelint cache
.stylelintcache
# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local
# parcel-bundler cache (https://parceljs.org/)
.parcel-cache
# Next.js build output
.next
out
# Nuxt.js build / generate output
.nuxt
dist
# Gatsby files
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public
# vuepress build output
.vuepress/dist
# vuepress v2.x temp and cache directory
.temp
# Docusaurus cache and generated files
.docusaurus
# Serverless directories
.serverless/
# FuseBox cache
.fusebox/
# DynamoDB Local files
.dynamodb/
# TernJS port file
.tern-port
# Stores VSCode versions used for testing VSCode extensions
.vscode-test
# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
# IntelliJ based IDEs
.idea
# Finder (MacOS) folder config
.DS_Store

View File

@@ -0,0 +1,15 @@
# genaiscript-rust-shim
To install dependencies:
```bash
bun install
```
To run:
```bash
bun run index.ts
```
This project was created using `bun init` in bun v1.1.36. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime.

Binary file not shown.

View File

@@ -0,0 +1,61 @@
#!/usr/bin/env node
import minimist from "minimist";
import { run } from "genaiscript/api";
import { RunScriptOptions } from "./shim-types";
type Args = {
file: string;
vars: Record<string, unknown>;
options: Partial<RunScriptOptions> & {
envVars?: Record<string, string>;
signal?: AbortSignal;
};
};
async function wrapper(args: Args) {
try {
await run(args.file, [], { vars: args.vars }, args.options);
} catch (error) {
console.error("Error executing script:", error);
process.exit(1);
}
}
function parseCliArgs(): Args {
const argv = minimist(process.argv.slice(2), {
string: ["file"],
alias: { f: "file" },
});
if (!argv.file) {
console.error("Error: Missing required argument --file");
process.exit(1);
}
const keyValuePairs = argv._;
const vars: Record<string, unknown> = keyValuePairs.reduce((acc, pair) => {
const [key, value] = pair.split("=");
if (key && value !== undefined) {
acc[key] = value; // Retain the `unknown` type for later flexibility
} else {
console.error(`Error: Invalid key=value pair "${pair}"`);
process.exit(1);
}
return acc;
}, {} as Record<string, unknown>);
return {
file: argv.file,
vars,
options: {},
};
}
async function main() {
const args = parseCliArgs();
await wrapper(args);
}
main();

View File

@@ -0,0 +1,2 @@
import './genaiscript-rust-shim';
export * from './genaiscript-rust-shim';

View File

@@ -0,0 +1,19 @@
{
"name": "@web-agent-rs/genaiscript-rust-shim",
"module": "index.ts",
"private": true,
"type": "module",
"scripts": {
"buildShim": "esbuild genaiscript-rust-shim.ts --bundle --format=esm --packages=external --outdir=dist --platform=node && chmod +x dist/genaiscript-rust-shim.js",
"setupDev": "cp dist/genaiscript-rust-shim.js ../../dist/genaiscript-rust-shim.js"
},
"devDependencies": {
"@types/bun": "latest",
"minimist": "^1.2.8",
"genaiscript": "^1.95.1",
"esbuild": "^0.24.2"
},
"peerDependencies": {
"typescript": "^5.0.0"
}
}

View File

@@ -0,0 +1,70 @@
type FenceFormat = "markdown" | "xml" | "none"
export interface WorkspaceFile {
/**
* Name of the file, relative to project root.
*/
filename: string
/**
* Content mime-type if known
*/
type?: string
/**
* Encoding of the content
*/
encoding?: "base64"
/**
* Content of the file.
*/
content?: string
}
export interface RunScriptOptions {
excludedFiles: string[]
excludeGitIgnore: boolean
runRetry: string
out: string
retry: string
retryDelay: string
maxDelay: string
json: boolean
yaml: boolean
outTrace: string
outOutput: string
outAnnotations: string
outChangelogs: string
pullRequest: string
pullRequestComment: string | boolean
pullRequestDescription: string | boolean
pullRequestReviews: boolean
outData: string
label: string
temperature: string | number
topP: string | number
seed: string | number
maxTokens: string | number
maxToolCalls: string | number
maxDataRepairs: string | number
model: string
smallModel: string
visionModel: string
embeddingsModel: string
modelAlias: string[]
provider: string
csvSeparator: string
cache: boolean | string
cacheName: string
applyEdits: boolean
failOnErrors: boolean
removeOut: boolean
vars: string[] | Record<string, string | boolean | number | object>
fallbackTools: boolean
jsSource: string
logprobs: boolean
topLogprobs: number
fenceFormat: FenceFormat
workspaceFiles?: WorkspaceFile[]
}

View File

@@ -0,0 +1,27 @@
{
"compilerOptions": {
// Enable latest features
"lib": ["ESNext", "DOM"],
"target": "ESNext",
"module": "ESNext",
"moduleDetection": "force",
"jsx": "react-jsx",
"allowJs": true,
// Bundler mode
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"verbatimModuleSyntax": true,
"noEmit": true,
// Best practices
"strict": true,
"skipLibCheck": true,
"noFallthroughCasesInSwitch": true,
// Some stricter flags (disabled by default)
"noUnusedLocals": false,
"noUnusedParameters": false,
"noPropertyAccessFromIndexSignature": false
}
}