@lark-apaas/coding-steering 0.1.83 → 0.1.84
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/package.json +1 -1
- package/steering/nestjs-react-fullstack/skills/authn-guide/SKILL.md +5 -1
- package/steering/nestjs-react-fullstack/skills/coding-guide/SKILL.md +1 -0
- package/steering/nestjs-react-fullstack/skills/tag-agent-task/SKILL.md +4 -4
- package/steering/nestjs-react-fullstack/skills/tag-agent-task/references/example.md +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: authn-guide
|
|
3
|
-
description: "Use when implementing authentication features: @NeedLogin decorator (AuthN is opt-in, public interfaces need no decorator), AuthNPaasGuard flow, or handling 401 errors. 触发词:认证, authn, 身份验证, 登录检查, NeedLogin, Public, 公开接口, AuthNPaasGuard, x-login-url, 401, 未授权"
|
|
3
|
+
description: "Use when implementing authentication features: @NeedLogin decorator (AuthN is opt-in, public interfaces need no decorator), AuthNPaasGuard flow, or handling 401 errors. 触发词:认证, authn, 42501, permission denied, SQLSTATE, 身份验证, 登录检查, NeedLogin, Public, 公开接口, AuthNPaasGuard, x-login-url, 401, 未授权"
|
|
4
4
|
steering: true
|
|
5
5
|
steering-topic: authn_guide
|
|
6
6
|
match-template-name: nestjs-react-fullstack
|
|
@@ -130,3 +130,7 @@ export class ApiController {
|
|
|
130
130
|
1. 检查 Controller 或父级是否打了 `@NeedLogin()`(继承到本方法);按 opt-in 默认行为,**移除装饰器**接口就会公开
|
|
131
131
|
2. **不要**用 `@Public()` 试图取消登录要求——它是 no-op,对 guard 无影响
|
|
132
132
|
3. 检查是否有自定义 Guard 比 `AuthNPaasGuard` 更早执行并主动拦了未登录请求
|
|
133
|
+
|
|
134
|
+
### 公开写接口报 `42501 permission denied`
|
|
135
|
+
|
|
136
|
+
裸 `INSERT` 能成功,但 `INSERT ... RETURNING` 或写后回查报 `42501` 时,说明同一运行时身份缺少 SELECT / RLS;默认改用 non-RETURNING + 写入前生成的回执,确需读回时只补最小 SELECT / RLS,禁止向 `anon` 开放全表 SELECT。
|
|
@@ -363,6 +363,7 @@ export class TestService {
|
|
|
363
363
|
|
|
364
364
|
- **数据库身份由平台管理**:平台会在每次 Drizzle 查询前注入当前请求的用户身份和数据库角色。业务代码不得执行 `SET app.user_id`、`SET LOCAL app.user_id`、`SET ROLE`,也不得调用身份注入内部实现或伪造请求、用户 ID、workspace role;这些设置不会传递给后续查询,且可能被平台覆盖
|
|
365
365
|
- **按请求实际身份设计 RLS**:登录请求使用 `req.userContext`;允许未登录访问时,为对应表配置 `anon` RLS policy。API Key、Webhook、Cron 等没有登录用户的入口不得冒充用户;现有 RLS 无法安全表达其权限时,停止该身份方案并说明能力限制
|
|
366
|
+
- **匿名或只写身份的创建接口**:当前身份只能写、不能读时,写前 `SELECT`、`INSERT ... RETURNING` 和写后回查都可能因缺少 SELECT / RLS 报 `42501`;默认用 non-RETURNING 并返回写入前生成的回执,确需读回时只补最小 SELECT / RLS,禁止开放全表 SELECT。本条只约束 `insert`,**不影响** update / delete——它们仍按下文「写操作必须校验生效行数」带 `.returning({ id })`
|
|
366
367
|
- **每次编写或修改数据库操作代码前,必须重新读取 `server/database/schema.ts`**——该文件由系统在 DDL 执行后自动重新生成,内容随时可能变化。禁止凭记忆或之前读取的版本编写字段名和类型,否则会引用不存在的字段导致 TS2339 批量报错
|
|
367
368
|
- `schema.ts` 是数据库结构的生成镜像,可用于字段、类型、普通索引及其完整表达的普通唯一结构;它不保留条件索引、表达式索引、CHECK 等复杂结构的全部语义。判断这类结构或复杂唯一性、约束的精确语义时,必须在首次下结论或编写依赖该语义的代码前,加载数据库操作 skill,并按其说明读取目标表的完整 DDL。不得只依据 `schema.ts`、代码或普通数据查询推断
|
|
368
369
|
- 禁止手改生成的 `schema.ts` 补回缺失的数据库语义;需要改变结构时,按数据库操作 skill 执行 DDL,再重新生成并读取 `schema.ts`
|
|
@@ -29,14 +29,14 @@ available-request-source:
|
|
|
29
29
|
|
|
30
30
|
```ts
|
|
31
31
|
const response = await this.platformHttp.instance.post(
|
|
32
|
-
'/api/v1/studio/innerapi/
|
|
32
|
+
'/api/v1/studio/innerapi/tag/call',
|
|
33
33
|
{ apiName: 'tag.create_agent_task', input }, // 不传 userID:操作人由平台按登录态识别
|
|
34
34
|
{ timeout: 30000 },
|
|
35
35
|
);
|
|
36
36
|
```
|
|
37
37
|
|
|
38
38
|
```
|
|
39
|
-
POST /api/v1/studio/innerapi/
|
|
39
|
+
POST /api/v1/studio/innerapi/tag/call
|
|
40
40
|
{
|
|
41
41
|
"apiName": "tag.create_agent_task",
|
|
42
42
|
"input": {
|
|
@@ -123,7 +123,7 @@ Agent 拿到的**只有** `content` 这段文字:看不到应用页面、不
|
|
|
123
123
|
|
|
124
124
|
- 请求体**不要传 `userID`**,也不要想办法指定别的操作人;传了也不作数,平台仍按登录用户派单。不能「替别人派单」。
|
|
125
125
|
- 必须在**处理登录用户这次请求的调用链里**调用(Controller → Service 一路 `await` 下去)。应用关闭了登录、匿名访问、触发器 / Webhook / OpenAPI Key 入口、定时任务、脱离请求的后台队列都没有登录用户,调用会返回 `Unauthenticated`——此时直接给出明确提示(「需要登录后才能派发任务」),不要伪造或硬编码用户 ID。
|
|
126
|
-
-
|
|
126
|
+
- 当前登录用户就是这个智能体本身时,**TAG 身份无法给自己派单**,返回参数错误,按 `100004001` 同样处理即可。使用 TAG 身份测试时,由此产生的派单报错属于正常情况,按预期限制记录,不要为通过测试绕过身份校验;成功派单需由有权限使用该智能体的用户登录后验证,其他报错仍按错误码排查。
|
|
127
127
|
|
|
128
128
|
### 要让某个人做事:content 里写明此人的 LarkID
|
|
129
129
|
|
|
@@ -155,7 +155,7 @@ Agent 拿到的**只有** `content` 这段文字:看不到应用页面、不
|
|
|
155
155
|
|
|
156
156
|
## 自检
|
|
157
157
|
|
|
158
|
-
- [ ] 只有服务端调用 `
|
|
158
|
+
- [ ] 只有服务端调用 `tag/call`,前端只调 `/api/agent-tasks`
|
|
159
159
|
- [ ] 用的是 `platformHttp.instance`(不是 `fetch` / `axios` / `rawInstance`),没有手写鉴权或泳道 header
|
|
160
160
|
- [ ] 请求体没有传 `userID`;在登录用户请求的调用链里调用,接口加了 `@NeedLogin()`,无登录用户时有明确提示
|
|
161
161
|
- [ ] 功能是让某个人做事时,`content` 里写了此人的 LarkID(字符串,不是 employee_id / open_id / 妙搭 userId),取不到时明确提示、不派单
|
|
@@ -89,7 +89,7 @@ export class AgentTaskService {
|
|
|
89
89
|
|
|
90
90
|
private async callOnce(task: CreateAgentTaskRequest): Promise<TagTaskOutput> {
|
|
91
91
|
const response = await this.platformHttp.instance.post(
|
|
92
|
-
'/api/v1/studio/innerapi/
|
|
92
|
+
'/api/v1/studio/innerapi/tag/call',
|
|
93
93
|
{
|
|
94
94
|
apiName: 'tag.create_agent_task',
|
|
95
95
|
input: {
|