@tbox.cn/app-module-alipay-activity 0.2.4 → 0.3.1
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 +1 -1
- package/dist/{chunk-RM7IUA3M.js → chunk-RLGO2HTZ.js} +3 -3
- package/dist/client/index.d.ts +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -1
- package/dist/server/index.d.ts +26 -25
- package/dist/server/index.js +1 -1
- package/package.json +6 -5
- package/schemas/credentials/alipay-open-v1.json +2 -2
- package/src/client/index.ts +1 -1
- package/src/server/handler.ts +1 -1
- package/src/server/index.ts +2 -2
- package/src/server/integrations/alipay/client.ts +1 -1
- package/src/server/ports.ts +2 -2
- package/src/server/tools.ts +2 -2
- package/tbox.module.json +19 -14
- package/tests/intent-routing.test.ts +3 -3
- package/tests/ports.test.ts +1 -1
- package/tests/pretool-routing.test.ts +1 -1
- package/tests/samples.test.ts +1 -1
- package/tests/tools.test.ts +4 -4
- package/tsup.config.ts +2 -1
package/AGENTS.md
CHANGED
|
@@ -12,5 +12,5 @@
|
|
|
12
12
|
|
|
13
13
|
## 真实厂商接入
|
|
14
14
|
|
|
15
|
-
官方 provider 包形态(manifest 槽声明 + 独立包发布)参照 `modules/provider-mock`
|
|
15
|
+
官方 provider 包形态(manifest 槽声明 + 独立包发布)参照 `modules/provider-mock`(极简形态)/ `modules/provider-mocktest`(带 configSchema 形态)结构样例与
|
|
16
16
|
docs/reference/providers.md;厂商中立措辞纪律见该参考(本文件受 vendor-neutrality 门禁扫描)。
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/server/index.ts
|
|
2
|
-
import { definePreTool, loadModuleSkills } from "@tbox.cn/app-sdk
|
|
2
|
+
import { definePreTool, loadModuleSkills } from "@tbox.cn/app-agent-sdk-server";
|
|
3
3
|
|
|
4
4
|
// src/server/cards/bumpin-activity/meta.ts
|
|
5
5
|
import {
|
|
@@ -190,12 +190,12 @@ var meta_default = meta;
|
|
|
190
190
|
|
|
191
191
|
// src/server/tools.ts
|
|
192
192
|
import { z } from "zod";
|
|
193
|
-
import { createTool, withCardEmissionHint, requireToolRequestContext } from "@tbox.cn/app-sdk
|
|
193
|
+
import { createTool, withCardEmissionHint, requireToolRequestContext } from "@tbox.cn/app-agent-sdk-server";
|
|
194
194
|
import { memberGateCardOf, toMallQueryContext } from "@tbox.cn/app-contracts-mall";
|
|
195
195
|
|
|
196
196
|
// src/server/ports.ts
|
|
197
197
|
import { existsSync as existsSync2, readFileSync as readFileSync2 } from "fs";
|
|
198
|
-
import { expandEnvVars } from "@tbox.cn/app-sdk
|
|
198
|
+
import { expandEnvVars } from "@tbox.cn/app-agent-sdk-server";
|
|
199
199
|
|
|
200
200
|
// src/server/integrations/alipay/adapter.ts
|
|
201
201
|
var ACT_STATUS_VALUES = /* @__PURE__ */ new Set(["NOT_START", "INIT", "PROCESSING", "FINISH", "RECEIVED"]);
|
package/dist/client/index.d.ts
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { AlipayActivityBumpInCardData, AlipayBumpInFileConfig, AlipayBumpInService, alipayBumpInAuthStrategy, bumpInActivityMeta, configureAlipayBumpIn, createAlipayActivityHandler, createBumpInTools, parseAlipayRichText, readAlipayBumpInConfig, resolveAlipayBumpInService, default as serverModule, toBumpInCardData } from './server/index.js';
|
|
2
|
+
import '@tbox.cn/app-agent-sdk-server';
|
|
2
3
|
import '@mastra/core/tools';
|
|
3
|
-
import '@tbox.cn/app-sdk
|
|
4
|
+
import '@tbox.cn/app-sdk-server';
|
|
4
5
|
import '@tbox.cn/app-contracts';
|
|
5
6
|
import 'zod';
|
|
6
7
|
import 'alipay-sdk';
|
package/dist/index.js
CHANGED
package/dist/server/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import * as _tbox_cn_app_agent_sdk_server from '@tbox.cn/app-agent-sdk-server';
|
|
2
|
+
import { ServerContext, HandlerDefinition, ProviderAuthStrategy, PreToolDef } from '@tbox.cn/app-agent-sdk-server';
|
|
1
3
|
import * as _mastra_core_tools from '@mastra/core/tools';
|
|
2
|
-
import * as _tbox_cn_app_sdk_server from '@tbox.cn/app-sdk
|
|
3
|
-
import { ServerContext, HandlerDefinition, ProviderAuthStrategy, PreToolDef } from '@tbox.cn/app-sdk/server';
|
|
4
|
+
import * as _tbox_cn_app_sdk_server from '@tbox.cn/app-sdk-server';
|
|
4
5
|
import * as _tbox_cn_app_contracts from '@tbox.cn/app-contracts';
|
|
5
6
|
import { CardMeta } from '@tbox.cn/app-contracts';
|
|
6
7
|
import * as zod from 'zod';
|
|
@@ -58,8 +59,8 @@ declare function parseAlipayRichText(text: string | undefined): string;
|
|
|
58
59
|
*/
|
|
59
60
|
declare function toBumpInCardData(detail: PromotionActivityDetail, mode: 'detail' | 'banner', backgroundUrl?: string): PromotionBumpInActivityCardData;
|
|
60
61
|
declare function createBumpInTools(getCtx: () => ServerContext): {
|
|
61
|
-
getBumpInActivity:
|
|
62
|
-
getBumpInActivityBanner:
|
|
62
|
+
getBumpInActivity: _tbox_cn_app_agent_sdk_server.Tool<{}, unknown, unknown, unknown, _mastra_core_tools.ToolExecutionContext<unknown, unknown, unknown>, "getBumpInActivity", unknown>;
|
|
63
|
+
getBumpInActivityBanner: _tbox_cn_app_agent_sdk_server.Tool<{}, unknown, unknown, unknown, _mastra_core_tools.ToolExecutionContext<unknown, unknown, unknown>, "getBumpInActivityBanner", unknown>;
|
|
63
64
|
};
|
|
64
65
|
|
|
65
66
|
/**
|
|
@@ -114,23 +115,23 @@ declare const serverModule: {
|
|
|
114
115
|
merchantLogo: zod.ZodOptional<zod.ZodString>;
|
|
115
116
|
itemLogo: zod.ZodOptional<zod.ZodString>;
|
|
116
117
|
}, "strip", zod.ZodTypeAny, {
|
|
118
|
+
merchantName: string;
|
|
117
119
|
prizeId: string;
|
|
118
120
|
voucherName: string;
|
|
119
121
|
voucherType: string;
|
|
120
122
|
reductionAmount: string;
|
|
121
123
|
thresholdAmountText: string;
|
|
122
124
|
unit: string;
|
|
123
|
-
merchantName: string;
|
|
124
125
|
merchantLogo?: string | undefined;
|
|
125
126
|
itemLogo?: string | undefined;
|
|
126
127
|
}, {
|
|
128
|
+
merchantName: string;
|
|
127
129
|
prizeId: string;
|
|
128
130
|
voucherName: string;
|
|
129
131
|
voucherType: string;
|
|
130
132
|
reductionAmount: string;
|
|
131
133
|
thresholdAmountText: string;
|
|
132
134
|
unit: string;
|
|
133
|
-
merchantName: string;
|
|
134
135
|
merchantLogo?: string | undefined;
|
|
135
136
|
itemLogo?: string | undefined;
|
|
136
137
|
}>, "many">;
|
|
@@ -147,25 +148,29 @@ declare const serverModule: {
|
|
|
147
148
|
description?: string | undefined;
|
|
148
149
|
}>, "many">>;
|
|
149
150
|
}, "strip", zod.ZodTypeAny, {
|
|
150
|
-
activityRef: string;
|
|
151
151
|
title: string;
|
|
152
|
+
mode: "detail" | "banner";
|
|
153
|
+
activityRef: string;
|
|
152
154
|
actStatus: "NOT_START" | "INIT" | "PROCESSING" | "FINISH" | "RECEIVED";
|
|
153
155
|
vouchers: {
|
|
156
|
+
merchantName: string;
|
|
154
157
|
prizeId: string;
|
|
155
158
|
voucherName: string;
|
|
156
159
|
voucherType: string;
|
|
157
160
|
reductionAmount: string;
|
|
158
161
|
thresholdAmountText: string;
|
|
159
162
|
unit: string;
|
|
160
|
-
merchantName: string;
|
|
161
163
|
merchantLogo?: string | undefined;
|
|
162
164
|
itemLogo?: string | undefined;
|
|
163
165
|
}[];
|
|
164
|
-
|
|
165
|
-
progressStyle: "bar" | "steps";
|
|
166
|
+
progressStyle: "steps" | "bar";
|
|
166
167
|
description?: string | undefined;
|
|
167
|
-
|
|
168
|
+
steps?: {
|
|
169
|
+
title: string;
|
|
170
|
+
description?: string | undefined;
|
|
171
|
+
}[] | undefined;
|
|
168
172
|
coverUrl?: string | undefined;
|
|
173
|
+
mainTitle?: string | undefined;
|
|
169
174
|
backgroundUrl?: string | undefined;
|
|
170
175
|
tagLabel?: string | undefined;
|
|
171
176
|
cardLogoUrl?: string | undefined;
|
|
@@ -174,28 +179,29 @@ declare const serverModule: {
|
|
|
174
179
|
progressUnit?: string | undefined;
|
|
175
180
|
startAtText?: string | undefined;
|
|
176
181
|
endAtText?: string | undefined;
|
|
177
|
-
steps?: {
|
|
178
|
-
title: string;
|
|
179
|
-
description?: string | undefined;
|
|
180
|
-
}[] | undefined;
|
|
181
182
|
}, {
|
|
182
|
-
activityRef: string;
|
|
183
183
|
title: string;
|
|
184
|
+
activityRef: string;
|
|
184
185
|
actStatus: "NOT_START" | "INIT" | "PROCESSING" | "FINISH" | "RECEIVED";
|
|
185
186
|
vouchers: {
|
|
187
|
+
merchantName: string;
|
|
186
188
|
prizeId: string;
|
|
187
189
|
voucherName: string;
|
|
188
190
|
voucherType: string;
|
|
189
191
|
reductionAmount: string;
|
|
190
192
|
thresholdAmountText: string;
|
|
191
193
|
unit: string;
|
|
192
|
-
merchantName: string;
|
|
193
194
|
merchantLogo?: string | undefined;
|
|
194
195
|
itemLogo?: string | undefined;
|
|
195
196
|
}[];
|
|
196
197
|
description?: string | undefined;
|
|
197
|
-
|
|
198
|
+
mode?: "detail" | "banner" | undefined;
|
|
199
|
+
steps?: {
|
|
200
|
+
title: string;
|
|
201
|
+
description?: string | undefined;
|
|
202
|
+
}[] | undefined;
|
|
198
203
|
coverUrl?: string | undefined;
|
|
204
|
+
mainTitle?: string | undefined;
|
|
199
205
|
backgroundUrl?: string | undefined;
|
|
200
206
|
tagLabel?: string | undefined;
|
|
201
207
|
cardLogoUrl?: string | undefined;
|
|
@@ -204,19 +210,14 @@ declare const serverModule: {
|
|
|
204
210
|
progressUnit?: string | undefined;
|
|
205
211
|
startAtText?: string | undefined;
|
|
206
212
|
endAtText?: string | undefined;
|
|
207
|
-
|
|
208
|
-
steps?: {
|
|
209
|
-
title: string;
|
|
210
|
-
description?: string | undefined;
|
|
211
|
-
}[] | undefined;
|
|
212
|
-
progressStyle?: "bar" | "steps" | undefined;
|
|
213
|
+
progressStyle?: "steps" | "bar" | undefined;
|
|
213
214
|
}>>;
|
|
214
215
|
};
|
|
215
216
|
skills: {
|
|
216
217
|
[k: string]: _tbox_cn_app_sdk_server.LocalSkill;
|
|
217
218
|
};
|
|
218
219
|
preTools: {
|
|
219
|
-
getBumpInActivity: PreToolDef<
|
|
220
|
+
getBumpInActivity: PreToolDef<_tbox_cn_app_agent_sdk_server.Tool<{}, unknown, unknown, unknown, _mastra_core_tools.ToolExecutionContext<unknown, unknown, unknown>, "getBumpInActivity", unknown>, {}>;
|
|
220
221
|
};
|
|
221
222
|
register(ctx: ServerContext): void;
|
|
222
223
|
};
|
package/dist/server/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tbox.cn/app-module-alipay-activity",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "支付宝互动营销活动模块:碰出惊喜(碰一下)活动查询与展示(codegen 源)。",
|
|
6
6
|
"exports": {
|
|
@@ -18,10 +18,11 @@
|
|
|
18
18
|
}
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@tbox.cn/app-
|
|
22
|
-
"@tbox.cn/app-contracts": "0.
|
|
23
|
-
"
|
|
24
|
-
"
|
|
21
|
+
"@tbox.cn/app-contracts": "0.12.0",
|
|
22
|
+
"@tbox.cn/app-contracts-mall": "0.12.0",
|
|
23
|
+
"alipay-sdk": "4.14.0",
|
|
24
|
+
"@tbox.cn/app-agent-sdk-client": "0.1.0",
|
|
25
|
+
"@tbox.cn/app-agent-sdk-server": "0.1.0"
|
|
25
26
|
},
|
|
26
27
|
"peerDependencies": {
|
|
27
28
|
"zod": "3.25.76",
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
"type": "object",
|
|
6
6
|
"properties": {
|
|
7
7
|
"appId": { "type": "string", "title": "支付宝小程序 appId" },
|
|
8
|
-
"alipayPublicKey": { "type": "string", "title": "
|
|
9
|
-
"privateKey": { "type": "string", "writeOnly": true, "title": "
|
|
8
|
+
"alipayPublicKey": { "type": "string", "title": "支付宝公钥", "description": "验签" },
|
|
9
|
+
"privateKey": { "type": "string", "writeOnly": true, "title": "商户私钥", "description": "签名源" }
|
|
10
10
|
},
|
|
11
11
|
"required": ["appId", "privateKey", "alipayPublicKey"]
|
|
12
12
|
}
|
package/src/client/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import './styles/bumpin.css';
|
|
2
2
|
|
|
3
3
|
import type { CardComponent } from '@tbox.cn/app-contracts';
|
|
4
|
-
import type { ClientContext, ClientModule } from '@tbox.cn/app-sdk
|
|
4
|
+
import type { ClientContext, ClientModule } from '@tbox.cn/app-agent-sdk-client';
|
|
5
5
|
import { AlipayActivityBumpInCard } from './cards/bumpin-activity/index';
|
|
6
6
|
|
|
7
7
|
const cards = {
|
package/src/server/handler.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* 可以充值」类无关长句误入本模块直出卡);「支付宝碰一下」/「我的惊喜活动」等句式仍可靠
|
|
7
7
|
* 碰一/一下/惊喜 bigram 桥接命中。
|
|
8
8
|
*/
|
|
9
|
-
import type { HandlerDefinition, ServerContext } from '@tbox.cn/app-sdk
|
|
9
|
+
import type { HandlerDefinition, ServerContext } from '@tbox.cn/app-agent-sdk-server';
|
|
10
10
|
import { memberGateCardOf, toMallQueryContext, PROMOTION_ACTIVITY_ROUTING_POLICY } from '@tbox.cn/app-contracts-mall';
|
|
11
11
|
import type {
|
|
12
12
|
MemberStatusFactory,
|
package/src/server/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ServerContext, ServerModule, PreToolDef } from '@tbox.cn/app-sdk
|
|
2
|
-
import { definePreTool, loadModuleSkills } from '@tbox.cn/app-sdk
|
|
1
|
+
import type { ServerContext, ServerModule, PreToolDef } from '@tbox.cn/app-agent-sdk-server';
|
|
2
|
+
import { definePreTool, loadModuleSkills } from '@tbox.cn/app-agent-sdk-server';
|
|
3
3
|
import bumpInActivityMeta from './cards/bumpin-activity/meta';
|
|
4
4
|
import { createBumpInTools } from './tools';
|
|
5
5
|
import { alipayBumpInAuthStrategy } from './integrations/alipay/client';
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
import { existsSync, readFileSync } from 'node:fs';
|
|
21
21
|
import path from 'node:path';
|
|
22
22
|
import { AlipaySdk } from 'alipay-sdk';
|
|
23
|
-
import type { ProviderAuthStrategy } from '@tbox.cn/app-sdk
|
|
23
|
+
import type { ProviderAuthStrategy } from '@tbox.cn/app-agent-sdk-server';
|
|
24
24
|
import type { AlipayBumpInProviderConfig } from './provider';
|
|
25
25
|
|
|
26
26
|
/** 凭证 JSON 文件的 value 结构 */
|
package/src/server/ports.ts
CHANGED
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
* 的模块零路径魔法)。未注入/缺文件/缺字段 → null,工具层静默降级。
|
|
10
10
|
*/
|
|
11
11
|
import { existsSync, readFileSync } from 'node:fs';
|
|
12
|
-
import type { ServerContext } from '@tbox.cn/app-sdk
|
|
13
|
-
import { expandEnvVars } from '@tbox.cn/app-sdk
|
|
12
|
+
import type { ServerContext } from '@tbox.cn/app-agent-sdk-server';
|
|
13
|
+
import { expandEnvVars } from '@tbox.cn/app-agent-sdk-server';
|
|
14
14
|
import { AlipayBumpInService } from './integrations/alipay/adapter';
|
|
15
15
|
import { createAlipaySdkClient } from './integrations/alipay/client';
|
|
16
16
|
|
package/src/server/tools.ts
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* getBumpInActivityBanner:首页 Banner 数据拉取,无需用户意图触发。
|
|
5
5
|
*/
|
|
6
6
|
import { z } from 'zod';
|
|
7
|
-
import type { ServerContext, ToolExecContextLike } from '@tbox.cn/app-sdk
|
|
8
|
-
import { createTool, withCardEmissionHint, requireToolRequestContext } from '@tbox.cn/app-sdk
|
|
7
|
+
import type { ServerContext, ToolExecContextLike } from '@tbox.cn/app-agent-sdk-server';
|
|
8
|
+
import { createTool, withCardEmissionHint, requireToolRequestContext } from '@tbox.cn/app-agent-sdk-server';
|
|
9
9
|
import { memberGateCardOf, toMallQueryContext } from '@tbox.cn/app-contracts-mall';
|
|
10
10
|
import type {
|
|
11
11
|
MemberStatusFactory,
|
package/tbox.module.json
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
|
-
"
|
|
3
|
+
"id": "module-alipay-activity",
|
|
4
|
+
"name": "联单活动",
|
|
5
|
+
"description": "支付宝联单活动",
|
|
4
6
|
"version": "0.1.0",
|
|
5
7
|
"kind": "business",
|
|
6
8
|
"risk": {
|
|
@@ -10,8 +12,19 @@
|
|
|
10
12
|
"distribution": {
|
|
11
13
|
"defaultMode": "codegen"
|
|
12
14
|
},
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"modules": [
|
|
17
|
+
{
|
|
18
|
+
"id": "contracts-mall",
|
|
19
|
+
"required": true
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
},
|
|
23
|
+
"env": [],
|
|
24
|
+
"declare": {
|
|
25
|
+
"handlers": [
|
|
26
|
+
"alipay-activity"
|
|
27
|
+
],
|
|
15
28
|
"tools": [
|
|
16
29
|
"getBumpInActivity",
|
|
17
30
|
"getBumpInActivityBanner"
|
|
@@ -25,15 +38,7 @@
|
|
|
25
38
|
"routes": [],
|
|
26
39
|
"pages": [],
|
|
27
40
|
"tabs": [],
|
|
28
|
-
"actions": []
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
"modules": [
|
|
32
|
-
{
|
|
33
|
-
"id": "contracts-mall",
|
|
34
|
-
"required": true
|
|
35
|
-
}
|
|
36
|
-
]
|
|
37
|
-
},
|
|
38
|
-
"env": []
|
|
41
|
+
"actions": [],
|
|
42
|
+
"owns": []
|
|
43
|
+
}
|
|
39
44
|
}
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
* - 洋葱守卫:prefix 误送达 content 无域词时 handler 放行(continueWith 原文、零卡零文案不吞轮)。
|
|
8
8
|
*/
|
|
9
9
|
import { describe, expect, it, vi } from 'vitest';
|
|
10
|
-
import { createServerContext, matchIntent } from '@tbox.cn/app-sdk
|
|
11
|
-
import type { IntentRoute } from '@tbox.cn/app-sdk
|
|
10
|
+
import { createServerContext, matchIntent } from '@tbox.cn/app-agent-sdk-server';
|
|
11
|
+
import type { IntentRoute } from '@tbox.cn/app-agent-sdk-server';
|
|
12
12
|
import { PROMOTION_ACTIVITY_ROUTING_POLICY } from '@tbox.cn/app-contracts-mall';
|
|
13
13
|
import { BUMPIN_INTENTS, createAlipayActivityHandler } from '../src/server/handler';
|
|
14
14
|
|
|
@@ -28,7 +28,7 @@ const BUMPIN_TEST_ROUTES: IntentRoute[] = Object.values(BUMPIN_INTENTS).map(({ p
|
|
|
28
28
|
}));
|
|
29
29
|
|
|
30
30
|
const testRequestContext = () => ({
|
|
31
|
-
identity: { userId: 'u_1', source: '
|
|
31
|
+
identity: { userId: 'u_1', source: 'local' as const },
|
|
32
32
|
attributes: { mall: { miniAppId: 'app', mallId: 'mall-1' } },
|
|
33
33
|
});
|
|
34
34
|
|
package/tests/ports.test.ts
CHANGED
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
readAlipayBumpInConfig,
|
|
14
14
|
resolveAlipayBumpInService,
|
|
15
15
|
} from '../src/server/ports.js';
|
|
16
|
-
import type { ServerContext } from '@tbox.cn/app-sdk
|
|
16
|
+
import type { ServerContext } from '@tbox.cn/app-agent-sdk-server';
|
|
17
17
|
|
|
18
18
|
/** 最小 ctx 桩(logger warn 收集;其余槽位不触达) */
|
|
19
19
|
function ctxStub(): { ctx: ServerContext; warns: string[] } {
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* (镜像 server/index.ts bumpInPreTool 声明:真实工具实例 + 同词表)
|
|
5
5
|
*/
|
|
6
6
|
import { describe, expect, it } from 'vitest';
|
|
7
|
-
import { definePreTool, selectPreTools } from '@tbox.cn/app-sdk
|
|
7
|
+
import { definePreTool, selectPreTools } from '@tbox.cn/app-agent-sdk-server';
|
|
8
8
|
import { z } from 'zod';
|
|
9
9
|
import { createBumpInTools } from '../src/server/tools';
|
|
10
10
|
|
package/tests/samples.test.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* 全样本 dataSchema.safeParse 通过 + findSampleShapeViolations 无越界键(样本即契约)。
|
|
4
4
|
*/
|
|
5
5
|
import { describe, expect, it } from 'vitest';
|
|
6
|
-
import { findSampleShapeViolations } from '@tbox.cn/app-sdk
|
|
6
|
+
import { findSampleShapeViolations } from '@tbox.cn/app-agent-sdk-server';
|
|
7
7
|
import meta from '../src/server/cards/bumpin-activity/meta';
|
|
8
8
|
|
|
9
9
|
describe('alipay-activity samples 双断言(样本即契约)', () => {
|
package/tests/tools.test.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { describe, expect, it, vi } from 'vitest';
|
|
2
2
|
import { toBumpInCardData, parseAlipayRichText, createBumpInTools } from '../src/server/tools.js';
|
|
3
3
|
import type { PromotionActivityDetail } from '@tbox.cn/app-contracts-mall';
|
|
4
|
-
import { createServerContext, createToolExecContext } from '@tbox.cn/app-sdk
|
|
4
|
+
import { createServerContext, createToolExecContext } from '@tbox.cn/app-agent-sdk-server';
|
|
5
5
|
import { createAlipayActivityHandler } from '../src/server/handler.js';
|
|
6
6
|
|
|
7
7
|
// mock ports 的服务解析(工具内部 import;测试注入)
|
|
@@ -87,14 +87,14 @@ describe('身份轴与登录轴门禁(SPEC-5:P4-3 修复 + 匿名只拦登
|
|
|
87
87
|
|
|
88
88
|
const stubService = () => ({ listActivities: async () => ({ items: [stubDetail()], nextCursor: undefined }) });
|
|
89
89
|
|
|
90
|
-
const ctxWith = (identity: { userId: string; source: '
|
|
90
|
+
const ctxWith = (identity: { userId: string; source: 'local' | 'external' | 'anonymous' } | null, gate?: unknown) => {
|
|
91
91
|
const ctx = createServerContext();
|
|
92
92
|
Object.assign(ctx, {
|
|
93
93
|
services: gate ? { resolve: (key: string) => (key === 'member.status' ? gate : undefined) } : {},
|
|
94
94
|
});
|
|
95
95
|
return {
|
|
96
96
|
ctx,
|
|
97
|
-
execCtx: (source: '
|
|
97
|
+
execCtx: (source: 'local' | 'external' | 'anonymous' = 'dev') =>
|
|
98
98
|
createToolExecContext({
|
|
99
99
|
identity: { userId: identity?.userId ?? 'u_bump', source: identity?.source ?? 'dev' },
|
|
100
100
|
attributes: { mall: { miniAppId: 'app', mallId: 'mall-1' } },
|
|
@@ -159,7 +159,7 @@ describe('身份轴与登录轴门禁(SPEC-5:P4-3 修复 + 匿名只拦登
|
|
|
159
159
|
const service = stubService();
|
|
160
160
|
const listActivities = vi.fn(service.listActivities);
|
|
161
161
|
vi.mocked(resolveAlipayBumpInService).mockResolvedValue({ listActivities } as never);
|
|
162
|
-
const { ctx, execCtx } = ctxWith({ userId: 'u_dev', source: '
|
|
162
|
+
const { ctx, execCtx } = ctxWith({ userId: 'u_dev', source: 'local' }, gate);
|
|
163
163
|
const tools = createBumpInTools(() => ctx);
|
|
164
164
|
const result = (await tools.getBumpInActivity.execute!({} as never, execCtx('dev'))) as {
|
|
165
165
|
cards?: { cardType: string }[];
|
package/tsup.config.ts
CHANGED
|
@@ -16,7 +16,8 @@ export default defineConfig({
|
|
|
16
16
|
// 声明产物一次性构建无需增量——仅 dts 关闭,typecheck 的增量缓存不受影响。
|
|
17
17
|
dts: { compilerOptions: { incremental: false } },
|
|
18
18
|
external: [
|
|
19
|
-
'@tbox.cn/app-sdk',
|
|
19
|
+
'@tbox.cn/app-agent-sdk-client',
|
|
20
|
+
'@tbox.cn/app-agent-sdk-server',
|
|
20
21
|
'@tbox.cn/app-contracts',
|
|
21
22
|
'@tbox.cn/app-contracts-mall',
|
|
22
23
|
'react',
|