Skip to content

Add standalone Agentuity Pi plugin package#1453

Merged
jhaynie merged 4 commits intomainfrom
split-pi-aigateway-plugin
May 7, 2026
Merged

Add standalone Agentuity Pi plugin package#1453
jhaynie merged 4 commits intomainfrom
split-pi-aigateway-plugin

Conversation

@jhaynie
Copy link
Copy Markdown
Member

@jhaynie jhaynie commented May 7, 2026

Summary

  • add @agentuity/pi workspace package for Agentuity plugins for the Pi coding agent
  • move the AI Gateway provider registration into the new package as setupAIGateway
  • update @agentuity/coder-tui to depend on and import @agentuity/pi
  • add the package to root build/project references and README package list

Verification

  • bunx biome check --write package.json packages/pi packages/coder-tui/src/index.ts packages/coder-tui/package.json packages/coder-tui/tsconfig.json tsconfig.json
  • bun run --filter='./packages/pi' build
  • bun run --filter='./packages/pi' typecheck
  • bun run --filter='./packages/coder-tui' build
  • bun run --filter='./packages/coder-tui' typecheck
  • bunx tsc --build

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced Pi coding agent provider plugin for Agentuity AI Gateway with organization and region selection commands.
    • Added dynamic model fetching from the AI Gateway provider with automatic configuration.
  • Chores

    • Restructured monorepo to integrate the new Pi provider package into the build pipeline.
    • Updated workspace dependencies and TypeScript configuration.

@agentuity-agent
Copy link
Copy Markdown

agentuity-agent Bot commented May 7, 2026

The latest Agentuity deployment details.

Project Deployment Preview Updated (UTC)
docs 🟢 Ready (deploy_36d8d6fd12d6d8366a573c3ab9b26152) - 2026-05-07T12:34:34Z

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 7, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

A new @agentuity/pi package extracts AI Gateway setup logic into a standalone module. The coder-tui consumer is refactored to depend on this package rather than local core/server files. Root monorepo configuration is updated to build and reference the new package.

Changes

Pi AI Gateway Package Extraction

Layer / File(s) Summary
Package Structure & Configuration
packages/pi/package.json, packages/pi/tsconfig.json, packages/pi/README.md
New @agentuity/pi package manifest defines ESM output with dist entrypoints, workspace dependencies on core/server, external dependency on pi-coding-agent, and TypeScript build configuration.
Data Types & Error Handling
packages/pi/src/index.ts
Defines KnownApi type union, AIGatewayModelFetchError, and JSON parsing helpers to extract structured data from CLI output.
Core Implementation
packages/pi/src/index.ts
Implements environment helpers, CLI discovery (organizations/regions), fetchModels() with AI Gateway service, model conversion to ProviderModelConfig, registerAIGatewayProviders(), region/organization UI command handlers, and setupAIGateway() orchestration with session-start initialization.
Consumer Package Dependencies
packages/coder-tui/package.json, packages/coder-tui/tsconfig.json, packages/coder-tui/src/index.ts
coder-tui adds @agentuity/pi workspace dependency, updates TypeScript path mappings and project references, and switches AI Gateway import from local ./aigateway.ts to external package.
Monorepo Build & References
package.json, tsconfig.json, README.md
Root build scripts insert @agentuity/pi build target between packages/server and packages/react. Root tsconfig modifies references array positioning and adds ./packages/pi project reference. README documents new package in monorepo structure.
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 7, 2026

📦 Canary Packages Published

version: 2.0.15-66e9fa2

