@delta-infra/cli 1.1.15 → 1.1.16

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
@@ -293,8 +293,10 @@ delta-cli sandbox kill <sandbox_id>
293
293
  v1.1.1 起线上 catalog 已包含 `qe`(Quantum ESPRESSO DFT,20 个端点:任务提交/查询/
294
294
  日志/artifact/PP 库等)与 `materials-design`(持久化材料代理建模,7 个端点:
295
295
  health/capabilities/job-submit(multipart)/job-status/job-cancel 等)。用法见
296
- Skill 文档 `skills/delta-science/references/qe.md` 与
297
- `skills/delta-science/references/materials-design.md`。
296
+ Skill 文档 `skills/delta-science/references/qe.md` 与
297
+ `skills/delta-science/references/materials-design.md`。
298
+ 云端 XRD 的相识别、artifact、CIF 模拟和精修契约见
299
+ `skills/delta-science/references/xrd.md`。
298
300
 
299
301
  ## 输出格式
300
302
 
@@ -336,7 +338,7 @@ Skill 文件位于 `skills/` 目录:
336
338
  - `delta-shared/` — 全局通用规则(认证、配置、错误处理)
337
339
  - `delta-sandbox/` — Sandbox 操作指南(生命周期、命令路由)
338
340
  - `delta-science/` — 唯一 Science 入口,包含统一 Delta CLI wrapper、跨工具工作流和
339
- PubChem、RDKit、pymatgen、GSAS-II、LAMMPS、Delta-BO、LDM-BO、SynBO、AntBO
341
+ PubChem、RDKit、pymatgen、XRD、GSAS-II、LAMMPS、Delta-BO、LDM-BO、SynBO、AntBO
340
342
  的按需 reference
341
343
 
342
344
  Memento 等宿主只需要选择 `delta-science`。Skill 根据自然语言科研目标选择 tool 和
@@ -437,7 +439,7 @@ make release
437
439
  ```bash
438
440
  export GH_TOKEN=<your-github-pat>
439
441
  export NPM_TOKEN=<your-npm-token>
440
- ./release.sh v1.1.15
442
+ ./release.sh v1.1.16
441
443
  ```
442
444
 
443
445
  脚本执行步骤:
package/checksums.txt CHANGED
@@ -1,5 +1,5 @@
1
- 79b30a0169261a0db4e862ee0f3d2b74946d1bff58b80ed96fca67deba0ae847 *delta-cli-darwin-amd64.tar.gz
2
- f40d24e602c5208974a8d4cd4869d76aad5a72af1a1dd98a660ad43ee42189f7 *delta-cli-darwin-arm64.tar.gz
3
- 1e5c118d9bfafb852b766a69d9f972aca956a2d92492cc8e0561ed4dbac90a8e *delta-cli-linux-amd64.tar.gz
4
- ef4fb5116c5d6972450b55b5fadba42757cbfc4fc578f504236ebd0af655f003 *delta-cli-linux-arm64.tar.gz
5
- ebb01fd6d036f787305858981e86250699f8807f362b0463881c229983e52e62 *delta-cli-windows-amd64.zip
1
+ 14ab0d943d50009a3caa7d5ee2db13e557de36dc39a347e67ae90f88cae582d6 *delta-cli-darwin-amd64.tar.gz
2
+ 998c5188c25ec474818cf8aca047e349303d26208e900379b8e7e053babc7d82 *delta-cli-darwin-arm64.tar.gz
3
+ c019843ac23cdf3f09f902686c6cdb0bfaa31136aa7d89cb32989992b1f2c255 *delta-cli-linux-amd64.tar.gz
4
+ 6ca4f2b73f99d1f78f339e2f171a7223d16b0a7a9e2e4667c1f8e418e9c9bedd *delta-cli-linux-arm64.tar.gz
5
+ 954bbd88f9ba7f706ec2e5106e0bba850553d809816a23cac30e2882a9753792 *delta-cli-windows-amd64.zip
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@delta-infra/cli",
3
- "version": "1.1.15",
3
+ "version": "1.1.16",
4
4
  "description": "Delta Agent Cloud CLI for sandbox compute and science tools.",
