mirror of
https://github.com/lobehub/lobehub.git
synced 2026-09-20 04:56:13 +08:00
866af8d2f0
* ✨ feat(composio): add Composio integration layer as Klavis replacement - Add @composio/core SDK client factory (src/libs/composio) - Add COMPOSIO_API_KEY server config + enableComposio flag - Add COMPOSIO_APP_TYPES const with 21 curated apps (appSlug-based) - Add lambda/composio tRPC router (createConnection, deleteConnection, getConnection, updateComposioPlugin) - Add tools/composio tRPC router (executeAction, listActions, getActions) - Add ComposioService with executeComposioTool + getComposioManifests - Add composioStore Zustand slice (7 files: types, initialState, action, selectors, index, test) - Wire composioStore into ToolStore state and action tree - Add composioStoreSelectors to tool selectors index - Add handleComposioInstall to AgentManagerRuntime - Extend CustomPluginParams with composio field - Add enableComposio to GlobalServerConfig types Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * 🔥 refactor(klavis): remove Klavis integration and migrate all references to Composio - Delete all Klavis source files (libs, config, const, routers, services, store, UI components) - Rename KlavisX components to ComposioX equivalents - Replace all Klavis store selectors, types, and action names with Composio counterparts - Fix authConfigId to be server-side managed (auto-fetch/create from Composio API) - Update DB customParams.klavis → customParams.composio throughout - Fix ToolSource type: 'klavis' → 'composio' - Fix TaskTemplateSkillSource: 'klavis' → 'composio' - Fix RecommendedSkillType.Klavis → RecommendedSkillType.Composio - Remove klavis npm package dependency - Update builtin-tool-creds: connectKlavisService → connectComposioService - Update RuntimeExecutors: KLAVIS_SERVICES_LIST → COMPOSIO_SERVICES_LIST - All Composio-related type errors: 0 remaining Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * 🐛 fix(composio): complete the klavis→composio migration and wire the OAuth callback The composio branch had renamed the klavis modules but left consumers half-migrated, so the OAuth connect link did not work end-to-end. Finish it: - Add the missing OAuth callback route `/api/composio/oauth/callback` (Composio uses managed auth, so it only lands the user back and closes the popup; the opener then polls getConnection and syncs tools). Allowlist it as a public cross-site redirect landing in the proxy define-config. - Remove leftover `import { type Klavis } from 'composio'` (non-existent package) and type the prop as `string`. - Fix undefined `oauthUrl` → `redirectUrl` in every OAuth popup opener. - Map `serverName` to `appSlug` (API) / `label` (display); unify every createComposioConnection call to `{ appSlug, identifier, label }`. - Compare against the `ComposioServerStatus` enum instead of the `'ACTIVE'` string literal. - Use the renamed store fields `composioServers` / `isComposioServersInit`. - executeComposioTool: `toolName` → `toolSlug`. - Rename onboarding `KlavisServerItem.tsx` → `ComposioServerItem.tsx` to match its import. * 🐛 fix(composio): use connectedAccounts.link for Composio-managed OAuth `connectedAccounts.initiate` is no longer supported for Composio-managed OAuth auth configs (HTTP 400), which broke connecting apps like Gmail. Switch to `connectedAccounts.link` (POST /api/v3/connected_accounts/link) — same `{ callbackUrl }` options and `{ id, redirectUrl }` result, so it is a drop-in. Also treat Composio's `status=failed` callback query param as a failed authorization in the OAuth callback page. * 🐛 fix(composio): correct tool sync, execution, callback build, and list dedup Four fixes found while testing the Composio integration end-to-end: - listActions: use `getRawComposioTools` (raw defs with slug/inputParameters) instead of `tools.get()` (provider-wrapped, name/params under `.function`). The wrapped shape left every synced tool with an empty name, so they all collapsed to `${identifier}____` and the LLM rejected the request with "Tool names must be unique." - tools.execute: pass `dangerouslySkipVersionCheck: true` (manual execution otherwise throws ComposioToolVersionRequiredError when the toolkit version resolves to "latest"). Applied to both the executeAction router and the ComposioService used by the agent runtime. - OAuth callback route: escape only `<`/`>`/`&` for the inline-script payload; the previous regex embedded literal U+2028/U+2029 line separators which broke the regex literal at build time ("Unterminated regular expression"). - installed-plugin selectors: filter out `customParams.composio` (was still checking the old `customParams.klavis`), so a connected Composio app no longer shows up twice in the skill picker / tool discovery list. * ✨ feat(composio): pin auth config id per toolkit via env Add `COMPOSIO_AUTH_CONFIG_IDS` (JSON map of `identifier -> authConfigId`) so a pre-created Composio auth config (e.g. a custom/white-label OAuth app set up in the dashboard) can be used directly per toolkit. `createConnection` now resolves the pinned auth config first, then falls back to discovering an existing one for the toolkit (matched case-insensitively), and only auto-creates a Composio-managed config when nothing is configured. * 🐛 fix(composio): update plugin invoke test to composio + sort tool initialState imports - action.test.ts: the action was renamed invokeKlavisTypePlugin → invokeComposioTypePlugin (Klavis is being removed); update the test to call the composio action and drop the klavis-era naming/mock field. - store/tool/initialState.ts: order the composioStore import before connector to satisfy simple-import-sort/imports. * 🐛 fix(composio): stop client deleting remote connections by static allowlist useFetchUserComposioConnections no longer deletes remote connections/plugins for identifiers outside the compile-time COMPOSIO_APP_TYPES list — an outdated client bundle would silently destroy a legitimate connection. Unknown identifiers are now only hidden locally. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * 🐛 fix(composio): resolve connectedAccountId server-side in executeAction executeAction now takes `identifier` and looks up the connectedAccountId from the caller's own user-scoped plugin record (PluginModel), instead of trusting a connectedAccountId supplied by the client — which would let a user drive another user's connection. Callers (callComposioTool, composioExecutor) pass identifier accordingly. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * 🐛 fix(composio): enable plugin only after OAuth succeeds Move enablePluginForAgent into the ACTIVE and post-auth-success branches so a cancelled/timed-out authorization no longer leaves an enabled-but-unauthorized Composio tool on the agent. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * 🔥 fix(composio): drop dead OAuth callback postMessage The lobe-composio-oauth postMessage had no consumer — the OAuth wait uses polling + window.closed detection. Remove it and its escaping helpers. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * 🐛 fix(composio): resolve type-check errors after canary merge - Guard authConfigId to a definite string before persisting/returning it (createConnection), fixing the string|undefined assignment in both the server router and the composio store server object. - Replace leftover KLAVIS_SERVER_TYPES with COMPOSIO_APP_TYPES in AgentTool. - Update SkillAuthRow test to a composio source/provider (klavis is removed from TaskTemplateSkillSource). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * ♻️ refactor(composio): remove leftover klavis naming after migration Klavis is deprecated and fully replaced by Composio. The migration kept the underlying composio wiring but left klavis-named identifiers, comments, prompt tags, i18n keys, and files throughout. Sweep them to composio: - Code identifiers/comments across ~70 files (isKlavisEnabled→isComposioEnabled, allKlavisServers→allComposioServers, klavisManifests→composioManifests, etc.) - LLM prompt tags (<klavis_tools>→<composio_tools>, KLAVIS_SERVICES_LIST→ COMPOSIO_SERVICES_LIST) — kept consistent across definition and substitution - i18n keys tools.klavis.*→tools.composio.* + user-facing "Klavis"→"Composio" brand strings, in default setting.ts and all locale setting.json files - Rename useKlavisOAuth→useComposioOAuth, useKlavisServerActions→ useComposioServerActions (+ imports) - klavis.ai homepage URLs → composio.dev - Remove the dead `klavis` npm peerDependency; swap .env.example Klavis section for Composio; update product docs Changelog history left untouched. Pure rename — no behavior change. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * 🐛 fix(composio): remove duplicate composio key in CustomPluginParams The klavis→composio rename collapsed the deprecated klavis param block onto the live composio one, producing a duplicate `composio` property. The klavis shape (instanceId/serverName/serverUrl/isAuthenticated) is dead — no code reads it — so drop it and keep the live composio shape. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * 🐛 fix(composio): let pending/errored connections re-authorize or be deleted A Composio connection link (lk_...) expires after a while. Previously a pending/errored row only offered to reopen the stored — now expired — redirectUrl, and the delete action existed only for ACTIVE connections, so an expired link left the tool permanently stuck: unauthenticatable and unremovable. - Add reauthorizeComposioConnection store action: best-effort delete the stale connection, then mint a fresh link (replaces the record in place) - Settings skill item + chat toolbar item: PENDING/ERROR now render a ··· menu with Re-authorize (fresh link) and Delete - Onboarding: pending/errored row click re-mints a fresh link instead of reopening the stale one - i18n: add tools.composio.reauthorize (en-US + zh-CN) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * 🐛 fix(composio): return auth link instead of opening popup from agent connectComposioService runs from the agent's response, which carries no user gesture, so window.open was blocked by the browser and the flow always failed with "Authorization was cancelled or timed out". Instead of opening the popup ourselves, return the authorization redirectUrl in the tool result so the agent can surface a clickable link — the user's click is a real gesture and completes the OAuth normally. Drops the now-unused popup/poll helper. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * 💄 fix(composio): match pending toolbar item to sibling authorize affordance The ··· dropdown I added to the chat-toolbar Composio item was a bare icon (inconsistent color/size with the app's standard menus), its popup was mis-anchored/offset, and replacing the visible "authorize" cue with a ··· made an un-authorized (pending) row look connected. Match the sibling LobehubSkillServerItem instead: render a clickable "Re-authorize" text + external-link icon for PENDING/ERROR. Clicking re-mints a fresh link (the prior one may have expired) and opens it. No dropdown, so no offset; the explicit affordance makes it clear the row still needs auth. Delete stays on the settings page (siblings have no inline delete here either). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
980 B
980 B