Packages
Package Version URL
@agentuity/pi 2.0.15-66e9fa2 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-pi-2.0.15-66e9fa2.tgz
@agentuity/email 2.0.15-66e9fa2 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-email-2.0.15-66e9fa2.tgz
@agentuity/evals 2.0.15-66e9fa2 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-evals-2.0.15-66e9fa2.tgz
@agentuity/webhook 2.0.15-66e9fa2 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-webhook-2.0.15-66e9fa2.tgz
@agentuity/cli 2.0.15-66e9fa2 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-cli-2.0.15-66e9fa2.tgz
@agentuity/drizzle 2.0.15-66e9fa2 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-drizzle-2.0.15-66e9fa2.tgz
@agentuity/postgres 2.0.15-66e9fa2 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-postgres-2.0.15-66e9fa2.tgz
@agentuity/coder 2.0.15-66e9fa2 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-coder-2.0.15-66e9fa2.tgz
@agentuity/aigateway 2.0.15-66e9fa2 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-aigateway-2.0.15-66e9fa2.tgz
@agentuity/sandbox 2.0.15-66e9fa2 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-sandbox-2.0.15-66e9fa2.tgz
@agentuity/keyvalue 2.0.15-66e9fa2 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-keyvalue-2.0.15-66e9fa2.tgz
@agentuity/task 2.0.15-66e9fa2 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-task-2.0.15-66e9fa2.tgz
@agentuity/server 2.0.15-66e9fa2 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-server-2.0.15-66e9fa2.tgz
@agentuity/react 2.0.15-66e9fa2 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-react-2.0.15-66e9fa2.tgz
@agentuity/migrate 2.0.15-66e9fa2 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-migrate-2.0.15-66e9fa2.tgz
@agentuity/workbench 2.0.15-66e9fa2 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-workbench-2.0.15-66e9fa2.tgz
@agentuity/runtime 2.0.15-66e9fa2 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-runtime-2.0.15-66e9fa2.tgz
@agentuity/claude-code 2.0.15-66e9fa2 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-claude-code-2.0.15-66e9fa2.tgz
@agentuity/queue 2.0.15-66e9fa2 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-queue-2.0.15-66e9fa2.tgz
@agentuity/frontend 2.0.15-66e9fa2 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-frontend-2.0.15-66e9fa2.tgz
@agentuity/schema 2.0.15-66e9fa2 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-schema-2.0.15-66e9fa2.tgz
@agentuity/opencode 2.0.15-66e9fa2 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-opencode-2.0.15-66e9fa2.tgz
@agentuity/schedule 2.0.15-66e9fa2 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-schedule-2.0.15-66e9fa2.tgz
@agentuity/auth 2.0.15-66e9fa2 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-auth-2.0.15-66e9fa2.tgz
@agentuity/core 2.0.15-66e9fa2 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-core-2.0.15-66e9fa2.tgz
@agentuity/coder-tui 2.0.15-66e9fa2 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-coder-tui-2.0.15-66e9fa2.tgz
@agentuity/vector 2.0.15-66e9fa2 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-vector-2.0.15-66e9fa2.tgz
@agentuity/db 2.0.15-66e9fa2 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-db-2.0.15-66e9fa2.tgz
Install

Add to your package.json:

