Skip to content

Commit a4c7849

Browse files
committed
feat: enable async token counting with piscina workers
Port tokenizer logic into a Piscina worker pool so token counting no longer blocks the main thread and exposes async APIs across IPC. Render live token estimates in chat input with Suspense fallback and tighten defensive assertions while adapting tests to the new async flow.
1 parent 48fb55a commit a4c7849

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1487
-1722
lines changed

.github/workflows/chromatic.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,3 @@ jobs:
3636
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
3737
exitZeroOnChanges: true
3838
onlyChanged: true
39-

.github/workflows/nightly-terminal-bench.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ name: Nightly Terminal-Bench
33
on:
44
schedule:
55
# Run full benchmark suite (~80 tasks) every night at midnight UTC
6-
- cron: '0 0 * * *'
6+
- cron: "0 0 * * *"
77
workflow_dispatch:
88
inputs:
99
models:
1010
description: 'Models to test (comma-separated, or "all" for both)'
1111
required: false
12-
default: 'all'
12+
default: "all"
1313
type: string
1414

1515
jobs:
@@ -41,9 +41,9 @@ jobs:
4141
uses: ./.github/workflows/terminal-bench.yml
4242
with:
4343
model_name: ${{ matrix.model }}
44-
thinking_level: 'high'
45-
dataset: 'terminal-bench-core==0.1.1'
46-
concurrency: '4'
44+
thinking_level: "high"
45+
dataset: "terminal-bench-core==0.1.1"
46+
concurrency: "4"
4747
livestream: true
4848
secrets:
4949
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}

.github/workflows/publish-npm.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
branches:
66
- main
77
tags:
8-
- 'v*'
8+
- "v*"
99
workflow_dispatch:
1010

1111
permissions:
@@ -24,12 +24,12 @@ jobs:
2424

2525
- uses: ./.github/actions/setup-cmux
2626
with:
27-
install-imagemagick: 'true'
27+
install-imagemagick: "true"
2828

2929
# Sets up .npmrc with the auth token
3030
- uses: actions/setup-node@v4
3131
with:
32-
registry-url: 'https://registry.npmjs.org'
32+
registry-url: "https://registry.npmjs.org"
3333

3434
- run: sudo npm i -g npm@latest
3535

