diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0d386c3b..06d57098 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -26,15 +26,27 @@ jobs: if: ${{ steps.release.outputs.release_created }} uses: oven-sh/setup-bun@v2 + - name: Install Node + if: ${{ steps.release.outputs.release_created }} + uses: actions/setup-node@v4 + with: + node-version: 22 + - name: Install dependencies if: ${{ steps.release.outputs.release_created }} run: bun install - - name: Build and publish package + - name: Build package if: ${{ steps.release.outputs.release_created }} - env: - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + run: bun run build + + - name: Creating .npmrc run: | - bun build - echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc - bun publish --access=public + cat << EOF > "$HOME/.npmrc" + //registry.npmjs.org/:_authToken=$NPM_TOKEN + EOF + env: + NPM_TOKEN: ${{ secrets.NPM_CONFIG_TOKEN }} + + - name: Publish package + run: npm publish --access public diff --git a/.gitignore b/.gitignore index 160c9219..ab076d19 100644 --- a/.gitignore +++ b/.gitignore @@ -174,4 +174,5 @@ dist # Finder (MacOS) folder config .DS_Store -.docs \ No newline at end of file +.docs +.npmrc diff --git a/.release-please-config.json b/.release-please-config.json index 2873958c..c429f133 100644 --- a/.release-please-config.json +++ b/.release-please-config.json @@ -8,7 +8,7 @@ "include-v-in-tag": true, "packages": { ".": { - "package-name": "stackone-ai-node" + "package-name": "@stackone/ai" } }, "$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json" diff --git a/README.md b/README.md index c2b46182..6c6f8d4a 100644 --- a/README.md +++ b/README.md @@ -6,13 +6,13 @@ StackOne AI provides a unified interface for accessing various SaaS tools throug ```bash # Using npm -npm install stackone-ai-node +npm install @stackone/ai # Using yarn -yarn add stackone-ai-node +yarn add @stackone/ai # Using bun -bun add stackone-ai-node +bun add @stackone/ai ``` ## Authentication @@ -32,7 +32,7 @@ StackOne uses account IDs to identify different integrations. You can specify th ## Quickstart ```typescript -import { StackOneToolSet } from 'stackone-ai-node'; +import { StackOneToolSet } from "@stackone/ai"; // Initialize with API key from environment variable const toolset = new StackOneToolSet(); @@ -41,11 +41,11 @@ const toolset = new StackOneToolSet(); // const toolset = new StackOneToolSet('your-api-key'); // Get all HRIS-related tools -const accountId = '45072196112816593343'; -const tools = toolset.getTools('hris_*', accountId); +const accountId = "45072196112816593343"; +const tools = toolset.getTools("hris_*", accountId); // Use a specific tool -const employeeTool = tools.getTool('hris_list_employees'); +const employeeTool = tools.getTool("hris_list_employees"); if (employeeTool) { const employees = await employeeTool.execute(); console.log(employees); @@ -57,20 +57,20 @@ if (employeeTool) { You can specify a custom base URL when initializing the SDK. This is useful for testing against development APIs or working with self-hosted StackOne instances. ```typescript -import { StackOneToolSet } from 'stackone-ai-node'; +import { StackOneToolSet } from "@stackone/ai"; // Initialize with a custom base URL const toolset = new StackOneToolSet( process.env.STACKONE_API_KEY, process.env.STACKONE_ACCOUNT_ID, - 'https://api.example-dev.com' + "https://api.example-dev.com" ); // Get tools with the custom base URL -const tools = toolset.getTools('hris_*'); +const tools = toolset.getTools("hris_*"); // All API requests will use the custom base URL -const employeeTool = tools.getTool('hris_list_employees'); +const employeeTool = tools.getTool("hris_list_employees"); if (employeeTool) { const employees = await employeeTool.execute(); console.log(employees); @@ -82,11 +82,11 @@ if (employeeTool) { ### OpenAI ```typescript -import { StackOneToolSet } from 'stackone-ai-node'; -import OpenAI from 'openai'; +import { StackOneToolSet } from "@stackone/ai"; +import OpenAI from "openai"; const toolset = new StackOneToolSet(); -const tools = toolset.getTools('hris_*', 'your-account-id'); +const tools = toolset.getTools("hris_*", "your-account-id"); // Convert to OpenAI functions const openAITools = tools.toOpenAI(); @@ -97,10 +97,10 @@ const openai = new OpenAI({ }); const response = await openai.chat.completions.create({ - model: 'gpt-4-turbo', + model: "gpt-4-turbo", messages: [ - { role: 'system', content: 'You are a helpful assistant.' }, - { role: 'user', content: 'List all employees' }, + { role: "system", content: "You are a helpful assistant." }, + { role: "user", content: "List all employees" }, ], tools: openAITools, }); @@ -116,20 +116,20 @@ The SDK provides specific error classes for different types of errors: - `ToolsetLoadError`: Raised when there is an error loading tools ```typescript -import { StackOneToolSet, StackOneAPIError } from 'stackone-ai-node'; +import { StackOneToolSet, StackOneAPIError } from "@stackone/ai"; const toolset = new StackOneToolSet(); -const tools = toolset.getTools('hris_*', 'your-account-id'); -const tool = tools.getTool('hris_get_employee'); +const tools = toolset.getTools("hris_*", "your-account-id"); +const tool = tools.getTool("hris_get_employee"); try { - const result = await tool.execute({ id: 'employee-id' }); + const result = await tool.execute({ id: "employee-id" }); console.log(result); } catch (error) { if (error instanceof StackOneAPIError) { console.error(`API Error (${error.statusCode}):`, error.responseBody); } else { - console.error('Error:', error); + console.error("Error:", error); } } ``` diff --git a/bun.lock b/bun.lock index 7719962b..b659849f 100644 --- a/bun.lock +++ b/bun.lock @@ -15,7 +15,7 @@ "@types/json-schema": "^7.0.15", "@types/node": "^22.13.5", "dotenv": "^16.3.1", - "husky": "^8.0.3", + "husky": "^9.1.7", "json-schema": "^0.4.0", "lint-staged": "^15.2.0", "mkdocs": "^0.0.1", @@ -166,7 +166,7 @@ "humanize-ms": ["humanize-ms@1.2.1", "", { "dependencies": { "ms": "^2.0.0" } }, "sha512-Fl70vYtsAFb/C06PTS9dZBo7ihau+Tu/DNCk/OyHhea07S+aeMWpFFkUaXRa8fI+ScZbEI8dfSxwY7gxZ9SAVQ=="], - "husky": ["husky@8.0.3", "", { "bin": { "husky": "lib/bin.js" } }, "sha512-+dQSyqPh4x1hlO1swXBiNb2HzTDN1I2IGLQx1GrBuiqFJfoMrnZWwVmatvSiO+Iz8fBUnf+lekwNo4c2LlXItg=="], + "husky": ["husky@9.1.7", "", { "bin": { "husky": "bin.js" } }, "sha512-5gs5ytaNjBrh5Ow3zrvdUUY+0VxIuWVL4i9irt6friV+BqdCfmV11CQTWMiBYWHbXhco+J1kHfTOUkePhCDvMA=="], "is-fullwidth-code-point": ["is-fullwidth-code-point@4.0.0", "", {}, "sha512-O4L094N2/dZ7xqVdrXhh9r1KODPJpFms8B5sGdJLPy664AgvXsreZUyCQQNItZRDlYug4xStLjNp/sz3HvBowQ=="], diff --git a/examples/index.ts b/examples/index.ts index 28039b53..70059991 100644 --- a/examples/index.ts +++ b/examples/index.ts @@ -3,13 +3,13 @@ * * ```bash * # Using npm - * npm install stackone-ai-node + * npm install @stackone/ai * * # Using yarn - * yarn add stackone-ai-node + * yarn add @stackone/ai * * # Using bun - * bun add stackone-ai-node + * bun add @stackone/ai * ``` * * # Authentication diff --git a/package.json b/package.json index 44d41fa3..69f217fc 100644 --- a/package.json +++ b/package.json @@ -1,20 +1,16 @@ { - "name": "stackone-ai-node", - "version": "0.0.2", + "name": "@stackone/ai", + "version": "0.0.1", "description": "Agents performing actions on your SaaS", "module": "dist/index.js", "main": "dist/index.js", "types": "dist/index.d.ts", "type": "module", - "files": [ - "dist", - "README.md", - "LICENSE" - ], + "files": ["dist", "README.md", "LICENSE"], "scripts": { "build": "bun build ./src/index.ts --outdir ./dist --target node", + "publish-package": "bun run build && bun publish --access=public", "test": "bun test", - "prepublishOnly": "bun run build", "fetch:specs": "bun run ./scripts/fetch-specs.ts", "build:docs": "bun run ./scripts/build-docs.ts", "docs:serve": "mkdocs serve", @@ -22,8 +18,7 @@ "docs:deploy": "bun run build:docs && mkdocs gh-deploy --force", "lint": "biome check .", "format": "biome format --write .", - "check": "biome check --write .", - "prepare": "husky install" + "check": "biome check --write ." }, "devDependencies": { "@biomejs/biome": "^1.5.3", @@ -31,7 +26,7 @@ "@types/json-schema": "^7.0.15", "@types/node": "^22.13.5", "dotenv": "^16.3.1", - "husky": "^8.0.3", + "husky": "^9.1.7", "json-schema": "^0.4.0", "lint-staged": "^15.2.0", "mkdocs": "^0.0.1", @@ -51,13 +46,7 @@ "type": "git", "url": "git+https://github.com/stackone-ai/stackone-ai-node.git" }, - "keywords": [ - "stackone", - "ai", - "saas", - "tools", - "agents" - ], + "keywords": ["stackone", "ai", "saas", "tools", "agents"], "author": "StackOne", "license": "MIT", "bugs": { @@ -65,9 +54,6 @@ }, "homepage": "https://github.com/stackone-ai/stackone-ai-node#readme", "lint-staged": { - "*.{js,ts,jsx,tsx}": [ - "biome check --write", - "biome format --write" - ] + "*.{js,ts,jsx,tsx}": ["biome check --write", "biome format --write"] } } diff --git a/scripts/build-docs.test.ts b/scripts/build-docs.test.ts index 59fcdcb6..01ecebaf 100644 --- a/scripts/build-docs.test.ts +++ b/scripts/build-docs.test.ts @@ -8,7 +8,7 @@ describe('convertFileToMarkdown', () => { * * \`\`\`bash * # Using npm - * npm install stackone-ai-node + * npm install @stackone/ai * \`\`\` * * # Authentication @@ -31,7 +31,7 @@ dotenv.config();`; \`\`\`bash # Using npm -npm install stackone-ai-node +npm install @stackone/ai \`\`\` # Authentication