{
  "dependencies": {
    "@agentuity/pi": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-pi-2.0.15-66e9fa2.tgz",
    "@agentuity/email": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-email-2.0.15-66e9fa2.tgz",
    "@agentuity/evals": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-evals-2.0.15-66e9fa2.tgz",
    "@agentuity/webhook": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-webhook-2.0.15-66e9fa2.tgz",
    "@agentuity/cli": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-cli-2.0.15-66e9fa2.tgz",
    "@agentuity/drizzle": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-drizzle-2.0.15-66e9fa2.tgz",
    "@agentuity/postgres": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-postgres-2.0.15-66e9fa2.tgz",
    "@agentuity/coder": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-coder-2.0.15-66e9fa2.tgz",
    "@agentuity/aigateway": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-aigateway-2.0.15-66e9fa2.tgz",
    "@agentuity/sandbox": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-sandbox-2.0.15-66e9fa2.tgz",
    "@agentuity/keyvalue": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-keyvalue-2.0.15-66e9fa2.tgz",
    "@agentuity/task": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-task-2.0.15-66e9fa2.tgz",
    "@agentuity/server": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-server-2.0.15-66e9fa2.tgz",
    "@agentuity/react": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-react-2.0.15-66e9fa2.tgz",
    "@agentuity/migrate": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-migrate-2.0.15-66e9fa2.tgz",
    "@agentuity/workbench": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-workbench-2.0.15-66e9fa2.tgz",
    "@agentuity/runtime": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-runtime-2.0.15-66e9fa2.tgz",
    "@agentuity/claude-code": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-claude-code-2.0.15-66e9fa2.tgz",
    "@agentuity/queue": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-queue-2.0.15-66e9fa2.tgz",
    "@agentuity/frontend": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-frontend-2.0.15-66e9fa2.tgz",
    "@agentuity/schema": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-schema-2.0.15-66e9fa2.tgz",
    "@agentuity/opencode": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-opencode-2.0.15-66e9fa2.tgz",
    "@agentuity/schedule": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-schedule-2.0.15-66e9fa2.tgz",
    "@agentuity/auth": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-auth-2.0.15-66e9fa2.tgz",
    "@agentuity/core": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-core-2.0.15-66e9fa2.tgz",
    "@agentuity/coder-tui": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-coder-tui-2.0.15-66e9fa2.tgz",
    "@agentuity/vector": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-vector-2.0.15-66e9fa2.tgz",
    "@agentuity/db": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-db-2.0.15-66e9fa2.tgz"
  }
}

Or install directly:

bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-pi-2.0.15-66e9fa2.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-email-2.0.15-66e9fa2.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-evals-2.0.15-66e9fa2.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-webhook-2.0.15-66e9fa2.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-cli-2.0.15-66e9fa2.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-drizzle-2.0.15-66e9fa2.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-postgres-2.0.15-66e9fa2.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-coder-2.0.15-66e9fa2.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-aigateway-2.0.15-66e9fa2.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-sandbox-2.0.15-66e9fa2.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-keyvalue-2.0.15-66e9fa2.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-task-2.0.15-66e9fa2.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-server-2.0.15-66e9fa2.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-react-2.0.15-66e9fa2.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-migrate-2.0.15-66e9fa2.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-workbench-2.0.15-66e9fa2.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-runtime-2.0.15-66e9fa2.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-claude-code-2.0.15-66e9fa2.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-queue-2.0.15-66e9fa2.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-frontend-2.0.15-66e9fa2.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-schema-2.0.15-66e9fa2.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-opencode-2.0.15-66e9fa2.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-schedule-2.0.15-66e9fa2.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-auth-2.0.15-66e9fa2.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-core-2.0.15-66e9fa2.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-coder-tui-2.0.15-66e9fa2.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-vector-2.0.15-66e9fa2.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.15-66e9fa2/agentuity-db-2.0.15-66e9fa2.tgz

