Skip to content

feat: add AI provider support (manifest type "ai", onAiChat handler) - #22

Open
Pierre-Gilles wants to merge 1 commit into
mainfrom
claude/sdk-changes-pr-2744-d6ltvk
Open

feat: add AI provider support (manifest type "ai", onAiChat handler)#22
Pierre-Gilles wants to merge 1 commit into
mainfrom
claude/sdk-changes-pr-2744-d6ltvk

Conversation

@Pierre-Gilles

Copy link
Copy Markdown
Contributor

SDK counterpart of GladysAssistant/Gladys#2744 (generic AI provider external integration, contract B.19): integrations can now declare manifest type: "ai" and serve as the AI backend of Gladys in place of Gladys Plus.

What's in

  • New WebSocket message type external-integration.ai.chat in WEBSOCKET_MESSAGE_TYPES.EXTERNAL_INTEGRATION.AI_CHAT.
  • New onAiChat(cb) handler: receives the OpenAI-compatible chat completion request relayed by the core ({ messages, tools?, tool_choice?, purpose?, categories? } — the model field is stripped core-side, picking one is the provider's job) and resolves an OpenAI-compatible completion, acked back as the command-result data. The core awaits the ack under 120 s (AI_CHAT_TIMEOUT_MS), not the standard 5 s.
  • Client-side completion validation, mirroring the core's contract check: the resolved value must be an object carrying an object choices[0].message — anything else (including undefined) acks the command as failed with an explicit error, instead of letting a malformed completion travel to Gladys and die at the contract boundary (ExternalIntegrationUnavailableError).
  • TypeScript typings: AiChatRequest, AiChatRequestMessage, AiChatCompletion, AiChatCompletionChoice, AiChatCompletionMessage, the onAiChat method and the AI_CHAT message type.
  • README: new "AI providers" section (fetch-based OpenAI-compatible example, 120 s ack window, no-silent-fallback doctrine) + a row in the Handlers table.
  • Tests: test/ai.test.js against the fake Gladys server (success with data, tool_calls-only completion, handler throw, malformed completions, "not implemented"), plus compile-time coverage in test/types/api.test-d.ts.

Checks

  • npm test: 185/185 pass
  • npm run coverage: thresholds green (100% stmts/funcs/lines)
  • npm run lint, npm run prettier-check, npm run check-types: clean

🤖 Generated with Claude Code

https://claude.ai/code/session_018mwqzunU7Hj5yXKoAwR1hi


Generated by Claude Code

Mirror of the Gladys core contract B.19 (GladysAssistant/Gladys#2744):
integrations can now declare manifest type "ai" and serve as the AI
backend of Gladys in place of Gladys Plus.

- New `external-integration.ai.chat` WebSocket message type
- New `onAiChat(cb)` handler: receives the OpenAI-compatible chat
  completion request relayed by the core, resolves an OpenAI-compatible
  completion acked back as the command-result data (120 s ack window)
- The SDK validates the resolved completion (object choices[0].message,
  same check as the core) and acks the command as failed otherwise
- TypeScript typings (AiChatRequest, AiChatCompletion, onAiChat), README
  section and tests

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018mwqzunU7Hj5yXKoAwR1hi
@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@Pierre-Gilles, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 59 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 91633573-65f0-4eb8-a52b-6067502920ec

📥 Commits

Reviewing files that changed from the base of the PR and between 800bd7d and c6f1c87.

📒 Files selected for processing (6)
  • README.md
  • index.d.ts
  • lib/constants.js
  • lib/gladys-integration.js
  • test/ai.test.js
  • test/types/api.test-d.ts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

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.

2 participants