@@ -38,10 +38,10 @@ jobs:
3838
run: |
3939
# Get base version from package.json
4040
BASE_VERSION=$(node -p "require('./package.json').version")
41-
41+
4242
# Generate git describe version
4343
GIT_DESCRIBE=$(git describe --tags --always --dirty 2>/dev/null || echo "unknown")
44-
44+
4545
if [[ $GITHUB_REF == refs/tags/* ]]; then
4646
# For tags, use the base version as-is (stable release)
4747
NPM_VERSION="${BASE_VERSION}"
@@ -56,13 +56,13 @@ jobs:
5656
NPM_TAG="next"
5757
echo "Publishing pre-release: ${NPM_VERSION}"
5858
fi
59-
59+
6060
echo "version=${NPM_VERSION}" >> $GITHUB_OUTPUT
6161
echo "tag=${NPM_TAG}" >> $GITHUB_OUTPUT
62-
62+
6363
# Update package.json with the new version
6464
node -e "const fs = require('fs'); const pkg = JSON.parse(fs.readFileSync('package.json')); pkg.version = '${NPM_VERSION}'; fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n');"
65-
65+
6666
echo "Updated package.json to version ${NPM_VERSION}"
6767
6868
- name: Generate version file
@@ -76,7 +76,7 @@ jobs:
7676
run: |
7777
PACKAGE_NAME=$(node -p "require('./package.json').name")
7878
VERSION="${{ steps.version.outputs.version }}"
79-
79+
8080
if npm view "${PACKAGE_NAME}@${VERSION}" version &>/dev/null; then
8181
echo "exists=true" >> $GITHUB_OUTPUT
8282
echo "Version ${VERSION} already exists on npm"
@@ -95,7 +95,7 @@ jobs:
9595
PACKAGE_NAME=$(node -p "require('./package.json').name")
9696
VERSION="${{ steps.version.outputs.version }}"
9797
TAG="${{ steps.version.outputs.tag }}"
98-
98+
9999
echo "Version ${VERSION} already published, updating dist-tag to ${TAG}"
100100
npm dist-tag add "${PACKAGE_NAME}@${VERSION}" "${TAG}"
101101

.github/workflows/terminal-bench.yml

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,34 +4,34 @@ on:
44
workflow_call:
55
inputs:
66
model_name:
7-
description: 'Model to use (e.g., anthropic:claude-sonnet-4-5)'
7+
description: "Model to use (e.g., anthropic:claude-sonnet-4-5)"
88
required: false
99
type: string
1010
thinking_level:
11-
description: 'Thinking level (off, low, medium, high)'
11+
description: "Thinking level (off, low, medium, high)"
1212
required: false
1313
type: string
1414
dataset:
15-
description: 'Terminal-Bench dataset to use'
15+
description: "Terminal-Bench dataset to use"
1616
required: false
1717
type: string
18-
default: 'terminal-bench-core==0.1.1'
18+
default: "terminal-bench-core==0.1.1"
1919
concurrency:
20-
description: 'Number of concurrent tasks (--n-concurrent)'
20+
description: "Number of concurrent tasks (--n-concurrent)"
2121
required: false
2222
type: string
23-
default: '4'
23+
default: "4"
2424
livestream:
25-
description: 'Enable livestream mode'
25+
description: "Enable livestream mode"
2626
required: false
2727
type: boolean
2828
default: true
2929
sample_size:
30-
description: 'Number of random tasks to run (empty = all tasks)'
30+
description: "Number of random tasks to run (empty = all tasks)"
3131
required: false
3232
type: string
3333
extra_args:
34-
description: 'Additional arguments to pass to terminal-bench'
34+
description: "Additional arguments to pass to terminal-bench"
3535
required: false
3636
type: string
3737
secrets:
@@ -42,34 +42,34 @@ on:
4242
workflow_dispatch:
4343
inputs:
4444
dataset:
45-
description: 'Terminal-Bench dataset to use'
45+
description: "Terminal-Bench dataset to use"
4646
required: false
47-
default: 'terminal-bench-core==0.1.1'
47+
default: "terminal-bench-core==0.1.1"
4848
type: string
4949
concurrency:
50-
description: 'Number of concurrent tasks (--n-concurrent)'
50+
description: "Number of concurrent tasks (--n-concurrent)"
5151
required: false
52-
default: '4'
52+
default: "4"
5353
type: string
5454
livestream:
55-
description: 'Enable livestream mode'
55+
description: "Enable livestream mode"
5656
required: false
5757
default: true
5858
type: boolean
5959
sample_size:
60-
description: 'Number of random tasks to run (empty = all tasks)'
60+
description: "Number of random tasks to run (empty = all tasks)"
6161
required: false
6262
type: string
6363
model_name:
64-
description: 'Model to use (e.g., anthropic:claude-sonnet-4-5, openai:gpt-5-codex)'
64+
description: "Model to use (e.g., anthropic:claude-sonnet-4-5, openai:gpt-5-codex)"
6565
required: false
6666
type: string
6767
thinking_level:
68-
description: 'Thinking level (off, low, medium, high)'
68+
description: "Thinking level (off, low, medium, high)"
6969
required: false
7070
type: string
7171
extra_args:
72-
description: 'Additional arguments to pass to terminal-bench'
72+
description: "Additional arguments to pass to terminal-bench"
7373
required: false
7474
type: string
7575

@@ -148,4 +148,3 @@ jobs:
148148
runs/
149149
if-no-files-found: warn
150150
retention-days: 30
151-

.storybook/main.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,7 @@ import path from "path";
44

55
const config: StorybookConfig = {
66
stories: ["../src/**/*.stories.@(ts|tsx)"],
7-
addons: [
8-
"@storybook/addon-links",
9-
"@storybook/addon-docs",
10-
"@storybook/addon-interactions",
11-
],
7+
addons: ["@storybook/addon-links", "@storybook/addon-docs", "@storybook/addon-interactions"],
128
framework: {
139
name: "@storybook/react-vite",
1410
options: {},

.storybook/mocks/version.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,3 @@ export const VERSION = {
66
git_describe: "v1.0.0",
77
buildTime: "2024-01-24T17:41:00Z", // 9:41 AM PST
88
};
9-

0 commit comments

Comments
 (0)