@jhaynie jhaynie changed the title Split Pi AI Gateway plugin into standalone package Add standalone Agentuity Pi plugin package May 7, 2026
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/pi/src/index.ts`:
- Line 162: Add a reasonable timeout option to every execFileSync invocation in
packages/pi/src/index.ts (the calls invoking agentuity: the one calling
execFileSync(agentuity, ['auth', 'whoami', '--json']) and the other three
execFileSync calls referenced around lines 179, 220, 225) so the thread can't
block indefinitely; update each call to pass an options object with a timeout
(e.g., 30_000 ms or whatever is appropriate for your CLI) and leave existing
try/catch handling as-is because execFileSync will throw ETIMEDOUT on timeout
and those catches will handle it.
- Around line 211-213: fetchModels currently builds orgId using
normalizeCredential(getEnv('AGENTUITY_ORGID', 'AGENTUITY_CLOUD_ORG_ID',
'AGENTUITY_ORG_ID')) but getCurrentOrgId checks AGENTUITY_AIGATEWAY_ORGID first,
causing inconsistent behavior; update the orgId resolution inside fetchModels to
include 'AGENTUITY_AIGATEWAY_ORGID' (the same precedence used in
getCurrentOrgId) by adding that key to the getEnv call used with
normalizeCredential so fetchModels will pick up the gateway org id when present.
- Around line 224-229: The code path where execFileSync(fn, ['auth', 'org',
'current']) yields an empty result currently does a silent early return (return
{}) — update the orgId-empty branch in the function that calls execFileSync and
normalizeCredential so it logs a warning (e.g., console.warn or the module's
logger) explaining that the CLI org lookup returned no org and models will not
be loaded, then return {}; ensure you match the style/message used by the other
early-return branches (the ones around the checks at lines 239–242 and 247–248)
and reference orgId, execFileSync, and normalizeCredential when locating the
block to change.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 09a6c57a-0713-4b5e-97b5-4651ca2f83b2

📥 Commits

Reviewing files that changed from the base of the PR and between 3bf6ce3 and 66e9fa2.

⛔ Files ignored due to path filters (1)
  • bun.lock is excluded by !**/*.lock
📒 Files selected for processing (10)
  • README.md
  • package.json
  • packages/coder-tui/package.json
  • packages/coder-tui/src/index.ts
  • packages/coder-tui/tsconfig.json
  • packages/pi/README.md
  • packages/pi/package.json
  • packages/pi/src/index.ts
  • packages/pi/tsconfig.json
  • tsconfig.json
✅ Files skipped from review due to trivial changes (5)
  • README.md
  • packages/pi/README.md
  • tsconfig.json
  • packages/pi/package.json
  • packages/coder-tui/src/index.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/coder-tui/tsconfig.json
  • package.json
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (12)
  • GitHub Check: Framework Integration Tests (TanStack & Next.js)
  • GitHub Check: Template Integration Tests
  • GitHub Check: Queue CLI Tests
  • GitHub Check: Playwright E2E Smoke Test
  • GitHub Check: Postgres SSL Integration Test
  • GitHub Check: SDK Integration Test Suite
  • GitHub Check: Cloud Deployment Tests
  • GitHub Check: Package Installation & Usage Test
  • GitHub Check: Standalone Agent Test
  • GitHub Check: Build
  • GitHub Check: Pack & Upload
  • GitHub Check: Agentuity Deployment
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

Use Biome as code formatter with tabs (width 3), single quotes, semicolons, lineWidth 100, and trailingCommas es5

Files:

  • packages/pi/src/index.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: Use TypeScript Strict mode with ESNext target and bundler moduleResolution
Use StructuredError from @agentuity/core for error handling

Files:

  • packages/pi/src/index.ts
**/index.ts

📄 CodeRabbit inference engine (AGENTS.md)

Use named exports from package index.ts files

Files:

  • packages/pi/src/index.ts
🧠 Learnings (3)
📚 Learning: 2026-01-09T20:33:30.464Z
Learnt from: jhaynie
Repo: agentuity/sdk PR: 515
File: apps/testing/nextjs-app/agentuity/tsconfig.json:0-0
Timestamp: 2026-01-09T20:33:30.464Z
Learning: In TypeScript tsconfig.json files used by Agentuity projects, when a generated type file (e.g. .agentuity/.agentuity_types.ts) must be included while its parent directory is excluded, use include with an explicit file path (or a precise glob) instead of files. The files array requires files to exist at parse time and will fail for generated files; include with a suitable pattern allows the file to be picked up once generated without failing if it doesn't exist yet.

Applied to files:

  • packages/pi/tsconfig.json
📚 Learning: 2026-03-27T23:18:58.450Z
Learnt from: jhaynie
Repo: agentuity/sdk PR: 1292
File: packages/keyvalue/package.json:3-3
Timestamp: 2026-03-27T23:18:58.450Z
Learning: In the agentuity/sdk monorepo, subpackage `package.json` files under `packages/` (e.g., `packages/keyvalue`) are allowed to depend on other workspace packages (such as `agentuity/server`) and are not limited to only `agentuity/core` and `zod`. Also, if a subpackage uses `bunx tsc --build --force` as its build script, treat it as a valid/intentional build command and do not flag it as a dependency/build-script violation.

Applied to files:

  • packages/coder-tui/package.json
📚 Learning: 2025-12-21T00:31:41.858Z
Learnt from: jhaynie
Repo: agentuity/sdk PR: 274
File: packages/cli/src/cmd/build/vite/server-bundler.ts:12-41
Timestamp: 2025-12-21T00:31:41.858Z
Learning: In Bun runtime, BuildMessage and ResolveMessage are global types and are not exported from the bun module. Do not import { BuildMessage } from 'bun' or similar; these types are available globally and should be used without import. This applies to all TypeScript files that target the Bun runtime within the repository.

Applied to files:

  • packages/pi/src/index.ts
🔇 Additional comments (2)
packages/coder-tui/package.json (1)

28-28: Looks good — no blocking concerns in this dependency update.

Line 28 is consistent with the package extraction in this PR and valid workspace dependency usage.

Based on learnings: subpackages under packages/ are allowed to depend on other workspace packages.

packages/pi/tsconfig.json (1)

9-9: ⚡ Quick win

Path mapping is correct.

The wildcard alias "@agentuity/core/*": ["../core/src/services/*"] correctly maps sub-path imports from the pi package. Verification confirms that aigateway is located at core/src/services/aigateway/, and the only sub-path import in pi (@agentuity/core/aigateway) resolves correctly through this mapping. Root-level exports in core are accessible via the non-wildcard mapping.

Comment thread packages/pi/src/index.ts
return [];
}

const res = execFileSync(agentuity, ['auth', 'whoami', '--json']);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

execFileSync calls have no timeout — thread can block indefinitely

All four execFileSync invocations (lines 162, 179, 220, 225) omit the timeout option. If the Agentuity CLI stalls (network auth, slow disk, etc.) the calling thread will block forever, hanging the UI command handler or the entire startup flow.

🛡️ Proposed fix — add a timeout to every `execFileSync` call
-	const res = execFileSync(agentuity, ['auth', 'whoami', '--json']);
+	const res = execFileSync(agentuity, ['auth', 'whoami', '--json'], { timeout: 10_000 });
-	const res = execFileSync(agentuity, ['cloud', 'region', 'list', '--json']);
+	const res = execFileSync(agentuity, ['cloud', 'region', 'list', '--json'], { timeout: 10_000 });
-				const res = execFileSync(fn, ['auth', 'apikey', '--json']);
+				const res = execFileSync(fn, ['auth', 'apikey', '--json'], { timeout: 10_000 });
-					const ores = execFileSync(fn, ['auth', 'org', 'current']);
+					const ores = execFileSync(fn, ['auth', 'org', 'current'], { timeout: 10_000 });

Note: when the timeout elapses, execFileSync throws an Error with code: 'ETIMEDOUT', so existing catch blocks at each call site already handle it correctly.

Also applies to: 179-179, 220-220, 225-225

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/pi/src/index.ts` at line 162, Add a reasonable timeout option to
every execFileSync invocation in packages/pi/src/index.ts (the calls invoking
agentuity: the one calling execFileSync(agentuity, ['auth', 'whoami', '--json'])
and the other three execFileSync calls referenced around lines 179, 220, 225) so
the thread can't block indefinitely; update each call to pass an options object
with a timeout (e.g., 30_000 ms or whatever is appropriate for your CLI) and
leave existing try/catch handling as-is because execFileSync will throw
ETIMEDOUT on timeout and those catches will handle it.

