@delta-infra/cli 1.0.73 → 1.0.75

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 +5 -5
  3. package/package.json +14 -5
  4. package/scripts/install-wizard.js +598 -602
  5. package/scripts/install.js +404 -404
  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
package/scripts/run.js CHANGED
@@ -1,65 +1,65 @@
1
- #!/usr/bin/env node
2
- // Copyright (c) 2026 Delta Infra Authors
3
- // SPDX-License-Identifier: MIT
4
-
5
- const { execFileSync } = require("child_process");
6
- const fs = require("fs");
7
- const path = require("path");
8
-
9
- const ext = process.platform === "win32" ? ".exe" : "";
10
- const bin = path.join(__dirname, "..", "bin", "delta-cli" + ext);
11
-
12
- // On Windows, a crashed self-update may have left the binary renamed to .old.
13
- const oldBin = bin + ".old";
14
- function restoreOldBinary() {
15
- try {
16
- if (fs.existsSync(bin)) {
17
- fs.rmSync(bin, { force: true });
18
- }
19
- fs.renameSync(oldBin, bin);
20
- return true;
21
- } catch { return false; }
22
- }
23
-
24
- if (process.platform === "win32" && fs.existsSync(oldBin)) {
25
- if (!fs.existsSync(bin)) {
26
- restoreOldBinary();
27
- } else {
28
- try {
29
- execFileSync(bin, ["--version"], { stdio: "ignore", timeout: 10000 });
30
- try { fs.rmSync(oldBin, { force: true }); } catch {}
31
- } catch {
32
- restoreOldBinary();
33
- }
34
- }
35
- }
36
-
37
- const args = process.argv.slice(2);
38
-
39
- // Intercept install/uninstall — run wizard, bypass native binary
40
- if (args[0] === "install" || args[0] === "uninstall") {
41
- require("./install-wizard.js");
42
- } else {
43
- // Auto-download binary if missing (e.g. npx skipped postinstall)
44
- if (!fs.existsSync(bin)) {
45
- try {
46
- execFileSync(process.execPath, [path.join(__dirname, "install.js")], {
47
- stdio: "inherit",
48
- env: { ...process.env, DELTA_CLI_RUN: "true", DELTA_CLI_VERSION: process.env.DELTA_CLI_VERSION || "" },
49
- });
50
- } catch {
51
- console.error(
52
- `\nFailed to auto-install delta-cli binary.\n` +
53
- `To fix, run the install script manually:\n` +
54
- ` node "${path.join(__dirname, "install.js")}"\n`
55
- );
56
- process.exit(1);
57
- }
58
- }
59
-
60
- try {
61
- execFileSync(bin, args, { stdio: "inherit" });
62
- } catch (e) {
63
- process.exit(e.status || 1);
64
- }
65
- }
1
+ #!/usr/bin/env node
2
+ // Copyright (c) 2026 Delta Infra Authors
3
+ // SPDX-License-Identifier: MIT
4
+
5
+ const { execFileSync } = require("child_process");
6
+ const fs = require("fs");
7
+ const path = require("path");
8
+
9
+ const ext = process.platform === "win32" ? ".exe" : "";
10
+ const bin = path.join(__dirname, "..", "bin", "delta-cli" + ext);
11
+
12
+ // On Windows, a crashed self-update may have left the binary renamed to .old.
13
+ const oldBin = bin + ".old";
14
+ function restoreOldBinary() {
15
+ try {
16
+ if (fs.existsSync(bin)) {
17
+ fs.rmSync(bin, { force: true });
18
+ }
19
+ fs.renameSync(oldBin, bin);
20
+ return true;
21
+ } catch { return false; }
22
+ }
23
+
24
+ if (process.platform === "win32" && fs.existsSync(oldBin)) {
25
+ if (!fs.existsSync(bin)) {
26
+ restoreOldBinary();
27
+ } else {
28
+ try {
29
+ execFileSync(bin, ["--version"], { stdio: "ignore", timeout: 10000 });
30
+ try { fs.rmSync(oldBin, { force: true }); } catch {}
31
+ } catch {
32
+ restoreOldBinary();
33
+ }
34
+ }
35
+ }
36
+
37
+ const args = process.argv.slice(2);
38
+
39
+ // Intercept install/uninstall — run wizard, bypass native binary
40
+ if (args[0] === "install" || args[0] === "uninstall") {
41
+ require("./install-wizard.js");
42
+ } else {
43
+ // Auto-download binary if missing (e.g. npx skipped postinstall)
44
+ if (!fs.existsSync(bin)) {
45
+ try {
46
+ execFileSync(process.execPath, [path.join(__dirname, "install.js")], {
47
+ stdio: "inherit",
48
+ env: { ...process.env, DELTA_CLI_RUN: "true", DELTA_CLI_VERSION: process.env.DELTA_CLI_VERSION || "" },
49
+ });
50
+ } catch {
51
+ console.error(
52
+ `\nFailed to auto-install delta-cli binary.\n` +
53
+ `To fix, run the install script manually:\n` +
54
+ ` node "${path.join(__dirname, "install.js")}"\n`
55
+ );
56
+ process.exit(1);
57
+ }
58
+ }
59
+
60
+ try {
61
+ execFileSync(bin, args, { stdio: "inherit" });
62
+ } catch (e) {
63
+ process.exit(e.status || 1);
64
+ }
65
+ }
@@ -0,0 +1,54 @@
1
+ ---
2
+ name: antbo-ldm-guard
3
+ description: 任何同时涉及 AntBO/抗体/CDRH3 与 LDM/suggest/下一条候选序列的请求都必须优先于所有其他 AntBO Skill 立即使用本 Skill,即使历史序列或评分尚未提供。当前 Delta CLI catalog 未暴露 AntBO LDM initialize/evaluate/suggest;唯一正确结果是说明未发送远端请求,禁止询问数据、建文件、调用 health/Science/filesystem 或改用小分子 LDM-BO。
4
+ ---
5
+
6
+ # AntBO LDM 能力边界
7
+
8
+ 本 Skill 没有可执行的 Science operation,也没有 wrapper、endpoint 或 payload 示例。
9
+ 为了兼容 Kimi 对“无 artifact 的 step_finish”误判为 loop,先生成一个只记录能力边界的
10
+ 本地证据文件;这不是 Science 调用,也不发送远端请求。
11
+
12
+ 第一次工具调用必须是 `python_repl`,工具参数只能包含 `code`,执行以下等价逻辑:
13
+
14
+ ```python
15
+ import json, os
16
+ from pathlib import Path
17
+
18
+ result = {
19
+ "supported": False,
20
+ "tool": "antbo",
21
+ "operation": "ldm-suggest",
22
+ "remote_request_sent": False,
23
+ "reason": "当前 Delta CLI catalog 未暴露 antbo LDM suggest operation",
24
+ }
25
+ output_path = Path(os.environ["WORKSPACE_ROOT"]) / "antbo_ldm_unsupported.json"
26
+ output_path.write_text(json.dumps(result, ensure_ascii=False, indent=2), encoding="utf-8")
27
+ print(str(output_path))
28
+ ```
29
+
30
+ 随后调用且只调用一次:
31
+
32
+ ```text
33
+ step_finish(
34
+ status="done",
35
+ summary="当前 Delta CLI catalog 未暴露 antbo LDM suggest operation;未发送远端请求。",
36
+ output_ref=<刚生成的 antbo_ldm_unsupported.json 绝对路径>
37
+ )
38
+ ```
39
+
40
+ 必须逐字使用上述 summary 和真实 output_ref。调用后立即结束,不输出其他文字,不调用
41
+ 任何工具。外层若核验,只能原子 `read_file(output_ref)` 一次,禁止其他操作。
42
+
43
+ 禁止行为:
44
+
45
+ - 除上述一次本地文件写入外,禁止其他 `python_repl`;禁止 Bash、health、catalog、
46
+ filesystem、目录 read/list、ask_user;
47
+ - 禁止创建 history JSON,禁止先要求用户提供序列或评分;
48
+ - 禁止调用 `antbo-service`、`ldm-bo` 或通用子代理;
49
+ - 禁止生成、转换、评价或声称返回候选 CDRH3;
50
+ - 禁止把 AntBO health 公布的公司内部 endpoint 当成 Delta CLI operation。
51
+
52
+ 公司服务能力与 Delta CLI catalog 是两层能力。当前 Memento 只能通过 CLI catalog
53
+ 调用 `antbo` 的 `health/run-default-job/run/log/jobs/stop`;因此 AntBO LDM 请求必须在
54
+ 本 Skill 内以固定能力边界答复结束。
@@ -0,0 +1,4 @@
1
+ interface:
2
+ display_name: "AntBO LDM ????"
3
+ short_description: "????? Delta CLI ??? AntBO LDM ????"
4
+ default_prompt: "?? $antbo-ldm-guard ???? AntBO LDM ?????? Delta CLI ???"
@@ -0,0 +1,74 @@
1
+ ---
2
+ name: antbo-service
3
+ description: 当用户明确要求检查 AntBO 服务健康状态、启动默认或自定义 AntBO 作业、读取 AntBO 日志、列出活动作业或停止指定作业时使用。当前 Delta CLI operation 为 health、run-default-job、run、log、jobs、stop。
4
+ ---
5
+
6
+ # AntBO 服务
7
+
8
+ ## 路由排除
9
+
10
+ AntBO/CDRH3 LDM、suggest、下一条候选序列请求不进入本 Skill,必须由
11
+ `antbo-ldm-guard` 处理。不得先调用本 Skill 的 health。
12
+
13
+ ## 路由与能力边界
14
+
15
+ 当前 Delta CLI catalog 暴露:
16
+
17
+ - `health`:健康检查,只读。
18
+ - `run-default-job`:启动默认后台任务,有副作用。
19
+ - `run`:自定义同步任务,有副作用且可能长时间运行。
20
+ - `log`:读取日志,只读。
21
+ - `jobs`:列出当前容器登记的活动任务,只读。
22
+ - `stop`:停止任务,有副作用。
23
+
24
+ 当前没有 `ldm/suggest`、`ldm/initialize` 或 `ldm/evaluate`。这些请求严格执行最上方
25
+ 终止分支;health 返回的公司内部 endpoint 不能覆盖 CLI catalog。
26
+
27
+ ## 强制执行规则
28
+
29
+ 1. 实时 Science 调用的第一个执行工具只能是 `python_repl`。
30
+ `python_repl` 工具参数只能包含 `code`,禁止 `deps/dependencies/packages`。
31
+ 2. 只通过 `os.environ["SKILLS_ROOT"]` 定位
32
+ `delta-science/scripts/invoke.py`,使用 `subprocess.run(..., shell=False)`。
33
+ 3. 禁止 Bash、`list_dir`、`read_file`、`which`、`where`、`ls`、wrapper/环境检查,
34
+ 禁止执行字面命令 `CLI`、`cli` 或 `delta-cli`。
35
+ 4. 禁止 `curl`、`requests`、`httpx`、浏览器、网关直连和本地 AntBO。
36
+ 5. 业务结果直接位于 `result["native"]`;禁止读取 `native.data`。
37
+ 6. 每个 operation 的场景、最小参数和投影必须按
38
+ `references/operations.md`,不得猜相近 endpoint。
39
+
40
+ ## 唯一 wrapper 模板
41
+
42
+ ```python
43
+ import json, os, subprocess, sys
44
+ wrapper = os.path.join(os.environ["SKILLS_ROOT"], "delta-science", "scripts", "invoke.py")
45
+ argv = [sys.executable, wrapper, "--tool", "antbo", "--endpoint", endpoint]
46
+ if data is not None:
47
+ argv += ["--data-json", json.dumps(data)]
48
+ if params is not None:
49
+ argv += ["--params-json", json.dumps(params)]
50
+ p = subprocess.run(argv, capture_output=True, text=True, shell=False)
51
+ if p.returncode != 0:
52
+ raise RuntimeError(p.stderr or p.stdout)
53
+ r = json.loads(p.stdout)
54
+ if r.get("ok") is not True or r.get("transport") != "delta-cli":
55
+ raise RuntimeError(r)
56
+ n = r["native"]
57
+ print(json.dumps({"transport": r["transport"], "endpoint": r["endpoint"], "native": n}, ensure_ascii=False))
58
+ ```
59
+
60
+ 执行前只按 `references/operations.md` 设置 `endpoint`、`data`、`params`。成功后将
61
+ 结果投影为用户要求的最小字段,不打印完整日志或 envelope。
62
+
63
+ ## 副作用与完成回执
64
+
65
+ - `run-default-job`、`run`、`stop` 只有用户明确授权时才能执行。
66
+ - 变更操作结果未知、超时或断连时禁止重试;客户端失败不表示远程操作未发生。
67
+ - 只有同一次 `run-default-job` native 同时含 `started=true`、非空 `pid` 以及
68
+ `log_name` 或 `log_path` 时,才能说任务已启动。
69
+ - `run` 仅用于用户明确提供并授权的受限脚本/config/antigen 路径,不生成任意路径。
70
+ - `stop` 优先使用用户确认的 PID;不得在多任务不明确时无参数停止。
71
+
72
+ 成功后立即调用 `step_finish(status="done", summary=<有界结果 JSON>)` 恰好一次;
73
+ 失败时调用 `step_finish(status="failed", summary=<原始错误短摘要>)`。调用后不得输出
74
+ 自由文本或使用其他工具。
@@ -0,0 +1,4 @@
1
+ interface:
2
+ display_name: "AntBO ????"
3
+ short_description: "?? Delta CLI ???????? AntBO ??????"
4
+ default_prompt: "?? $antbo-service ??????? AntBO ???????"
@@ -0,0 +1,45 @@
1
+ # AntBO operation 契约
2
+
3
+ 在 `SKILL.md` 的 wrapper 模板中设置 `endpoint`、`data`、`params`。业务结果直接位于
4
+ `r["native"]`。标为“变更”的 operation 只有用户明确授权时才能执行,且不得重试。
5
+
6
+ ## health(只读)
7
+
8
+ - 情景:检查远程 AntBO 环境是否可用。
9
+ - 代码:`endpoint="health"; data=None; params=None`
10
+ - 投影:status、antbo_available、metadata、limits、warnings。
11
+
12
+ ## run-default-job(变更)
13
+
14
+ - 情景:用户明确要求启动标准后台续跑任务。
15
+ - 代码:`endpoint="run-default-job"; data=None; params={"log_name":"antbo_<唯一时间戳>.log","append":False,"timeout_seconds":86400}`
16
+ - 投影:started、pid、log_name/log_path、timeout_seconds;未知结果禁止重试。
17
+
18
+ ## run(重型变更)
19
+
20
+ - 情景:用户明确给出受限 AntBO 脚本、配置、抗原文件并要求同步执行。
21
+ - 代码:`endpoint="run"; data={"script_path":"./bo/main.py","config_path":"./bo/config.yaml","n_trials":1,"seed":42,"antigens_file":"<项目根内路径>","extra_args":[],"timeout_seconds":86400,"cuda_visible_devices":"0","conda_env":"DGM","log_name":"antbo_custom.log","append":False}; params=None`
22
+ - 投影:ok、returncode、timed_out、log_path、日志截断状态;不在最终答复展开完整日志。
23
+
24
+ ## log(只读)
25
+
26
+ - 情景:用户提供已知 log_name 并要求查看尾部日志。
27
+ - 代码:`endpoint="log"; data=None; params={"log_name":"antbo_run.log"}`
28
+ - 投影:log_name、log、log_truncated;长日志只给有界尾部摘要。
29
+
30
+ ## jobs(只读)
31
+
32
+ - 情景:查看当前 service 容器登记的活动作业。
33
+ - 代码:`endpoint="jobs"; data=None; params=None`
34
+ - 投影:jobs 中 pid、running、returncode、log_name、log_path。
35
+
36
+ ## stop(变更)
37
+
38
+ - 情景:用户明确要求停止已确认 PID 的任务。
39
+ - 代码:`endpoint="stop"; data=None; params={"pid":12345}`
40
+ - 投影:stopped、pid、message;不得盲目重试或在多任务时无参数调用。
41
+
42
+ ## 当前不支持:AntBO LDM
43
+
44
+ `ldm/suggest`、`ldm/initialize`、`ldm/evaluate` 不在 CLI catalog。不得调用工具或
45
+ 切换到分子 `ldm-bo`,以 Skill 规定的固定能力边界答复结束步骤。
@@ -0,0 +1,31 @@
1
+ ---
2
+ name: delta-bo
3
+ description: 当用户需要列出当前 Delta-BO 命令,或针对数值、整数、分类实验变量生成随机搜索/贝叶斯优化建议时使用。当前 Delta CLI catalog 只暴露 commands 与 generate;不得通过 Skill 猜测或直连旧的 stateful command API。
4
+ ---
5
+
6
+ # Delta-BO 服务
7
+
8
+ ## 强制规则
9
+
10
+ - 只用 `python_repl` 执行 `$SKILLS_ROOT/delta-science/scripts/invoke.py`,
11
+ tool=`delta-bo`;禁止 Bash、路径探测、字面 CLI、直接 HTTP 和本地 BO。
12
+ - `python_repl` 工具参数只能包含 `code`,禁止 `deps/dependencies/packages`。
13
+ - 业务结果直接在 `r["native"]`,禁止 `native.data`。
14
+ - 当前 catalog 只有 `commands`(无 body)与 `generate`(JSON body)。旧文档中的
15
+ session/space/objective/policy/suggest/observe/loop 等不是当前 CLI operation,
16
+ 不得执行或猜 endpoint。
17
+
18
+ ## generate 最小规则
19
+
20
+ - 没有真实历史,或历史少于 5 条且用户未明确要求 BO:用
21
+ `algorithm:"random-search"`,给有界 `params`、`num_suggestions` 和 seed。
22
+ - 有真实历史且明确要求 BO:使用 `objectives`、object-form
23
+ `histories.decisions/observations`,必要时才加入 model/acquisition/solver。
24
+ - 参数类型仅 `numeric`、`integer`、`categorical`;不得编造观测或最优结果。
25
+ - 只报告 native 的 suggestions、metadata、warnings、diversity;空建议或失败不得用
26
+ 本地 GP/UCB/随机数替代。
27
+
28
+ 最小 payload 见 `references/endpoints.md` 的 Stateless Generate。通过 wrapper 一次
29
+ 调用、校验并显式打印有界 JSON,然后立即
30
+ `step_finish(status="done", summary=<同一 JSON>)`;失败则 `status="failed"`。
31
+ 调用后不得输出自由文本或使用其他工具。
@@ -0,0 +1,4 @@
1
+ interface:
2
+ display_name: "Delta-BO ????"
3
+ short_description: "?? Delta CLI ???????????????"
4
+ default_prompt: "?? $delta-bo ??????????????????"
@@ -0,0 +1,263 @@
1
+ # Delta-BO API Endpoint Reference
2
+
3
+ All paths are relative to `http://111.2.199.31:52317/api/v1`.
4
+
5
+ This reference is for using the exposed HTTP API. It is not a demo runner.
6
+
7
+ ## Health And Command Discovery
8
+
9
+ `GET /chem/delta-bo/health`
10
+
11
+ `GET /chem/delta-bo/commands`
12
+
13
+ `/commands` returns the native route list exposed by the deployed service.
14
+
15
+ For a formatted catalog with gateway URLs against the deployed service, run the
16
+ bundled skill-local script (no local `delta_bo` package required):
17
+
18
+ ```bash
19
+ python3 scripts/remote_list_eng_cmds.py --format markdown
20
+ python3 scripts/remote_list_eng_cmds.py --format json
21
+ ```
22
+
23
+ For complete local route metadata including parameters, the offline equivalent
24
+ `list_eng_cmds.py` (requires a Delta-BO dev environment with dependencies
25
+ installed, not bundled) walks the same command registry used by the service
26
+ dispatcher and is the source of truth for possible native API usage.
27
+
28
+ ## Stateless Generate
29
+
30
+ `POST /chem/delta-bo/generate`
31
+
32
+ Random search:
33
+
34
+ ```json
35
+ {
36
+ "params": [{"name": "x", "type": "numeric", "low": 0.0, "high": 1.0}],
37
+ "num_suggestions": 3,
38
+ "algorithm": "random-search",
39
+ "seed": 42
40
+ }
41
+ ```
42
+
43
+ BO with history:
44
+
45
+ ```json
46
+ {
47
+ "params": [
48
+ {"name": "temperature", "type": "numeric", "low": 20.0, "high": 120.0},
49
+ {"name": "catalyst", "type": "categorical", "choices": ["A", "B", "C"]}
50
+ ],
51
+ "objectives": [{"name": "yield", "minimize": false}],
52
+ "num_suggestions": 2,
53
+ "algorithm": "bo",
54
+ "model": {"name": "gp", "min_samples": 2, "train_steps": 50},
55
+ "acq_target": {"name": "ucb", "beta": 2.0},
56
+ "solver": {"name": "ga", "pop_size": 40, "n_gen": 10},
57
+ "histories": {
58
+ "decisions": [[40.0, "A"], [80.0, "B"], [100.0, "C"]],
59
+ "observations": [0.42, 0.61, 0.53]
60
+ },
61
+ "seed": 7
62
+ }
63
+ ```
64
+
65
+ Parameter types: `numeric`, `integer`, `categorical`.
66
+
67
+ Histories may also use object-form rows, which are safer for agents:
68
+
69
+ ```json
70
+ {
71
+ "histories": {
72
+ "decisions": [
73
+ {"temperature": 40.0, "catalyst": "A"},
74
+ {"temperature": 80.0, "catalyst": "B"}
75
+ ],
76
+ "observations": [
77
+ {"yield": 0.42},
78
+ {"yield": 0.61}
79
+ ]
80
+ }
81
+ }
82
+ ```
83
+
84
+ Optional diversity controls:
85
+
86
+ ```json
87
+ {
88
+ "diversity": {
89
+ "deduplicate": true,
90
+ "min_numeric_distance": {"temperature": 5.0},
91
+ "prefer_unique_categories": true
92
+ },
93
+ "constraints": [
94
+ {"type": "unique_batch"},
95
+ {"type": "avoid_seen_decisions"},
96
+ {
97
+ "type": "max_temperature_for_category",
98
+ "category_param": "solvent",
99
+ "temperature_param": "temperature",
100
+ "category": "dichloromethane",
101
+ "max": 40
102
+ }
103
+ ]
104
+ }
105
+ ```
106
+
107
+ Response fields include:
108
+
109
+ ```json
110
+ {
111
+ "suggestions": [[{"name": "temperature", "value": 72.0}]],
112
+ "suggestion_metadata": [
113
+ {
114
+ "acquisition_value": null,
115
+ "nearest_history": {
116
+ "decision": [{"name": "temperature", "value": 80.0}],
117
+ "distance": 0.08
118
+ },
119
+ "rationale": "exploitation"
120
+ }
121
+ ],
122
+ "warnings": [
123
+ "Only 3 observations supplied; GP fit may be weak. Consider random-search or more initial points."
124
+ ],
125
+ "generated_candidate_count": 15,
126
+ "diversity": {
127
+ "requested": true,
128
+ "deduplicated": true,
129
+ "duplicates_removed": 2
130
+ }
131
+ }
132
+ ```
133
+
134
+ ## Native Stateful Command API
135
+
136
+ Gateway path pattern:
137
+
138
+ ```text
139
+ POST /chem/delta-bo/v1/{command_path}
140
+ ```
141
+
142
+ Native route `/v1/session/new` maps to gateway route:
143
+
144
+ ```text
145
+ /api/v1/chem/delta-bo/v1/session/new
146
+ ```
147
+
148
+ Minimal random-search session:
149
+
150
+ ```bash
151
+ curl -s "$DBO/v1/session/new" \
152
+ -H "Content-Type: application/json" \
153
+ -d '{"name":"api_session"}'
154
+
155
+ curl -s "$DBO/v1/space" \
156
+ -H "Content-Type: application/json" \
157
+ -d '{"decision_expression":"Joint({\"x\": Num(-5, 10), \"y\": Num(0, 15)})"}'
158
+
159
+ curl -s "$DBO/v1/objective" \
160
+ -H "Content-Type: application/json" \
161
+ -d '{"source":"objectives/branin_simple.py","minimize":true}'
162
+
163
+ curl -s "$DBO/v1/policy/random-search" \
164
+ -H "Content-Type: application/json" \
165
+ -d '{"policy_id":"random_init","replace":true}'
166
+
167
+ curl -s "$DBO/v1/suggest" \
168
+ -H "Content-Type: application/json" \
169
+ -d '{"num":3,"policy_id":"random_init"}'
170
+ ```
171
+
172
+ Common native commands:
173
+
174
+ ```text
175
+ session/new
176
+ session/save
177
+ space
178
+ objective
179
+ policy/random-search
180
+ policy/bo
181
+ policy/bo.model/gp
182
+ policy/bo.target/ucb
183
+ policy/bo.target/ei
184
+ policy/bo.solver/ga
185
+ policy/flags
186
+ suggest
187
+ observe
188
+ loop
189
+ status
190
+ best
191
+ plot/best-so-far
192
+ ```
193
+
194
+ Use `GET /chem/delta-bo/commands` for the deployed list; run the bundled
195
+ `scripts/remote_list_eng_cmds.py --format markdown/json` for a formatted catalog
196
+ against the deployed service, or the offline `list_eng_cmds.py` (local Delta-BO
197
+ dev environment, not bundled) for full parameter schemas.
198
+
199
+ ## Native BO Policy Setup
200
+
201
+ A typical stateful BO configuration is:
202
+
203
+ ```bash
204
+ curl -s "$DBO/v1/policy/bo" \
205
+ -H "Content-Type: application/json" \
206
+ -d '{"replace":true}'
207
+
208
+ curl -s "$DBO/v1/policy/bo.model/gp" \
209
+ -H "Content-Type: application/json" \
210
+ -d '{"train_steps":50,"min_samples":2}'
211
+
212
+ curl -s "$DBO/v1/policy/bo.target/ucb" \
213
+ -H "Content-Type: application/json" \
214
+ -d '{"beta":2.0}'
215
+
216
+ curl -s "$DBO/v1/policy/bo.solver/ga" \
217
+ -H "Content-Type: application/json" \
218
+ -d '{"pop_size":40,"n_gen":10}'
219
+ ```
220
+
221
+ For random initialization policy creation:
222
+
223
+ ```bash
224
+ curl -s "$DBO/v1/policy/random-search" \
225
+ -H "Content-Type: application/json" \
226
+ -d '{"policy_id":"random_init","replace":true}'
227
+ ```
228
+
229
+ Then run an optimization loop:
230
+
231
+ ```bash
232
+ curl -s "$DBO/v1/loop" \
233
+ -H "Content-Type: application/json" \
234
+ -d '{"iterations":5,"batch_size":1,"policy_id":"main","timeout":300}'
235
+ ```
236
+
237
+ Response shape is nested:
238
+
239
+ ```json
240
+ {
241
+ "code": 0,
242
+ "message": "success",
243
+ "data": {
244
+ "ok": true,
245
+ "result": {
246
+ "data": {},
247
+ "summary": "...",
248
+ "meta": {"command_path": "/v1/..."}
249
+ }
250
+ }
251
+ }
252
+ ```
253
+
254
+ ## Retry Safety
255
+
256
+ Setup/configuration requests such as `space`, `objective`, `policy/bo`, and
257
+ `policy/random-search` can be repeated with the same payload. Use
258
+ `{"replace": true}` for policy creation so repeated setup calls remain
259
+ idempotent.
260
+
261
+ Do not blindly retry state-changing optimization commands such as `loop`,
262
+ `suggest`, `observe`, `session/new`, or `session/save`, because a retry may
263
+ advance or duplicate remote experiment state.