Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 7 additions & 24 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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

Expand Down
6 changes: 4 additions & 2 deletions examples/ai-sdk-integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,20 @@ 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) {
console.error('STACKONE_API_KEY environment variable is required');
process.exit(1);
}

// Replace with your actual account ID from StackOne dashboard
const accountId = 'your-hris-account-id';

const aiSdkIntegration = async (): Promise<void> => {
// Initialise StackOne
const toolset = new StackOneToolSet({
accountId: ACCOUNT_IDS.HRIS,
accountId,
baseUrl: process.env.STACKONE_BASE_URL ?? 'https://api.stackone.com',
});

Expand Down
26 changes: 0 additions & 26 deletions examples/constants.ts

This file was deleted.

6 changes: 4 additions & 2 deletions examples/human-in-the-loop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,16 @@ 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) {
console.error('STACKONE_API_KEY environment variable is required');
process.exit(1);
}

// Replace with your actual account ID from StackOne dashboard
const accountId = 'your-hris-account-id';

interface ToolCall {
toolName: string;
args: Record<string, unknown>;
Expand All @@ -27,7 +29,7 @@ interface ToolCall {
const humanInTheLoopExample = async (): Promise<void> => {
// Create a toolset
const toolset = new StackOneToolSet({
accountId: ACCOUNT_IDS.HRIS,
accountId,
baseUrl: process.env.STACKONE_BASE_URL ?? 'https://api.stackone.com',
});

Expand Down
8 changes: 3 additions & 5 deletions examples/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 7 additions & 5 deletions examples/meta-tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,16 @@ 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) {
console.error('STACKONE_API_KEY environment variable is required');
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
*/
Expand All @@ -26,7 +28,7 @@ const metaToolsWithAISDK = async (): Promise<void> => {

// Initialise StackOne toolset
const toolset = new StackOneToolSet({
accountId: ACCOUNT_IDS.HRIS,
accountId,
baseUrl: process.env.STACKONE_BASE_URL ?? 'https://api.stackone.com',
});

Expand Down Expand Up @@ -64,7 +66,7 @@ const metaToolsWithOpenAI = async (): Promise<void> => {

// Initialise StackOne toolset
const toolset = new StackOneToolSet({
accountId: ACCOUNT_IDS.HRIS,
accountId,
baseUrl: process.env.STACKONE_BASE_URL ?? 'https://api.stackone.com',
});

Expand Down Expand Up @@ -118,7 +120,7 @@ const directMetaToolUsage = async (): Promise<void> => {

// Initialise toolset
const toolset = new StackOneToolSet({
accountId: ACCOUNT_IDS.HRIS,
accountId,
baseUrl: process.env.STACKONE_BASE_URL ?? 'https://api.stackone.com',
});

Expand Down Expand Up @@ -188,7 +190,7 @@ const dynamicToolRouter = async (): Promise<void> => {
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',
});

Expand Down
6 changes: 4 additions & 2 deletions examples/openai-integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,20 @@ 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) {
console.error('STACKONE_API_KEY environment variable is required');
process.exit(1);
}

// Replace with your actual account ID from StackOne dashboard
const accountId = 'your-hris-account-id';

const openaiIntegration = async (): Promise<void> => {
// Initialise StackOne
const toolset = new StackOneToolSet({
accountId: ACCOUNT_IDS.HRIS,
accountId,
baseUrl: process.env.STACKONE_BASE_URL ?? 'https://api.stackone.com',
});

Expand Down
7 changes: 5 additions & 2 deletions examples/planning.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> => {
const toolset = new StackOneToolSet();
Expand All @@ -19,7 +22,7 @@ export const planningModule = async (): Promise<void> => {
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
});

Expand Down
Loading