Comment thread packages/pi/src/index.ts
Comment on lines +211 to +213
let orgId = normalizeCredential(
getEnv('AGENTUITY_ORGID', 'AGENTUITY_CLOUD_ORG_ID', 'AGENTUITY_ORG_ID')
);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

fetchModels omits AGENTUITY_AIGATEWAY_ORGID from its initial orgId lookup, inconsistent with getCurrentOrgId

getCurrentOrgId (line 193) checks AGENTUITY_AIGATEWAY_ORGID first, but the orgId resolution inside fetchModels only checks AGENTUITY_ORGID, AGENTUITY_CLOUD_ORG_ID, AGENTUITY_ORG_ID. If a user's environment has only AGENTUITY_AIGATEWAY_ORGID set (or it was written by a previous process invocation), fetchModels silently falls through to CLI-based org lookup instead of using the already-known value.

🐛 Proposed fix
 	let orgId = normalizeCredential(
-		getEnv('AGENTUITY_ORGID', 'AGENTUITY_CLOUD_ORG_ID', 'AGENTUITY_ORG_ID')
+		getEnv('AGENTUITY_AIGATEWAY_ORGID', 'AGENTUITY_ORGID', 'AGENTUITY_CLOUD_ORG_ID', 'AGENTUITY_ORG_ID')
 	);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
