@xtalpi/agentic-lab-skills 0.0.9 → 0.0.11
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 +1 -1
- package/package.json +14 -14
- package/skills/lab-flow-designer/SKILL.md +612 -593
- package/skills/lab-flow-designer/embedded-template/SKILL.md +103 -88
- package/skills/lab-flow-designer/embedded-template/pools//345/205/245/345/217/243/346/261/240.md +21 -12
- package/skills/lab-flow-designer/embedded-template/pools//345/207/272/345/217/243/346/261/240.md +21 -12
- package/skills/lab-flow-designer/embedded-template/scripts//347/244/272/344/276/213/346/225/260/346/215/256/344/270/216/346/240/241/351/252/214/351/227/250/346/216/247.js +142 -142
- package/skills/lab-flow-designer/embedded-template/valves//347/244/272/344/276/213/346/225/260/346/215/256/344/270/216/346/240/241/351/252/214/351/227/250/346/216/247.md +114 -99
- package/skills/lab-flow-designer/references/agentic-lab-processer.md +122 -78
- package/skills/lab-flow-designer/references/agentic-lab-sdk.md +534 -361
- package/skills/lab-flow-designer/references/rhea-api/README.md +7 -7
- package/skills/lab-flow-designer/references/rhea-api/execute_process_batch.md +58 -58
- package/skills/lab-flow-designer/references/skill-package-layout.md +268 -204
- package/skills/lab-flow-designer/references//344/270/232/345/212/241/346/265/201/347/250/213/346/226/207/346/241/243/346/240/207/345/207/206.md +216 -208
- package/skills/lab-flow-designer/templates//344/270/232/345/212/241/346/265/201/347/250/213/346/226/207/346/241/243/346/250/241/346/235/277.md +192 -169
- package/skills/lab-flow-designer/templates//344/270/232/345/212/241/346/265/201/347/250/213/346/226/207/346/241/243/347/244/272/344/276/213.md +207 -197
- package/skills/lab-flow-designer/testing/test-processer.mjs +1240 -1075
- package/skills/lab-nocobase-flow-generator/SKILL.md +164 -164
- package/skills/lab-nocobase-flow-generator/examples/setting/350/241/250/350/216/267/345/217/226/345/244/226/351/203/250/346/234/215/345/212/241.js +70 -70
- package/skills/lab-nocobase-flow-generator/examples//346/237/245/350/257/242/345/214/226/345/255/246/345/223/201/344/277/241/346/201/257.js +30 -30
- package/skills/lab-nocobase-flow-generator/references/doc-standard.md +84 -84
- package/skills/lab-nocobase-flow-generator/references/runtime-api.md +224 -224
- package/skills/lab-nocobase-flow-generator/templates//350/204/232/346/234/254/351/200/273/350/276/221/346/226/207/346/241/243/346/250/241/346/235/277.md +121 -121
- package/skills/lab-nocobase-flow-generator/templates//350/204/232/346/234/254/351/200/273/350/276/221/346/226/207/346/241/243/347/244/272/344/276/213.md +67 -67
- package/skills/lab-orbit-component-builder/SKILL.md +353 -353
- package/skills/lab-orbit-component-builder/examples/xnb-component-template/.env.local.example +27 -27
- package/skills/lab-orbit-component-builder/examples/xnb-component-template/.eslintignore +7 -7
- package/skills/lab-orbit-component-builder/examples/xnb-component-template/.eslintrc.cjs +88 -88
- package/skills/lab-orbit-component-builder/examples/xnb-component-template/.nvmrc +1 -1
- package/skills/lab-orbit-component-builder/examples/xnb-component-template/AgenticAppAPI.md +268 -268
- package/skills/lab-orbit-component-builder/examples/xnb-component-template/Jenkinsfile +106 -106
- package/skills/lab-orbit-component-builder/examples/xnb-component-template/OrbitAPI.md +453 -453
- package/skills/lab-orbit-component-builder/examples/xnb-component-template/README.md +176 -176
- package/skills/lab-orbit-component-builder/examples/xnb-component-template/dev/public/index.html +12 -12
- package/skills/lab-orbit-component-builder/examples/xnb-component-template/dev/src/App.vue +151 -151
- package/skills/lab-orbit-component-builder/examples/xnb-component-template/dev/src/components/DevOpenerLauncher.vue +143 -143
- package/skills/lab-orbit-component-builder/examples/xnb-component-template/dev/src/global.d.ts +77 -77
- package/skills/lab-orbit-component-builder/examples/xnb-component-template/dev/src/main.ts +308 -308
- package/skills/lab-orbit-component-builder/examples/xnb-component-template/dev/src/mockXNBBitable.ts +119 -119
- package/skills/lab-orbit-component-builder/examples/xnb-component-template/dev/src/shims-vue.d.ts +6 -6
- package/skills/lab-orbit-component-builder/examples/xnb-component-template/dev/src/utils/devOpenerHost.ts +75 -75
- package/skills/lab-orbit-component-builder/examples/xnb-component-template/index.html +13 -13
- package/skills/lab-orbit-component-builder/examples/xnb-component-template/package.json +60 -60
- package/skills/lab-orbit-component-builder/examples/xnb-component-template/src/api/agenticlabTickets.ts +110 -110
- package/skills/lab-orbit-component-builder/examples/xnb-component-template/src/entries/bitable.ts +4 -4
- package/skills/lab-orbit-component-builder/examples/xnb-component-template/src/entries/custom-page.ts +4 -4
- package/skills/lab-orbit-component-builder/examples/xnb-component-template/src/index.ts +1 -1
- package/skills/lab-orbit-component-builder/examples/xnb-component-template/src/styles/orbit-quasar-host.scss +19 -19
- package/skills/lab-orbit-component-builder/examples/xnb-component-template/src/types/context.ts +15 -15
- package/skills/lab-orbit-component-builder/examples/xnb-component-template/src/types/xnb-context.ts +70 -70
- package/skills/lab-orbit-component-builder/examples/xnb-component-template/src/use/useBitablePage.ts +189 -189
- package/skills/lab-orbit-component-builder/examples/xnb-component-template/src/use/useSuperCellDemo.ts +257 -257
- package/skills/lab-orbit-component-builder/examples/xnb-component-template/src/use/useSuperTableBitableLifecycle.ts +555 -555
- package/skills/lab-orbit-component-builder/examples/xnb-component-template/src/utils/openerInitParams.ts +158 -158
- package/skills/lab-orbit-component-builder/examples/xnb-component-template/src/utils/openerTicketIds.ts +32 -32
- package/skills/lab-orbit-component-builder/examples/xnb-component-template/src/utils/orbitHttpClient.ts +110 -110
- package/skills/lab-orbit-component-builder/examples/xnb-component-template/src/utils/request.ts +92 -92
- package/skills/lab-orbit-component-builder/examples/xnb-component-template/src/views/bitable.vue +67 -67
- package/skills/lab-orbit-component-builder/examples/xnb-component-template/src/views/custom-page.vue +140 -140
- package/skills/lab-orbit-component-builder/examples/xnb-component-template/tsconfig.json +45 -45
- package/skills/lab-orbit-component-builder/examples/xnb-component-template/vite.config.ts +170 -170
- package/skills/lab-orbit-component-builder/examples/xnb-component-template/vite.dev.config.ts +58 -58
- package/skills/lab-orbit-component-builder/references/flow-document-human-ui.md +65 -65
- package/skills/lab-orbit-component-builder/references/orbit-vue-conventions.md +133 -133
- package/skills/lab-orbit-component-builder/references/pool-schema-to-columns.md +67 -67
- package/skills/lab-orbit-component-builder/references/vue-template-checklist.md +179 -179
- package/skills/lab-orbit-component-builder/references/xnb-context-vue-props.md +49 -49
- package/skills/lab-orbit-component-builder/references/xnbitable-vue-parity.md +32 -32
|
@@ -1,361 +1,534 @@
|
|
|
1
|
-
# Agentic Lab SDK
|
|
2
|
-
|
|
3
|
-
# API 文档
|
|
4
|
-
|
|
5
|
-
本节为 **`this.context` 门控/SDK 能力**约定。**`process.execute`** 须传入任务数组 **`items`** 与服务根 **`baseURL`**(Rhea 或等价 Process 服务地址);单次请求的 **path、HTTP 方法** 仍与 Wire 文档一致并由 **SDK 封装**,门控不拼完整 URL。其余常见查询类能力仍以 SDK 封装为主。`items` 单项形状与 **[`rhea-api/execute_process_batch.md`](rhea-api/execute_process_batch.md)** 中请求体 `items[]` 一项对齐。
|
|
6
|
-
|
|
7
|
-
## 门控脚本生成约定(lab-flow-designer)
|
|
8
|
-
|
|
9
|
-
对 **`ticket.list`**、**`process.list`** 等支持 **`limit` / `offset`** 的查询:若流程说明**未**明确要求分页或条数,生成门控脚本时应显式传入 **`limit: 999999`**、**`offset: 0`**,避免引擎默认小页长截断。若流程说明写了分页或「查全部」的**具体数值**,以流程说明为准。
|
|
10
|
-
|
|
11
|
-
> **`compound.getStockFromXfcSh`** 使用 `pageSize` / `page` 分页(非 `limit` / `offset`),不传分页参数时使用 API 默认值。
|
|
12
|
-
|
|
13
|
-
---
|
|
14
|
-
|
|
15
|
-
## 可用方法一览
|
|
16
|
-
|
|
17
|
-
| 方法 | 命名空间 | 用途 | 分页方式 |
|
|
18
|
-
|------|----------|------|----------|
|
|
19
|
-
| `pool.getNext(valveId)` | `context.pool` | 获取指定门控的出口池数组 | 无 |
|
|
20
|
-
| `ticket.list(params)` | `context.ticket` | 按条件筛选并分页返回 ticket 列表 | `limit` / `offset` |
|
|
21
|
-
| `ticket.update(tickets)` | `context.ticket` | 批量更新 ticket | 无 |
|
|
22
|
-
| `ticket.append(tickets)` | `context.ticket` | 批量追加 ticket | 无 |
|
|
23
|
-
| `process.list(params)` | `context.process` | 查询 process 列表 | `limit` / `offset` |
|
|
24
|
-
| `process.execute(items, baseURL)` | `context.process` | 批量提交 Process 执行任务 | 无 |
|
|
25
|
-
| `station.list()` | `context.station` | 列出所有工站 | 无 |
|
|
26
|
-
| `compound.getStockFromXfcSh(params)` | `context.compound` | 获取 XFC 上海化合物库存 | `pageSize` / `page` |
|
|
27
|
-
| `agent.chat(params)` | `context.agent` | 调用外部 Agent(流式/非流式),返回文本或解析后的 JSON | 无 |
|
|
28
|
-
|
|
29
|
-
> 生成「核心概念」中的 `this.context` 能力列表时,从本表选取流程实际使用的方法即可。各方法的完整签名、参数类型与返回类型见下文各节。
|
|
30
|
-
|
|
31
|
-
---
|
|
32
|
-
|
|
33
|
-
## pool.getNext
|
|
34
|
-
|
|
35
|
-
- **别名**:`context.pool.getNext`
|
|
36
|
-
- **描述**:获取指定门控节点的出口池(返回出口池数组)
|
|
37
|
-
|
|
38
|
-
```typescript
|
|
39
|
-
interface Pool {
|
|
40
|
-
id: number;
|
|
41
|
-
name: string;
|
|
42
|
-
description: string;
|
|
43
|
-
schema: {
|
|
44
|
-
fields: Array<Record<string, any>>;
|
|
45
|
-
};
|
|
46
|
-
type: PoolType;
|
|
47
|
-
}
|
|
48
|
-
async function pool.getNext(valveId: number): Promise<Pool[]>
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
---
|
|
52
|
-
|
|
53
|
-
## ticket.list
|
|
54
|
-
|
|
55
|
-
- **别名**:`context.ticket.list`
|
|
56
|
-
- **描述**:按 `ListTicketParams` 筛选并分页返回 **`TicketListResponse`**(`{ list: Ticket[] }`)。业务上取 **`response.list`** 得到 ticket 数组。`limit` **默认 20**、`offset` **默认 0**(以引擎实现为准)。可选组合:`flow_id__in`、`order_id__in`、`pool_id__in`、`status__in`、单条主键 `id`。**`id` 仅筛选一条**;若需按多条主键召回而类型中尚无 `id__in` 等批量字段,以运行环境为准(可分次传入 `id` 调用,或改用 `pool_id__in` + `status__in` 等缩小集合)。
|
|
57
|
-
|
|
58
|
-
```typescript
|
|
59
|
-
interface ListTicketParams {
|
|
60
|
-
flow_id__in?: number[];
|
|
61
|
-
order_id__in?: number[];
|
|
62
|
-
pool_id__in?: number[]; // 按 pool 筛选
|
|
63
|
-
status__in?: string[];
|
|
64
|
-
id?: number; // 按 ticket 筛选(单条主键)
|
|
65
|
-
limit: number; // 默认为 20
|
|
66
|
-
offset: number; // 默认为 0
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
interface Ticket {
|
|
70
|
-
id: number;
|
|
71
|
-
flow_id: number;
|
|
72
|
-
pool_id: number;
|
|
73
|
-
order_id: number;
|
|
74
|
-
parent_ticket_id: number;
|
|
75
|
-
detail: Record<string, any>;
|
|
76
|
-
status: string;
|
|
77
|
-
uuid: string;
|
|
78
|
-
createdAt?: Date | number;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/** `ticket.list` 返回体;列表字段为 `list` */
|
|
82
|
-
interface TicketListResponse {
|
|
83
|
-
list: Ticket[];
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
async function ticket.list(
|
|
87
|
-
params: ListTicketParams,
|
|
88
|
-
): Promise<TicketListResponse>
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
---
|
|
92
|
-
|
|
93
|
-
## ticket.update
|
|
94
|
-
|
|
95
|
-
- **别名**:`context.ticket.update`
|
|
96
|
-
- **描述**:批量更新 ticket
|
|
97
|
-
|
|
98
|
-
```typescript
|
|
99
|
-
async function ticket.update(tickets: Ticket[]): Promise<void>
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
---
|
|
103
|
-
|
|
104
|
-
## ticket.append
|
|
105
|
-
|
|
106
|
-
- **别名**:`context.ticket.append`
|
|
107
|
-
- **描述**:批量追加 ticket。`status` 未传时由引擎采用默认状态(以实现为准);`parent_ticket_id` 用于挂接父 ticket,无父子关系时可省略。
|
|
108
|
-
|
|
109
|
-
```typescript
|
|
110
|
-
enum TicketStatus {
|
|
111
|
-
Created = 'created',
|
|
112
|
-
Running = 'running',
|
|
113
|
-
Finished = 'finished',
|
|
114
|
-
Failed = 'failed',
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
interface CreateTicketParams {
|
|
118
|
-
flow_id: number;
|
|
119
|
-
pool_id: number;
|
|
120
|
-
order_id: number;
|
|
121
|
-
detail: Record<string, any>;
|
|
122
|
-
status?: TicketStatus | string;
|
|
123
|
-
parent_ticket_id?: number;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
async function ticket.append(tickets: CreateTicketParams[]): Promise<Ticket[]>
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
---
|
|
130
|
-
|
|
131
|
-
## process.list
|
|
132
|
-
|
|
133
|
-
- **别名**:`context.process.list`
|
|
134
|
-
- **描述**:查询 Bluprint process(process/list_process)
|
|
135
|
-
|
|
136
|
-
```typescript
|
|
137
|
-
interface ListProcessParams {
|
|
138
|
-
processIds?: string[]; // 按 exp_id 筛选
|
|
139
|
-
limit: number; // 默认为20
|
|
140
|
-
offset: number; // 默认为0
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
async function process.list(params: ListProcessParams): Promise<any>
|
|
144
|
-
```
|
|
145
|
-
|
|
146
|
-
---
|
|
147
|
-
|
|
148
|
-
## process.execute
|
|
149
|
-
|
|
150
|
-
- **别名**:`context.process.execute`
|
|
151
|
-
- **描述**:流程说明中需要 **Process 执行 / 设备侧批量提交任务** 时调用。传入 **`items`**(与 Rhea 请求体 **`items` 数组**同形;每项**必填** **`process`(流程模板名)**、**`params`**;**`table_objects`** 等可选字段的拼装须由流程文档写清)及 **`baseURL`**(服务根地址,如 `https://rhea.example.com`)。**path、HTTP 方法** 由 SDK 按 Wire 固定,门控不传。返回数据形如 **`{ results: { … } }`**,具体键名以实现为准。
|
|
152
|
-
|
|
153
|
-
```typescript
|
|
154
|
-
// baseURL: 服务地址
|
|
155
|
-
// 返回数据形如 { results: { ... } }
|
|
156
|
-
|
|
157
|
-
/** 单条任务:与 Rhea `items[]` 一项对齐;必填性以 rhea-api/execute_process_batch.md 为准 */
|
|
158
|
-
interface ExecuteProcessItem {
|
|
159
|
-
exp_name?: string;
|
|
160
|
-
/** 流程模板名称(流程文档中的 process / process_name) */
|
|
161
|
-
process: string;
|
|
162
|
-
priority?: number;
|
|
163
|
-
/** 流程参数,键值以流程文档为准 */
|
|
164
|
-
params: Record<string, unknown>;
|
|
165
|
-
/** 表对象,如 `{ 表名: { id: value } }`,以流程文档为准;无表绑定时可省略 */
|
|
166
|
-
table_objects?: Record<string, Record<string, unknown>>;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
/** 典型成功响应;`results` 内字段以实现为准(如 `exp_id_list`) */
|
|
170
|
-
interface ExecuteProcessResult {
|
|
171
|
-
results?: {
|
|
172
|
-
exp_id_list?: string[];
|
|
173
|
-
[key: string]: unknown;
|
|
174
|
-
};
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
async function process.execute(
|
|
178
|
-
items: ExecuteProcessItem[],
|
|
179
|
-
baseURL: string,
|
|
180
|
-
): Promise<ExecuteProcessResult>
|
|
181
|
-
```
|
|
182
|
-
|
|
183
|
-
- **Wire 与实现参考**(供 SDK 实现者):URL 路径、方法、示例请求体见 [rhea-api/execute_process_batch.md](rhea-api/execute_process_batch.md)。
|
|
184
|
-
- **流程文档侧**:写明**何时调用**、**`baseURL` 语义来源**(配置键、环境变量名、或 ticket/订单字段等,由集成解析为字符串 URL)、每条 **`process`**、**`params` 键与取值来源**;若需表绑定再写 **`table_objects`**。**不要求**写 path / HTTP 方法。生成 `valves/*.md` 与 `scripts/*.js` 须能追溯到上述说明;脚本调用形态为 **`this.context.process.execute(items, baseURL)`**。
|
|
185
|
-
|
|
186
|
-
---
|
|
187
|
-
|
|
188
|
-
## station.list
|
|
189
|
-
|
|
190
|
-
- **别名**:`context.station.list`
|
|
191
|
-
- **描述**:列出所有工站
|
|
192
|
-
|
|
193
|
-
```typescript
|
|
194
|
-
async function station.list(): Promise<Station[]>
|
|
195
|
-
```
|
|
196
|
-
|
|
197
|
-
---
|
|
198
|
-
|
|
199
|
-
## compound.getStockFromXfcSh
|
|
200
|
-
|
|
201
|
-
- **别名**:`context.compound.getStockFromXfcSh`
|
|
202
|
-
- **描述**:获取 XFC 上海系统化合物库存。使用 `pageSize` / `page` 分页(非 `limit` / `offset`),不传分页参数时使用 API 默认值(默认 `pageSize: 400`、`page: 1`)。
|
|
203
|
-
|
|
204
|
-
```typescript
|
|
205
|
-
interface StockFromXfcShParams {
|
|
206
|
-
filter?: Record<string, any>;
|
|
207
|
-
fields?: string[] | string;
|
|
208
|
-
pageSize?: number;
|
|
209
|
-
page?: number;
|
|
210
|
-
[propName: string]: any;
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
async function compound.getStockFromXfcSh(
|
|
214
|
-
params?: StockFromXfcShParams
|
|
215
|
-
): Promise<CompoundResponse>
|
|
216
|
-
```
|
|
217
|
-
|
|
218
|
-
### 参数说明
|
|
219
|
-
|
|
220
|
-
| 参数名 | 含义 | 备注 |
|
|
221
|
-
|--------|------|------|
|
|
222
|
-
| `filter` | 筛选条件 | 查询化合物常用 `cas`、`cmpd_id`;**不传时默认筛选 `'status': '可用'`**。使用 **dot-notation** 格式(如 `'cas.$in': [...]`),**非**嵌套对象格式 |
|
|
223
|
-
| `fields` | 查询返回的字段 | **默认返回字段(不传时)**:`id, cas, status, source, barcode, cmpd_id, owner`。**全部可用字段**:`barcode, cas, cmpd_id, po_num, source, owner, hazard_class_adr, odor, initial_weight, initial_amount, initial_checkin_time, latest_weight, latest_amount_mg, latest_amount_ml, latest_checkin_time, latest_checkout_time, latest_location, location_detail, checkin_user, status, checkout_user, chemical_name`。**外键**:`f_category, f_account, f_latest_request_user, f_project` |
|
|
224
|
-
| `pageSize` | 分页大小 | 默认 `400` |
|
|
225
|
-
| `page` | 页码 | 默认 `1` |
|
|
226
|
-
|
|
227
|
-
### 调用示例
|
|
228
|
-
|
|
229
|
-
```javascript
|
|
230
|
-
const xfcStockSH = await this.context.compound.getStockFromXfcSh({
|
|
231
|
-
filter: {
|
|
232
|
-
'cas.$in': ['1065657-51-3']
|
|
233
|
-
}
|
|
234
|
-
});
|
|
235
|
-
// xfcStockSH.data → 数据数组
|
|
236
|
-
// xfcStockSH.meta → 分页信息
|
|
237
|
-
```
|
|
238
|
-
|
|
239
|
-
### 返回类型
|
|
240
|
-
|
|
241
|
-
```typescript
|
|
242
|
-
interface CompoundItem {
|
|
243
|
-
id: number;
|
|
244
|
-
cas: string;
|
|
245
|
-
status: string;
|
|
246
|
-
source: string;
|
|
247
|
-
barcode: string;
|
|
248
|
-
cmpd_id: string;
|
|
249
|
-
owner: string;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
interface CompoundMeta {
|
|
253
|
-
count: number;
|
|
254
|
-
page: number;
|
|
255
|
-
pageSize: number;
|
|
256
|
-
totalPage: number;
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
interface CompoundResponse {
|
|
260
|
-
data: CompoundItem[];
|
|
261
|
-
meta: CompoundMeta;
|
|
262
|
-
}
|
|
263
|
-
```
|
|
264
|
-
|
|
265
|
-
### 返回数据示例
|
|
266
|
-
|
|
267
|
-
```json
|
|
268
|
-
{
|
|
269
|
-
"data": [
|
|
270
|
-
{
|
|
271
|
-
"id": 151,
|
|
272
|
-
"cas": "1065657-51-3",
|
|
273
|
-
"status": "可用",
|
|
274
|
-
"source": "上海锐谱医药科技有限公司",
|
|
275
|
-
"barcode": "XFC25103100049",
|
|
276
|
-
"cmpd_id": "BA0062",
|
|
277
|
-
"owner": "张琳"
|
|
278
|
-
},
|
|
279
|
-
{
|
|
280
|
-
"id": 6613,
|
|
281
|
-
"cas": "1065657-51-3",
|
|
282
|
-
"status": "可用",
|
|
283
|
-
"source": "上海锐谱医药科技有限公司",
|
|
284
|
-
"barcode": "XFC25121900056",
|
|
285
|
-
"cmpd_id": "BA0062",
|
|
286
|
-
"owner": "张琳"
|
|
287
|
-
}
|
|
288
|
-
],
|
|
289
|
-
"meta": { "count": 2, "page": 1, "pageSize": 400, "totalPage": 1 }
|
|
290
|
-
}
|
|
291
|
-
```
|
|
292
|
-
|
|
293
|
-
---
|
|
294
|
-
|
|
295
|
-
## agent.chat
|
|
296
|
-
|
|
297
|
-
- **别名**:`context.agent.chat`
|
|
298
|
-
- **描述**:调用外部 Agent 服务。SDK 负责发起请求、消费流式(SSE / NDJSON)或普通 JSON 响应,并将各 chunk 的 `content` 拼接为完整文本。`url`、`query` **必填**。`parseJson: true` 时从返回文本中提取并解析 JSON(支持 Markdown 代码块与多段 JSON 合并);解析成功返回 object / array,失败返回 `null`。未开启 `parseJson` 时返回原始字符串。请求失败抛出以 `agent.chat:` 为前缀的错误。
|
|
299
|
-
|
|
300
|
-
```typescript
|
|
301
|
-
interface ChatAgentParams {
|
|
302
|
-
/** Agent 服务完整 URL(必填) */
|
|
303
|
-
url: string; // Agent 服务完整 URL(必填
|
|
304
|
-
/** 用户查询文本(必填;非空字符串) */
|
|
305
|
-
query: string;
|
|
306
|
-
/**
|
|
307
|
-
* true:从返回文本提取并解析 JSON,成功返回 object/array,失败返回 null;
|
|
308
|
-
* 未传或 false:返回拼接后的原始 string
|
|
309
|
-
*/
|
|
310
|
-
parseJson?: boolean;
|
|
311
|
-
[propName: string]: any;
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
/**
|
|
315
|
-
* parseJson 未开启:Promise<string>
|
|
316
|
-
* parseJson 开启且解析成功:Promise<object | any[]>
|
|
317
|
-
* parseJson 开启且解析失败:Promise<null>
|
|
318
|
-
*/
|
|
319
|
-
async function agent.chat(params: ChatAgentParams): Promise<string | object | any[] | null>
|
|
320
|
-
```
|
|
321
|
-
|
|
322
|
-
### 参数说明
|
|
323
|
-
|
|
324
|
-
| 参数名 | 含义 | 备注 |
|
|
325
|
-
|--------|------|------|
|
|
326
|
-
| `url` | Agent 服务完整 URL | **必填**;空字符串会抛错 |
|
|
327
|
-
| `query` | 用户查询文本 | **必填**;空字符串会抛错 |
|
|
328
|
-
| `parseJson` | 是否解析返回 JSON | 默认不解析,返回拼接后的 string。为 `true` 时尝试从正文或 markdown 的 json 代码块中提取 JSON;多段合法 JSON 合并为数组;失败返回 `null`(不抛错) |
|
|
329
|
-
|
|
330
|
-
### 调用示例
|
|
331
|
-
|
|
332
|
-
```javascript
|
|
333
|
-
// 返回原始文本
|
|
334
|
-
const text = await this.context.agent.chat({
|
|
335
|
-
url: agentUrl,
|
|
336
|
-
query: '请根据以下实验数据给出结论:...',
|
|
337
|
-
});
|
|
338
|
-
|
|
339
|
-
// 期望 Agent 返回 JSON,解析失败时得到 null
|
|
340
|
-
const result = await this.context.agent.chat({
|
|
341
|
-
url: agentUrl,
|
|
342
|
-
query: prompt,
|
|
343
|
-
parseJson: true
|
|
344
|
-
});
|
|
345
|
-
if (result == null) {
|
|
346
|
-
throw new Error('agent.chat: failed to parse JSON from response');
|
|
347
|
-
}
|
|
348
|
-
```
|
|
349
|
-
|
|
350
|
-
### 返回说明
|
|
351
|
-
|
|
352
|
-
| 场景 | 返回值 |
|
|
353
|
-
|------|--------|
|
|
354
|
-
| `parseJson` 未开启 / 为 `false` | `string`:流式各 chunk `content` 的拼接结果 |
|
|
355
|
-
| `parseJson: true` 且解析成功 | `object` 或 `any[]` |
|
|
356
|
-
| `parseJson: true` 且解析失败 | `null` |
|
|
357
|
-
| 请求 / 流读取失败 | 抛出 `Error`,消息以 `agent.chat:` 为前缀 |
|
|
358
|
-
|
|
359
|
-
### 请求体要点(SDK 封装,门控不必手拼)
|
|
360
|
-
|
|
361
|
-
SDK 向 `url` 发送的 JSON 主体主要包括:`query`、`messages`、`context_link`、`message_id`、`response_mode`、`agent_params_global`、`user_info`、`skills`。Header 使用 `Authorization: Bearer <api_key>`。门控脚本侧只需组装 `ChatAgentParams` 并调用 **`this.context.agent.chat(params)`**。
|
|
1
|
+
# Agentic Lab SDK
|
|
2
|
+
|
|
3
|
+
# API 文档
|
|
4
|
+
|
|
5
|
+
本节为 **`this.context` 门控/SDK 能力**约定。**`process.execute`** 须传入任务数组 **`items`** 与服务根 **`baseURL`**(Rhea 或等价 Process 服务地址);单次请求的 **path、HTTP 方法** 仍与 Wire 文档一致并由 **SDK 封装**,门控不拼完整 URL。其余常见查询类能力仍以 SDK 封装为主。`items` 单项形状与 **[`rhea-api/execute_process_batch.md`](rhea-api/execute_process_batch.md)** 中请求体 `items[]` 一项对齐。
|
|
6
|
+
|
|
7
|
+
## 门控脚本生成约定(lab-flow-designer)
|
|
8
|
+
|
|
9
|
+
对 **`ticket.list`**、**`process.list`** 等支持 **`limit` / `offset`** 的查询:若流程说明**未**明确要求分页或条数,生成门控脚本时应显式传入 **`limit: 999999`**、**`offset: 0`**,避免引擎默认小页长截断。若流程说明写了分页或「查全部」的**具体数值**,以流程说明为准。
|
|
10
|
+
|
|
11
|
+
> **`compound.getStockFromXfcSh`** 使用 `pageSize` / `page` 分页(非 `limit` / `offset`),不传分页参数时使用 API 默认值。
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## 可用方法一览
|
|
16
|
+
|
|
17
|
+
| 方法 | 命名空间 | 用途 | 分页方式 |
|
|
18
|
+
|------|----------|------|----------|
|
|
19
|
+
| `pool.getNext(valveId)` | `context.pool` | 获取指定门控的出口池数组 | 无 |
|
|
20
|
+
| `ticket.list(params)` | `context.ticket` | 按条件筛选并分页返回 ticket 列表 | `limit` / `offset` |
|
|
21
|
+
| `ticket.update(tickets)` | `context.ticket` | 批量更新 ticket | 无 |
|
|
22
|
+
| `ticket.append(tickets)` | `context.ticket` | 批量追加 ticket | 无 |
|
|
23
|
+
| `process.list(params)` | `context.process` | 查询 process 列表 | `limit` / `offset` |
|
|
24
|
+
| `process.execute(items, baseURL)` | `context.process` | 批量提交 Process 执行任务 | 无 |
|
|
25
|
+
| `station.list()` | `context.station` | 列出所有工站 | 无 |
|
|
26
|
+
| `compound.getStockFromXfcSh(params)` | `context.compound` | 获取 XFC 上海化合物库存 | `pageSize` / `page` |
|
|
27
|
+
| `agent.chat(params)` | `context.agent` | 调用外部 Agent(流式/非流式),返回文本或解析后的 JSON | 无 |
|
|
28
|
+
|
|
29
|
+
> 生成「核心概念」中的 `this.context` 能力列表时,从本表选取流程实际使用的方法即可。各方法的完整签名、参数类型与返回类型见下文各节。
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## pool.getNext
|
|
34
|
+
|
|
35
|
+
- **别名**:`context.pool.getNext`
|
|
36
|
+
- **描述**:获取指定门控节点的出口池(返回出口池数组)
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
interface Pool {
|
|
40
|
+
id: number;
|
|
41
|
+
name: string;
|
|
42
|
+
description: string;
|
|
43
|
+
schema: {
|
|
44
|
+
fields: Array<Record<string, any>>;
|
|
45
|
+
};
|
|
46
|
+
type: PoolType;
|
|
47
|
+
}
|
|
48
|
+
async function pool.getNext(valveId: number): Promise<Pool[]>
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## ticket.list
|
|
54
|
+
|
|
55
|
+
- **别名**:`context.ticket.list`
|
|
56
|
+
- **描述**:按 `ListTicketParams` 筛选并分页返回 **`TicketListResponse`**(`{ list: Ticket[] }`)。业务上取 **`response.list`** 得到 ticket 数组。`limit` **默认 20**、`offset` **默认 0**(以引擎实现为准)。可选组合:`flow_id__in`、`order_id__in`、`pool_id__in`、`status__in`、单条主键 `id`。**`id` 仅筛选一条**;若需按多条主键召回而类型中尚无 `id__in` 等批量字段,以运行环境为准(可分次传入 `id` 调用,或改用 `pool_id__in` + `status__in` 等缩小集合)。
|
|
57
|
+
|
|
58
|
+
```typescript
|
|
59
|
+
interface ListTicketParams {
|
|
60
|
+
flow_id__in?: number[];
|
|
61
|
+
order_id__in?: number[];
|
|
62
|
+
pool_id__in?: number[]; // 按 pool 筛选
|
|
63
|
+
status__in?: string[];
|
|
64
|
+
id?: number; // 按 ticket 筛选(单条主键)
|
|
65
|
+
limit: number; // 默认为 20
|
|
66
|
+
offset: number; // 默认为 0
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
interface Ticket {
|
|
70
|
+
id: number;
|
|
71
|
+
flow_id: number;
|
|
72
|
+
pool_id: number;
|
|
73
|
+
order_id: number;
|
|
74
|
+
parent_ticket_id: number;
|
|
75
|
+
detail: Record<string, any>;
|
|
76
|
+
status: string;
|
|
77
|
+
uuid: string;
|
|
78
|
+
createdAt?: Date | number;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** `ticket.list` 返回体;列表字段为 `list` */
|
|
82
|
+
interface TicketListResponse {
|
|
83
|
+
list: Ticket[];
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
async function ticket.list(
|
|
87
|
+
params: ListTicketParams,
|
|
88
|
+
): Promise<TicketListResponse>
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## ticket.update
|
|
94
|
+
|
|
95
|
+
- **别名**:`context.ticket.update`
|
|
96
|
+
- **描述**:批量更新 ticket
|
|
97
|
+
|
|
98
|
+
```typescript
|
|
99
|
+
async function ticket.update(tickets: Ticket[]): Promise<void>
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## ticket.append
|
|
105
|
+
|
|
106
|
+
- **别名**:`context.ticket.append`
|
|
107
|
+
- **描述**:批量追加 ticket。`status` 未传时由引擎采用默认状态(以实现为准);`parent_ticket_id` 用于挂接父 ticket,无父子关系时可省略。
|
|
108
|
+
|
|
109
|
+
```typescript
|
|
110
|
+
enum TicketStatus {
|
|
111
|
+
Created = 'created',
|
|
112
|
+
Running = 'running',
|
|
113
|
+
Finished = 'finished',
|
|
114
|
+
Failed = 'failed',
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
interface CreateTicketParams {
|
|
118
|
+
flow_id: number;
|
|
119
|
+
pool_id: number;
|
|
120
|
+
order_id: number;
|
|
121
|
+
detail: Record<string, any>;
|
|
122
|
+
status?: TicketStatus | string;
|
|
123
|
+
parent_ticket_id?: number;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
async function ticket.append(tickets: CreateTicketParams[]): Promise<Ticket[]>
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
## process.list
|
|
132
|
+
|
|
133
|
+
- **别名**:`context.process.list`
|
|
134
|
+
- **描述**:查询 Bluprint process(process/list_process)
|
|
135
|
+
|
|
136
|
+
```typescript
|
|
137
|
+
interface ListProcessParams {
|
|
138
|
+
processIds?: string[]; // 按 exp_id 筛选
|
|
139
|
+
limit: number; // 默认为20
|
|
140
|
+
offset: number; // 默认为0
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
async function process.list(params: ListProcessParams): Promise<any>
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
## process.execute
|
|
149
|
+
|
|
150
|
+
- **别名**:`context.process.execute`
|
|
151
|
+
- **描述**:流程说明中需要 **Process 执行 / 设备侧批量提交任务** 时调用。传入 **`items`**(与 Rhea 请求体 **`items` 数组**同形;每项**必填** **`process`(流程模板名)**、**`params`**;**`table_objects`** 等可选字段的拼装须由流程文档写清)及 **`baseURL`**(服务根地址,如 `https://rhea.example.com`)。**path、HTTP 方法** 由 SDK 按 Wire 固定,门控不传。返回数据形如 **`{ results: { … } }`**,具体键名以实现为准。
|
|
152
|
+
|
|
153
|
+
```typescript
|
|
154
|
+
// baseURL: 服务地址
|
|
155
|
+
// 返回数据形如 { results: { ... } }
|
|
156
|
+
|
|
157
|
+
/** 单条任务:与 Rhea `items[]` 一项对齐;必填性以 rhea-api/execute_process_batch.md 为准 */
|
|
158
|
+
interface ExecuteProcessItem {
|
|
159
|
+
exp_name?: string;
|
|
160
|
+
/** 流程模板名称(流程文档中的 process / process_name) */
|
|
161
|
+
process: string;
|
|
162
|
+
priority?: number;
|
|
163
|
+
/** 流程参数,键值以流程文档为准 */
|
|
164
|
+
params: Record<string, unknown>;
|
|
165
|
+
/** 表对象,如 `{ 表名: { id: value } }`,以流程文档为准;无表绑定时可省略 */
|
|
166
|
+
table_objects?: Record<string, Record<string, unknown>>;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/** 典型成功响应;`results` 内字段以实现为准(如 `exp_id_list`) */
|
|
170
|
+
interface ExecuteProcessResult {
|
|
171
|
+
results?: {
|
|
172
|
+
exp_id_list?: string[];
|
|
173
|
+
[key: string]: unknown;
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
async function process.execute(
|
|
178
|
+
items: ExecuteProcessItem[],
|
|
179
|
+
baseURL: string,
|
|
180
|
+
): Promise<ExecuteProcessResult>
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
- **Wire 与实现参考**(供 SDK 实现者):URL 路径、方法、示例请求体见 [rhea-api/execute_process_batch.md](rhea-api/execute_process_batch.md)。
|
|
184
|
+
- **流程文档侧**:写明**何时调用**、**`baseURL` 语义来源**(配置键、环境变量名、或 ticket/订单字段等,由集成解析为字符串 URL)、每条 **`process`**、**`params` 键与取值来源**;若需表绑定再写 **`table_objects`**。**不要求**写 path / HTTP 方法。生成 `valves/*.md` 与 `scripts/*.js` 须能追溯到上述说明;脚本调用形态为 **`this.context.process.execute(items, baseURL)`**。
|
|
185
|
+
|
|
186
|
+
---
|
|
187
|
+
|
|
188
|
+
## station.list
|
|
189
|
+
|
|
190
|
+
- **别名**:`context.station.list`
|
|
191
|
+
- **描述**:列出所有工站
|
|
192
|
+
|
|
193
|
+
```typescript
|
|
194
|
+
async function station.list(): Promise<Station[]>
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
---
|
|
198
|
+
|
|
199
|
+
## compound.getStockFromXfcSh
|
|
200
|
+
|
|
201
|
+
- **别名**:`context.compound.getStockFromXfcSh`
|
|
202
|
+
- **描述**:获取 XFC 上海系统化合物库存。使用 `pageSize` / `page` 分页(非 `limit` / `offset`),不传分页参数时使用 API 默认值(默认 `pageSize: 400`、`page: 1`)。
|
|
203
|
+
|
|
204
|
+
```typescript
|
|
205
|
+
interface StockFromXfcShParams {
|
|
206
|
+
filter?: Record<string, any>;
|
|
207
|
+
fields?: string[] | string;
|
|
208
|
+
pageSize?: number;
|
|
209
|
+
page?: number;
|
|
210
|
+
[propName: string]: any;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
async function compound.getStockFromXfcSh(
|
|
214
|
+
params?: StockFromXfcShParams
|
|
215
|
+
): Promise<CompoundResponse>
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
### 参数说明
|
|
219
|
+
|
|
220
|
+
| 参数名 | 含义 | 备注 |
|
|
221
|
+
|--------|------|------|
|
|
222
|
+
| `filter` | 筛选条件 | 查询化合物常用 `cas`、`cmpd_id`;**不传时默认筛选 `'status': '可用'`**。使用 **dot-notation** 格式(如 `'cas.$in': [...]`),**非**嵌套对象格式 |
|
|
223
|
+
| `fields` | 查询返回的字段 | **默认返回字段(不传时)**:`id, cas, status, source, barcode, cmpd_id, owner`。**全部可用字段**:`barcode, cas, cmpd_id, po_num, source, owner, hazard_class_adr, odor, initial_weight, initial_amount, initial_checkin_time, latest_weight, latest_amount_mg, latest_amount_ml, latest_checkin_time, latest_checkout_time, latest_location, location_detail, checkin_user, status, checkout_user, chemical_name`。**外键**:`f_category, f_account, f_latest_request_user, f_project` |
|
|
224
|
+
| `pageSize` | 分页大小 | 默认 `400` |
|
|
225
|
+
| `page` | 页码 | 默认 `1` |
|
|
226
|
+
|
|
227
|
+
### 调用示例
|
|
228
|
+
|
|
229
|
+
```javascript
|
|
230
|
+
const xfcStockSH = await this.context.compound.getStockFromXfcSh({
|
|
231
|
+
filter: {
|
|
232
|
+
'cas.$in': ['1065657-51-3']
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
// xfcStockSH.data → 数据数组
|
|
236
|
+
// xfcStockSH.meta → 分页信息
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
### 返回类型
|
|
240
|
+
|
|
241
|
+
```typescript
|
|
242
|
+
interface CompoundItem {
|
|
243
|
+
id: number;
|
|
244
|
+
cas: string;
|
|
245
|
+
status: string;
|
|
246
|
+
source: string;
|
|
247
|
+
barcode: string;
|
|
248
|
+
cmpd_id: string;
|
|
249
|
+
owner: string;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
interface CompoundMeta {
|
|
253
|
+
count: number;
|
|
254
|
+
page: number;
|
|
255
|
+
pageSize: number;
|
|
256
|
+
totalPage: number;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
interface CompoundResponse {
|
|
260
|
+
data: CompoundItem[];
|
|
261
|
+
meta: CompoundMeta;
|
|
262
|
+
}
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
### 返回数据示例
|
|
266
|
+
|
|
267
|
+
```json
|
|
268
|
+
{
|
|
269
|
+
"data": [
|
|
270
|
+
{
|
|
271
|
+
"id": 151,
|
|
272
|
+
"cas": "1065657-51-3",
|
|
273
|
+
"status": "可用",
|
|
274
|
+
"source": "上海锐谱医药科技有限公司",
|
|
275
|
+
"barcode": "XFC25103100049",
|
|
276
|
+
"cmpd_id": "BA0062",
|
|
277
|
+
"owner": "张琳"
|
|
278
|
+
},
|
|
279
|
+
{
|
|
280
|
+
"id": 6613,
|
|
281
|
+
"cas": "1065657-51-3",
|
|
282
|
+
"status": "可用",
|
|
283
|
+
"source": "上海锐谱医药科技有限公司",
|
|
284
|
+
"barcode": "XFC25121900056",
|
|
285
|
+
"cmpd_id": "BA0062",
|
|
286
|
+
"owner": "张琳"
|
|
287
|
+
}
|
|
288
|
+
],
|
|
289
|
+
"meta": { "count": 2, "page": 1, "pageSize": 400, "totalPage": 1 }
|
|
290
|
+
}
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
---
|
|
294
|
+
|
|
295
|
+
## agent.chat
|
|
296
|
+
|
|
297
|
+
- **别名**:`context.agent.chat`
|
|
298
|
+
- **描述**:调用外部 Agent 服务。SDK 负责发起请求、消费流式(SSE / NDJSON)或普通 JSON 响应,并将各 chunk 的 `content` 拼接为完整文本。`url`、`query` **必填**。`parseJson: true` 时从返回文本中提取并解析 JSON(支持 Markdown 代码块与多段 JSON 合并);解析成功返回 object / array,失败返回 `null`。未开启 `parseJson` 时返回原始字符串。请求失败抛出以 `agent.chat:` 为前缀的错误。
|
|
299
|
+
|
|
300
|
+
```typescript
|
|
301
|
+
interface ChatAgentParams {
|
|
302
|
+
/** Agent 服务完整 URL(必填) */
|
|
303
|
+
url: string; // Agent 服务完整 URL(必填
|
|
304
|
+
/** 用户查询文本(必填;非空字符串) */
|
|
305
|
+
query: string;
|
|
306
|
+
/**
|
|
307
|
+
* true:从返回文本提取并解析 JSON,成功返回 object/array,失败返回 null;
|
|
308
|
+
* 未传或 false:返回拼接后的原始 string
|
|
309
|
+
*/
|
|
310
|
+
parseJson?: boolean;
|
|
311
|
+
[propName: string]: any;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* parseJson 未开启:Promise<string>
|
|
316
|
+
* parseJson 开启且解析成功:Promise<object | any[]>
|
|
317
|
+
* parseJson 开启且解析失败:Promise<null>
|
|
318
|
+
*/
|
|
319
|
+
async function agent.chat(params: ChatAgentParams): Promise<string | object | any[] | null>
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
### 参数说明
|
|
323
|
+
|
|
324
|
+
| 参数名 | 含义 | 备注 |
|
|
325
|
+
|--------|------|------|
|
|
326
|
+
| `url` | Agent 服务完整 URL | **必填**;空字符串会抛错 |
|
|
327
|
+
| `query` | 用户查询文本 | **必填**;空字符串会抛错 |
|
|
328
|
+
| `parseJson` | 是否解析返回 JSON | 默认不解析,返回拼接后的 string。为 `true` 时尝试从正文或 markdown 的 json 代码块中提取 JSON;多段合法 JSON 合并为数组;失败返回 `null`(不抛错) |
|
|
329
|
+
|
|
330
|
+
### 调用示例
|
|
331
|
+
|
|
332
|
+
```javascript
|
|
333
|
+
// 返回原始文本
|
|
334
|
+
const text = await this.context.agent.chat({
|
|
335
|
+
url: agentUrl,
|
|
336
|
+
query: '请根据以下实验数据给出结论:...',
|
|
337
|
+
});
|
|
338
|
+
|
|
339
|
+
// 期望 Agent 返回 JSON,解析失败时得到 null
|
|
340
|
+
const result = await this.context.agent.chat({
|
|
341
|
+
url: agentUrl,
|
|
342
|
+
query: prompt,
|
|
343
|
+
parseJson: true
|
|
344
|
+
});
|
|
345
|
+
if (result == null) {
|
|
346
|
+
throw new Error('agent.chat: failed to parse JSON from response');
|
|
347
|
+
}
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
### 返回说明
|
|
351
|
+
|
|
352
|
+
| 场景 | 返回值 |
|
|
353
|
+
|------|--------|
|
|
354
|
+
| `parseJson` 未开启 / 为 `false` | `string`:流式各 chunk `content` 的拼接结果 |
|
|
355
|
+
| `parseJson: true` 且解析成功 | `object` 或 `any[]` |
|
|
356
|
+
| `parseJson: true` 且解析失败 | `null` |
|
|
357
|
+
| 请求 / 流读取失败 | 抛出 `Error`,消息以 `agent.chat:` 为前缀 |
|
|
358
|
+
|
|
359
|
+
### 请求体要点(SDK 封装,门控不必手拼)
|
|
360
|
+
|
|
361
|
+
SDK 向 `url` 发送的 JSON 主体主要包括:`query`、`messages`、`context_link`、`message_id`、`response_mode`、`agent_params_global`、`user_info`、`skills`。Header 使用 `Authorization: Bearer <api_key>`。门控脚本侧只需组装 `ChatAgentParams` 并调用 **`this.context.agent.chat(params)`**。
|
|
362
|
+
|
|
363
|
+
|
|
364
|
+
|
|
365
|
+
## compound.returnCmpdToXfcSh
|
|
366
|
+
|
|
367
|
+
- **别名**:`context.compound.returnCmpdToXfcSh`
|
|
368
|
+
- **描述**:执行 XFC 上海系统化合物批量退库功能。通过传入需要批量退库的化合物数组(包含化合物barcode、剩余重量、退库位置)以及可选参数(如执行退库人),执行业务的批量退库功能,并返回完成退库的化合物信息数组。
|
|
369
|
+
|
|
370
|
+
```typescript
|
|
371
|
+
interface ReturnCmpdToXfcShItem {
|
|
372
|
+
barcode: string;
|
|
373
|
+
latest_weight: number;
|
|
374
|
+
location: string;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
interface ReturnCmpdToXfcShOptions {
|
|
378
|
+
submit_user?: string;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
interface ReturnCmpdToXfcShParams {
|
|
382
|
+
items: ReturnCmpdToXfcShItem[];
|
|
383
|
+
options?: ReturnCmpdToXfcShOptions;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
### 参数说明
|
|
389
|
+
|
|
390
|
+
| 参数名 | 含义 | 是否必填 | 示例 |
|
|
391
|
+
| :------ | :------------- | :------- | :----------------------------------------------------------- |
|
|
392
|
+
| items | 退库化合物列表 | 是 | `[ { barcode: 'XFC26071300041', latest_weight: 1, // 单位为g,退库重量(含瓶身) location: 'KWA-R00-L0-A00', // 注意:此location必须是位置映射表中存在的库外位置 }, { barcode: 'XFC26071300042', latest_weight: 1, location: 'KWA-R00-L0-A00', } ]` |
|
|
393
|
+
| options | 可选参数 | 否 | `{ submit_user: 'shuyan.wang' // 退库check in单提交人,默认为lab }` |
|
|
394
|
+
|
|
395
|
+
|
|
396
|
+
|
|
397
|
+
### 调用示例
|
|
398
|
+
|
|
399
|
+
```javascript
|
|
400
|
+
const res = await sdk.compound.returnCmpdToXfcSh([
|
|
401
|
+
{
|
|
402
|
+
barcode: 'XFC26071300031',
|
|
403
|
+
latest_weight: 2,
|
|
404
|
+
location: 'KWA-R00-L0-A00',
|
|
405
|
+
},
|
|
406
|
+
{
|
|
407
|
+
barcode: 'XFC26071300032',
|
|
408
|
+
latest_weight: 0.1,
|
|
409
|
+
location: 'KWA-R00-L0-A00',
|
|
410
|
+
},
|
|
411
|
+
{
|
|
412
|
+
barcode: 'XFC26071300033',
|
|
413
|
+
latest_weight: 0.5,
|
|
414
|
+
location: 'KWA-R00-L0-A00',
|
|
415
|
+
},
|
|
416
|
+
], { submit_user: 'shuyan.wang' })
|
|
417
|
+
// res → 完成退库的化合物数据数组
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
|
|
421
|
+
|
|
422
|
+
### 返回类型
|
|
423
|
+
|
|
424
|
+
```typescript
|
|
425
|
+
interface CmpdItem {
|
|
426
|
+
createdAt: string;
|
|
427
|
+
updatedAt: string;
|
|
428
|
+
initial_checkin_time: string;
|
|
429
|
+
latest_checkin_time: string;
|
|
430
|
+
latest_checkout_time: string | null;
|
|
431
|
+
id: number;
|
|
432
|
+
cas: string | null;
|
|
433
|
+
po_num: string | null;
|
|
434
|
+
f_account: number;
|
|
435
|
+
f_project: number;
|
|
436
|
+
source: string;
|
|
437
|
+
barcode: string;
|
|
438
|
+
cmpd_id: string;
|
|
439
|
+
owner: string;
|
|
440
|
+
f_category: number;
|
|
441
|
+
hazard_class_adr: string | null;
|
|
442
|
+
odor: string;
|
|
443
|
+
initial_amount: number;
|
|
444
|
+
initial_weight: number;
|
|
445
|
+
latest_weight: number;
|
|
446
|
+
latest_amount_mg: number;
|
|
447
|
+
latest_amount_ml: number;
|
|
448
|
+
latest_location: string;
|
|
449
|
+
location_detail: Record<string, any>;
|
|
450
|
+
f_latest_request_user: number;
|
|
451
|
+
status: string;
|
|
452
|
+
checkin_user: string;
|
|
453
|
+
checkout_user: string;
|
|
454
|
+
chemical_name: string | null;
|
|
455
|
+
createdById: number | null;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
async returnCmpdToXfcSh(
|
|
459
|
+
items: ReturnCmpdToXfcShItem[],
|
|
460
|
+
options: ReturnCmpdToXfcShOptions = {},
|
|
461
|
+
): Promise<CmpdItem[]> {}
|
|
462
|
+
```
|
|
463
|
+
|
|
464
|
+
### 返回数据示例
|
|
465
|
+
|
|
466
|
+
```json
|
|
467
|
+
[
|
|
468
|
+
{
|
|
469
|
+
"createdAt": "2026-07-13T09:55:20.578Z",
|
|
470
|
+
"updatedAt": "2026-07-23T06:03:58.221Z",
|
|
471
|
+
"initial_checkin_time": "2026-07-13T09:55:20.577Z",
|
|
472
|
+
"latest_checkin_time": "2026-07-23T06:03:58.143Z",
|
|
473
|
+
"latest_checkout_time": "2026-07-13T10:27:41.293Z",
|
|
474
|
+
"id": 9720,
|
|
475
|
+
"cas": "220598-45-8",
|
|
476
|
+
"po_num": "PO20250821000113",
|
|
477
|
+
"f_account": 39,
|
|
478
|
+
"f_project": 81,
|
|
479
|
+
"source": "上海皓鸿生物医药科技有限公司",
|
|
480
|
+
"barcode": "XFC26071300041",
|
|
481
|
+
"cmpd_id": "BC0998",
|
|
482
|
+
"owner": "李辉",
|
|
483
|
+
"f_category": 1,
|
|
484
|
+
"hazard_class_adr": null,
|
|
485
|
+
"odor": "",
|
|
486
|
+
"initial_amount": 100,
|
|
487
|
+
"initial_weight": 1,
|
|
488
|
+
"latest_weight": 1,
|
|
489
|
+
"latest_amount_mg": 100,
|
|
490
|
+
"latest_amount_ml": 1,
|
|
491
|
+
"latest_location": "KWA-R00-L0-A00",
|
|
492
|
+
"location_detail": {},
|
|
493
|
+
"f_latest_request_user": 11,
|
|
494
|
+
"status": "可用",
|
|
495
|
+
"checkin_user": "xtalppi",
|
|
496
|
+
"checkout_user": "auto",
|
|
497
|
+
"chemical_name": null,
|
|
498
|
+
"createdById": null
|
|
499
|
+
},
|
|
500
|
+
{
|
|
501
|
+
"createdAt": "2026-07-13T09:56:36.025Z",
|
|
502
|
+
"updatedAt": "2026-07-23T06:03:58.225Z",
|
|
503
|
+
"initial_checkin_time": "2026-07-13T09:56:36.024Z",
|
|
504
|
+
"latest_checkin_time": "2026-07-23T06:03:58.143Z",
|
|
505
|
+
"latest_checkout_time": "2026-07-13T10:27:41.293Z",
|
|
506
|
+
"id": 9721,
|
|
507
|
+
"cas": "851288-57-8",
|
|
508
|
+
"po_num": "PO20250821000113",
|
|
509
|
+
"f_account": 39,
|
|
510
|
+
"f_project": 81,
|
|
511
|
+
"source": "上海皓鸿生物医药科技有限公司",
|
|
512
|
+
"barcode": "XFC26071300042",
|
|
513
|
+
"cmpd_id": "CA5019",
|
|
514
|
+
"owner": "李辉",
|
|
515
|
+
"f_category": 1,
|
|
516
|
+
"hazard_class_adr": null,
|
|
517
|
+
"odor": "",
|
|
518
|
+
"initial_amount": 100,
|
|
519
|
+
"initial_weight": 1,
|
|
520
|
+
"latest_weight": 1,
|
|
521
|
+
"latest_amount_mg": 100,
|
|
522
|
+
"latest_amount_ml": 1,
|
|
523
|
+
"latest_location": "KWA-R00-L0-A00",
|
|
524
|
+
"location_detail": {},
|
|
525
|
+
"f_latest_request_user": 11,
|
|
526
|
+
"status": "可用",
|
|
527
|
+
"checkin_user": "xtalppi",
|
|
528
|
+
"checkout_user": "auto",
|
|
529
|
+
"chemical_name": null,
|
|
530
|
+
"createdById": null
|
|
531
|
+
}
|
|
532
|
+
]
|
|
533
|
+
```
|
|
534
|
+
|