@delta-infra/cli 1.0.73 → 1.0.74

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.
Files changed (52) hide show
  1. package/README.md +422 -413
  2. package/checksums.txt +7 -5
  3. package/package.json +14 -5
  4. package/scripts/install-wizard.js +598 -602
  5. package/scripts/install.js +410 -410
  6. package/scripts/run.js +65 -65
  7. package/skills/antbo-ldm-guard/SKILL.md +54 -0
  8. package/skills/antbo-ldm-guard/agents/openai.yaml +4 -0
  9. package/skills/antbo-service/SKILL.md +74 -0
  10. package/skills/antbo-service/agents/openai.yaml +4 -0
  11. package/skills/antbo-service/references/operations.md +45 -0
  12. package/skills/delta-bo/SKILL.md +31 -0
  13. package/skills/delta-bo/agents/openai.yaml +4 -0
  14. package/skills/delta-bo/references/endpoints.md +263 -0
  15. package/skills/delta-sandbox/SKILL.md +356 -357
  16. package/skills/delta-sandbox/agents/openai.yaml +4 -0
  17. package/skills/delta-sandbox/references/commands.md +56 -56
  18. package/skills/delta-sandbox/references/lifecycle.md +92 -92
  19. package/skills/delta-sandbox/references/recipes.md +133 -133
  20. package/skills/delta-science/SKILL.md +166 -115
  21. package/skills/delta-science/agents/openai.yaml +4 -4
  22. package/skills/delta-science/references/cli-contract.md +84 -65
  23. package/skills/delta-science/references/operation-contracts.md +137 -0
  24. package/skills/delta-science/references/services.md +112 -85
  25. package/skills/delta-science/references/workflows.md +44 -34
  26. package/skills/delta-science/scripts/invoke.py +329 -189
  27. package/skills/delta-shared/SKILL.md +95 -96
  28. package/skills/delta-shared/agents/openai.yaml +4 -0
  29. package/skills/gsasii/SKILL.md +37 -0
  30. package/skills/gsasii/agents/openai.yaml +4 -0
  31. package/skills/gsasii/references/endpoints.md +130 -0
  32. package/skills/lammps/SKILL.md +34 -0
  33. package/skills/lammps/agents/openai.yaml +4 -0
  34. package/skills/lammps/references/endpoints.md +61 -0
  35. package/skills/ldm-bo/SKILL.md +30 -0
  36. package/skills/ldm-bo/agents/openai.yaml +4 -0
  37. package/skills/ldm-bo/references/endpoints.md +127 -0
  38. package/skills/manifest.json +17 -0
  39. package/skills/pubchem/SKILL.md +88 -0
  40. package/skills/pubchem/agents/openai.yaml +4 -0
  41. package/skills/pubchem/references/endpoints.md +122 -0
  42. package/skills/pubchem/references/operations.md +41 -0
  43. package/skills/pymatgen/SKILL.md +49 -0
  44. package/skills/pymatgen/agents/openai.yaml +4 -0
  45. package/skills/pymatgen/references/endpoints.md +68 -0
  46. package/skills/rdkit/SKILL.md +107 -0
  47. package/skills/rdkit/agents/openai.yaml +4 -0
  48. package/skills/rdkit/references/endpoints.md +133 -0
  49. package/skills/rdkit/references/operations.md +64 -0
  50. package/skills/synbo-service/SKILL.md +31 -0
  51. package/skills/synbo-service/agents/openai.yaml +4 -0
  52. package/skills/synbo-service/references/endpoints.md +157 -0
