Skip to content

feat(providers): add forge provider support#401

Merged
iamtoruk merged 3 commits into
getagentseal:mainfrom
sleicht:feature/forge-provider
May 26, 2026
Merged

feat(providers): add forge provider support#401
iamtoruk merged 3 commits into
getagentseal:mainfrom
sleicht:feature/forge-provider

Conversation

@sleicht
Copy link
Copy Markdown
Contributor

@sleicht sleicht commented May 26, 2026

Summary

  • Add Forge as a supported provider by reading conversations from ~/.forge/.forge.db.
  • Parse assistant usage into prompt, completion, cached token counts, model names, tool calls, and shell commands.
  • Register Forge in the provider list and document its local data source.

Fixes #400

Testing

  • I have tested this locally against real data (not just unit tests)
  • npm test passes
  • npm run build succeeds

For new providers only:

  • I installed the tool and generated real sessions by using it
  • npm run dev -- today shows correct costs and session counts for this provider
  • npm run dev -- models --provider forge shows correct model names and pricing
  • Screenshot or terminal output attached below proving it works with real data
Real Forge DB smoke test:
- Data source: ~/.forge/.forge.db
- Discovered 167 Forge sources
- Parsed 68 calls from the first 5 sources
- Provider output uses provider: forge
- Parsed model, input tokens, output tokens, cached tokens, tools, and session id without printing message content

Verification commands:
- CI=1 npm test -- tests/providers/forge.test.ts tests/provider-registry.test.ts tests/cli-status-menubar.test.ts
  - 23 tests passed
- CI=1 npm test -- --testTimeout=15000
  - 68 files passed
  - 993 tests passed
- npx tsc --noEmit
  - passed
- npx tsup
  - passed
- NODE_USE_ENV_PROXY=1 npm run build
  - passed

@sleicht sleicht force-pushed the feature/forge-provider branch from 199b08c to 6dc089a Compare May 26, 2026 08:33
@sleicht sleicht force-pushed the feature/forge-provider branch from 6dc089a to 8ca3669 Compare May 26, 2026 08:41
Copy link
Copy Markdown
Member

@iamtoruk iamtoruk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review

Security — clean. All SQL is parameterized (WHERE conversation_id = ?), DB opened read-only, no credentials/auth exposed, splitSourcePath handles : in paths correctly via lastIndexOf, user messages truncated to 500 chars.

Correctness — solid. Token math matches the codex.ts pattern: inputTokens = Math.max(0, promptTokens - cachedInputTokens) normalizes OpenAI-style inclusive prompt tokens to Anthropic semantics. calculateCost parameter order verified against the signature. CAST(workspace_id AS TEXT) for BigInt is tested and documented. Timestamp parsing handles SQLite format, ISO, and epoch fallback.

Tests — thorough. 8 tests covering core parsing, missing DB, zero-token skip, multi-message user prompt tracking, null title fallback, large integer workspace_id, invalid JSON, and registry integration. All 994 tests pass, tsc clean, build clean.

No breaking changes — purely additive.


One fix needed before merge:

discoverFromDb (line 238) selects context, created_at, updated_at but only uses conversation_id, title, and workspace_id. The context column holds the full conversation JSON (potentially megabytes per row). With 167+ conversations this pulls all message data into memory just to build a list of IDs.

-- current (wasteful)
SELECT conversation_id, title, CAST(workspace_id AS TEXT) AS workspace_id, context, created_at, updated_at
FROM conversations WHERE context IS NOT NULL

-- fix
SELECT conversation_id, title, CAST(workspace_id AS TEXT) AS workspace_id
FROM conversations WHERE context IS NOT NULL

You can narrow the ConversationRow type or just use a separate type for discovery rows. The parse query (line 155) still needs all columns — only discovery is affected.

Once that's addressed this is good to go.

@sleicht
Copy link
Copy Markdown
Contributor Author

sleicht commented May 26, 2026

Thank you for the review. I addressed the conversationrow issue.

Copy link
Copy Markdown
Member

@iamtoruk iamtoruk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discovery query fix verified — only selects the 3 columns needed, separate DiscoveryRow type, source-level test guarding against regression. 995/995 tests pass, tsc clean, build clean.

@iamtoruk iamtoruk merged commit ff139bc into getagentseal:main May 26, 2026
@sleicht
Copy link
Copy Markdown
Contributor Author

sleicht commented May 26, 2026

Thank you.

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.

Add Forge as a supported provider

2 participants