Skip to content

Lazy-load koffi for bun runtime compatibility - #6

Draft
pranavpatilsce wants to merge 2549 commits into
mainfrom
bun-migration
Draft

Lazy-load koffi for bun runtime compatibility#6
pranavpatilsce wants to merge 2549 commits into
mainfrom
bun-migration

Conversation

@pranavpatilsce

@pranavpatilsce pranavpatilsce commented Mar 25, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Moves import koffi from a top-level static import to a dynamic require("koffi") inside enableWindowsVTInput() in packages/tui/src/terminal.ts
  • This prevents the TUI barrel export from crashing on bun (or any non-Node runtime) where koffi's native bindings may not load
  • No behavior change for Node users — koffi still loads on first ProcessTerminal.start() call, and the existing try/catch handles unavailability

Test plan

  • bun install succeeds (koffi installs fine as a package)
  • TUI imports under bun without crash (53 exports loaded)
  • TUI test suite passes (389/389)
  • tsc compiles cleanly

badlogic and others added 30 commits February 5, 2026 21:21
…and add EU profile

- Remove :0 suffix from Opus 4.6 Bedrock model IDs (not valid for this model)
- Fix us/eu Opus 4.6 cache pricing (0.5/6.25 instead of 1.5/18.75)
- Add missing eu.anthropic.claude-opus-4-6-v1 inference profile
- Fix coding-agent default Bedrock model ID to match catalog
…tings extensions paths

collectAutoExtensionEntries now checks if the directory itself has a
package.json with pi.extensions (or index.ts) before scanning children.
This fixes duplicate extension loading when a manifest-aware directory
is specified directly in settings.json extensions array.

Fixes #1274
…thinking

Handle Bedrock Opus 4.6 adaptive thinking and interleaved beta
The process.env access was outside the typeof process check, which
would throw in browser environments. Moved inside the Node.js/Bun
block for consistency with other env var access.

Also added changelog entry for #1320 and improved docs clarity.
cartazio and others added 26 commits March 7, 2026 20:47
Covers OpenRouter and all OpenAI-compatible providers.
…pection CLI

Bug fixes:
- max_tokens: read per-model limits from ~/.agent/settings.toml
  [modelMaxTokens.anthropic] instead of hardcoded model.maxTokens/3
  (~1.3K). Fallback: 128K for Opus 4.6, 64K for all others.
  max_tokens is a per-turn output cap, not context window.
- budget_tokens: only set when explicitly configured via
  thinkingBudgetTokens. Was silently defaulting to 1024 (minimum),
  starving the model of thinking capacity.
- Wire maxEmptyRetries/maxEmptyRetryTimeMs from AgentOptions through
  to AgentLoopConfig for empty response retry control.

New features:
- --dump-settings-template: print ~/.agent/settings_template.toml
- --promote-settings: print effective merged settings as TOML candidate
- SettingsManager.getResolvedSettings(): expose merged settings

Files: agent.ts, anthropic.ts, args.ts, settings-manager.ts, main.ts
* uses pre-exchanged-api key
* anthropic only atm
- basic text gen, tool calling, streaming (sonnet-4-6 + haiku-4-5)
- thinking with budget tokens (sonnet-4-6)
- model registry verification
- all 9 tests passing against tokens.vers.sh
When terminal is resized smaller than buildInfo width, the repeat()
call would receive a negative argument causing RangeError. Now properly
guards the condition and truncates when needed.
- Add alwaysHas1MContext() to detect opus-4-6, sonnet-4-6
- Update effectiveContextWindow() to return 1M unconditionally for 4.6 models
- Fixes context pressure showing 60% when actual usage is 25% of 1M
koffi is only used for Windows VT input, but the top-level import
causes module load failures on non-Node runtimes. Move to a dynamic
require inside enableWindowsVTInput() which already guards on
win32 and has a try/catch.
@pranavpatilsce pranavpatilsce changed the title lazy-load koffi to avoid crash on bun runtime Lazy-load koffi for bun runtime compatibility Mar 25, 2026
@pranavpatilsce
pranavpatilsce marked this pull request as draft March 26, 2026 17:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.