diff --git a/package.json b/package.json index 51fad0c..21e71bc 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { "name": "s1-agents", "module": "src/index.ts", - "main": "dist/src/index.js", - "type": "module", + "main": "dist/index.js", + "types": "dist/src/index.d.ts", "author": "Gabriel Silvestre ", "license": "MIT", "version": "0.3.1", @@ -11,7 +11,7 @@ ], "scripts": { "prebuild": "rm -rf dist", - "build": "rollup -c", + "build": "rollup -c rollup.config.js", "prepublish": "npm run build", "prepublishOnly": "bun test --coverage", "release": "standard-version", diff --git a/rollup.config.cjs b/rollup.config.js similarity index 100% rename from rollup.config.cjs rename to rollup.config.js diff --git a/src/agents/function.ts b/src/agents/function.ts index e94af2c..8af9060 100644 --- a/src/agents/function.ts +++ b/src/agents/function.ts @@ -18,7 +18,7 @@ export abstract class AgentFunction implements IFunction { log: false, schema: { output: false, - path: path.resolve(import.meta.dir, '../..', 'dist', 'openai-functions'), + path: path.resolve(__dirname, '../..', 'dist', 'openai-functions'), }, }; @@ -88,13 +88,16 @@ export abstract class AgentFunction implements IFunction { ); const schema = JSON.stringify(this.schema, null, 2); - const directoryAlreadyExists = await Bun.file(schemaPath).exists(); + const directoryAlreadyExists = await fs + .access(path.dirname(schemaPath)) + .then(() => true) + .catch(() => false); if (!directoryAlreadyExists) { await fs.mkdir(path.dirname(schemaPath), { recursive: true }); } if (this._props.log) console.log(`Writing schema to ${schemaPath}`); - await Bun.write(schemaPath, schema); + await fs.writeFile(schemaPath, schema); } }