@@ -0,0 +1,88 @@
1
+ ---
2
+ name: pubchem
3
+ description: 当用户给出化学品、分子、药物名称并询问 CID、同义词、分子式、分子量、SMILES、InChI、IUPAC 名、XLogP、TPSA 或供受体数量时使用;也用于在 RDKit 前批量把名称解析为 SMILES。所有实时请求只走 Delta CLI wrapper,并以当前 WORKSPACE_ROOT 下的有界 JSON 作为权威交接产物。
4
+ ---
5
+
6
+ # PubChem 服务
7
+
8
+ ## 强制执行规则
9
+
10
+ 1. 第一个且唯一实时执行工具是 `python_repl`,直接执行
11
+ `$SKILLS_ROOT/delta-science/scripts/invoke.py`。
12
+ 调用 `python_repl` 时工具参数对象只能包含 `code`;禁止传入 `deps`、
13
+ `dependencies`、`packages` 或其他参数。
14
+ 2. `SKILLS_ROOT` 只通过 `os.environ["SKILLS_ROOT"]` 读取;禁止 Bash、
15
+ `list_dir/read_file/which/where/ls`、wrapper 检查和路径探测。
16
+ 3. 禁止执行字面命令 `CLI/cli/delta-cli`,禁止 curl、requests、httpx、浏览器、
17
+ PUG-REST 和本地替代。
18
+ 4. wrapper 已解包所有 envelope,业务结果直接位于 `r["native"]`;禁止
19
+ `native.data` 和递归找值。
20
+ 5. 不先调用 health/schema,不为“验证”重复同一请求。
21
+
22
+ ## 单化合物默认模板
23
+
24
+ ```python
25
+ import json, os, subprocess, sys
26
+ from pathlib import Path
27
+ wrapper=os.path.join(os.environ["SKILLS_ROOT"],"delta-science","scripts","invoke.py")
28
+ payload={"identifier":"aspirin","namespace":"name"}
29
+ p=subprocess.run([sys.executable,wrapper,"--tool","pubchem","--endpoint","compound-summary",
30
+ "--data-json",json.dumps(payload)],capture_output=True,text=True,
31
+ encoding="utf-8",errors="replace",shell=False,timeout=150)
32
+ if p.returncode != 0: raise RuntimeError(p.stderr or p.stdout)
33
+ r=json.loads(p.stdout)
34
+ if r.get("ok") is not True or r.get("transport")!="delta-cli": raise RuntimeError(r)
35
+ n=r["native"]; x=n["properties"]
36
+ out={"transport":r["transport"],"endpoint":r["endpoint"],"valid":n["valid"],
37
+ "cid":n.get("cid") or x.get("CID"),"canonical_smiles":x.get("CanonicalSMILES"),
38
+ "molecular_formula":x.get("MolecularFormula"),
39
+ "molecular_weight":x.get("MolecularWeight")}
40
+ output_path=Path(os.environ["WORKSPACE_ROOT"])/"pubchem_result.json"
41
+ output_path.write_text(json.dumps(out,ensure_ascii=False,indent=2),encoding="utf-8")
42
+ print(json.dumps({"output_ref":str(output_path),"result":out},ensure_ascii=False))
43
+ ```
44
+
45
+ `out` 只保留用户要求的字段。逐字复制返回值:不得改写等价 SMILES、给公式加排版、
46
+ 给数值加单位、添加 URL/链接/用途/机制或未请求属性。
47
+
48
+ ## operation 选择
49
+
50
+ - 一个名称的基础信息:一次 `compound-summary`。
51
+ - 两个及以上名称:一次 `compound-batch-summary`,body 只用
52
+ `{"identifiers":[...],"namespace":"name"}`。
53
+ - 只解析 CID、只查属性或同义词:分别使用 `compound-resolve-cids`、
54
+ `compound-properties`、`compound-synonyms`。
55
+ - 每个 operation 的准确情景、payload 和投影见
56
+ `references/operations.md`;复杂字段再看 `references/endpoints.md`。
57
+
58
+ 批量结果从 `native.results[*]` 读取,原标签是 `input`,化合物字段在嵌套
59
+ `properties`。SMILES 回退顺序固定为:
60
+
61
+ ```text
62
+ CanonicalSMILES || ConnectivitySMILES || SMILES || IsomericSMILES
63
+ ```
64
+
65
+ 无机材料化学式、组成和式量路由 pymatgen;PubChem not_found 原样保留,不编造 CID
66
+ 或本地补算。PubChem `XLogP` 与 RDKit `MolLogP` 不得互换。
67
+
68
+ 成功写入有界 JSON 后,用其中的原始字符串和数值构造无 Markdown、无单位的最终文本,
69
+ 并立即调用 `step_finish` 恰好一次。例如:
70
+
71
+ ```text
72
+ 【最终答案,必须逐字转发】
73
+ CID: 2244
74
+ 规范 SMILES: CC(=O)OC1=CC=CC=C1C(=O)O
75
+ 分子式: C9H8O4
76
+ 分子量: 180.16
77
+ ```
78
+
79
+ `status="done"`,`summary` 第一行必须逐字为 `【最终答案,必须逐字转发】`,其余行
80
+ 逐字使用当前 out;`output_ref` 必须是刚写入的绝对 `pubchem_result.json` 路径。
81
+ 不得使用示例固定值。缺少首行或 output_ref 时不得结束步骤。
82
+ Skill 自身的 final_response 和外层 Memento 都必须逐字复制 summary,包括大小写和标点,
83
+ 不得改成 Markdown/LaTeX、另一种等价 SMILES、添加单位、链接或说明。失败时调用
84
+ `step_finish(status="failed", summary=<原始错误短摘要>)`。调用后禁止自由文本和工具。
85
+
86
+ 具名 Skill 返回后,外层若需要核验只能对 `output_ref` 使用一次原子 `read_file`;禁止
87
+ `python_repl`、`list_dir`、路径探测或再次调用 PubChem/Science。该文件只是当前会话的
88
+ 内部证据交接,不是用户要求的额外交付物。
@@ -0,0 +1,4 @@
1
+ interface:
2
+ display_name: "PubChem ?????"
3
+ short_description: "?? Delta CLI ????????????????"
4
+ default_prompt: "?? $pubchem ????????????????"
@@ -0,0 +1,122 @@
1
+ # PubChem Endpoint Reference
2
+
3
+ 在 Memento 中只能通过 `delta-science/scripts/invoke.py` 调用。wrapper 已解包服务
4
+ 信封,因此以下文档所说的业务 `data` 在 wrapper 结果中就是 `result["native"]`
5
+ 顶层;禁止再读取 `result["native"]["data"]`。本文件中的 URL 只用于说明 endpoint
6
+ schema,不授权直接 HTTP。
7
+
8
+ All paths are relative to `http://111.2.199.31:52317/api/v1`.
9
+
10
+ Namespaces: `cid`, `name`, `smiles`, `inchi`, `inchikey`, `formula`.
11
+
12
+ ## Health
13
+
14
+ `GET /chem/pubchem/health`
15
+
16
+ ## Resolve CIDs
17
+
18
+ `POST /chem/pubchem/compound/resolve-cids`
19
+
20
+ ```json
21
+ {"identifier": "aspirin", "namespace": "name", "max_records": 20}
22
+ ```
23
+
24
+ `max_records`: 1-100.
25
+
26
+ ## Properties
27
+
28
+ `POST /chem/pubchem/compound/properties`
29
+
30
+ ```json
31
+ {
32
+ "identifier": "2244",
33
+ "namespace": "cid",
34
+ "properties": ["MolecularFormula", "MolecularWeight", "CanonicalSMILES", "IUPACName"]
35
+ }
36
+ ```
37
+
38
+ Allowed properties include `MolecularFormula`, `MolecularWeight`,
39
+ `CanonicalSMILES`, `IsomericSMILES`, `SMILES`, `ConnectivitySMILES`,
40
+ `IUPACName`, `InChI`, `InChIKey`, `XLogP`, `TPSA`, `HBondDonorCount`,
41
+ `HBondAcceptorCount`, `RotatableBondCount`, `ExactMass`, `MonoisotopicMass`,
42
+ `Charge`, `HeavyAtomCount`, `Complexity`, `CovalentUnitCount`,
43
+ `DefinedAtomStereoCount`, `UndefinedAtomStereoCount`, `DefinedBondStereoCount`,
44
+ `UndefinedBondStereoCount`, and `IsotopeAtomCount`.
45
+
46
+ ## Synonyms
47
+
48
+ `POST /chem/pubchem/compound/synonyms`
49
+
50
+ ```json
51
+ {"identifier": "2244", "namespace": "cid", "max_synonyms": 50}
52
+ ```
53
+
54
+ `max_synonyms`: 1-500.
55
+
56
+ ## Summary
57
+
58
+ `POST /chem/pubchem/compound/summary`
59
+
60
+ ```json
61
+ {
62
+ "identifier": "aspirin",
63
+ "namespace": "name",
64
+ "properties": ["MolecularFormula", "MolecularWeight", "CanonicalSMILES", "IUPACName"],
65
+ "synonym_limit": 20
66
+ }
67
+ ```
68
+
69
+ `synonym_limit`: 0-100. Use this endpoint for general compound lookup because
70
+ it resolves CID, selected properties, and synonyms in one call.
71
+
72
+ Response fields include `valid`, `cid`, `properties`, `properties_raw`,
73
+ `aliases`, `synonyms`, and `metadata`. Numeric properties are coerced to JSON
74
+ numbers when possible. Requested SMILES aliases are filled when PubChem returns
75
+ an equivalent key such as `ConnectivitySMILES`.
76
+
77
+ ## Batch Summary
78
+
79
+ `POST /chem/pubchem/compound/batch-summary`
80
+
81
+ ```json
82
+ {
83
+ "identifiers": ["aspirin", "ibuprofen", "caffeine"],
84
+ "namespace": "name",
85
+ "properties": ["MolecularFormula", "MolecularWeight", "CanonicalSMILES", "XLogP", "TPSA"],
86
+ "synonym_limit": 5
87
+ }
88
+ ```
89
+
90
+ Limits: 1-100 identifiers. The response preserves input order and includes
91
+ per-item errors:
92
+
93
+ ```json
94
+ {
95
+ "valid": false,
96
+ "namespace": "name",
97
+ "properties_requested": ["CanonicalSMILES"],
98
+ "results": [
99
+ {
100
+ "input": "aspirin",
101
+ "valid": true,
102
+ "cid": 2244,
103
+ "properties": {
104
+ "CanonicalSMILES": "CC(=O)Oc1ccccc1C(=O)O",
105
+ "ConnectivitySMILES": "CC(=O)Oc1ccccc1C(=O)O",
106
+ "_aliases": {"CanonicalSMILES": "ConnectivitySMILES"},
107
+ "properties_raw": {}
108
+ },
109
+ "properties_raw": {},
110
+ "aliases": {"CanonicalSMILES": "ConnectivitySMILES"},
111
+ "synonyms": []
112
+ },
113
+ {
114
+ "input": "bad-name",
115
+ "valid": false,
116
+ "error": "not found"
117
+ }
118
+ ],
119
+ "count": 2,
120
+ "failed_count": 1
121
+ }
122
+ ```
@@ -0,0 +1,41 @@
1
+ # PubChem operation 契约
2
+
3
+ 先使用 `SKILL.md` 的唯一 wrapper 模板。下面每行都是对应 operation 的最小设置;
4
+ wrapper 成功后的业务结果均为 `r["native"]`,不是 `native.data`。执行一次后调用
5
+ `step_finish`,不得重复调用。
6
+
7
+ ## health
8
+
9
+ - 情景:用户明确询问 PubChem 服务是否可用。
10
+ - 代码:`endpoint="health"; data=None; params=None`
11
+ - 投影:只保留 `status`、可用性、metadata、limits、warnings 中实际存在的字段。
12
+
13
+ ## compound-resolve-cids
14
+
15
+ - 情景:把名称、SMILES、InChI 等标识符解析为 CID 列表。
16
+ - 代码:`endpoint="compound-resolve-cids"; data={"identifier":"aspirin","namespace":"name","max_records":20}; params=None`
17
+ - 投影:输入标签、有效性、CID 列表和错误。
18
+
19
+ ## compound-properties
20
+
21
+ - 情景:已有标识符,只要求指定 PubChem 属性。
22
+ - 代码:`endpoint="compound-properties"; data={"identifier":"aspirin","namespace":"name","properties":["MolecularFormula","MolecularWeight"]}; params=None`
23
+ - 投影:只复制本次返回的 CID、请求属性、aliases、valid/error。
24
+
25
+ ## compound-synonyms
26
+
27
+ - 情景:查询一个化合物的同义词。
28
+ - 代码:`endpoint="compound-synonyms"; data={"identifier":"aspirin","namespace":"name","max_synonyms":5}; params=None`
29
+ - 投影:CID、有效性和最多用户要求数量的 synonyms。
30
+
31
+ ## compound-summary
32
+
33
+ - 情景:一个已命名分子的 CID、SMILES、分子式、分子量等基础属性。
34
+ - 代码:`endpoint="compound-summary"; data={"identifier":"aspirin","namespace":"name"}; params=None`
35
+ - 投影:`native.valid`、`native.cid` 与 `native.properties` 中用户要求的键。
36
+
37
+ ## compound-batch-summary
38
+
39
+ - 情景:一次解析两个或更多名称,供后续比较或 RDKit 使用。
40
+ - 代码:`endpoint="compound-batch-summary"; data={"identifiers":["aspirin","caffeine"],"namespace":"name"}; params=None`
41
+ - 投影:`native.results[*]` 的 `input`、valid/error 及嵌套 `properties`;不得加 `properties` 或 `synonym_limit` 请求字段。
@@ -0,0 +1,49 @@
1
+ ---
2
+ name: pymatgen
3
+ description: 当用户需要解析材料化学式与组成、计算式量、解析或总结 CIF/POSCAR/JSON/CSSR/XSF 晶体结构、转换结构格式或分析空间群和对称性时使用。所有实时请求只走 Delta CLI wrapper;无机化学式优先使用本 Skill,不用 PubChem 或本地元素表替代。
4
+ ---
5
+
6
+ # pymatgen 服务
7
+
8
+ ## 强制规则
9
+
10
+ - 第一个且唯一实时执行工具是 `python_repl`;直接执行
11
+ `$SKILLS_ROOT/delta-science/scripts/invoke.py`,tool 固定为 `pymatgen`。
12
+ - `python_repl` 工具参数只能包含 `code`,禁止 `deps/dependencies/packages`。
13
+ - `SKILLS_ROOT` 只通过 `os.environ` 读取。禁止 Bash、目录/路径探测、字面 CLI
14
+ 命令、直接 HTTP 和本地 pymatgen。
15
+ - wrapper 成功后的业务结果是 `r["native"]` 顶层,禁止 `native.data`。
16
+ - 结构接口必须发送完整结构文本,不能发送本地文件路径;只支持
17
+ `cif/poscar/json/cssr/xsf`,不接收 LAMMPS data/dump。
18
+
19
+ ## wrapper 模板
20
+
21
+ ```python
22
+ import json, os, subprocess, sys
23
+ wrapper=os.path.join(os.environ["SKILLS_ROOT"],"delta-science","scripts","invoke.py")
24
+ p=subprocess.run([sys.executable,wrapper,"--tool","pymatgen","--endpoint",endpoint,
25
+ "--data-json",json.dumps(payload)],capture_output=True,text=True,shell=False)
26
+ if p.returncode != 0: raise RuntimeError(p.stderr or p.stdout)
27
+ r=json.loads(p.stdout)
28
+ if r.get("ok") is not True or r.get("transport")!="delta-cli": raise RuntimeError(r)
29
+ n=r["native"]
30
+ print(json.dumps(out,ensure_ascii=False))
31
+ ```
32
+
33
+ `out` 必须从 `n` 投影,不得用记忆补值。
34
+
35
+ ## operation 选择
36
+
37
+ - `health`:明确健康检查;省略 `--data-json`。
38
+ - `composition-parse`:`{"formula":"LiFePO4","format":"formula"}`。
39
+ - `structure-parse`:`{"input":结构文本,"format":"cif","primitive":false}`。
40
+ - `structure-summary`:同上,用于 formula、density、volume、lattice、species。
41
+ - `structure-convert`:`{"input":结构文本,"input_format":"cif","output_format":"poscar","primitive":false}`。
42
+ - `structure-symmetry`:`{"input":结构文本,"format":"cif","primitive":false,"symprec":0.01,"angle_tolerance":5.0}`。
43
+
44
+ 详细 native 字段见 `references/endpoints.md`。一个请求只调用所需 operation;无机式量
45
+ 只报告当前 native 的 `weight`,PubChem not_found 不得改写或本地补算。
46
+
47
+ 成功打印有界 JSON 后立即调用 `step_finish(status="done", summary=<同一 JSON>)`
48
+ 恰好一次;失败时调用 `step_finish(status="failed", summary=<原始错误短摘要>)`。
49
+ 调用后不得输出自由文本或使用其他工具。
@@ -0,0 +1,4 @@
1
+ interface:
2
+ display_name: "pymatgen ????"
3
+ short_description: "?? Delta CLI ???????????????"
4
+ default_prompt: "?? $pymatgen ??????????????"
@@ -0,0 +1,68 @@
1
+ # pymatgen Endpoint Reference
2
+
3
+ All paths are relative to `http://111.2.199.31:52317/api/v1`.
4
+
5
+ ## Health
6
+
7
+ `GET /chem/pymatgen/health`
8
+
9
+ ## Composition Parse
10
+
11
+ `POST /chem/pymatgen/composition/parse`
12
+
13
+ ```json
14
+ {"formula": "LiFePO4", "format": "formula"}
15
+ ```
16
+
17
+ Key response fields in `data`: `valid`, `formula`, `reduced_formula`,
18
+ `alphabetic_formula`, `anonymous_formula`, `chemical_system`,
19
+ `number_of_atoms`, `weight`, `element_amounts`, `atomic_fractions`,
20
+ `weight_fractions`, `error`.
21
+
22
+ ## Structure Parse / Summary
23
+
24
+ `POST /chem/pymatgen/structure/parse`
25
+
26
+ `POST /chem/pymatgen/structure/summary`
27
+
28
+ ```json
29
+ {"input": "<CIF text>", "format": "cif", "primitive": false}
30
+ ```
31
+
32
+ Input formats: `cif`, `poscar`, `json`, `cssr`, `xsf`.
33
+
34
+ Summary fields include `formula`, `reduced_formula`, `chemical_system`,
35
+ `nsites`, `nelements`, `density`, `volume`, `lattice`, `element_amounts`, and
36
+ `species`.
37
+
38
+ ## Structure Convert
39
+
40
+ `POST /chem/pymatgen/structure/convert`
41
+
42
+ ```json
43
+ {
44
+ "input": "<CIF text>",
45
+ "input_format": "cif",
46
+ "output_format": "poscar",
47
+ "primitive": false
48
+ }
49
+ ```
50
+
51
+ Output formats: `cif`, `poscar`, `json`, `cssr`, `xsf`.
52
+
53
+ ## Symmetry
54
+
55
+ `POST /chem/pymatgen/structure/symmetry`
56
+
57
+ ```json
58
+ {
59
+ "input": "<CIF text>",
60
+ "format": "cif",
61
+ "primitive": false,
62
+ "symprec": 0.01,
63
+ "angle_tolerance": 5.0
64
+ }
65
+ ```
66
+
67
+ Returns `space_group_symbol`, `space_group_number`, `crystal_system`,
68
+ `point_group_symbol`, `hall`, and `nsites`.
@@ -0,0 +1,107 @@
1
+ ---
2
+ name: rdkit
3
+ description: 当用户需要通过已部署的 Delta Science 服务校验或规范化 SMILES/InChI、计算 RDKit 描述符、指纹、相似度、渲染或子结构筛选时使用。所有实时请求只能由 python_repl 直接执行 delta-science Skill 的 invoke.py;禁止 Bash、目录探测、直接 HTTP、本地 RDKit 和 native.data 路径。
4
+ ---
5
+
6
+ # RDKit 服务
7
+
8
+ ## 不可违反的执行规则
9
+
10
+ 1. 第一个且唯一允许用于实时 Science 调用的工具是 `python_repl`。
11
+ `python_repl` 的工具参数对象只能包含 `code`;禁止 `deps`、`dependencies`、
12
+ `packages` 或其他参数。
13
+ 2. 在 `python_repl` 中直接执行同级 Skill 的
14
+ `$SKILLS_ROOT/delta-science/scripts/invoke.py`。`SKILLS_ROOT` 只能通过
15
+ `os.environ["SKILLS_ROOT"]` 读取,不能把 `@SKILLS_ROOT` 当成目录。
16
+ 3. 禁止使用 Bash、`list_dir`、`read_file`、`which`、`where`、`ls`,禁止检查
17
+ wrapper 或寻找 CLI,禁止执行字面命令 `CLI`、`cli`、`delta-cli`。
18
+ 4. 禁止 `curl`、`requests`、`httpx`、浏览器和本地 RDKit 回退。
19
+ 5. wrapper 成功后,业务结果就在 `result["native"]` 顶层;绝不读取
20
+ `result["native"]["data"]`。
21
+ 6. 一个请求只执行完成任务所需的最少调用。失败后不得自行探测路径、改走 HTTP
22
+ 或改用本地计算。
23
+
24
+ ## 唯一调用模板
25
+
26
+ ```python
27
+ import json, os, subprocess, sys
28
+ wrapper = os.path.join(os.environ["SKILLS_ROOT"], "delta-science", "scripts", "invoke.py")
29
+ payload = {
30
+ "molecules": [{"id": "aspirin", "smiles": "CC(=O)OC1=CC=CC=C1C(=O)O"}],
31
+ "descriptor_set": "basic",
32
+ "sanitize": True,
33
+ }
34
+ p = subprocess.run(
35
+ [sys.executable, wrapper, "--tool", "rdkit", "--endpoint", "batch-parse-describe",
36
+ "--data-json", json.dumps(payload)],
37
+ capture_output=True, text=True, shell=False,
38
+ )
39
+ if p.returncode != 0:
40
+ raise RuntimeError(p.stderr or p.stdout)
41
+ r = json.loads(p.stdout)
42
+ if r.get("ok") is not True or r.get("transport") != "delta-cli":
43
+ raise RuntimeError(r)
44
+ n = r["native"]
45
+ item = n["results"][0]
46
+ answer = {
47
+ "endpoint": r["endpoint"],
48
+ "valid": item["valid"],
49
+ "canonical_smiles": item.get("canonical_smiles"),
50
+ "descriptors": item.get("descriptors"),
51
+ "warnings": item.get("warnings", []),
52
+ }
53
+ print(json.dumps(answer, ensure_ascii=False))
54
+ ```
55
+
56
+ 只替换 payload 和逻辑 endpoint。不要先调用 health,也不要增加第二次 parse 或
57
+ descriptors 调用。只要进程退出码、`ok`、`transport` 和解析均成功,本次调用就已
58
+ 完成;不得因为界面未显示 Python 表达式值而重复调用,不得通过打印 stdout、stderr
59
+ 或完整 native 调试。
60
+
61
+ 成功打印有界 JSON 后,立即调用 `step_finish(status="done", summary=<该 JSON>)`
62
+ 恰好一次,不设置 `output_ref`,随后不得输出自由文本或调用工具。失败时调用
63
+ `step_finish(status="failed", summary=<原始错误的短摘要>)`,禁止重试、调试打印或
64
+ 路径探测。
65
+
66
+ ## 端点选择
67
+
68
+ - 同时要求解析和基础描述符:只调用一次 `batch-parse-describe`,payload 必须使用
69
+ `molecules`,每项使用 `id` 和 `smiles`;`descriptor_set` 为 `basic`,
70
+ `sanitize` 为 `true`。
71
+ - 只解析或规范化一个输入:`parse`,payload 为
72
+ `{"input":"...","format":"smiles"}` 或相应 InChI 格式。
73
+ - 只计算描述符:`descriptors`;批量只计算描述符:`batch-descriptors`。
74
+ - 两个分子的相似度:`similarity`;多个分子的全对相似度:
75
+ `similarity-matrix`。
76
+ - 渲染:`render`;指纹:`fingerprint`;SMARTS 筛选:`substructure`。
77
+
78
+ 非默认 operation 先读 `references/operations.md` 中对应小节;完整字段和允许值再见
79
+ `references/endpoints.md`。不要根据其他服务相似端点猜 schema。
80
+
81
+ ## 多分子相似度
82
+
83
+ 名称必须先由 PubChem Skill 得到 SMILES,再执行一次 `similarity-matrix`:
84
+
85
+ ```python
86
+ payload = {
87
+ "molecules": [{"id": name, "smiles": smiles} for name, smiles in resolved],
88
+ "fingerprint": {"type": "morgan", "radius": 2, "n_bits": 2048},
89
+ "sanitize": True,
90
+ }
91
+ ```
92
+
93
+ 结果从 `n["matrix"]` 和 `n["ranked_pairs"]` 读取。每个排名项固定为
94
+ `{"a": 名称, "b": 名称, "similarity": 数值}`;禁止读取 `i`、`j`、
95
+ `score`,禁止自行重算或添加阈值解释。
96
+
97
+ ## 结果与失败边界
98
+
99
+ - 只报告本次 `native` 返回的字段、数值和警告,不用记忆补值。
100
+ - 描述符只能逐项复制 `item["descriptors"]` 中实际存在的键和值;不得补充
101
+ `NumAromaticRings`、形式电荷、官能团、手性、结构原因、单位或解释,除非这些字段
102
+ 确实由本次 native 返回且用户明确要求。
103
+ - `valid: false` 是化学输入校验失败,原样报告 `error`/`warnings`。
104
+ - wrapper、CLI 或后端失败时,报告实际阶段和错误;不要继续探测或回退。
105
+ - 渲染结果只有在解码后的字节以 PNG magic bytes 开头时才能保存为 `.png`;禁止
106
+ 把 JSON envelope 保存成图片。
107
+ - PubChem 的 `XLogP` 与 RDKit 的 `MolLogP` 不是同一来源,不得互相替代。
@@ -0,0 +1,4 @@
1
+ interface:
2
+ display_name: "RDKit ?????"
3
+ short_description: "?? Delta CLI ?????????????????"
4
+ default_prompt: "?? $rdkit ???????????????????"
@@ -0,0 +1,133 @@
1
+ # RDKit Endpoint Reference
2
+
3
+ 在 Memento 中只能通过 `delta-science/scripts/invoke.py` 调用。wrapper 已解包服务
4
+ 信封,因此以下业务响应在 wrapper 结果中位于 `result["native"]` 顶层;禁止读取
5
+ `result["native"]["data"]`。本文件中的 URL 只说明 schema,不授权直接 HTTP。
6
+
7
+ All paths are relative to `http://111.2.199.31:52317/api/v1`.
8
+
9
+ ## Health
10
+
11
+ `GET /chem/rdkit/health`
12
+
13
+ ## Parse
14
+
15
+ `POST /chem/rdkit/parse`
16
+
17
+ ```json
18
+ {"input": "CCO", "format": "smiles", "sanitize": true}
19
+ ```
20
+
21
+ Formats: `smiles`, `inchi`, `molblock`.
22
+
23
+ Key response fields in `data`: `valid`, `canonical_smiles`, `formula`,
24
+ `molecular_weight`, `exact_molecular_weight`, `inchi_key`, `atom_count`,
25
+ `heavy_atom_count`, `bond_count`, `warnings`, `error`.
26
+
27
+ ## Descriptors
28
+
29
+ `POST /chem/rdkit/descriptors`
30
+
31
+ ```json
32
+ {"smiles": "CCO", "descriptor_set": "basic", "sanitize": true}
33
+ ```
34
+
35
+ `descriptor_set` currently supports `basic`. Descriptor keys include `Formula`,
36
+ `MolWt`, `ExactMolWt`, `HeavyAtomMolWt`, `TPSA`, `MolLogP`, `NumHDonors`,
37
+ `NumHAcceptors`, `NumRotatableBonds`, `RingCount`, `FractionCSP3`,
38
+ `HeavyAtomCount`, `AtomCount`, and `BondCount`.
39
+
40
+ ## Batch Descriptors
41
+
42
+ `POST /chem/rdkit/batch-descriptors`
43
+
44
+ ```json
45
+ {"smiles": ["CCO", "c1ccccc1"], "descriptor_set": "basic", "sanitize": true}
46
+ ```
47
+
48
+ Limits: 1-500 SMILES.
49
+
50
+ ## Batch Parse Describe
51
+
52
+ `POST /chem/rdkit/batch-parse-describe`
53
+
54
+ ```json
55
+ {
56
+ "molecules": [
57
+ {"id": "aspirin", "smiles": "CC(=O)Oc1ccccc1C(=O)O"},
58
+ {"id": "caffeine", "smiles": "Cn1cnc2c1c(=O)n(C)c(=O)n2C"}
59
+ ],
60
+ "descriptor_set": "basic",
61
+ "fingerprint": {"type": "morgan", "radius": 2, "n_bits": 2048},
62
+ "sanitize": true
63
+ }
64
+ ```
65
+
66
+ Limits: 1-500 molecules. Returns per-item `valid`, `canonical_smiles`, parse
67
+ fields, `descriptors`, optional `fingerprint_metadata`, `on_bits`, `bit_count`,
68
+ `warnings`, and `error`.
69
+
70
+ ## Render
71
+
72
+ `POST /chem/rdkit/render`
73
+
74
+ ```json
75
+ {"smiles": "CCO", "image_format": "svg", "width": 450, "height": 320}
76
+ ```
77
+
78
+ Image formats: `svg`, `png`. SVG returns text; PNG returns base64.
79
+ Width/height range: 150-2000.
80
+
81
+ ## Fingerprint
82
+
83
+ `POST /chem/rdkit/fingerprint`
84
+
85
+ ```json
86
+ {"smiles": "CCO", "radius": 2, "n_bits": 2048}
87
+ ```
88
+
89
+ Morgan fingerprint parameters: `radius` 1-6, `n_bits` 128-8192.
90
+
91
+ ## Similarity
92
+
93
+ `POST /chem/rdkit/similarity`
94
+
95
+ ```json
96
+ {"query_smiles": "CCO", "target_smiles": "CCCO", "radius": 2, "n_bits": 2048}
97
+ ```
98
+
99
+ Returns Tanimoto similarity.
100
+
101
+ ## Similarity Matrix
102
+
103
+ `POST /chem/rdkit/similarity-matrix`
104
+
105
+ ```json
106
+ {
107
+ "molecules": [
108
+ {"id": "aspirin", "smiles": "CC(=O)Oc1ccccc1C(=O)O"},
109
+ {"id": "ibuprofen", "smiles": "CC(C)Cc1ccc(cc1)[C@@H](C)C(=O)O"}
110
+ ],
111
+ "fingerprint": {"type": "morgan", "radius": 2, "n_bits": 2048},
112
+ "sanitize": true
113
+ }
114
+ ```
115
+
116
+ Returns `matrix` in input order and `ranked_pairs` sorted by descending
117
+ Tanimoto similarity. Each ranked record is named, not index-based:
118
+
119
+ ```json
120
+ {"a":"aspirin","b":"ibuprofen","similarity":0.195122}
121
+ ```
122
+
123
+ Do not expect `i`, `j`, or `score` fields.
124
+
125
+ ## Substructure
126
+
127
+ `POST /chem/rdkit/substructure`
128
+
129
+ ```json
130
+ {"query_smarts": "c1ccccc1", "target_smiles": ["c1ccccc1", "CCO"]}
131
+ ```
132
+
133
+ Limits: SMARTS max length 5000; target list size 1-500.