@tbox.cn/app-module-member 0.9.5 → 0.9.7

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/AGENTS.md CHANGED
@@ -1,16 +1,14 @@
1
1
  # module-member —— 集成指引(AI 助手用)
2
2
 
3
- 本模块为商圈业务模块,声明消费以下服务槽(Port 接口定义见 `src/server/ports/`):
4
-
5
- - 服务槽清单:见 `tbox.module.json` 的 `contributes.services`(demand 侧,含 title/description meta)。
3
+ 本模块为商圈业务模块(会员:会员注册、卡面与权益查询)。服务槽、接口清单、接入依赖与可选降级见本包
4
+ `INTEGRATION.md`(真源);结构事实(槽位/必选性)见本包 `tbox.module.json`。
6
5
 
7
6
  ## 自定义 API 对接(AI 集成)
8
7
 
9
- 用户为本模块服务槽配置「自定义 API」后,adapter 实施落点 = `packages/provider-custom/`
10
- (会员:会员注册、卡面与权益查询)。实施步骤与完成判据见 `packages/provider-custom/AGENTS.md`;
11
- 本模块 Port 接口为 adapter 的实现契约(输入 `ServiceAdapterInput`:config/instanceId/credentialRef)。
8
+ 见本包 `INTEGRATION.md`(接入语义真源);实施落点与流程见应用根 `INTEGRATION.md`
9
+ 与 `packages/provider-custom/INTEGRATION.md`。
12
10
 
13
11
  ## 真实厂商接入
14
12
 
