diff --git a/examples/README.md b/examples/README.md index d452d73..40f33bc 100644 --- a/examples/README.md +++ b/examples/README.md @@ -38,32 +38,15 @@ OPENAI_API_KEY=your_api_key_here ### 3. Configure Account IDs -Update the account IDs in [`constants.ts`](./constants.ts) with your actual integration account IDs: +Each example includes a placeholder account ID that you need to replace with your actual StackOne account ID: ```typescript -export const ACCOUNT_IDS = { - // Human Resources Information System - HRIS: "your_hris_account_id", - - // Applicant Tracking System - ATS: "your_ats_account_id", - - // Customer Relationship Management - CRM: "your_crm_account_id", - - // Document Management System - DOCUMENTS: "your_documents_account_id", - - // Test account IDs (used in examples that don't make real API calls) - TEST: { - VALID: "test_account_id", - OVERRIDE: "test_account_id_override", - DIRECT: "test_account_id_direct", - INVALID: "invalid_test_account_id", - }, -}; +// Replace with your actual account ID from StackOne dashboard +const accountId = 'your-hris-account-id'; ``` +You can find your account IDs in the [StackOne dashboard](https://app.stackone.com). + ## Running Examples ### Run Individual Examples @@ -287,7 +270,7 @@ cd examples && pnpm test examples.spec.ts ### Common Issues 1. **Authentication Errors**: Ensure `STACKONE_API_KEY` is set correctly -2. **Account ID Errors**: Update account IDs in `constants.ts` with your actual values +2. **Account ID Errors**: Update account ID placeholders in the example files with your actual values 3. **Network Errors**: Check if you're behind a proxy or firewall 4. **TypeScript Errors**: Ensure you're using compatible Node.js and TypeScript versions @@ -306,7 +289,7 @@ When adding new examples: 3. Include proper error handling 4. Add TypeScript types 5. Test with the examples test suite -6. Update `constants.ts` if new account IDs are needed +6. Use inline placeholder account IDs with clear comments (e.g., `const accountId = 'your-hris-account-id';`) ## License diff --git a/examples/ai-sdk-integration.ts b/examples/ai-sdk-integration.ts index 3f0e9c6..278700f 100644 --- a/examples/ai-sdk-integration.ts +++ b/examples/ai-sdk-integration.ts @@ -7,7 +7,6 @@ import process from 'node:process'; import { openai } from '@ai-sdk/openai'; import { StackOneToolSet } from '@stackone/ai'; import { generateText, stepCountIs } from 'ai'; -import { ACCOUNT_IDS } from './constants'; const apiKey = process.env.STACKONE_API_KEY; if (!apiKey) { @@ -15,10 +14,13 @@ if (!apiKey) { process.exit(1); } +// Replace with your actual account ID from StackOne dashboard +const accountId = 'your-hris-account-id'; + const aiSdkIntegration = async (): Promise => { // Initialise StackOne const toolset = new StackOneToolSet({ - accountId: ACCOUNT_IDS.HRIS, + accountId, baseUrl: process.env.STACKONE_BASE_URL ?? 'https://api.stackone.com', }); diff --git a/examples/constants.ts b/examples/constants.ts deleted file mode 100644 index ae132d7..0000000 --- a/examples/constants.ts +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Centralized account IDs for StackOne examples - * - * These account IDs are organized by vertical and can be reused across examples. - * Update these values with your actual account IDs for each integration. - */ -export const ACCOUNT_IDS = { - // Human Resources Information System - HRIS: '46132201201510402136', - - // Applicant Tracking System - ATS: '46132127373317208518', - - // Customer Relationship Management - CRM: '46132129512514182883', - - // Document Management System - DOCUMENTS: '46132143471913690795', - - TEST: { - VALID: 'test_account_id', - OVERRIDE: 'test_account_id_override', - DIRECT: 'test_account_id_direct', - INVALID: 'invalid_test_account_id', - }, -} as const; diff --git a/examples/human-in-the-loop.ts b/examples/human-in-the-loop.ts index 534f3ac..d874635 100644 --- a/examples/human-in-the-loop.ts +++ b/examples/human-in-the-loop.ts @@ -11,7 +11,6 @@ import process from 'node:process'; import { openai } from '@ai-sdk/openai'; import { type JsonDict, StackOneToolSet } from '@stackone/ai'; import { generateText, stepCountIs } from 'ai'; -import { ACCOUNT_IDS } from './constants'; const apiKey = process.env.STACKONE_API_KEY; if (!apiKey) { @@ -19,6 +18,9 @@ if (!apiKey) { process.exit(1); } +// Replace with your actual account ID from StackOne dashboard +const accountId = 'your-hris-account-id'; + interface ToolCall { toolName: string; args: Record; @@ -27,7 +29,7 @@ interface ToolCall { const humanInTheLoopExample = async (): Promise => { // Create a toolset const toolset = new StackOneToolSet({ - accountId: ACCOUNT_IDS.HRIS, + accountId, baseUrl: process.env.STACKONE_BASE_URL ?? 'https://api.stackone.com', }); diff --git a/examples/index.ts b/examples/index.ts index 0cbc9c6..701b479 100644 --- a/examples/index.ts +++ b/examples/index.ts @@ -27,15 +27,13 @@ * # Account IDs * * StackOne uses account IDs to identify different integrations. - * See the example in the README for more details. - * - * This example will use the centralised account ID: + * Replace the placeholder below with your actual account ID from the StackOne dashboard. */ import process from 'node:process'; -import { ACCOUNT_IDS } from './constants'; -const accountId = ACCOUNT_IDS.HRIS; +// Replace with your actual account ID from StackOne dashboard +const accountId = 'your-hris-account-id'; /** * # Quickstart diff --git a/examples/meta-tools.ts b/examples/meta-tools.ts index aeea0fb..40d657b 100644 --- a/examples/meta-tools.ts +++ b/examples/meta-tools.ts @@ -10,7 +10,6 @@ import process from 'node:process'; import { openai } from '@ai-sdk/openai'; import { StackOneToolSet, Tools } from '@stackone/ai'; import { generateText, stepCountIs } from 'ai'; -import { ACCOUNT_IDS } from './constants'; const apiKey = process.env.STACKONE_API_KEY; if (!apiKey) { @@ -18,6 +17,9 @@ if (!apiKey) { process.exit(1); } +// Replace with your actual account ID from StackOne dashboard +const accountId = 'your-hris-account-id'; + /** * Example 1: Using meta tools with AI SDK for dynamic tool discovery */ @@ -26,7 +28,7 @@ const metaToolsWithAISDK = async (): Promise => { // Initialise StackOne toolset const toolset = new StackOneToolSet({ - accountId: ACCOUNT_IDS.HRIS, + accountId, baseUrl: process.env.STACKONE_BASE_URL ?? 'https://api.stackone.com', }); @@ -64,7 +66,7 @@ const metaToolsWithOpenAI = async (): Promise => { // Initialise StackOne toolset const toolset = new StackOneToolSet({ - accountId: ACCOUNT_IDS.HRIS, + accountId, baseUrl: process.env.STACKONE_BASE_URL ?? 'https://api.stackone.com', }); @@ -118,7 +120,7 @@ const directMetaToolUsage = async (): Promise => { // Initialise toolset const toolset = new StackOneToolSet({ - accountId: ACCOUNT_IDS.HRIS, + accountId, baseUrl: process.env.STACKONE_BASE_URL ?? 'https://api.stackone.com', }); @@ -188,7 +190,7 @@ const dynamicToolRouter = async (): Promise => { console.log('\nšŸ”„ Example 4: Dynamic tool router\n'); const toolset = new StackOneToolSet({ - accountId: ACCOUNT_IDS.HRIS, + accountId, baseUrl: process.env.STACKONE_BASE_URL ?? 'https://api.stackone.com', }); diff --git a/examples/openai-integration.ts b/examples/openai-integration.ts index a67299c..847a78c 100644 --- a/examples/openai-integration.ts +++ b/examples/openai-integration.ts @@ -6,7 +6,6 @@ import assert from 'node:assert'; import process from 'node:process'; import { StackOneToolSet } from '@stackone/ai'; import OpenAI from 'openai'; -import { ACCOUNT_IDS } from './constants'; const apiKey = process.env.STACKONE_API_KEY; if (!apiKey) { @@ -14,10 +13,13 @@ if (!apiKey) { process.exit(1); } +// Replace with your actual account ID from StackOne dashboard +const accountId = 'your-hris-account-id'; + const openaiIntegration = async (): Promise => { // Initialise StackOne const toolset = new StackOneToolSet({ - accountId: ACCOUNT_IDS.HRIS, + accountId, baseUrl: process.env.STACKONE_BASE_URL ?? 'https://api.stackone.com', }); diff --git a/examples/planning.ts b/examples/planning.ts index 28e0a4d..34d247c 100644 --- a/examples/planning.ts +++ b/examples/planning.ts @@ -9,7 +9,10 @@ import { openai } from '@ai-sdk/openai'; import { StackOneToolSet } from '@stackone/ai'; import { generateText, stepCountIs } from 'ai'; -import { ACCOUNT_IDS } from './constants'; + +// Replace with your actual account IDs from StackOne dashboard +const atsAccountId = 'your-ats-account-id'; +const hrisAccountId = 'your-hris-account-id'; export const planningModule = async (): Promise => { const toolset = new StackOneToolSet(); @@ -19,7 +22,7 @@ export const planningModule = async (): Promise => { input: 'Onboard the last new hire from Teamtailor to Workday', model: 'stackone-planner-latest', tools: ['hris_*', 'ats_*'], - accountIds: [ACCOUNT_IDS.ATS, ACCOUNT_IDS.HRIS], + accountIds: [atsAccountId, hrisAccountId], cache: true, // saves the plan to $HOME/.stackone/plans });