@reachv2/sdk 0.1.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -8,7 +8,7 @@ Reach(reach.codes)统一平台的官方 TypeScript SDK —— 由 aiservicer
8
8
 
9
9
  ## 文档
10
10
 
11
- - **[API Reference](docs/API-REFERENCE.md)**(P2.6):全部 20 个资源类 + `ReachClient` 共 **120 个方法**的签名 / 端点 / 参数 / 返回类型 / 错误 / 示例,与 `sdk/src` 源码一一对应。
11
+ - **[API Reference](docs/API-REFERENCE.md)**(P2.6,v0.2.0 扩展统一租户):全部 27 个资源类 + `ReachClient` 共 **203 个资源方法**(另含 `ReachClient.setToken` / `request`)的签名 / 端点 / 参数 / 返回类型 / 错误 / 示例,与 `sdk/src` 源码一一对应。
12
12
 
13
13
  ## 安装
14
14
 
@@ -68,6 +68,38 @@ client.setToken(jwt); // SDK 不会自动接线,需手动 setToken 切换为 J
68
68
 
69
69
  > `setToken()` 是全局切换,调用后所有资源请求优先使用 JWT。
70
70
 
71
+ ## MCP 接入(Phase 5 P5.2)
72
+
73
+ Reach 将自身能力以 **MCP(Model Context Protocol)** 形式对外开放(Streamable HTTP,路径 `/mcp`),
74
+ 让支持 MCP 的客户端(Claude Desktop / Cursor / 自研 Agent)可直接调用 crm + social 域工具。
75
+
76
+ - 端点:`https://reach.codes/mcp`(探活:`GET https://reach.codes/mcp/health`)
77
+ - 鉴权:`X-API-Key: reach-xxx` 或 `Authorization: Bearer sk-xxx`(复用 REST API Key,租户隔离由此 Key 决定)
78
+ - 权限:MCP 工具调用为写操作,API Key 需含 `write` / `all` scope
79
+ - 工具域:按平台配置白名单裁剪(当前 `crm` / `social`),`tools/list` 返回实际可用集合
80
+
81
+ 会话按 MCP Streamable HTTP 规范:先 `initialize` 取得 `mcp-session-id`,
82
+ 再发 `notifications/initialized`,之后 `tools/call`,结束时 `DELETE` 会话。
83
+
84
+ ```ts
85
+ import { Client } from "@modelcontextprotocol/sdk/client/index.js";
86
+ import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
87
+
88
+ const transport = new StreamableHTTPClientTransport(
89
+ new URL("https://reach.codes/mcp"),
90
+ { requestInit: { headers: { "X-API-Key": "reach-xxx" } } }
91
+ );
92
+ const client = new Client({ name: "my-agent", version: "1.0.0" });
93
+ await client.connect(transport);
94
+
95
+ const { tools } = await client.listTools(); // 实际可用的域白名单工具
96
+ const res = await client.callTool({ name: "social_accounts_list", arguments: {} });
97
+ await transport.close(); // 释放会话
98
+ ```
99
+
100
+ > 平台内部闭环(reach server → mcp,`/api/bridge/mcp/discover|call`)走 `x-reach-internal-token`,
101
+ > 不对外暴露;外部集成一律使用 API Key。
102
+
71
103
  ## 统一网关(A.2.4)
72
104
 
73
105
  合并后 Reach 采用**单后端 + 统一网关层**:`@reachv2/sdk` 只走网关。默认 `serverBaseUrl` 省略时等于 `baseUrl`,全部请求经统一网关;`serverBaseUrl` 仅作内部调试 override。
