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
56 changes: 56 additions & 0 deletions .github/workflows/ci.yaml
Original file line numberDiff line numberDiff line change
Expand Up@@ -60,6 +60,62 @@ jobs:
- name: Run Tests
run: pnpm test

# The `ai` peer range spans three majors whose tool types differ, so the
# single build-and-test job above only ever proves whichever version the dev
# catalog pins. This job covers the declared range independently of that pin.
#
# Every entry is an exact version, not a range. A range resolves to whatever
# the lockfile already holds unless the lockfile is deleted, and deleting it
# re-resolves every dependency to its newest in-range version, which trips
# this repo's `trustPolicy: no-downgrade` on unrelated packages. Each pin is
# therefore a boundary worth holding still:
# v5 - the lower bound of the declared peer range
# v6 - the last v6 the dev catalog shipped
# v7 - the major boundary where the AI SDK tool types changed shape
# The newest v7 is not covered here; build-and-test covers whatever the dev
# catalog pins, which is the only v7 that moves.
ai-peer-range:
name: ai-peer-range (${{ matrix.ai }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ai:
- 5.0.108 # lower bound of the peer range
- 6.0.7 # last v6 the dev catalog shipped
- 7.0.0 # first v7, where Tool became a union
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Setup Nix
uses: ./.github/actions/setup-nix
with:
skip-pnpm-install: 'true'

# `--filter .` keeps the examples workspace out of resolution; it pulls a
# dependency that `blockExoticSubdeps` rejects on any lockfile update.
#
# Assert the resolved version, not just that the edit looked applied. A
# `sed` that stops matching would otherwise leave the catalog untouched
# and the job would pass while silently testing the version it was meant
# to replace.
- name: Install with ai@${{ matrix.ai }}
run: |
sed -i -E "/^ dev:/,/^ [a-z]+:/ s|^ ai: .*| ai: '${{ matrix.ai }}'|" pnpm-workspace.yaml
Comment thread
cubic-dev-ai[bot] marked this conversation as resolved.
pnpm install --no-frozen-lockfile --filter .
resolved=$(node -p "require('./node_modules/ai/package.json').version")
echo "resolved ai@$resolved"
if [ "$resolved" != "${{ matrix.ai }}" ]; then
echo "::error::expected ai@${{ matrix.ai }} but resolved ai@$resolved"
exit 1
fi

# Type errors are the failure mode here, and vitest type-checks the suite
# via the root project's `typecheck` config.
- name: Run Tests
run: pnpm exec vitest run --project root

coverage:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -196,9 +196,11 @@ await anthropic.messages.create({
npm install @stackone/ai ai @ai-sdk/openai # or: yarn/pnpm/bun add
```

> Supports AI SDK v5–v7 (`ai` `>=5.0.108 <8.0.0`). AI SDK v7 requires Node.js 22+.

```typescript
import { openai } from '@ai-sdk/openai';
import { generateText } from 'ai';
import { generateText, stepCountIs } from 'ai';
import { StackOneToolSet } from '@stackone/ai';

// Reads STACKONE_API_KEY and STACKONE_ACCOUNT_ID from environment
Expand All@@ -209,7 +211,7 @@ const tools = await toolset.fetchTools();
await generateText({
model: openai('gpt-5.1'),
tools: await tools.toAISDK(),
maxSteps: 3,
stopWhen: stepCountIs(3),
});
```

Expand Down
2 changes: 1 addition & 1 deletion examples/README.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -60,7 +60,7 @@ Converts StackOne tools to Anthropic format with `tools.toAnthropic()` and sends

### [`ai-sdk-integration.ts`](./ai-sdk-integration.ts) -- Vercel AI SDK

Integrates with the Vercel AI SDK via `tools.toAISDK()`. Runs a multi-step agent loop using `generateText` with `stopWhen: stepCountIs(3)`, letting the model autonomously call tools and reason over results.
Integrates with the Vercel AI SDK via `tools.toAISDK()`. Runs a multi-step agent loop using `generateText` with `stopWhen: stepCountIs(3)`, letting the model autonomously call tools and reason over results. Compatible with AI SDK v5–v7; AI SDK v7 requires Node.js 22+.

### [`claude-agent-sdk-integration.ts`](./claude-agent-sdk-integration.ts) -- Claude Agent SDK

Expand Down
6 changes: 4 additions & 2 deletions examples/ai-sdk-integration.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,8 +6,10 @@
* can autonomously call tools and reason over results until the stop condition
* is met.
*
* In AI SDK v6+, you can use the `ToolLoopAgent` class for more explicit
* agent functionality.
* Compatible with AI SDK v5–v7 (`ai` peer `>=5.0.108 <8.0.0`). Uses
* `stepCountIs`, which exists in v5/v6 and remains available as an alias in v7.
* AI SDK v7 requires Node.js 22+. On v6+ you can also use the `ToolLoopAgent`
* class for more explicit agent functionality; v5 has no such export.
*/

import process from 'node:process';
Expand Down
Loading
Loading