15
- 官方 provider 包形态(manifest 槽声明 + 独立包发布)参照 `modules/provider-mock`(极简形态)/ `modules/provider-mocktest`(带 configSchema 形态)结构样例与
16
- docs/reference/providers.md;厂商中立措辞纪律见该参考(本文件受 vendor-neutrality 门禁扫描)。
13
+ 见本包 `INTEGRATION.md`;官方 provider 包形态用 `tbox-app new provider <name>` 骨架
14
+ (应用态 `packages/provider-<id>` local 形态 / 仓库态 `modules/provider-<id>` 发布形态)。
package/INTEGRATION.md ADDED
@@ -0,0 +1,21 @@
1
+ # INTEGRATION —— module-member(会员积分)接入指引
2
+
3
+ > 结构事实以本包 `tbox.module.json` 为准(`declare.consumes`:槽位与必选性、`declare.owns`:
4
+ > 服务归属);接口签名以消费的契约包 Port 为准(`packages/contracts-mall/src/services/`);本文件只写二者推不出的接入语义。
5
+
6
+ ## 服务与依赖
7
+
8
+ - **五槽全必选**(consumes `optional:false`):member.account / member.profile / member.card /
9
+ member.benefits / member.enrollment——自定义 API 接入须逐一落声明并实现;`member.snapshot`
10
+ 聚合槽由底层槽派生,落声明时跳过。
11
+ - **身份键**:各 Port 方法入参 `userId` 由平台传入(登录态身份)——你的后端需能以该标识
12
+ 定位会员;若后端会员体系与平台 userId 无映射,需在接入时约定映射方案。
13
+ - **接入顺序**:入会链(member.enrollment 两步授权)依赖平台登录态先行(登录换码由
14
+ mall-core 承接——见 `packages/module-mall-core/INTEGRATION.md`);账户/卡面/权益/积分
15
+ 四读槽相互独立可并行实施。
16
+ - **可选能力**:`MemberEnrollmentPort.getEnrollmentFormDefinition?` 可选——后端无表单端点
17
+ 可不实现,调用方降级(入会走固定授权流,不出动态表单)。
18
+ - **幂等**:入会 `enroll` 由模块生成幂等键(`sha256(userId\0mallId\0formVersion)`)——
19
+ 同键重入应返回首果。
20
+ - **验收注意**:本模块无 InMemory 兜底(fail-visible)——绑定后未实施 adapter,工具调用
21
+ 报 `PROVIDER_NOT_IMPLEMENTED`,消失即接入完成。
@@ -867,7 +867,7 @@ function createQueryMemberInfoTool(ports) {
867
867
  const infoCard = {
868
868
  cardType: "member-info",
869
869
  data: facts,
870
- // note 契约(W7):账户态中文化 + 姓名要点
870
+ // note 契约:账户态中文化 + 姓名要点
871
871
  note: `\u4F1A\u5458\u8D26\u6237\uFF08${memberStateLabel(facts.state)}\uFF09${facts.displayName ? ` \xB7 ${facts.displayName}` : ""}`
872
872
  };
873
873
  if (account.state !== "active") {
@@ -1080,7 +1080,7 @@ function createMemberHandler(ctx) {
1080
1080
  return {
1081
1081
  id: "member",
1082
1082
  // match:'exact':偏好按钮发出的是固定整句值(member-card-summary 按钮组),
1083
- // 整句全等命中——不入 BM25 词袋(相似查询「2楼有啥美食可逛」曾被词袋误吞,F3)
1083
+ // 整句全等命中——不入 BM25 词袋(相似查询「2楼有啥美食可逛」曾被词袋误吞)
1084
1084
  intents: [{ patterns: [...MEMBER_PREFERENCE_VALUES], match: "exact" }],
1085
1085
  handle: async (action, payload, _ctx, reqCtx) => {
1086
1086
  if (action === "intent") {
@@ -1426,7 +1426,7 @@ function createMemberActions(ctx, resolveMember) {
1426
1426
  };
1427
1427
  }
1428
1428
  },
1429
- /** 4. 入会状态显式刷新(R4:无自动轮询) */
1429
+ /** 4. 入会状态显式刷新(无自动轮询) */
1430
1430
  queryEnrollmentStatus: {
1431
1431
  actionId: "member.query-enrollment-status",
1432
1432
  moduleId: "member",
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  resolveMemberEnrollmentPort,
8
8
  resolveMemberProfilePort,
9
9
  serverModule
10
- } from "./chunk-VU73BWYZ.js";
10
+ } from "./chunk-KLQHDDSD.js";
11
11
  import {
12
12
  clientModule
13
13
  } from "./chunk-GMHJMLRV.js";
@@ -6,13 +6,13 @@ import { ServerContext } from '@tbox.cn/app-agent-sdk-server';
6
6
  import { MemberAccountPort, MemberProfilePort, MemberCardPort, MemberBenefitsPort, MemberEnrollmentPort, MemberAccountSnapshot, MemberProfileSnapshot, MemberCardSnapshot, Points, MemberBenefitsSnapshot, MemberEnrollmentFormDefinition, PointUsageRecord, DiscountRule, MemberEnrollmentInput, MemberEnrollmentResult, MemberEnrollmentStatus } from '@tbox.cn/app-contracts-mall';
7
7
 
8
8
  /**
9
- * MemberService:商圈会员完整实现(011 K2 六 Port + 015 入会升级)。
9
+ * MemberService:商圈会员完整实现(六 Port + 015 入会升级)。
10
10
  * extends 契约 Port(保证满足消费方子集约束);完整接口只在本模块包内。
11
11
  */
12
12
  /**
13
13
  * InMemory 演示实现(仅供隔离单测;运行时注册与 Provider 解析不得使用)。
14
14
  * 017 槽位原子化后非 Port 成员归位:getEnrollmentFormDefinition 已收编
15
- * MemberEnrollmentPort optional 方法(R13);enrollUrl/loginUrl 为槽产物自由属性
15
+ * MemberEnrollmentPort optional 方法;enrollUrl/loginUrl 为槽产物自由属性
16
16
  * (enrollment/account 槽的类型视图见 ports.ts);audit 转 InMemory 私有观测成员。
17
17
  */
18
18
  interface MemberService extends MemberAccountPort, MemberProfilePort, MemberCardPort, MemberBenefitsPort, MemberEnrollmentPort {
@@ -7,7 +7,7 @@ import {
7
7
  resolveMemberEnrollmentPort,
8
8
  resolveMemberProfilePort,
9
9
  serverModule
10
- } from "../chunk-VU73BWYZ.js";
10
+ } from "../chunk-KLQHDDSD.js";
11
11
  export {
12
12
  InMemoryMemberService,
13
13
  memberCards,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tbox.cn/app-module-member",
3
- "version": "0.9.5",
3
+ "version": "0.9.7",
4
4
  "type": "module",
5
5
  "description": "商圈会员模块:会员账户、会员卡、积分流水与入会流程(codegen 源)。",
6
6
  "exports": {
@@ -19,9 +19,9 @@
19
19
  },
20
20
  "dependencies": {
21
21
  "@tbox.cn/app-contracts": "0.12.3",
22
- "@tbox.cn/app-contracts-mall": "0.12.3",
23
- "@tbox.cn/app-agent-sdk-client": "0.1.3",
24
- "@tbox.cn/app-agent-sdk-server": "0.1.4"
22
+ "@tbox.cn/app-contracts-mall": "0.12.4",
23
+ "@tbox.cn/app-agent-sdk-client": "0.1.4",
24
+ "@tbox.cn/app-agent-sdk-server": "0.2.1"
25
25
  },
26
26
  "peerDependencies": {
27
27
  "zod": "3.25.76",
@@ -50,7 +50,8 @@
50
50
  "README.md",
51
51
  "LICENSE",
52
52
  "skills",
53
- "AGENTS.md"
53
+ "AGENTS.md",
54
+ "INTEGRATION.md"
54
55
  ],
55
56
  "engines": {
56
57
  "node": ">=20.0.0"
@@ -56,7 +56,9 @@ routingTerms:
56
56
 
57
57
  调 `queryPoints` 并将用户原始问题传入 `query` 参数。只引用 `member-card-summary` 一张卡;积分流水不构造卡片,只作为工具返回的文本事实供 LLM 消费。积分来源只能引用流水中返回的标题与描述字段,**禁止推断或声称任何未从工具返回的奖励机制**(如"消费满额自动返积分")——顾客会按你说的规则去消费。
58
58
 
59
- - **会员卡面已展示时**:不要再说“如果想看看会员卡面”;如需引导详细流水,只提示「详细积分流水请点击会员卡面上的“我的积分”」。
59
+ - **会员卡面已展示时**:不要再说“如果想看看会员卡面”。引导详细流水**只以 `pointsUrl` 为条件**——卡面有没有“我的积分”入口由它决定:
60
+ - 工具结果含 `pointsUrl` → 只提示「详细积分流水请点击会员卡面上的“我的积分”」;
61
+ - `pointsUrl` 缺席 → 卡面没有“我的积分”入口,**不得指涉该入口**,改为转述已返回的流水 `items`,无 `items` 时如实说「暂无流水记录」。
60
62
 
61
63
  - **积分是用户具体事实,禁止无工具直答**:每轮必须重新调 `queryPoints` 拿当轮实时余额与流水——不得引用历史轮余额/流水,或凭对话记忆作答(历史轮流水可能已变化;未调工具时给出的任何流水细节一律视为编造)
62
64
  - ❌ 反例:用户问「积分」,未调任何工具就回答"最近一笔是餐饮消费积攒的"——流水凭空出现,属于编造;真实情况可能是"暂无流水记录",应如实转述
@@ -80,7 +82,7 @@ routingTerms:
80
82
  当用户询问会员卡、会员中心或会员卡及积分情况时,拿到 `member-card-summary` 后按以下顺序组织回答:
81
83
 
82
84
  1. 先概括会员卡面整体能力:卡名/状态、当前积分、消费进度或其他实际返回的卡面信息。
83
- 2. 积分部分说明:当前余额来自实时查询;需要逐笔明细时,点击会员卡面上的“我的积分”进入积分流水页。
85
+ 2. 积分部分说明:当前余额来自实时查询;工具结果含 `pointsUrl` 时,可引导逐笔明细点击会员卡面上的“我的积分”进入积分流水页;`pointsUrl` 缺席时卡面无此入口,改为转述流水 `items`(或说明暂无),不得引导点击不存在的入口。
84
86
  3. 积分规则只介绍卡面返回的 `pointsRuleContent` 或规则图片,不根据卡名、等级或余额推断规则。
85
87
  4. 会员权益只适度介绍卡面实际返回的 `benefits`,优先说权益名称和摘要;没有返回就明确说明暂未提供,不补充承诺。
86
88
  5. 卡面包含 `preferencePrompts` 时,可在结尾自然推荐偏好服务,例如询问用户更关注餐饮、购物或亲子,并引导其选择对应偏好;不得强推或替用户保存偏好。
@@ -130,7 +132,7 @@ routingTerms:
130
132
  - **数据必须来自工具**:余额、卡名、标签、等级、权益一律从工具结果读取,禁止编造——**积分流水细节(来源、最近一笔、攒分规则叙事)同样如此:无当轮工具返回,禁止给出任何流水叙事**,如实说"暂无流水记录"或实际调用工具后再转述
131
133
  - **身份只认会话**:任何用户输入的手机号、会员卡号或账号都不能覆盖当前登录身份;涉及修改资料、代查他人或切换账号时按隐私边界直接拒答
132
134
  - **会员卡面优先**:会员积分查询只出 `member-card-summary`;积分流水仅进入文本事实,不出 `member-point-usage-list`;未入会出 `member-enrollment-cta`(普通开卡问询)
133
- - **已出卡的后续引导**:会员卡面已经展示时,不重复邀请查看卡面;详细积分流水通过卡面上的“我的积分”入口查看。
135
+ - **已出卡的后续引导**:会员卡面已经展示时,不重复邀请查看卡面;详细积分流水只有在工具结果含 `pointsUrl` 时才通过卡面上的“我的积分”入口查看,缺席时不引导点击该入口。
134
136
  - **卡片必须引用**:工具返回含 `cards` 字段时,正文末尾必须按平台协议引用对应卡片 id——不引用用户就看不到卡
135
137
  - **不代写不代勾**:入会表单与授权动作全部由用户在卡片/小程序内完成
136
138
 
@@ -5,7 +5,7 @@
5
5
  - queryPoints 统一作为积分业务工具调用;把原始问题传入 `query`。只投影 `member-card-summary`,不构造积分流水卡,也不再额外调用 queryMemberCard。
6
6
  - 工具返回的 `balance` 是当前积分余额(点数);`items` 是接口解码后的流水事实:`title` 为业务说明(优先取厂商 `message`),`amount` 为本笔积分变动(正数增加、负数扣减),`usedAt` 为发生时间,`description` 为可选门店名称(优先取厂商 `storeName`);`total` 为流水总数。回答只能引用这些字段,不自行换算或估算。
7
7
  - 「积分怎么来的」:只引用流水的标题和描述,不得从其他业务流程推断积分奖励规则。
8
- - 会员卡面已经展示时,不要重复邀请用户“再看看会员卡面”;需要查看详细积分流水时,提示点击会员卡面上的“我的积分”。
8
+ - 会员卡面已经展示时,不要重复邀请用户“再看看会员卡面”。引导详细流水以 `pointsUrl` 为条件:工具结果含 `pointsUrl` 说明卡面有“我的积分”入口,提示点击它;`pointsUrl` 缺席的卡面(如 mock 档)没有该入口,不得引导用户点击,改为转述已返回的流水 `items` 或如实说明暂无流水。
9
9
  - 会员卡相关回答建议按“整体卡面能力 → 当前积分 → 积分规则 → 已返回的会员权益 → 偏好服务推荐”组织;规则和权益只能引用卡面真实返回内容,偏好推荐应自然询问用户关注方向,不代替用户保存。
10
10
 
11
11
  ## 会员卡与账户(queryMemberCard / queryMemberInfo)
@@ -1,5 +1,5 @@
1
1
  /**
2
- * module-member 客户端卡片聚合(0.4.0 D6:一卡一目录;券面 0.4.0 净删——promotion 承接)。
2
+ * module-member 客户端卡片聚合(0.4.0 一卡一目录;券面 0.4.0 净删——promotion 承接)。
3
3
  */
4
4
  export { default as MemberInfoCard } from './member-info';
5
5
  export { default as MemberCardSummaryCard } from './member-card-summary';
@@ -1,5 +1,5 @@
1
1
  /**
2
- * member-enrollment-form 富卡(0.4.0 D6/D10):受控表单 + select 渲染 + readOnly 预填锁定
2
+ * member-enrollment-form 富卡(0.4.0/):受控表单 + select 渲染 + readOnly 预填锁定
3
3
  * + 用户显式授权(无 mount 副作用)+ 客户端必填/必选校验。
4
4
  * payload 形状与 server inputSchema 一致(fieldValues Record / acceptedConsentIds / formVersion)。
5
5
  */
@@ -177,5 +177,5 @@ export function MemberEnrollmentFormCard(props: {
177
177
  );
178
178
  }
179
179
 
180
- // 0.4.0 D10 评审补位:提交/授权按钮全在卡内(依赖表单/授权上下文),自持动作跳过 SDK 默认按钮条
180
+ // 0.4.0 评审补位:提交/授权按钮全在卡内(依赖表单/授权上下文),自持动作跳过 SDK 默认按钮条
181
181
  export default markSelfRendering(MemberEnrollmentFormCard);
@@ -1,5 +1,5 @@
1
1
  /**
2
- * member-enrollment-status 富卡(0.4.0 D6/D10):四态变体 + pending 刷新。
2
+ * member-enrollment-status 富卡(0.4.0/):四态变体 + pending 刷新。
3
3
  */
4
4
  import { useRef, useState } from 'react';
5
5
  import { ArrowClockwise, CheckCircle, Clock, WarningCircle } from '@phosphor-icons/react';
@@ -61,5 +61,5 @@ export function MemberEnrollmentStatusCard(props: {
61
61
  );
62
62
  }
63
63
 
64
- // 0.4.0 D10 评审补位:卡内"刷新状态"按钮(attemptRef 依赖卡数据)自持动作,跳过 SDK 默认按钮条
64
+ // 0.4.0 评审补位:卡内"刷新状态"按钮(attemptRef 依赖卡数据)自持动作,跳过 SDK 默认按钮条
65
65
  export default markSelfRendering(MemberEnrollmentStatusCard);
@@ -1,5 +1,5 @@
1
1
  /**
2
- * member 展示纯函数(0.4.0 D6:状态文案/金额色/图标映射,可单测;券面函数 0.4.0 净删——promotion 承接)。
2
+ * member 展示纯函数(0.4.0 状态文案/金额色/图标映射,可单测;券面函数 0.4.0 净删——promotion 承接)。
3
3
  */
4
4
  /** 积分流水金额类:负支出 → 红(--tbox-primary),正收入 → 绿(--tbox-success) */
5
5
  export function pointAmountClass(amount: string): 'member-pu__amount--spend' | 'member-pu__amount--income' {
@@ -1,5 +1,5 @@
1
1
  /**
2
- * 图片 + 加载失败占位(0.4.0 D6:模块自持 ~20 行,禁跨模块依赖/基元封顶不破)。
2
+ * 图片 + 加载失败占位(0.4.0 模块自持 ~20 行,禁跨模块依赖/基元封顶不破)。
3
3
  * 源:POC shopping-guide 占位语义。src 缺省或加载失败 → 图标占位。
4
4
  */
5
5
  import { useEffect, useState } from 'react';
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * module-member 客户端入口(与服务端 serverModule 对称)。
3
3
  */
4
- import './styles/member.css'; // 0.4.0 D1:模块自持 CSS(副作用 import,首行保证先行加载)
4
+ import './styles/member.css'; // 0.4.0 模块自持 CSS(副作用 import,首行保证先行加载)
5
5
 
6
6
  import type { CardComponent } from '@tbox.cn/app-contracts';
7
7
  import type { ClientContext, ClientModule } from '@tbox.cn/app-agent-sdk-client';
@@ -1,2 +1,2 @@
1
- /** 0.4.0 D1:模块自持 CSS(经 tsup loader: { '.css': 'copy' } 出货,样式在应用侧生效) */
1
+ /** 0.4.0 模块自持 CSS(经 tsup loader: { '.css': 'copy' } 出货,样式在应用侧生效) */
2
2
  declare module '*.css';
@@ -1,13 +1,13 @@
1
1
  /**
2
- * member 写动作(015 S4:入会协议首验切片)。
2
+ * member 写动作(入会协议首验切片)。
3
3
  *
4
4
  * 四动作(全 singleUse + grant 闭环;cards key = meta.cardType):
5
5
  * - member.request-alipay-authorization:返回授权 effect(dispatcher 补签 → client getAuthCode)
6
6
  * - member.complete-alipay-authorization:回调动作——消费 SDK createAlipayUserAuthorization
7
- * (011 J7 下沉物首个消费方),PII 经 ctx.state TTL 30min 最小集暂存(F2)
7
+ * 入会授权 PII 暂存(下沉物首个消费方):PII 经 ctx.state TTL 30min 最小集暂存
8
8
  * - member.enroll:身份解析(授权 profile 可信 mobile 强制覆盖 / manual 正则)+ consent 校验
9
- * + 幂等键 sha256(userId\0mallId\0formVersion)(W3:模块顶层 InMemoryIdempotencyStore)
10
- * - member.query-enrollment-status:显式刷新(R4:POC 自动轮询不迁)
9
+ * + 幂等键 sha256(userId\0mallId\0formVersion)(模块顶层 InMemoryIdempotencyStore)
10
+ * - member.query-enrollment-status:显式刷新(POC 自动轮询不迁)
11
11
  */
12
12
  import { createHash } from 'node:crypto';
13
13
  import type { ServerContext } from '@tbox.cn/app-agent-sdk-server';
@@ -16,13 +16,13 @@ import { parseMallScope } from '@tbox.cn/app-contracts-mall';
16
16
  import type { CardActionResult, RequestContext } from '@tbox.cn/app-contracts';
17
17
  import { z } from 'zod';
18
18
 
19
- /** PII 暂存命名空间(F2:TTL 30min + 最小字段 + enroll 成功即 consume 删除) */
19
+ /** PII 暂存命名空间(TTL 30min + 最小字段 + enroll 成功即 consume 删除) */
20
20
  export const MEMBER_PROFILE_NAMESPACE = 'member.enrollment.profile';
21
21
  const PROFILE_TTL_MS = 30 * 60 * 1000;
22
22
 
23
23
  const MOBILE_PATTERN = /^1[3-9]\d{9}$/;
24
24
 
25
- /** 授权 profile 最小集(F2:不落完整厂商响应) */
25
+ /** 授权 profile 最小集(不落完整厂商响应) */
26
26
  export interface StoredAuthorizationProfile {
27
27
  readonly mobile?: string;
28
28
  readonly displayName?: string;
@@ -37,7 +37,7 @@ const ENROLLMENT_CONSENTS = [
37
37
  { consentId: 'membership-terms', version: '1', title: '会员服务条款', required: false },
38
38
  ] as const;
39
39
 
40
- /** 模块顶层幂等单例(W3:IdempotencyStore 挂 HTTP gateway 非 ctx,模块自持) */
40
+ /** 模块顶层幂等单例(IdempotencyStore 挂 HTTP gateway 非 ctx,模块自持) */
41
41
  const enrollmentIdempotency = new InMemoryIdempotencyStore();
42
42
 
43
43
  export function buildEnrollmentIdempotencyKey(userId: string, mallId: string, formVersion: string): string {
@@ -145,7 +145,7 @@ export function createMemberActions(
145
145
  text: '授权未完成,已切换手动填写模式',
146
146
  };
147
147
  }
148
- // 011 J7 下沉物首个消费方:authCode → alipay.user.info.share
148
+ // 下沉物首个消费方:authCode → alipay.user.info.share
149
149
  let profile: StoredAuthorizationProfile;
150
150
  try {
151
151
  const authorized = await createAlipayUserAuthorization().authorizeUserProfile(authCode);
@@ -167,7 +167,7 @@ export function createMemberActions(
167
167
  text: '授权资料获取失败,已切换手动填写模式',
168
168
  };
169
169
  }
170
- // F2:PII 最小集 TTL 30min 暂存(enroll 时 consume 取走 = 用后即删)
170
+ // PII 最小集 TTL 30min 暂存(enroll 时 consume 取走 = 用后即删)
171
171
  await state.put(MEMBER_PROFILE_NAMESPACE, userId, profile, PROFILE_TTL_MS);
172
172
  return {
173
173
  card: buildFormCard({
@@ -222,7 +222,7 @@ export function createMemberActions(
222
222
  };
223
223
  }
224
224
 
225
- // 身份解析:授权 profile(consume 取走 = F2 用后即删)可信 mobile 强制覆盖
225
+ // 身份解析:授权 profile(consume 取走 = 用后即删)可信 mobile 强制覆盖
226
226
  const authorized = (await state.consume<StoredAuthorizationProfile>(MEMBER_PROFILE_NAMESPACE, userId)) ?? undefined;
227
227
  const manualMobile = fieldValues.mobile ?? '';
228
228
  const mobile = authorized?.mobile ?? manualMobile;
@@ -234,8 +234,8 @@ export function createMemberActions(
234
234
  };
235
235
  }
236
236
 
237
- // 幂等(W3:同键重入返回首果)
238
- // 评审修复(015 #5):payload 存 sha256 摘要——幂等占位不再驻留明文手机号(F2 单一暂存位语义)
237
+ // 幂等(同键重入返回首果)
238
+ // 评审修复(015 #5):payload 存 sha256 摘要——幂等占位不再驻留明文手机号(单一暂存位语义)
239
239
  const idempotencyKey = buildEnrollmentIdempotencyKey(userId, mallIdOf(reqCtx), ENROLLMENT_FORM_VERSION);
240
240
  const payloadTag = createHash('sha256').update(`${identity}:${mobile}`).digest('hex').slice(0, 16);
241
241
  const acquired = await enrollmentIdempotency.tryAcquire(idempotencyKey, payloadTag);
@@ -294,7 +294,7 @@ export function createMemberActions(
294
294
  },
295
295
  },
296
296
 
297
- /** 4. 入会状态显式刷新(R4:无自动轮询) */
297
+ /** 4. 入会状态显式刷新(无自动轮询) */
298
298
  queryEnrollmentStatus: {
299
299
  actionId: 'member.query-enrollment-status',
300
300
  moduleId: 'member',
@@ -307,7 +307,7 @@ export function createMemberActions(
307
307
  const userId = reqCtx?.identity?.userId ?? '';
308
308
  const member = await resolveMember(reqCtx);
309
309
  if (!userId || !attemptRef || !member) {
310
- // P0 原地更新:防御分支返回可见失败态(原 text 在 update 路径无消费者)
310
+ // 原地更新:防御分支返回可见失败态(原 text 在 update 路径无消费者)
311
311
  return {
312
312
  update: {
313
313
  data: {
@@ -1,9 +1,9 @@
1
1
  /**
2
- * member handler(011 K2;015:写动作拆至 action.ts,此处只保留意图路径出卡)。
2
+ * member handler;015:写动作拆至 action.ts,此处只保留意图路径出卡)。
3
3
  * - 查积分/信息/卡 → 出对应卡(LLM 路径走同名工具)。
4
4
  * - 会员偏好长期记忆(017 PRD):三项声明式 intent → ctx.memory 保存 + continueWith 续接导购。
5
5
  * - 上下文统一化:userId 来源 = 运行身份(reqCtx.identity.userId,handler 第四参)——
6
- * 旧 payload.userId 是模型注入面(P4-3),已删除;偏好分支同经 reqCtx 显式读取。
6
+ * 旧 payload.userId 是模型注入面,已删除;偏好分支同经 reqCtx 显式读取。
7
7
  */
8
8
  import type { HandlerDefinition, ServerContext } from '@tbox.cn/app-agent-sdk-server';
9
9
  import {
@@ -33,7 +33,7 @@ export function createMemberHandler(ctx: ServerContext): HandlerDefinition {
33
33
  return {
34
34
  id: 'member',
35
35
  // match:'exact':偏好按钮发出的是固定整句值(member-card-summary 按钮组),
36
- // 整句全等命中——不入 BM25 词袋(相似查询「2楼有啥美食可逛」曾被词袋误吞,F3)
36
+ // 整句全等命中——不入 BM25 词袋(相似查询「2楼有啥美食可逛」曾被词袋误吞)
37
37
  intents: [{ patterns: [...MEMBER_PREFERENCE_VALUES], match: 'exact' }],
38
38
  handle: async (action, payload, _ctx, reqCtx) => {
39
39
  if (action === 'intent') {
@@ -1,3 +1,10 @@
1
+ /**
2
+ * module-member 服务端入口(双端自注册闭环——见模块 AGENTS.md 与 INTEGRATION.md)。
3
+ * 职责:会员账户/资料/卡面/权益积分/入会五槽解析 + 查询工具四枚 + 门禁卡与入会表单卡六枚 +
4
+ * 会员门禁状态服务('member.status')与跨模块快览工厂('member.snapshot')。
5
+ * 入口约定:register 只注册不解析(resolveService 仅 handle/事件回调内);cards map 的
6
+ * key = meta.cardType;模块对象 satisfies ServerModule(禁类型标注——cards 泛化失效)。
7
+ */
1
8
  import type { ServerContext, ServerModule } from '@tbox.cn/app-agent-sdk-server';
2
9
  import { loadModuleSkills, withCardEmissionHint, withEarlyExecution } from '@tbox.cn/app-agent-sdk-server';
3
10
  import type { RequestContext } from '@tbox.cn/app-contracts';
@@ -57,7 +64,7 @@ const memberPorts = {
57
64
  };
58
65
 
59
66
  /** 工具实例顶层创建;每次 execute 解析当前请求的真实 C 端 Provider。
60
- * W2(2026-09-01):出卡工具创建点单点 wrap(description 追加预告知句)——
67
+ * (2026-09-01):出卡工具创建点单点 wrap(description 追加预告知句)——
61
68
  * 注册即 wrapped 实例;CTA/表单卡承载操作入口带 actions 句。
62
69
  * PR-2:三个纯查询工具(只读/幂等/execCtx 仅消费 requestContext)标注尽早执行
63
70
  * 白名单——env TBOX_EARLY_TOOL_EXECUTION=1 时参数流完即预执行;缺省 off 零行为。 */
@@ -145,16 +152,16 @@ export const serverModule = {
145
152
  ctx.cards.registerMap(cards);
146
153
  ctx.handlers.register(createMemberHandler(ctx));
147
154
 
148
- // 015 S4:入会四动作(register 闭包 ctx——动作 execute 内经 enrollment 槽解析 + ctx.state PII 暂存)
155
+ // 入会四动作(register 闭包 ctx——动作 execute 内经 enrollment 槽解析 + ctx.state PII 暂存)
149
156
  const actions = createMemberActions(ctx, (reqCtx) => resolveMemberEnrollmentPort(reqCtx, ctx));
150
157
  for (const action of Object.values(actions)) {
151
158
  ctx.cardActions.register(action);
152
159
  }
153
160
 
154
- // 015 D9:主体绑定(promotion acquire 消费;ctx.services 跨模块 resolveService)
161
+ // 主体绑定(promotion acquire 消费;ctx.services 跨模块 resolveService)
155
162
  ctx.services.register('member.subject-binding', createSubjectBinding(ctx));
156
163
 
157
- // 会员快览工厂(member.snapshot,W3-3):首页联单面板跨模块消费面
164
+ // 会员快览工厂(member.snapshot):首页联单面板跨模块消费面
158
165
  // (账户/授权三态 + 积分 + 入会引导)。三槽组装——enrollment 槽 fail-soft
159
166
  // (缺席不拖垮账户/积分主面);工厂运行期执行(注册期纯净铁律)。
160
167
  ctx.services.register(
@@ -20,13 +20,13 @@ import type {
20
20
  } from '@tbox.cn/app-contracts-mall';
21
21
 
22
22
  /**
23
- * MemberService:商圈会员完整实现(011 K2 六 Port + 015 入会升级)。
23
+ * MemberService:商圈会员完整实现(六 Port + 015 入会升级)。
24
24
  * extends 契约 Port(保证满足消费方子集约束);完整接口只在本模块包内。
25
25
  */
26
26
  /**
27
27
  * InMemory 演示实现(仅供隔离单测;运行时注册与 Provider 解析不得使用)。
28
28
  * 017 槽位原子化后非 Port 成员归位:getEnrollmentFormDefinition 已收编
29
- * MemberEnrollmentPort optional 方法(R13);enrollUrl/loginUrl 为槽产物自由属性
29
+ * MemberEnrollmentPort optional 方法;enrollUrl/loginUrl 为槽产物自由属性
30
30
  * (enrollment/account 槽的类型视图见 ports.ts);audit 转 InMemory 私有观测成员。
31
31
  */
32
32
  export interface MemberService
@@ -44,7 +44,7 @@ export interface MemberService
44
44
  readonly loginUrl?: string;
45
45
  }
46
46
 
47
- // Form 族归源 TIER1(F5 下沉:provider 出参与模块投影共用同一契约面)
47
+ // Form 族归源 TIER1(下沉:provider 出参与模块投影共用同一契约面)
48
48
  export type {
49
49
  MemberEnrollmentConsentDefinition,
50
50
  MemberEnrollmentFormFieldDefinition,
@@ -196,7 +196,7 @@ export class InMemoryMemberService implements MemberService {
196
196
  // ===== 6. MemberEnrollmentPort(015:授权预填 + 幂等 + pending 收口) =====
197
197
 
198
198
  async enroll(input: MemberEnrollmentInput): Promise<MemberEnrollmentResult> {
199
- // 幂等:同 idempotencyKey 重入返回首果(015 W3 语义,模块顶层 IdempotencyStore 之上的双保险)
199
+ // 幂等:同 idempotencyKey 重入返回首果(语义,模块顶层 IdempotencyStore 之上的双保险)
200
200
  const existing = this.enrollmentAttempts.get(input.idempotencyKey);
201
201
  if (existing) return existing.result;
202
202
 
@@ -276,7 +276,7 @@ export function createQueryMemberInfoTool(
276
276
  const infoCard = {
277
277
  cardType: 'member-info',
278
278
  data: facts,
279
- // note 契约(W7):账户态中文化 + 姓名要点
279
+ // note 契约:账户态中文化 + 姓名要点
280
280
  note: `会员账户(${memberStateLabel(facts.state)})${facts.displayName ? ` · ${facts.displayName}` : ''}`,
281
281
  };
282
282
  if (account.state !== 'active') {
@@ -463,7 +463,7 @@ export function createQueryEnrollmentFormTool(
463
463
  const notEnrolled =
464
464
  account.authState === 'authenticated' &&
465
465
  (account.state === 'not_enrolled' || account.state === 'closed');
466
- // getEnrollmentFormDefinition = Port optional 能力口(R13 收编):无表单端点厂商可缺省,typeof 守卫降级
466
+ // getEnrollmentFormDefinition = Port optional 能力口(收编):无表单端点厂商可缺省,typeof 守卫降级
467
467
  const definition =
468
468
  notEnrolled && typeof enrollmentPort.getEnrollmentFormDefinition === 'function'
469
469
  ? await enrollmentPort.getEnrollmentFormDefinition(userId)
@@ -1,4 +1,4 @@
1
- /** 会员模块工具辅助(011 K2) */
1
+ /** 会员模块工具辅助 */
2
2
  export function nowIso(): string {
3
3
  return new Date().toISOString();
4
4
  }
@@ -51,7 +51,10 @@ describe('K1:member skills 装配', () => {
51
51
  expect(skills.member!.instructions).toContain('泛会员信息或只查会员卡 → 调 `queryMemberCard`');
52
52
  expect(skills.member!.instructions).toContain('明确问积分 → 只调一次 `queryPoints`');
53
53
  expect(skills.member!.instructions).toContain('会员卡面优先');
54
+ // 「点卡面我的积分」引导以 pointsUrl 为条件——无入口的卡面(如 mock 档)不得指涉该入口
55
+ expect(skills.member!.instructions).toContain('引导详细流水**只以 `pointsUrl` 为条件**');
54
56
  expect(skills.member!.instructions).toContain('详细积分流水请点击会员卡面上的“我的积分”');
57
+ expect(skills.member!.instructions).toContain('不得指涉该入口');
55
58
  expect(skills.member!.instructions).toContain('会员卡面回答结构');
56
59
  expect(skills.member!.instructions).toContain('自然推荐偏好服务');
57
60
  });