let orgId = normalizeCredential(
getEnv('AGENTUITY_ORGID', 'AGENTUITY_CLOUD_ORG_ID', 'AGENTUITY_ORG_ID')
);
let orgId = normalizeCredential(
getEnv('AGENTUITY_AIGATEWAY_ORGID', 'AGENTUITY_ORGID', 'AGENTUITY_CLOUD_ORG_ID', 'AGENTUITY_ORG_ID')
);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/pi/src/index.ts` around lines 211 - 213, fetchModels currently
builds orgId using normalizeCredential(getEnv('AGENTUITY_ORGID',
'AGENTUITY_CLOUD_ORG_ID', 'AGENTUITY_ORG_ID')) but getCurrentOrgId checks
AGENTUITY_AIGATEWAY_ORGID first, causing inconsistent behavior; update the orgId
resolution inside fetchModels to include 'AGENTUITY_AIGATEWAY_ORGID' (the same
precedence used in getCurrentOrgId) by adding that key to the getEnv call used
with normalizeCredential so fetchModels will pick up the gateway org id when
present.

Comment thread packages/pi/src/index.ts
Comment on lines +224 to +229
if (!orgId) {
const ores = execFileSync(fn, ['auth', 'org', 'current']);
orgId = normalizeCredential(ores);
if (!orgId) {
return {};
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Silent return {} when CLI org lookup yields an empty result

When the API key is successfully retrieved via the CLI but execFileSync(fn, ['auth', 'org', 'current']) returns an empty string, the function returns {} without any console.warn. The user will see no models loaded and receive no indication of why, unlike the other early-return paths (lines 239–242 and 247–248) which both emit a warning.

🐛 Proposed fix
 					if (!orgId) {
+						console.warn(
+							'Could not determine current Agentuity organization; cannot fetch models from AI Gateway'
+						);
 						return {};
 					}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (!orgId) {
const ores = execFileSync(fn, ['auth', 'org', 'current']);
orgId = normalizeCredential(ores);
if (!orgId) {
return {};
}
if (!orgId) {
const ores = execFileSync(fn, ['auth', 'org', 'current']);
orgId = normalizeCredential(ores);
if (!orgId) {
console.warn(
'Could not determine current Agentuity organization; cannot fetch models from AI Gateway'
);
return {};
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/pi/src/index.ts` around lines 224 - 229, The code path where
execFileSync(fn, ['auth', 'org', 'current']) yields an empty result currently
does a silent early return (return {}) — update the orgId-empty branch in the
function that calls execFileSync and normalizeCredential so it logs a warning
(e.g., console.warn or the module's logger) explaining that the CLI org lookup
returned no org and models will not be loaded, then return {}; ensure you match
the style/message used by the other early-return branches (the ones around the
checks at lines 239–242 and 247–248) and reference orgId, execFileSync, and
normalizeCredential when locating the block to change.

@jhaynie jhaynie merged commit ebe85e6 into main May 7, 2026
15 checks passed
@jhaynie jhaynie deleted the split-pi-aigateway-plugin branch May 7, 2026 12:36
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.

1 participant