@@ -93,6 +125,14 @@ const client = new ReachClient({
93
125
  | `client.dashboard` | **统一看板**(DashboardApi):crm 客服指标 + social 社媒运营看板 | 双域 |
94
126
  | `client.orchestration` | 对话编排(多 task × 多 agent) | Server |
95
127
 
128
+ ### 统一租户成员模型(G-1~G-3,v0.2.0 新增)
129
+
130
+ | 资源 | 主要能力 | API 域 |
131
+ |------|----------|--------|
132
+ | `client.tenants` | **统一租户(TenantsResource)**:清单/建 org/成员列表/直加/邀请(意图记录)/接受/撤销/改派/移除/owner 转让(shared.tenant_members 权威面) | Server |
133
+ | `client.team` | **社媒团队薄适配(TeamResource)**:/api/team/*(web 社媒后台 Team tab 契约;同表同 token 与 tenants 互通) | Server |
134
+ | `client.health` | **存活探活(HealthResource)**:GET /api/health(匿名 200) | Server |
135
+
96
136
  ### crm 域(源自 aiservicer)
97
137
 
98
138
  | 资源 | 主要能力 | API 域 |
@@ -118,6 +158,15 @@ const client = new ReachClient({
118
158
  | `client.tts` | 文本转语音(synthesize/voices/history) | Server |
119
159
  | `client.accounts` | 社媒账号矩阵(list/connect) | Server |
120
160
 
161
+ ### social 域 — P-REACH(效果 / SEO-GEO / 内容规则 / 数据源,v0.2.0 新增)
162
+
163
+ | 资源 | 主要能力 | API 域 |
164
+ |------|----------|--------|
165
+ | `client.effect` | **效果追踪(EffectResource)**:指标字典、日快照、目标、汇总/ROI/归因/周报、告警、GEO 探针问题集(22 方法) | Server |
166
+ | `client.seoGeo` | **SEO/GEO 域(SeoGeoResource)**:品牌档案 / 渠道集 / 内容矩阵(草稿→发布→回采)/ GEO 资产(24 方法) | Server |
167
+ | `client.contentRules` | **内容规则引擎(ContentRulesResource)**:规则 CRUD + 发布前打分/优化 + 发布后效果/GEO 评估 + 记录趋势(12 方法) | Server |
168
+ | `client.dataSources` | **数据源适配器(DataSourcesResource)**:明细/趋势/告警/定时同步(12 方法;无创建入口,内置源只读) | Server |
169
+
121
170
  > crm 客服指标(原 `client.analytics`)与社媒运营看板(原 `client.dashboard`)已统一为 `client.dashboard`(DashboardApi);AgentX(原 `client.agentx`)与社媒 Agent 市场已统一为 `client.agents`(AgentApi)。
122
171
 
123
172
  ## 统一入口说明
package/dist/client.d.ts CHANGED
@@ -18,7 +18,14 @@ import { AbiResource } from "./resources/abis.js";
18
18
  import { ContentResource } from "./resources/content.js";
19
19
  import { TtsResource } from "./resources/tts.js";
20
20
  import { AccountsResource } from "./resources/accounts.js";
21
+ import { EffectResource } from "./resources/effect.js";
22
+ import { SeoGeoResource } from "./resources/seo-geo.js";
23
+ import { ContentRulesResource } from "./resources/content-rules.js";
24
+ import { DataSourcesResource } from "./resources/data-sources.js";
21
25
  import { DashboardApi } from "./resources/dashboard-api.js";
26
+ import { HealthResource } from "./resources/health.js";
27
+ import { TenantsResource } from "./resources/tenants.js";
28
+ import { TeamResource } from "./resources/team.js";
22
29
  export declare class ReachClient {
23
30
  private apiKey?;
24
31
  private token?;
@@ -45,6 +52,13 @@ export declare class ReachClient {
45
52
  content: ContentResource;
46
53
  tts: TtsResource;
47
54
  accounts: AccountsResource;
55
+ effect: EffectResource;
56
+ seoGeo: SeoGeoResource;
57
+ contentRules: ContentRulesResource;
58
+ dataSources: DataSourcesResource;
59
+ tenants: TenantsResource;
60
+ team: TeamResource;
61
+ health: HealthResource;
48
62
  constructor(config: ReachClientConfig);
49
63
  /** Set token after wallet login */
50
64
  setToken(token: string): void;
package/dist/client.js CHANGED
@@ -18,7 +18,14 @@ import { AbiResource } from "./resources/abis.js";
18
18
  import { ContentResource } from "./resources/content.js";
19
19
  import { TtsResource } from "./resources/tts.js";
20
20
  import { AccountsResource } from "./resources/accounts.js";
21
+ import { EffectResource } from "./resources/effect.js";
22
+ import { SeoGeoResource } from "./resources/seo-geo.js";
23
+ import { ContentRulesResource } from "./resources/content-rules.js";
24
+ import { DataSourcesResource } from "./resources/data-sources.js";
21
25
  import { DashboardApi } from "./resources/dashboard-api.js";
26
+ import { HealthResource } from "./resources/health.js";
27
+ import { TenantsResource } from "./resources/tenants.js";
28
+ import { TeamResource } from "./resources/team.js";
22
29
  export class ReachClient {
23
30
  constructor(config) {
24
31
  if (!config.apiKey && !config.token) {
@@ -50,6 +57,13 @@ export class ReachClient {
50
57
  this.content = new ContentResource(this.requestServer.bind(this));
51
58
  this.tts = new TtsResource(this.requestServer.bind(this));
52
59
  this.accounts = new AccountsResource(this.requestServer.bind(this));
60
+ this.effect = new EffectResource(this.requestServer.bind(this));
61
+ this.seoGeo = new SeoGeoResource(this.requestServer.bind(this));
62
+ this.contentRules = new ContentRulesResource(this.requestServer.bind(this));
63
+ this.dataSources = new DataSourcesResource(this.requestServer.bind(this));
64
+ this.tenants = new TenantsResource(this.requestServer.bind(this));
65
+ this.team = new TeamResource(this.requestServer.bind(this));
66
+ this.health = new HealthResource(this.requestServer.bind(this));
53
67
  }
54
68
  /** Set token after wallet login */
55
69
  setToken(token) {
package/dist/index.d.ts CHANGED
@@ -20,5 +20,12 @@ export { AbiResource } from "./resources/abis.js";
20
20
  export { ContentResource } from "./resources/content.js";
21
21
  export { TtsResource } from "./resources/tts.js";
22
22
  export { AccountsResource } from "./resources/accounts.js";
23
- export type { ReachClientConfig, BotType, AgentType, BotStatus, ChannelType, ChannelStatus, KnowledgeStatus, Pagination, PaginatedResponse, Project, ProjectCreateParams, ProjectUpdateParams, TransactionBotConfig, Bot, BotStats, BotCreateParams, BotUpdateParams, KnowledgeDoc, KnowledgeRecommendation, Channel, ChannelConfigureParams, Conversation, Message, ChatParams, ChatResponse, ChatToolDefinition, ChatToolFunction, DashboardData, BotMetrics, TxIntent, TxStep, PreparedTransaction, ContractInfo, ContractMethod, SimulationResult, DecodedCalldata, ProtocolSummary, ProtocolRegistryEntry, ChainDeployment, ProtocolAction, ParamHint, WalletChallenge, WalletLoginParams, AuthResult, CaptchaResponse, CaptchaAnswer, AgentXAgent, AgentXAgentDetail, AgentXMarketplaceResult, AgentXSubscriptionPlans, AgentXSubscriptionCheck, AgentXAgentContext, AgentXPublishParams, AgentXPublishResult, AgentXSkill, AgentXSkillCreateParams, AgentXAgentStatus, AgentXAgentUsage, AgentXSubscriptionDetail, AgentXSubscriptionList, ServerChatParams, ServerChatResponse, ChatUsage, ChatUsageSummary, AgentSummary, AgentListResult, AgentListParams, AgentChainInfo, AgentActionType, AgentCapabilities, AgentChatParams, AgentChatResult, LightRAGKeyInfo, LightRAGDocumentParams, LightRAGQueryParams, LightRAGQueryResult, LightRAGBatchItem, LightRAGBatchError, LightRAGBatchResult, GlobalAnalytics, AdminDashboard, AdminMerchant, AdminMerchantDetail, AdminBillingRecord, AdminCreateBillingParams, LlmSettings, LlmUpdateParams, ConversationTask, ConversationTaskStatus, ConversationSession, ConversationCapabilities, ConversationMessage, OrchestrationTaskParams, OrchestrateParams, OrchestratedTaskResult, OrchestrateResult, ScheduledTask, ScheduledTaskStatus, ScheduledTaskTriggerType, MonitorConnectorKind, EnterpriseDoc, MonitorConnector, MonitorEvent, MerchantAbi, MerchantAbiCreateParams, } from "./types.js";
23
+ export { EffectResource } from "./resources/effect.js";
24
+ export { SeoGeoResource } from "./resources/seo-geo.js";
25
+ export { ContentRulesResource } from "./resources/content-rules.js";
26
+ export { DataSourcesResource } from "./resources/data-sources.js";
27
+ export { HealthResource } from "./resources/health.js";
28
+ export { TenantsResource } from "./resources/tenants.js";
29
+ export { TeamResource } from "./resources/team.js";
30
+ export type { ReachClientConfig, BotType, AgentType, BotStatus, ChannelType, ChannelStatus, KnowledgeStatus, Pagination, PaginatedResponse, Project, ProjectCreateParams, ProjectUpdateParams, TransactionBotConfig, Bot, BotStats, BotCreateParams, BotUpdateParams, KnowledgeDoc, KnowledgeRecommendation, Channel, ChannelConfigureParams, Conversation, Message, ChatParams, ChatResponse, ChatToolDefinition, ChatToolFunction, DashboardData, BotMetrics, TxIntent, TxStep, PreparedTransaction, ContractInfo, ContractMethod, SimulationResult, DecodedCalldata, ProtocolSummary, ProtocolRegistryEntry, ChainDeployment, ProtocolAction, ParamHint, WalletChallenge, WalletLoginParams, AuthResult, CaptchaResponse, CaptchaAnswer, AgentXAgent, AgentXAgentDetail, AgentXMarketplaceResult, AgentXSubscriptionPlans, AgentXSubscriptionCheck, AgentXAgentContext, AgentXPublishParams, AgentXPublishResult, AgentXSkill, AgentXSkillCreateParams, AgentXAgentStatus, AgentXAgentUsage, AgentXSubscriptionDetail, AgentXSubscriptionList, ServerChatParams, ServerChatResponse, ChatUsage, ChatUsageSummary, AgentSummary, AgentListResult, AgentListParams, AgentChainInfo, AgentActionType, AgentCapabilities, AgentChatParams, AgentChatResult, LightRAGKeyInfo, LightRAGDocumentParams, LightRAGQueryParams, LightRAGQueryResult, LightRAGBatchItem, LightRAGBatchError, LightRAGBatchResult, GlobalAnalytics, AdminDashboard, AdminMerchant, AdminMerchantDetail, AdminBillingRecord, AdminCreateBillingParams, LlmSettings, LlmUpdateParams, ConversationTask, ConversationTaskStatus, ConversationSession, ConversationCapabilities, ConversationMessage, OrchestrationTaskParams, OrchestrateParams, OrchestratedTaskResult, OrchestrateResult, ScheduledTask, ScheduledTaskStatus, ScheduledTaskTriggerType, MonitorConnectorKind, EnterpriseDoc, MonitorConnector, MonitorEvent, MerchantAbi, MerchantAbiCreateParams, SimpleResult, TenantType, TenantMemberRole, TenantMemberStatus, Tenant, TenantMemberInfo, TenantInvite, PublicInviteInfo, InviteAcceptResult, MemberRoleUpdateResult, TransferOwnerResult, TeamMemberItem, TeamInviteResult, HealthInfo, } from "./types.js";
24
31
  export type { ApiKeyInfo, ApiKeyCreated } from "./resources/api-key.js";
package/dist/index.js CHANGED
@@ -20,3 +20,10 @@ export { AbiResource } from "./resources/abis.js";
20
20
  export { ContentResource } from "./resources/content.js";
21
21
  export { TtsResource } from "./resources/tts.js";
22
22
  export { AccountsResource } from "./resources/accounts.js";
23
+ export { EffectResource } from "./resources/effect.js";
24
+ export { SeoGeoResource } from "./resources/seo-geo.js";
25
+ export { ContentRulesResource } from "./resources/content-rules.js";
26
+ export { DataSourcesResource } from "./resources/data-sources.js";
27
+ export { HealthResource } from "./resources/health.js";
28
+ export { TenantsResource } from "./resources/tenants.js";
29
+ export { TeamResource } from "./resources/team.js";
@@ -8,14 +8,15 @@ export declare class AuthResource {
8
8
  /** 钱包签名登录,返回 token + user */
9
9
  walletLogin(params: WalletLoginParams): Promise<AuthResult>;
10
10
  /**
11
- * 获取数学验证码(login/register 前置)。
12
- * svg 为 `data:image/svg+xml;base64,...`,算式形如 "7 + 5 = ?",结果恒为非负。
11
+ * 获取图形验证码(login/register 前置,可选)。
12
+ * image 为 `data:image/svg+xml;base64,...`,算式形如 "7 + 5 = ?",结果恒为非负。
13
+ * 服务端校验码存 Redis 5 分钟一次性(reach:captcha:*)。
13
14
  */
14
15
  getCaptcha(): Promise<CaptchaResponse>;
15
- /** 用户名密码登录(服务端强制要求验证码,必须传 captcha) */
16
- login(username: string, password: string, captcha?: CaptchaAnswer): Promise<AuthResult>;
17
- /** 用户名密码注册(服务端强制要求验证码,必须传 captcha) */
18
- register(username: string, password: string, opts?: {
16
+ /** 邮箱密码登录(server 契约:email+password;captcha 可选,传 captchaToken+captchaAnswer 时服务端强校验) */
17
+ login(email: string, password: string, captcha?: CaptchaAnswer): Promise<AuthResult>;
18
+ /** 邮箱密码注册(server 契约:email+password;captcha 可选) */
19
+ register(email: string, password: string, opts?: {
19
20
  name?: string;
20
21
  email?: string;
21
22
  captcha?: CaptchaAnswer;
@@ -11,28 +11,28 @@ export class AuthResource {
11
11
  return this.request("POST", "/api/auth/wallet-login", params);
12
12
  }
13
13
  /**
14
- * 获取数学验证码(login/register 前置)。
15
- * svg 为 `data:image/svg+xml;base64,...`,算式形如 "7 + 5 = ?",结果恒为非负。
14
+ * 获取图形验证码(login/register 前置,可选)。
15
+ * image 为 `data:image/svg+xml;base64,...`,算式形如 "7 + 5 = ?",结果恒为非负。
16
+ * 服务端校验码存 Redis 5 分钟一次性(reach:captcha:*)。
16
17
  */
17
18
  getCaptcha() {
18
19
  return this.request("POST", "/api/auth/captcha");
19
20
  }
20
- /** 用户名密码登录(服务端强制要求验证码,必须传 captcha) */
21
- login(username, password, captcha) {
21
+ /** 邮箱密码登录(server 契约:email+password;captcha 可选,传 captchaToken+captchaAnswer 时服务端强校验) */
22
+ login(email, password, captcha) {
22
23
  return this.request("POST", "/api/auth/login", {
23
- username,
24
+ email,
24
25
  password,
25
26
  captchaToken: captcha?.token,
26
27
  captchaAnswer: captcha?.answer,
27
28
  });
28
29
  }
29
- /** 用户名密码注册(服务端强制要求验证码,必须传 captcha) */
30
- register(username, password, opts) {
30
+ /** 邮箱密码注册(server 契约:email+password;captcha 可选) */
31
+ register(email, password, opts) {
31
32
  return this.request("POST", "/api/auth/register", {
32
- username,
33
+ email,
33
34
  password,
34
35
  name: opts?.name,
35
- email: opts?.email,
36
36
  captchaToken: opts?.captcha?.token,
37
37
  captchaAnswer: opts?.captcha?.answer,
38
38
  });
@@ -0,0 +1,37 @@
1
+ import { RequestMethod } from "../types.js";
2
+ import { QueryParams } from "./query.js";
3
+ type RequestFn = <T>(method: RequestMethod, path: string, body?: unknown) => Promise<T>;
4
+ /**
5
+ * ContentRules 资源 — 通用内容规则引擎(发布前 SEO/GEO/合规/品牌打分 + 发布后效果评估)。
6
+ * 端点走 Server API(/api/content-rules/*),与社媒域 MCP content_rules_* / seo_geo_optimize 工具同源。
7
+ * 列表/记录 authAny(API Key 可读),写与评估 authenticate(需 JWT 登录态)。
8
+ */
9
+ export declare class ContentRulesResource {
10
+ private request;
11
+ constructor(request: RequestFn);
12
+ /** 规则列表(内置模板 + 自定义;可按 status/category/q 过滤) */
13
+ list(params?: QueryParams): Promise<any>;
14
+ /** 创建自定义规则(condition.items 打分项) */
15
+ create(data: unknown): Promise<any>;
16
+ /** 规则详情 */
17
+ get(id: string): Promise<any>;
18
+ /** 更新规则(内置模板锁定 severity/condition) */
19
+ update(id: string, patch: unknown): Promise<any>;
20
+ /** 状态机 active/archived */
21
+ activate(id: string, status: "active" | "archived"): Promise<any>;
22
+ /** 删除规则(需 archived 且非内置) */
23
+ delete(id: string): Promise<any>;
24
+ /** 发布前打分(可传 ruleIds 子集;persist 默认落库) */
25
+ evaluate(data: unknown): Promise<any>;
26
+ /** SEO/GEO LLM 优化闭环(打分 → 改写 → 复评) */
27
+ optimize(data: unknown): Promise<any>;
28
+ /** 发布后效果评估(effect 规则 × 内置效果监测源指标) */
29
+ evaluateEffect(data?: unknown): Promise<any>;
30
+ /** 收录 + AI 引用(GEO)效果评估(品牌维度) */
31
+ evaluateSeoGeo(data?: unknown): Promise<any>;
32
+ /** 打分历史(ruleId/stepId/siteCode/passed/page) */
33
+ records(params?: QueryParams): Promise<any>;
34
+ /** 打分趋势聚合(days 默认 30) */
35
+ recordsTrend(params?: QueryParams): Promise<any>;
36
+ }
37
+ export {};
@@ -0,0 +1,59 @@
1
+ import { buildQuery } from "./query.js";
2
+ /**
3
+ * ContentRules 资源 — 通用内容规则引擎(发布前 SEO/GEO/合规/品牌打分 + 发布后效果评估)。
4
+ * 端点走 Server API(/api/content-rules/*),与社媒域 MCP content_rules_* / seo_geo_optimize 工具同源。
5
+ * 列表/记录 authAny(API Key 可读),写与评估 authenticate(需 JWT 登录态)。
6
+ */
7
+ export class ContentRulesResource {
8
+ constructor(request) {
9
+ this.request = request;
10
+ }
11
+ /** 规则列表(内置模板 + 自定义;可按 status/category/q 过滤) */
12
+ list(params = {}) {
13
+ return this.request("GET", `/api/content-rules${buildQuery(params)}`);
14
+ }
15
+ /** 创建自定义规则(condition.items 打分项) */
16
+ create(data) {
17
+ return this.request("POST", "/api/content-rules", data);
18
+ }
19
+ /** 规则详情 */
20
+ get(id) {
21
+ return this.request("GET", `/api/content-rules/${encodeURIComponent(id)}`);
22
+ }
23
+ /** 更新规则(内置模板锁定 severity/condition) */
24
+ update(id, patch) {
25
+ return this.request("PUT", `/api/content-rules/${encodeURIComponent(id)}`, patch);
26
+ }
27
+ /** 状态机 active/archived */
28
+ activate(id, status) {
29
+ return this.request("POST", `/api/content-rules/${encodeURIComponent(id)}/activate`, { status });
30
+ }
31
+ /** 删除规则(需 archived 且非内置) */
32
+ delete(id) {
33
+ return this.request("DELETE", `/api/content-rules/${encodeURIComponent(id)}`);
34
+ }
35
+ /** 发布前打分(可传 ruleIds 子集;persist 默认落库) */
36
+ evaluate(data) {
37
+ return this.request("POST", "/api/content-rules/evaluate", data);
38
+ }
39
+ /** SEO/GEO LLM 优化闭环(打分 → 改写 → 复评) */
40
+ optimize(data) {
41
+ return this.request("POST", "/api/content-rules/optimize", data);
42
+ }
43
+ /** 发布后效果评估(effect 规则 × 内置效果监测源指标) */
44
+ evaluateEffect(data = {}) {
45
+ return this.request("POST", "/api/content-rules/evaluate-effect", data);
46
+ }
47
+ /** 收录 + AI 引用(GEO)效果评估(品牌维度) */
48
+ evaluateSeoGeo(data = {}) {
49
+ return this.request("POST", "/api/content-rules/evaluate-seo-geo", data);
50
+ }
51
+ /** 打分历史(ruleId/stepId/siteCode/passed/page) */
52
+ records(params = {}) {
53
+ return this.request("GET", `/api/content-rules/records${buildQuery(params)}`);
54
+ }
55
+ /** 打分趋势聚合(days 默认 30) */
56
+ recordsTrend(params = {}) {
57
+ return this.request("GET", `/api/content-rules/records/trend${buildQuery(params)}`);
58
+ }
59
+ }
@@ -0,0 +1,38 @@
1
+ import { RequestMethod } from "../types.js";
2
+ import { QueryParams } from "./query.js";
3
+ type RequestFn = <T>(method: RequestMethod, path: string, body?: unknown) => Promise<T>;
4
+ /**
5
+ * DataSources 资源 — 数据源适配器(指标明细/趋势/告警/定时同步)。
6
+ * 端点走 Server API(/api/data-sources/*),与社媒域 MCP data_sources_* 工具同源。
7
+ * 全部 authenticate(需 JWT 登录态);内置 effect_monitor 源拒绝改/删/同步(400)。
8
+ * 创建入口不提供:P3.7.1 后无可创建的外部适配器(ADAPTERS 为空)。
9
+ */
10
+ export declare class DataSourcesResource {
11
+ private request;
12
+ constructor(request: RequestFn);
13
+ /** 数据源列表(含内置效果监测源) */
14
+ list(): Promise<any>;
15
+ /** 适配器类型注册表(type + meta.fields 驱动动态表单) */
16
+ adapters(): Promise<any>;
17
+ /** 数据源详情 */
18
+ get(id: string): Promise<any>;
19
+ /** 更新数据源(name/config/status) */
20
+ update(id: string, patch: unknown): Promise<any>;
21
+ /** 状态机 active/paused/archived */
22
+ activate(id: string, status: "active" | "paused" | "archived"): Promise<any>;
23
+ /** 删除数据源(连同指标与定时规则) */
24
+ delete(id: string): Promise<any>;
25
+ /** 手动拉取指标 */
26
+ sync(id: string): Promise<any>;
27
+ /** 指标明细(可按 metric/entity/from/to/limit 过滤) */
28
+ metrics(id: string, params?: QueryParams): Promise<any>;
29
+ /** 按天趋势聚合(metric/days) */
30
+ trend(id: string, params?: QueryParams): Promise<any>;
31
+ /** 告警记录(days) */
32
+ alerts(id: string, params?: QueryParams): Promise<any>;
33
+ /** 设置定时同步 {cron, timezone?} */
34
+ setSchedule(id: string, data: unknown): Promise<any>;
35
+ /** 移除定时同步 */
36
+ removeSchedule(id: string): Promise<any>;
37
+ }
38
+ export {};
@@ -0,0 +1,60 @@
1
+ import { buildQuery } from "./query.js";
2
+ /**
3
+ * DataSources 资源 — 数据源适配器(指标明细/趋势/告警/定时同步)。
4
+ * 端点走 Server API(/api/data-sources/*),与社媒域 MCP data_sources_* 工具同源。
5
+ * 全部 authenticate(需 JWT 登录态);内置 effect_monitor 源拒绝改/删/同步(400)。
6
+ * 创建入口不提供:P3.7.1 后无可创建的外部适配器(ADAPTERS 为空)。
7
+ */
8
+ export class DataSourcesResource {
9
+ constructor(request) {
10
+ this.request = request;
11
+ }
12
+ /** 数据源列表(含内置效果监测源) */
13
+ list() {
14
+ return this.request("GET", "/api/data-sources");
15
+ }
16
+ /** 适配器类型注册表(type + meta.fields 驱动动态表单) */
17
+ adapters() {
18
+ return this.request("GET", "/api/data-sources/adapters");
19
+ }
20
+ /** 数据源详情 */
21
+ get(id) {
22
+ return this.request("GET", `/api/data-sources/${encodeURIComponent(id)}`);
23
+ }
24
+ /** 更新数据源(name/config/status) */
25
+ update(id, patch) {
26
+ return this.request("PUT", `/api/data-sources/${encodeURIComponent(id)}`, patch);
27
+ }
28
+ /** 状态机 active/paused/archived */
29
+ activate(id, status) {
30
+ return this.request("POST", `/api/data-sources/${encodeURIComponent(id)}/activate`, { status });
31
+ }
32
+ /** 删除数据源(连同指标与定时规则) */
33
+ delete(id) {
34
+ return this.request("DELETE", `/api/data-sources/${encodeURIComponent(id)}`);
35
+ }
36
+ /** 手动拉取指标 */
37
+ sync(id) {
38
+ return this.request("POST", `/api/data-sources/${encodeURIComponent(id)}/sync`);
39
+ }
40
+ /** 指标明细(可按 metric/entity/from/to/limit 过滤) */
41
+ metrics(id, params = {}) {
42
+ return this.request("GET", `/api/data-sources/${encodeURIComponent(id)}/metrics${buildQuery(params)}`);
43
+ }
44
+ /** 按天趋势聚合(metric/days) */
45
+ trend(id, params = {}) {
46
+ return this.request("GET", `/api/data-sources/${encodeURIComponent(id)}/trend${buildQuery(params)}`);
47
+ }
48
+ /** 告警记录(days) */
49
+ alerts(id, params = {}) {
50
+ return this.request("GET", `/api/data-sources/${encodeURIComponent(id)}/alerts${buildQuery(params)}`);
51
+ }
52
+ /** 设置定时同步 {cron, timezone?} */
53
+ setSchedule(id, data) {
54
+ return this.request("POST", `/api/data-sources/${encodeURIComponent(id)}/schedule`, data);
55
+ }
56
+ /** 移除定时同步 */
57
+ removeSchedule(id) {
58
+ return this.request("POST", `/api/data-sources/${encodeURIComponent(id)}/schedule`, { remove: true });
59
+ }
60
+ }
@@ -0,0 +1,57 @@
1
+ import { RequestMethod } from "../types.js";
2
+ import { QueryParams } from "./query.js";
3
+ type RequestFn = <T>(method: RequestMethod, path: string, body?: unknown) => Promise<T>;
4
+ /**
5
+ * Effect 资源 — 效果追踪(P6.6):指标字典 / 日快照 / 目标 / 汇总 ROI / 周报告警 / GEO 探针问题集。
6
+ * 端点走 Server API(/api/effect/*),与社媒域 MCP effect_* 工具同源。
7
+ * 读接口 authAny(API Key 可读),写接口 authenticate(需 JWT 登录态)。
8
+ */
9
+ export declare class EffectResource {
10
+ private request;
11
+ constructor(request: RequestFn);
12
+ /** 有效指标字典(平台默认 + 租户覆盖),可按 module 过滤 */
13
+ listDefs(params?: QueryParams): Promise<any>;
14
+ /** 新增/覆盖租户指标定义 {module, metricKey, name, unit?, direction?, agg?, source?, enabled?} */
15
+ upsertDef(data: unknown): Promise<any>;
16
+ /** 删除租户自定义指标定义(平台默认不可删) */
17
+ deleteDef(id: string): Promise<any>;
18
+ /** 维度可配置聚合查询(groupBy/fn/filters) */
19
+ queryMetrics(params?: QueryParams): Promise<any>;
20
+ /** 批量写入日快照(幂等 upsert,单次上限 500 行) */
21
+ writeMetrics(metrics: unknown[]): Promise<any>;
22
+ /** 单指标按天趋势 */
23
+ series(params?: QueryParams): Promise<any>;
24
+ /** 目标列表(可按 module/status 过滤) */
25
+ listTargets(params?: QueryParams): Promise<any>;
26
+ /** 创建目标(module/scope/metric/period/targetValue/periodStart/periodEnd) */
27
+ createTarget(data: unknown): Promise<any>;
28
+ /** 更新目标(部分字段) */
29
+ updateTarget(id: string, patch: unknown): Promise<any>;
30
+ /** 删除目标 */
31
+ deleteTarget(id: string): Promise<any>;
32
+ /** 模块汇总(指标实际值 + 目标达成) */
33
+ summary(params?: QueryParams): Promise<any>;
34
+ /** 成本-效果(转化 vs 用量) */
35
+ roi(params?: QueryParams): Promise<any>;
36
+ /** 对象级归因链 */
37
+ attribution(params?: QueryParams): Promise<any>;
38
+ /** 周报(默认上一个完整自然周,含环比) */
39
+ report(params?: QueryParams): Promise<any>;
40
+ /** 效果告警记录 */
41
+ listAlerts(params?: QueryParams): Promise<any>;
42
+ /** 立即评估告警(目标未达成 / 指标异常;参数走 query) */
43
+ evaluateAlerts(params?: QueryParams): Promise<any>;
44
+ /** GEO 问题集列表(可按 brandProfileId/enabled 过滤) */
45
+ listGeoPrompts(params?: QueryParams): Promise<any>;
46
+ /** 按品牌关键词自动派生问题集(幂等) */
47
+ deriveGeoPrompts(data?: unknown): Promise<any>;
48
+ /** 人工新增问题 {brandProfileId, text} */
49
+ createGeoPrompt(data: unknown): Promise<any>;
50
+ /** 改问题文本 / 启停 */
51
+ updateGeoPrompt(id: string, patch: unknown): Promise<any>;
52
+ /** 删人工问题(自动派生只能停用) */
53
+ deleteGeoPrompt(id: string): Promise<any>;
54
+ /** 立即执行一轮 GEO 探针 {day?}(默认昨日 UTC,同日快照) */
55
+ runGeoProbe(data?: unknown): Promise<any>;
56
+ }
57
+ export {};
@@ -0,0 +1,104 @@
1
+ import { buildQuery } from "./query.js";
2
+ /**
3
+ * Effect 资源 — 效果追踪(P6.6):指标字典 / 日快照 / 目标 / 汇总 ROI / 周报告警 / GEO 探针问题集。
4
+ * 端点走 Server API(/api/effect/*),与社媒域 MCP effect_* 工具同源。
5
+ * 读接口 authAny(API Key 可读),写接口 authenticate(需 JWT 登录态)。
6
+ */
7
+ export class EffectResource {
8
+ constructor(request) {
9
+ this.request = request;
10
+ }
11
+ // ── 指标字典 ──
12
+ /** 有效指标字典(平台默认 + 租户覆盖),可按 module 过滤 */
13
+ listDefs(params = {}) {
14
+ return this.request("GET", `/api/effect/defs${buildQuery(params)}`);
15
+ }
16
+ /** 新增/覆盖租户指标定义 {module, metricKey, name, unit?, direction?, agg?, source?, enabled?} */
17
+ upsertDef(data) {
18
+ return this.request("POST", "/api/effect/defs", data);
19
+ }
20
+ /** 删除租户自定义指标定义(平台默认不可删) */
21
+ deleteDef(id) {
22
+ return this.request("DELETE", `/api/effect/defs/${encodeURIComponent(id)}`);
23
+ }
24
+ // ── 日快照事实表 ──
25
+ /** 维度可配置聚合查询(groupBy/fn/filters) */
26
+ queryMetrics(params = {}) {
27
+ return this.request("GET", `/api/effect/metrics${buildQuery(params)}`);
28
+ }
29
+ /** 批量写入日快照(幂等 upsert,单次上限 500 行) */
30
+ writeMetrics(metrics) {
31
+ return this.request("POST", "/api/effect/metrics", { metrics });
32
+ }
33
+ /** 单指标按天趋势 */
34
+ series(params = {}) {
35
+ return this.request("GET", `/api/effect/series${buildQuery(params)}`);
36
+ }
37
+ // ── 目标 ──
38
+ /** 目标列表(可按 module/status 过滤) */
39
+ listTargets(params = {}) {
40
+ return this.request("GET", `/api/effect/targets${buildQuery(params)}`);
41
+ }
42
+ /** 创建目标(module/scope/metric/period/targetValue/periodStart/periodEnd) */
43
+ createTarget(data) {
44
+ return this.request("POST", "/api/effect/targets", data);
45
+ }
46
+ /** 更新目标(部分字段) */
47
+ updateTarget(id, patch) {
48
+ return this.request("PUT", `/api/effect/targets/${encodeURIComponent(id)}`, patch);
49
+ }
50
+ /** 删除目标 */
51
+ deleteTarget(id) {
52
+ return this.request("DELETE", `/api/effect/targets/${encodeURIComponent(id)}`);
53
+ }
54
+ // ── 汇总 / ROI / 报告 / 告警 ──
55
+ /** 模块汇总(指标实际值 + 目标达成) */
56
+ summary(params = {}) {
57
+ return this.request("GET", `/api/effect/summary${buildQuery(params)}`);
58
+ }
59
+ /** 成本-效果(转化 vs 用量) */
60
+ roi(params = {}) {
61
+ return this.request("GET", `/api/effect/roi${buildQuery(params)}`);
62
+ }
63
+ /** 对象级归因链 */
64
+ attribution(params = {}) {
65
+ return this.request("GET", `/api/effect/attribution${buildQuery(params)}`);
66
+ }
67
+ /** 周报(默认上一个完整自然周,含环比) */
68
+ report(params = {}) {
69
+ return this.request("GET", `/api/effect/report${buildQuery(params)}`);
70
+ }
71
+ /** 效果告警记录 */
72
+ listAlerts(params = {}) {
73
+ return this.request("GET", `/api/effect/alerts${buildQuery(params)}`);
74
+ }
75
+ /** 立即评估告警(目标未达成 / 指标异常;参数走 query) */
76
+ evaluateAlerts(params = {}) {
77
+ return this.request("POST", `/api/effect/alerts/evaluate${buildQuery(params)}`, {});
78
+ }
79
+ // ── GEO 探针问题集 / 手动执行 ──
80
+ /** GEO 问题集列表(可按 brandProfileId/enabled 过滤) */
81
+ listGeoPrompts(params = {}) {
82
+ return this.request("GET", `/api/effect/geo/prompts${buildQuery(params)}`);
83
+ }
84
+ /** 按品牌关键词自动派生问题集(幂等) */
85
+ deriveGeoPrompts(data = {}) {
86
+ return this.request("POST", "/api/effect/geo/prompts/derive", data);
87
+ }
88
+ /** 人工新增问题 {brandProfileId, text} */
89
+ createGeoPrompt(data) {
90
+ return this.request("POST", "/api/effect/geo/prompts", data);
91
+ }
92
+ /** 改问题文本 / 启停 */
93
+ updateGeoPrompt(id, patch) {
94
+ return this.request("PUT", `/api/effect/geo/prompts/${encodeURIComponent(id)}`, patch);
95
+ }
96
+ /** 删人工问题(自动派生只能停用) */
97
+ deleteGeoPrompt(id) {
98
+ return this.request("DELETE", `/api/effect/geo/prompts/${encodeURIComponent(id)}`);
99
+ }
100
+ /** 立即执行一轮 GEO 探针 {day?}(默认昨日 UTC,同日快照) */
101
+ runGeoProbe(data = {}) {
102
+ return this.request("POST", "/api/effect/geo/run", data);
103
+ }
104
+ }
@@ -0,0 +1,13 @@
1
+ import { RequestMethod, HealthInfo } from "../types.js";
2
+ type RequestFn = <T>(method: RequestMethod, path: string, body?: unknown) => Promise<T>;
3
+ /**
4
+ * Health 资源 — 平台存活探活(REQ-4)。
5
+ * GET /api/health 匿名 200(无需鉴权头,但 SDK 构造仍需 apiKey/token 任一)。
6
+ */
7
+ export declare class HealthResource {
8
+ private request;
9
+ constructor(request: RequestFn);
10
+ /** 存活探活 */
11
+ check(): Promise<HealthInfo>;
12
+ }
13
+ export {};
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Health 资源 — 平台存活探活(REQ-4)。
3
+ * GET /api/health 匿名 200(无需鉴权头,但 SDK 构造仍需 apiKey/token 任一)。
4
+ */
5
+ export class HealthResource {
6
+ constructor(request) {
7
+ this.request = request;
8
+ }
9
+ /** 存活探活 */
10
+ check() {
11
+ return this.request("GET", "/api/health");
12
+ }
13
+ }
@@ -0,0 +1,3 @@
1
+ /** 社媒域资源共用 query 构造:过滤 undefined/null/''(避免 ?module=undefined 触达后端枚举校验)。 */
2
+ export type QueryParams = Record<string, string | number | boolean | undefined | null>;
3
+ export declare function buildQuery(params?: QueryParams): string;
@@ -0,0 +1,10 @@
1
+ export function buildQuery(params) {
2
+ const qs = new URLSearchParams();
3
+ for (const [k, v] of Object.entries(params || {})) {
4
+ if (v === undefined || v === null || v === "")
5
+ continue;
6
+ qs.set(k, String(v));
7
+ }
8
+ const s = qs.toString();
9
+ return s ? `?${s}` : "";
10
+ }
@@ -0,0 +1,65 @@
1
+ import { RequestMethod } from "../types.js";
2
+ import { QueryParams } from "./query.js";
3
+ type RequestFn = <T>(method: RequestMethod, path: string, body?: unknown) => Promise<T>;
4
+ /**
5
+ * SeoGeo 资源 — P-REACH 角色2 SEO/GEO 域:品牌档案 / 渠道集 / 内容矩阵 / GEO 资产。
6
+ * 端点走 Server API(/api/seo-geo/*),与社媒域 MCP seo_geo_* 工具同源。
7
+ * 列表/目录 authAny(API Key 可读),详情与写操作 authenticate(需 JWT 登录态)。
8
+ */
9
+ export declare class SeoGeoResource {
10
+ private request;
11
+ constructor(request: RequestFn);
12
+ /** SEO/GEO 可收录渠道目录(siteCode/name/category/article/tags) */
13
+ catalog(): Promise<any>;
14
+ /** 品牌档案列表(可按 status/q 过滤) */
15
+ listBrands(params?: QueryParams): Promise<any>;
16
+ /** 创建品牌档案 */
17
+ createBrand(data: unknown): Promise<any>;
18
+ /** 品牌档案详情 */
19
+ getBrand(id: string): Promise<any>;
20
+ /** 更新品牌档案(部分字段) */
21
+ updateBrand(id: string, patch: unknown): Promise<any>;
22
+ /** 删除品牌档案(被矩阵引用时 409) */
23
+ deleteBrand(id: string): Promise<any>;
24
+ /** 渠道集列表(可按 status/q 过滤) */
25
+ listChannelSets(params?: QueryParams): Promise<any>;
26
+ /** 创建渠道集 {name, channels: siteCode[]} */
27
+ createChannelSet(data: unknown): Promise<any>;
28
+ /** 渠道集详情 */
29
+ getChannelSet(id: string): Promise<any>;
30
+ /** 更新渠道集(channels 全量替换) */
31
+ updateChannelSet(id: string, patch: unknown): Promise<any>;
32
+ /** 删除渠道集(被矩阵引用时 409) */
33
+ deleteChannelSet(id: string): Promise<any>;
34
+ /** 矩阵计划列表(可按 status/q 过滤) */
35
+ listPlans(params?: QueryParams): Promise<any>;
36
+ /** 创建矩阵计划(按渠道集生成任务行) */
37
+ createPlan(data: unknown): Promise<any>;
38
+ /** 矩阵详情(含任务行) */
39
+ getPlan(id: string): Promise<any>;
40
+ /** 更新矩阵(换渠道集会镜像任务行) */
41
+ updatePlan(id: string, patch: unknown): Promise<any>;
42
+ /** 任务同步(补齐渠道集新增渠道,add-only) */
43
+ syncPlan(id: string): Promise<any>;
44
+ /** 生成单任务优化草稿(打分 → LLM 改写 → 复评) */
45
+ draftTask(planId: string, taskId: string): Promise<any>;
46
+ /** 批量生成草稿 {includeFailed?} */
47
+ draftAll(id: string, params?: {
48
+ includeFailed?: boolean;
49
+ }): Promise<any>;
50
+ /** 一步执行(批量生成 + 发布){publish?} */
51
+ runPlan(id: string, params?: {
52
+ publish?: boolean;
53
+ }): Promise<any>;
54
+ /** 一键发布(ready 草稿 → 发布计划编排) */
55
+ publishPlan(id: string): Promise<any>;
56
+ /** 人工渠道发布回采 {postUrl, publishedAt?} */
57
+ recordPublish(taskId: string, data: unknown): Promise<any>;
58
+ /** 删除单任务行 */
59
+ deleteTask(taskId: string): Promise<any>;
60
+ /** 删除矩阵(级联任务) */
61
+ deletePlan(id: string): Promise<any>;
62
+ /** 生成可部署 GEO 资产(robots.txt / llms.txt / JSON-LD) */
63
+ geoAssets(brandProfileId: string): Promise<any>;
64
+ }
65
+ export {};
@@ -0,0 +1,112 @@
1
+ import { buildQuery } from "./query.js";
2
+ /**
3
+ * SeoGeo 资源 — P-REACH 角色2 SEO/GEO 域:品牌档案 / 渠道集 / 内容矩阵 / GEO 资产。
4
+ * 端点走 Server API(/api/seo-geo/*),与社媒域 MCP seo_geo_* 工具同源。
5
+ * 列表/目录 authAny(API Key 可读),详情与写操作 authenticate(需 JWT 登录态)。
6
+ */
7
+ export class SeoGeoResource {
8
+ constructor(request) {
9
+ this.request = request;
10
+ }
11
+ // ── 渠道目录 ──
12
+ /** SEO/GEO 可收录渠道目录(siteCode/name/category/article/tags) */
13
+ catalog() {
14
+ return this.request("GET", "/api/seo-geo/catalog");
15
+ }
16
+ // ── 品牌档案 ──
17
+ /** 品牌档案列表(可按 status/q 过滤) */
18
+ listBrands(params = {}) {
19
+ return this.request("GET", `/api/seo-geo/brands${buildQuery(params)}`);
20
+ }
21
+ /** 创建品牌档案 */
22
+ createBrand(data) {
23
+ return this.request("POST", "/api/seo-geo/brands", data);
24
+ }
25
+ /** 品牌档案详情 */
26
+ getBrand(id) {
27
+ return this.request("GET", `/api/seo-geo/brands/${encodeURIComponent(id)}`);
28
+ }
29
+ /** 更新品牌档案(部分字段) */
30
+ updateBrand(id, patch) {
31
+ return this.request("PUT", `/api/seo-geo/brands/${encodeURIComponent(id)}`, patch);
32
+ }
33
+ /** 删除品牌档案(被矩阵引用时 409) */
34
+ deleteBrand(id) {
35
+ return this.request("DELETE", `/api/seo-geo/brands/${encodeURIComponent(id)}`);
36
+ }
37
+ // ── 渠道集 ──
38
+ /** 渠道集列表(可按 status/q 过滤) */
39
+ listChannelSets(params = {}) {
40
+ return this.request("GET", `/api/seo-geo/channel-sets${buildQuery(params)}`);
41
+ }
42
+ /** 创建渠道集 {name, channels: siteCode[]} */
43
+ createChannelSet(data) {
44
+ return this.request("POST", "/api/seo-geo/channel-sets", data);
45
+ }
46
+ /** 渠道集详情 */
47
+ getChannelSet(id) {
48
+ return this.request("GET", `/api/seo-geo/channel-sets/${encodeURIComponent(id)}`);
49
+ }
50
+ /** 更新渠道集(channels 全量替换) */
51
+ updateChannelSet(id, patch) {
52
+ return this.request("PUT", `/api/seo-geo/channel-sets/${encodeURIComponent(id)}`, patch);
53
+ }
54
+ /** 删除渠道集(被矩阵引用时 409) */
55
+ deleteChannelSet(id) {
56
+ return this.request("DELETE", `/api/seo-geo/channel-sets/${encodeURIComponent(id)}`);
57
+ }
58
+ // ── 内容矩阵 ──
59
+ /** 矩阵计划列表(可按 status/q 过滤) */
60
+ listPlans(params = {}) {
61
+ return this.request("GET", `/api/seo-geo/matrix${buildQuery(params)}`);
62
+ }
63
+ /** 创建矩阵计划(按渠道集生成任务行) */
64
+ createPlan(data) {
65
+ return this.request("POST", "/api/seo-geo/matrix", data);
66
+ }
67
+ /** 矩阵详情(含任务行) */
68
+ getPlan(id) {
69
+ return this.request("GET", `/api/seo-geo/matrix/${encodeURIComponent(id)}`);
70
+ }
71
+ /** 更新矩阵(换渠道集会镜像任务行) */
72
+ updatePlan(id, patch) {
73
+ return this.request("PUT", `/api/seo-geo/matrix/${encodeURIComponent(id)}`, patch);
74
+ }
75
+ /** 任务同步(补齐渠道集新增渠道,add-only) */
76
+ syncPlan(id) {
77
+ return this.request("POST", `/api/seo-geo/matrix/${encodeURIComponent(id)}/sync`, {});
78
+ }
79
+ /** 生成单任务优化草稿(打分 → LLM 改写 → 复评) */
80
+ draftTask(planId, taskId) {
81
+ return this.request("POST", `/api/seo-geo/matrix/${encodeURIComponent(planId)}/tasks/${encodeURIComponent(taskId)}/draft`, {});
82
+ }
83
+ /** 批量生成草稿 {includeFailed?} */
84
+ draftAll(id, params = {}) {
85
+ return this.request("POST", `/api/seo-geo/matrix/${encodeURIComponent(id)}/draft-all`, params);
86
+ }
87
+ /** 一步执行(批量生成 + 发布){publish?} */
88
+ runPlan(id, params = {}) {
89
+ return this.request("POST", `/api/seo-geo/matrix/${encodeURIComponent(id)}/run`, params);
90
+ }
91
+ /** 一键发布(ready 草稿 → 发布计划编排) */
92
+ publishPlan(id) {
93
+ return this.request("POST", `/api/seo-geo/matrix/${encodeURIComponent(id)}/publish`, {});
94
+ }
95
+ /** 人工渠道发布回采 {postUrl, publishedAt?} */
96
+ recordPublish(taskId, data) {
97
+ return this.request("POST", `/api/seo-geo/matrix/tasks/${encodeURIComponent(taskId)}/publish-back`, data);
98
+ }
99
+ /** 删除单任务行 */
100
+ deleteTask(taskId) {
101
+ return this.request("DELETE", `/api/seo-geo/matrix/tasks/${encodeURIComponent(taskId)}`);
102
+ }
103
+ /** 删除矩阵(级联任务) */
104
+ deletePlan(id) {
105
+ return this.request("DELETE", `/api/seo-geo/matrix/${encodeURIComponent(id)}`);
106
+ }
107
+ // ── GEO 资产 ──
108
+ /** 生成可部署 GEO 资产(robots.txt / llms.txt / JSON-LD) */
109
+ geoAssets(brandProfileId) {
110
+ return this.request("GET", `/api/seo-geo/geo-assets${buildQuery({ brandProfileId })}`);
111
+ }
112
+ }
@@ -0,0 +1,34 @@
1
+ import { RequestMethod, TenantMemberRole, TeamMemberItem, TeamInviteResult, SimpleResult } from "../types.js";
2
+ type RequestFn = <T>(method: RequestMethod, path: string, body?: unknown) => Promise<T>;
3
+ /**
4
+ * Team 资源 — 社媒团队面(/api/team/*,web 社媒后台 Settings Team tab 契约的薄适配层)。
5
+ *
6
+ * P4.6 后为统一租户成员模型(shared.tenant_members)的适配层:邀请为意图记录
7
+ * (accountId 可空,不预建占位账户),受邀者经统一 POST /invites/:token/accept 激活
8
+ * (可用 tenants.acceptInvite(token))。角色 GRANTABLE=admin/editor/member/viewer,
9
+ * owner 仅经 tenants.transferOwner 产生;PUT/DELETE 纪律对齐 G-3。
10
+ *
11
+ * 鉴权:JWT(Bearer token)。社媒上下文租户 = 账号默认(最早加入)active 租户;
12
+ * 明确租户作用域的成员管理请用 Tenants 资源(path 内显式 tenantId)。
13
+ */
14
+ export declare class TeamResource {
15
+ private request;
16
+ constructor(request: RequestFn);
17
+ /** 当前上下文租户成员列表(受邀未接受行 userId=null;{items,total} 契约) */
18
+ members(): Promise<{
19
+ items: TeamMemberItem[];
20
+ total: number;
21
+ }>;
22
+ /** 邀请成员(email 必填;role 缺省 editor;未注册邮箱亦有效,接受时绑定) */
23
+ invite(params: {
24
+ email: string;
25
+ role?: TenantMemberRole;
26
+ }): Promise<TeamInviteResult>;
27
+ /** 改派成员角色(id = TenantMember.id 行 id,来自 members() 的 item.id) */
28
+ updateMemberRole(memberRowId: string, params: {
29
+ role: TenantMemberRole;
30
+ }): Promise<TeamMemberItem>;
31
+ /** 移除/撤销成员(id = TenantMember.id 行 id;撤销待接受邀请复用本方法) */
32
+ removeMember(memberRowId: string): Promise<SimpleResult>;
33
+ }
34
+ export {};
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Team 资源 — 社媒团队面(/api/team/*,web 社媒后台 Settings Team tab 契约的薄适配层)。
3
+ *
4
+ * P4.6 后为统一租户成员模型(shared.tenant_members)的适配层:邀请为意图记录
5
+ * (accountId 可空,不预建占位账户),受邀者经统一 POST /invites/:token/accept 激活
6
+ * (可用 tenants.acceptInvite(token))。角色 GRANTABLE=admin/editor/member/viewer,
7
+ * owner 仅经 tenants.transferOwner 产生;PUT/DELETE 纪律对齐 G-3。
8
+ *
9
+ * 鉴权:JWT(Bearer token)。社媒上下文租户 = 账号默认(最早加入)active 租户;
10
+ * 明确租户作用域的成员管理请用 Tenants 资源(path 内显式 tenantId)。
11
+ */
12
+ export class TeamResource {
13
+ constructor(request) {
14
+ this.request = request;
15
+ }
16
+ /** 当前上下文租户成员列表(受邀未接受行 userId=null;{items,total} 契约) */
17
+ members() {
18
+ return this.request("GET", "/api/team/members");
19
+ }
20
+ /** 邀请成员(email 必填;role 缺省 editor;未注册邮箱亦有效,接受时绑定) */
21
+ invite(params) {
22
+ return this.request("POST", "/api/team/invite", {
23
+ email: params.email,
24
+ role: params.role || "editor",
25
+ });
26
+ }
27
+ /** 改派成员角色(id = TenantMember.id 行 id,来自 members() 的 item.id) */
28
+ updateMemberRole(memberRowId, params) {
29
+ return this.request("PUT", `/api/team/members/${encodeURIComponent(memberRowId)}`, { role: params.role });
30
+ }
31
+ /** 移除/撤销成员(id = TenantMember.id 行 id;撤销待接受邀请复用本方法) */
32
+ removeMember(memberRowId) {
33
+ return this.request("DELETE", `/api/team/members/${encodeURIComponent(memberRowId)}`);
34
+ }
35
+ }
@@ -0,0 +1,52 @@
1
+ import { RequestMethod, Tenant, TenantMemberRole, TenantMemberInfo, TenantInvite, PublicInviteInfo, InviteAcceptResult, SimpleResult, MemberRoleUpdateResult, TransferOwnerResult } from "../types.js";
2
+ type RequestFn = <T>(method: RequestMethod, path: string, body?: unknown) => Promise<T>;
3
+ /**
4
+ * Tenants 资源 — 平台统一租户成员模型(G-1~G-3,/api/shared/tenants)。
5
+ *
6
+ * 模型:注册即自动建 personal 个人租户(owner);可显式创建 org 企业租户(owner);
7
+ * 成员档位 owner(唯一,转让制) > admin > editor > member/viewer(GRANTABLE=admin/editor/member/viewer,
8
+ * owner 仅经 transferOwner 产生);未注册邮箱走 invite 意图记录(不预建占位账户),
9
+ * 受邀者注册/登录后经 acceptInvite 绑定身份激活(邮箱匹配防冒领)。
10
+ *
11
+ * 鉴权:除 getInvite(token) 公开外,全部需 JWT(Bearer token,client 以 token 构造)。
12
+ */
13
+ export declare class TenantsResource {
14
+ private request;
15
+ constructor(request: RequestFn);
16
+ /** 我加入的租户清单(含 type 与我的角色) */
17
+ list(): Promise<Tenant[]>;
18
+ /** 创建企业/组织租户(创建者为 owner,type=org) */
19
+ create(params: {
20
+ name: string;
21
+ }): Promise<Tenant>;
22
+ /** 租户成员列表(含 invited 待接受行;owner/admin 可见 inviteToken 便于管理邀请链接) */
23
+ members(tenantId: string): Promise<TenantMemberInfo[]>;
24
+ /** 直加已注册账户(owner/admin;email 或 wallet 定位账户;未注册邮箱请用 invite) */
25
+ addMember(tenantId: string, params: {
26
+ email?: string;
27
+ wallet?: string;
28
+ role?: TenantMemberRole;
29
+ }): Promise<TenantMemberInfo>;
30
+ /** 邀请未注册邮箱(意图记录;受邀者注册/登录后 acceptInvite 激活) */
31
+ invite(tenantId: string, params: {
32
+ email: string;
33
+ role?: TenantMemberRole;
34
+ }): Promise<TenantInvite>;
35
+ /** 公开查询邀请(无需登录;展示租户/受邀邮箱/角色/状态) */
36
+ getInvite(token: string): Promise<PublicInviteInfo>;
37
+ /** 登录后接受邀请:邮箱须与邀请一致,绑定身份并激活(幂等) */
38
+ acceptInvite(token: string): Promise<InviteAcceptResult>;
39
+ /** 撤销待接受邀请(owner/admin) */
40
+ revokeInvite(tenantId: string, token: string): Promise<SimpleResult>;
41
+ /** 改派成员角色(owner 全权;admin 仅改 editor/member/viewer,不可授/动 admin;owner 只经转让) */
42
+ updateMemberRole(tenantId: string, accountId: string, params: {
43
+ role: TenantMemberRole;
44
+ }): Promise<MemberRoleUpdateResult>;
45
+ /** 移除成员(owner 移除非 owner;admin 仅移除 editor/member/viewer;owner 移除前须先转让) */
46
+ removeMember(tenantId: string, accountId: string): Promise<SimpleResult>;
47
+ /** owner 转让(仅当前 owner;目标须为 active 成员;转让后原 owner 降 admin) */
48
+ transferOwner(tenantId: string, params: {
49
+ accountId: string;
50
+ }): Promise<TransferOwnerResult>;
51
+ }
52
+ export {};
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Tenants 资源 — 平台统一租户成员模型(G-1~G-3,/api/shared/tenants)。
3
+ *
4
+ * 模型:注册即自动建 personal 个人租户(owner);可显式创建 org 企业租户(owner);
5
+ * 成员档位 owner(唯一,转让制) > admin > editor > member/viewer(GRANTABLE=admin/editor/member/viewer,
6
+ * owner 仅经 transferOwner 产生);未注册邮箱走 invite 意图记录(不预建占位账户),
7
+ * 受邀者注册/登录后经 acceptInvite 绑定身份激活(邮箱匹配防冒领)。
8
+ *
9
+ * 鉴权:除 getInvite(token) 公开外,全部需 JWT(Bearer token,client 以 token 构造)。
10
+ */
11
+ export class TenantsResource {
12
+ constructor(request) {
13
+ this.request = request;
14
+ }
15
+ /** 我加入的租户清单(含 type 与我的角色) */
16
+ list() {
17
+ return this.request("GET", "/api/shared/tenants");
18
+ }
19
+ /** 创建企业/组织租户(创建者为 owner,type=org) */
20
+ create(params) {
21
+ return this.request("POST", "/api/shared/tenants", { name: params.name });
22
+ }
23
+ /** 租户成员列表(含 invited 待接受行;owner/admin 可见 inviteToken 便于管理邀请链接) */
24
+ members(tenantId) {
25
+ return this.request("GET", `/api/shared/tenants/${encodeURIComponent(tenantId)}/members`);
26
+ }
27
+ /** 直加已注册账户(owner/admin;email 或 wallet 定位账户;未注册邮箱请用 invite) */
28
+ addMember(tenantId, params) {
29
+ return this.request("POST", `/api/shared/tenants/${encodeURIComponent(tenantId)}/members`, { email: params.email, wallet: params.wallet, role: params.role || "member" });
30
+ }
31
+ /** 邀请未注册邮箱(意图记录;受邀者注册/登录后 acceptInvite 激活) */
32
+ invite(tenantId, params) {
33
+ return this.request("POST", `/api/shared/tenants/${encodeURIComponent(tenantId)}/invites`, { email: params.email, role: params.role || "member" });
34
+ }
35
+ /** 公开查询邀请(无需登录;展示租户/受邀邮箱/角色/状态) */
36
+ getInvite(token) {
37
+ return this.request("GET", `/api/shared/tenants/invites/${encodeURIComponent(token)}`);
38
+ }
39
+ /** 登录后接受邀请:邮箱须与邀请一致,绑定身份并激活(幂等) */
40
+ acceptInvite(token) {
41
+ return this.request("POST", `/api/shared/tenants/invites/${encodeURIComponent(token)}/accept`);
42
+ }
43
+ /** 撤销待接受邀请(owner/admin) */
44
+ revokeInvite(tenantId, token) {
45
+ return this.request("POST", `/api/shared/tenants/${encodeURIComponent(tenantId)}/invites/${encodeURIComponent(token)}/revoke`);
46
+ }
47
+ /** 改派成员角色(owner 全权;admin 仅改 editor/member/viewer,不可授/动 admin;owner 只经转让) */
48
+ updateMemberRole(tenantId, accountId, params) {
49
+ return this.request("PUT", `/api/shared/tenants/${encodeURIComponent(tenantId)}/members/${encodeURIComponent(accountId)}`, { role: params.role });
50
+ }
51
+ /** 移除成员(owner 移除非 owner;admin 仅移除 editor/member/viewer;owner 移除前须先转让) */
52
+ removeMember(tenantId, accountId) {
53
+ return this.request("DELETE", `/api/shared/tenants/${encodeURIComponent(tenantId)}/members/${encodeURIComponent(accountId)}`);
54
+ }
55
+ /** owner 转让(仅当前 owner;目标须为 active 成员;转让后原 owner 降 admin) */
56
+ transferOwner(tenantId, params) {
57
+ return this.request("POST", `/api/shared/tenants/${encodeURIComponent(tenantId)}/transfer-owner`, { accountId: params.accountId });
58
+ }
59
+ }
package/dist/types.d.ts CHANGED
@@ -12,7 +12,7 @@ export type BotStatus = "running" | "stopped";
12
12
  export type ChannelType = "telegram" | "whatsapp" | "webwidget";
13
13
  export type ChannelStatus = "configured" | "unconfigured" | "pairing";
14
14
  export type KnowledgeStatus = "processing" | "ready" | "error";
15
- export type RequestMethod = "GET" | "POST" | "PATCH" | "DELETE";
15
+ export type RequestMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
16
16
  export interface Pagination {
17
17
  page: number;
18
18
  pageSize: number;
@@ -292,13 +292,13 @@ export interface AuthResult {
292
292
  walletAddress?: string;
293
293
  };
294
294
  }
295
- /** 数学验证码(login/register 前置):svg 为 data URI,算式恒为非负结果 */
295
+ /** 图形验证码(login/register 前置,可选):image 为 data URI,算式恒为非负结果 */
296
296
  export interface CaptchaResponse {
297
- token: string;
298
- svg: string;
297
+ captchaId: string;
298
+ image: string;
299
299
  expiresIn: number;
300
300
  }
301
- /** 验证码作答参数(服务端校验通过才放行登录/注册) */
301
+ /** 验证码作答参数(以 captchaId 为 token;服务端校验通过才放行登录/注册) */
302
302
  export interface CaptchaAnswer {
303
303
  token: string;
304
304
  answer: number;
@@ -791,3 +791,108 @@ export interface MonitorEvent {
791
791
  payload: Record<string, unknown>;
792
792
  received_at: string;
793
793
  }
794
+ /** 通用 ok 结果({ok:true} 契约:revoke/remove 等) */
795
+ export interface SimpleResult {
796
+ ok: boolean;
797
+ }
798
+ export type TenantType = "personal" | "org";
799
+ /** 租户内档位全集(owner 仅经转让产生;GRANTABLE=admin/editor/member/viewer) */
800
+ export type TenantMemberRole = "owner" | "admin" | "editor" | "member" | "viewer";
801
+ export type TenantMemberStatus = "active" | "invited";
802
+ /** 租户(清单响应含我在此租户的角色 role) */
803
+ export interface Tenant {
804
+ id: string;
805
+ name: string;
806
+ slug: string;
807
+ type: TenantType;
808
+ status?: string | null;
809
+ tokenBalance?: number | null;
810
+ createdAt?: string | null;
811
+ role?: TenantMemberRole;
812
+ }
813
+ /** 租户成员行(GET /:id/members;owner/admin 可见 inviteToken) */
814
+ export interface TenantMemberInfo {
815
+ id: string;
816
+ tenantId: string;
817
+ accountId: string | null;
818
+ role: TenantMemberRole;
819
+ status: TenantMemberStatus;
820
+ email: string | null;
821
+ username?: string | null;
822
+ wallet?: string | null;
823
+ /** 仅 owner/admin 可见;受邀未接受行存在 */
824
+ inviteToken?: string | null;
825
+ joinedAt?: string | null;
826
+ }
827
+ /** 邀请意图记录(POST /:id/invites 响应) */
828
+ export interface TenantInvite {
829
+ id: string;
830
+ tenantId: string;
831
+ email: string;
832
+ role: TenantMemberRole;
833
+ status: TenantMemberStatus;
834
+ inviteToken: string;
835
+ }
836
+ /** 公开邀请查询(GET /invites/:token) */
837
+ export interface PublicInviteInfo {
838
+ tenant: {
839
+ id: string;
840
+ name: string;
841
+ slug: string;
842
+ type: TenantType;
843
+ };
844
+ email: string;
845
+ role: TenantMemberRole;
846
+ status: TenantMemberStatus;
847
+ }
848
+ /** 接受邀请结果(POST /invites/:token/accept;幂等) */
849
+ export interface InviteAcceptResult {
850
+ accepted: boolean;
851
+ tenantId?: string;
852
+ role?: TenantMemberRole;
853
+ /** 该邀请此前已被处理(重复接受/已是成员) */
854
+ alreadyProcessed?: boolean;
855
+ alreadyMember?: boolean;
856
+ }
857
+ /** 改派成员角色结果(PUT /:id/members/:accountId) */
858
+ export interface MemberRoleUpdateResult {
859
+ id: string;
860
+ accountId: string;
861
+ role: TenantMemberRole;
862
+ status: TenantMemberStatus;
863
+ }
864
+ /** owner 转让结果(POST /:id/transfer-owner) */
865
+ export interface TransferOwnerResult {
866
+ ok: boolean;
867
+ newOwner: string;
868
+ }
869
+ /** 社媒团队成员行(GET /api/team/members item;id = TenantMember.id 行 id) */
870
+ export interface TeamMemberItem {
871
+ id: string;
872
+ tenantId: string;
873
+ /** 受邀未接受时 null(accountId 可空,不预建占位账户) */
874
+ userId: string | null;
875
+ role: TenantMemberRole;
876
+ status: TenantMemberStatus;
877
+ email: string | null;
878
+ name?: string | null;
879
+ username?: string | null;
880
+ avatarUrl?: string | null;
881
+ joinedAt?: string | null;
882
+ }
883
+ /** 社媒团队邀请结果(POST /api/team/invite) */
884
+ export interface TeamInviteResult {
885
+ invited: boolean;
886
+ id: string;
887
+ email: string;
888
+ role: TenantMemberRole;
889
+ inviteToken: string;
890
+ }
891
+ /** 存活探活(GET /api/health 匿名 200) */
892
+ export interface HealthInfo {
893
+ status: string;
894
+ service?: string;
895
+ version?: string;
896
+ uptime?: number;
897
+ [key: string]: unknown;
898
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@reachv2/sdk",
3
- "version": "0.1.0",
4
- "description": "Reach unified REST API client library for TypeScript — crm 域(AgentApi/Project/Bot/Knowledge/Channel/Conversation/Transaction/Auth/Chat/ApiKey/LightRAG/Orchestration/ScheduledTasks/Internal/Abis/Admin)+ social 域(Content/Tts/Accounts)+ 统一 DashboardApi(crm/social 看板)",
3
+ "version": "0.3.0",
4
+ "description": "Reach unified REST API client library for TypeScript — crm 域(AgentApi/Project/Bot/Knowledge/Channel/Conversation/Transaction/Auth/Chat/ApiKey/LightRAG/Orchestration/ScheduledTasks/Internal/Abis/Admin)+ social 域(Content/Tts/Accounts/Effect 效果追踪/SeoGeo SEO-GEO 矩阵/ContentRules 内容规则引擎/DataSources 数据源)+ 统一 DashboardApi(crm/social 看板)+ 统一租户成员模型(Tenants/Team/Health,G-1~G-3)",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",