# 03 — ExtensionPlugin 接入

## 1. 服务定义

- Service：`ExtensionPlugin`
- RPC：`Call(GenericRequest) returns (GenericResponse)`

用于 **命令/查询型** 能力，不适合替代 `pre_send` 生命周期 Hook。

## 2. 路由规则

- 插件实现 `ExtensionOperationHandler`（Rust 宿主）或对外暴露 `ExtensionPlugin` gRPC。
- 按 **operation 字符串最长前缀** 匹配。
- 命名建议：`{域}.{子系统}.{动作}`，例如 `yourcorp.im.custom_query`。

## 3. Social 读模型同步（不在 ExtensionPlugin）

好友、通讯录、群目录、pending 申请等 **Social 读模型** 已迁出 IM `ExecuteSync`：

| 数据 | 客户端路径 |
|------|------------|
| 通讯录 / 群目录 | Social Gateway REST + `flare-social-sdk` SyncTask |
| 好友/入群申请 | IM DATA `Notification`（在线）+ REST 列表（离线补偿） |

**不要** 再通过 `social.sync.*` ExtensionPlugin 或 `SYNC_KIND_GROUP_DIRECTORY` 拉取群目录。

## 4. 与 Sync Orchestrator 的关系

- `sync-orchestrator` **仅**编排 IM 域：会话列表、消息 seq、关键事件、会话成员。
- Social 业务数据 **禁止**注入 `ExecuteSync` payload。

## 5. 自行扩展 operation

1. 选定前缀，如 `yourcorp.im.`。
2. 在独立服务或 bridge 中注册 handler。
3. 使用 `prost` 定义 `Any` 内消息，或复用 `flare-proto` 已有类型。
4. 在 `CapabilityService.ListCapabilities` 中登记目录项（可选）。

**不要** 在 `flare-im-core` 源码中硬编码你的 operation。