5
5
  "bin": {
6
6
  "delta-cli": "scripts/run.js"
@@ -17,7 +17,7 @@ delta-science/
17
17
  └── references/
18
18
  └── <tool>.md # one real tool's operation contract (pubchem, rdkit, pymatgen,
19
19
  # gsasii, lammps, delta-bo, ldm-bo, materials-design, qe,
20
- # strbo, synbo, antbo)
20
+ # strbo, synbo, antbo, xrd)
21
21
  ```
22
22
 
23
23
  ## WHERE TO LOOK
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: delta-science
3
- description: "公司在线 Science 能力的统一入口,所有调用都经 Delta CLI。凡是查询具体化合物/CID/SMILES/分子性质、批量 PubChem 与 RDKit 分子增强、计算分子描述符或相似度、解析晶体/CIF/空间群、材料表格建模与候选推荐、Quantum ESPRESSO/QE DFT、模拟或精修 XRD、执行 LAMMPS、根据实验数据做贝叶斯优化、反应条件优化,以及任何 LDM/大发现模型、KRAS G12D 小分子生成优化、固定候选池/PDF2Dock 轨迹或抗体 CDRH3 优化任务,都必须使用本 Skill;不得调用旧 large-discovery-model Skill、旧 gateway 脚本、网页搜索或本地科学库绕过 Delta CLI。普通查询、比较或校验默认直接返回文本,不要主动增加 JSON/CSV、报告、图片或图表步骤;只有用户明确要求保存、导出、绘图或生成文件时才创建产物。"
3
+ description: "公司在线 Science 能力的统一入口,所有调用都经 Delta CLI。凡是查询具体化合物/CID/SMILES/分子性质、批量 PubChem 与 RDKit 分子增强、计算分子描述符或相似度、解析晶体/CIF/空间群、云端 XRD 相识别与精修、材料表格建模与候选推荐、Quantum ESPRESSO/QE DFT、执行 LAMMPS、根据实验数据做贝叶斯优化、反应条件优化,以及任何 LDM/大发现模型、KRAS G12D 小分子生成优化、固定候选池/PDF2Dock 轨迹或抗体 CDRH3 优化任务,都必须使用本 Skill;不得调用旧 large-discovery-model Skill、旧 gateway 脚本、网页搜索或本地科学库绕过 Delta CLI。普通查询、比较或校验默认直接返回文本,不要主动增加 JSON/CSV、报告、图片或图表步骤;只有用户明确要求保存、导出、绘图或生成文件时才创建产物。"
4
4
  metadata:
5
5
  requires:
6
6
  bins: ["delta-cli"]
@@ -88,7 +88,8 @@ catalog、render、descriptors 或文件操作;用户请求、诊断需要或
88
88
  | 化合物身份、CID、同义词、公共属性、名称转 SMILES | `pubchem` | [pubchem.md](references/pubchem.md) |
89
89
  | SMILES/InChI、描述符、指纹、相似度、渲染、子结构 | `rdkit` | [rdkit.md](references/rdkit.md) |
90
90
  | 无机化学式、CIF/POSCAR、晶体结构、空间群 | `pymatgen` | [pymatgen.md](references/pymatgen.md) |
91
- | 粉末衍射模拟、Rietveld 精修 | `gsasii` | [gsasii.md](references/gsasii.md) |
91
+ | 云端 XRD 相识别、XQueryer/XMatcher/XDecomposer、CIF 模拟、MP500、artifact 与精修作业 | `xrd` | [xrd.md](references/xrd.md) |
92
+ | 直接 GSAS-II 模拟或精修 | `gsasii` | [gsasii.md](references/gsasii.md) |
92
93
  | 分子动力学、最小化、thermo 与输出文件 | `lammps` | [lammps.md](references/lammps.md) |
93
94
  | 通用数值/整数/分类实验变量优化 | `delta-bo` | [delta-bo.md](references/delta-bo.md) |
94
95
  | 表格材料 surrogate、候选空间、EI/PI/UCB 与异步推荐作业 | `materials-design` | [materials-design.md](references/materials-design.md) |
@@ -118,8 +119,10 @@ catalog、render、descriptors 或文件操作;用户请求、诊断需要或
118
119
  ## 路由边界
119
120
 
120
121
  - 普通分子名称先用 PubChem;只有需要结构计算时才把成功返回的 SMILES 交给 RDKit。
121
- - 无机化学式、组成和式量优先 pymatgen,不用 PubChem 或本地元素表补算。
122
- - 表格材料建模与候选排序使用 Materials Design;必须区分可控变量、目标、候选空间、
122
+ - 无机化学式、组成和式量优先 pymatgen,不用 PubChem 或本地元素表补算。
123
+ - 云端粉末 XRD 相识别、峰匹配、相分解、CIF/MP500 操作和精修生命周期使用 `xrd`;
124
+ 直接请求 GSAS-II 工具时才使用 `gsasii`。两者的 score、作业状态和后端语义不能混用。
125
+ - 表格材料建模与候选排序使用 Materials Design;必须区分可控变量、目标、候选空间、
123
126
  交叉验证和不确定性,推荐结果只是待验证假设。
124
127
  - 需要显式电子结构计算时使用 QE;先处理元素全集、PP policy/lock 和结构 artifact,
125
128
  再提交异步 workflow,不把作业接收、scheduler 完成或 solver 收敛混为一谈。
@@ -0,0 +1,186 @@
1
+ # XRD Cloud Compute 详细规则
2
+
3
+ `xrd` 是通过 Science 工具代理访问 XRD cloud compute 的真实工具。所有调用必须经由
4
+ `delta-cli`,禁止使用 broker URL、`curl`、`requests`、`httpx`、浏览器或本地 XRD
5
+ 科学库绕过 CLI。本文是 `delta-science` 的工具 reference,不是第二套 HTTP 客户端。
6
+
7
+ ## 工具与 endpoint
8
+
9
+ 执行前使用实时目录确认当前环境中的 canonical 名称和启用状态:
10
+
11
+ ```text
12
+ delta-cli science list
13
+ delta-cli science endpoints list xrd
14
+ ```
15
+
16
+ `xrd` endpoint 名称必须逐字取自第二条命令的结果。当前 reference 覆盖以下稳定契约:
17
+
18
+ | endpoint | 方法/用途 | 请求类型 |
19
+ | --- | --- | --- |
20
+ | `healthz`、`readyz`、`capabilities`、`xmatcher-status` | 就绪、能力和数据库状态 | 只读 JSON |
21
+ | `xmatcher-artifacts` | 上传观测曲线、模型输入、CIF 或仪器参数 | `invoke --file` |
22
+ | `xmatcher-artifact`、`xmatcher-artifact-content` | 查询/读取 artifact | `invoke --path-params` |
23
+ | `xqueryer-predictions` | XQueryer 单相候选预测 | JSON |
24
+ | `xmatcher-detect-peaks`、`xmatcher-match` | 峰检测和单相匹配 | JSON |
25
+ | `xmatcher-multiphase-match`、`xdecomposer-predictions` | 多相匹配和相分解 | JSON |
26
+ | `xmatcher-cif-xrd`、`xmatcher-pdf-peaks-xlsx` | CIF 模拟及 PDF 峰表导出 | JSON/二进制 |
27
+ | `xmatcher-refinement-patterns` | 生成精修输入和 provenance manifest | JSON |
28
+ | `refinement-fullprof`、`refinement-gsasii`、`refinement-wpem` | 提交对应后端精修作业 | JSON + header |
29
+ | `refinement-job`、`refinement-job-events`、`refinement-job-artifacts` | 查询精修作业 | `invoke --path-params` |
30
+ | `refinement-job-cancel` | 请求取消精修作业 | `invoke --path-params` |
31
+ | `mp500-cif-exports` | MP500 结构导出为 CIF | JSON |
32
+
33
+ 目录是最终权威。若 endpoint 不在实时目录中,停止并报告配置问题,不改名重试。
34
+
35
+ ## CLI 参数映射
36
+
37
+ ```text
38
+ --data 上游 JSON body
39
+ --params 上游 URL query 参数
40
+ --path-params 替换 endpoint path 中的 {artifact_id}/{job_id}
41
+ --headers 额外上游请求头,例如 Idempotency-Key
42
+ --file 将本地文件通过 file_base64 传给工具代理
43
+ --content-type file 的原始 MIME 类型
44
+ ```
45
+
46
+ `--params` 不能替代 `--path-params`。不要把本地路径、base64、路径参数或幂等键塞进
47
+ 普通业务 `--data`。`science file` 是 QE/Materials Design 等独立文件接口;XRD 的
48
+ `xmatcher-artifacts` 属于工具代理 endpoint,应使用 `science invoke --file`。
49
+
50
+ ## 调用顺序
51
+
52
+ 1. 用户明确要求诊断或执行时,先读取 `healthz`;需要选择后端时再读取
53
+ `capabilities`。
54
+ 2. 通过 `xmatcher-artifacts` 上传真实文件,保存返回的 `artifact_id` 和 `sha256`。
55
+ 3. 观测数据使用 `xmatcher-match`、`xmatcher-multiphase-match` 或
56
+ `xdecomposer-predictions`;XQueryer 使用 `model_input_pattern`。
57
+ 4. CIF 模拟使用 `xmatcher-cif-xrd`;精修先调用 `xmatcher-refinement-patterns`,再选择
58
+ 与 `data.backends` 一致的 refinement endpoint。
59
+ 5. 精修提交后用 `refinement-job`、`refinement-job-events` 和
60
+ `refinement-job-artifacts` 读取状态和产物。
61
+
62
+ 不要把服务返回的 queued、scheduler completed 或 backend success 直接描述成科学结论。
63
+ 精修至少分开报告传输/作业终态、后端执行状态和科学接受状态。
64
+
65
+ ## 就绪检查
66
+
67
+ ```text
68
+ delta-cli science invoke --tool xrd --endpoint healthz
69
+ delta-cli science invoke --tool xrd --endpoint capabilities
70
+ ```
71
+
72
+ 只有需要诊断或用户明确要求时才额外调用 readiness/status。能力结果中的每个所需组件
73
+ 都必须满足 `available`;生产任务还应检查 `asset_release_approved`、checksum 字段和
74
+ warnings。`auto` 不代表实际使用 GPU,只有结果明确返回 GPU backend 才能这样报告。
75
+
76
+ ## Artifact 上传与身份
77
+
78
+ 上传观测曲线:
79
+
80
+ ```text
81
+ delta-cli science invoke --tool xrd --endpoint xmatcher-artifacts `
82
+ --file observed.csv `
83
+ --params '{"filename":"observed.csv","kind":"observed_pattern","media_type":"text/csv"}' `
84
+ --content-type application/octet-stream
85
+ ```
86
+
87
+ 允许的 `kind` 为:`observed_pattern`、`model_input_pattern`、`cif`、
88
+ `instrument_parameters`。成功响应中的 `artifact_id` 和 `sha256` 必须成对保存并原样
89
+ 传给下游。模式文件会在服务端标准化,返回的 digest 是标准化 artifact 的 digest,
90
+ 不是一定等于本地上传字节的 digest。
91
+
92
+ 查询 artifact 时使用路径参数:
93
+
94
+ ```text
95
+ delta-cli science invoke --tool xrd --endpoint xmatcher-artifact `
96
+ --path-params '{"artifact_id":"art_<returned-id>"}'
97
+ ```
98
+
99
+ 二进制内容响应可能返回 `data._binary=true`、`content_base64`、`media_type` 和
100
+ `content_length`。只有用户要求保存或工作流需要时才解码,并按服务返回的 SHA-256
101
+ 校验;不要凭文件名猜测格式。
102
+
103
+ ## 相识别与匹配
104
+
105
+ XQueryer 的 `model_input_pattern` 必须正好包含 3500 个样本,覆盖 10 到 90 度 2theta,
106
+ 强度不超过服务能力限制:
107
+
108
+ ```text
109
+ delta-cli science invoke --tool xrd --endpoint xqueryer-predictions `
110
+ --data '{"schema_version":1,"pattern":{"artifact_id":"art_<model>","sha256":"<sha>"},"top_k":10,"radiation_profile":"CuKa"}'
111
+ ```
112
+
113
+ XMatcher 观测曲线:
114
+
115
+ ```text
116
+ delta-cli science invoke --tool xrd --endpoint xmatcher-match `
117
+ --data '{"schema_version":1,"pattern":{"artifact_id":"art_<observed>","sha256":"<sha>"},"top_n":10,"element_filter_mode":"contains"}'
118
+ ```
119
+
120
+ 多相匹配:
121
+
122
+ ```text
123
+ delta-cli science invoke --tool xrd --endpoint xmatcher-multiphase-match `
124
+ --data '{"schema_version":1,"pattern":{"artifact_id":"art_<observed>","sha256":"<sha>"},"max_phases":3,"candidate_pool":8}'
125
+ ```
126
+
127
+ `xqueryer-predictions` 的 `score` 是 softmax probability;XMatcher 的 `score` 是
128
+ `raw_score / 100`。两者不可直接平均或当作同一校准概率。
129
+
130
+ ## CIF 模拟与峰表
131
+
132
+ `cifs` 中的每个 artifact 都必须同时提供 `artifact_id` 和 `sha256`:
133
+
134
+ ```text
135
+ delta-cli science invoke --tool xrd --endpoint xmatcher-cif-xrd `
136
+ --data '{"schema_version":1,"cifs":[{"artifact":{"artifact_id":"art_<cif>","sha256":"<sha>"},"name":"phase"}],"two_theta_range":[5.0,90.0],"wavelength":"CuKa"}'
137
+ ```
138
+
139
+ `xmatcher-pdf-peaks-xlsx` 返回二进制 XLSX;只有用户要求导出时才读取和保存它。
140
+
141
+ ## 精修作业
142
+
143
+ 先生成校正曲线和 provenance manifest:
144
+
145
+ ```text
146
+ delta-cli science invoke --tool xrd --endpoint xmatcher-refinement-patterns `
147
+ --data '{"schema_version":1,"source_pattern":{"artifact_id":"art_<observed>","sha256":"<sha>"}}'
148
+ ```
149
+
150
+ 然后使用与 `data.backends` 匹配的 endpoint。示例结构如下,所有 artifact 身份必须来自
151
+ 当前调用链:
152
+
153
+ ```text
154
+ delta-cli science invoke --tool xrd --endpoint refinement-gsasii `
155
+ --data '{"schema_version":1,"radiation_profile":"CuKa","refinement_pattern":{"observed_pattern":{"artifact_id":"art_<obs>","sha256":"<sha>"},"corrected_pattern":{"artifact_id":"art_<corrected>","sha256":"<sha>"},"provenance_manifest":{"artifact_id":"art_<manifest>","sha256":"<sha>"}},"phases":[{"phase_index":0,"name":"phase","cif":{"artifact_id":"art_<cif>","sha256":"<sha>"}}],"wavelengths_angstrom":[1.540593,1.544414],"backends":["gsasii"]}' `
156
+ --headers '{"Idempotency-Key":"<stable-unique-key>"}'
157
+ ```
158
+
159
+ `refinement-fullprof`、`refinement-gsasii`、`refinement-wpem` 选择计费/后端入口;不要
160
+ 因为它们映射到同一路径就互换 endpoint 名或 `backends`。提交、取消、重试和审核是
161
+ 远端变更,必须得到用户明确授权;超时或连接中断时不要盲目重试,先查询是否已经创建
162
+ 作业。
163
+
164
+ 查询作业时:
165
+
166
+ ```text
167
+ delta-cli science invoke --tool xrd --endpoint refinement-job `
168
+ --path-params '{"job_id":"refjob_<returned-id>"}'
169
+
170
+ delta-cli science invoke --tool xrd --endpoint refinement-job-events `
171
+ --path-params '{"job_id":"refjob_<returned-id>"}'
172
+ ```
173
+
174
+ ## 结果与错误
175
+
176
+ - 只有 CLI 退出码为 0 且顶层 JSON `ok` 为 `true` 才算调用成功。
177
+ - 原样保留服务返回的 `data`、warnings、错误 detail 和稳定错误码。
178
+ - `202`、`queued` 或 `running` 只代表作业接收/执行状态,不代表 solver 收敛或科学接受。
179
+ - `TIER_CONCURRENCY_EXCEEDED`、`Endpoint is disabled`、`ARTIFACT_MISSING`、
180
+ `MP500_IDENTITY_MISMATCH` 等错误应停止当前调用链并报告原始 detail;不要换 endpoint、
181
+ 改名、猜参数或用本地算法替代。
182
+ - 付费 endpoint 的价格和可用状态以实时目录为准;执行前确认用户确实要求该业务调用。
183
+
184
+ 证据边界:仅限当前 Delta CLI `data` 中的业务结果。
185
+ 调用链:`delta-cli`。
186
+ 禁止补充未返回内容:是。