@barivia/barmesh-mcp 0.3.0 → 0.3.1
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 +5 -2
- package/dist/cfd_finalize.js +23 -0
- package/dist/cfd_prepare.js +17 -0
- package/dist/shared.js +1 -1
- package/dist/tools/cfd.js +6 -2
- package/dist/tools/jobs.js +15 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -13,7 +13,10 @@ form on a shared self-organizing map (SOM)**:
|
|
|
13
13
|
- **`barmesh_mesh_convergence`** — trains one SOM on all meshes (joint-normalized), projects
|
|
14
14
|
each mesh to a volume-weighted fingerprint, and computes **symmetric KL** and
|
|
15
15
|
**Wasserstein-1 (EMD)** distances stepwise and against a reference mesh, with publication
|
|
16
|
-
figures and an advisory convergence reading.
|
|
16
|
+
figures and an advisory convergence reading. Submit enqueues **`cfd_prepare`** on worker-io
|
|
17
|
+
when needed; the proxy auto-polls `prepare_job_id` before the mesh job runs. Default
|
|
18
|
+
**`defer_figures=true`** → **`cfd_finalize`** on worker-io; **`barmesh_jobs(status)`** auto-polls
|
|
19
|
+
**`finalize_job_id`** when figures are deferred.
|
|
17
20
|
- **`barmesh_richardson`** — classical three-level Richardson extrapolation / Grid
|
|
18
21
|
Convergence Index (GCI) on scalar quantities of interest.
|
|
19
22
|
|
|
@@ -48,7 +51,7 @@ API key; otherwise the analysis calls return HTTP 403. Contact Barivia to enable
|
|
|
48
51
|
| `barmesh_datasets` | Upload / preview / list the mesh CSV. |
|
|
49
52
|
| `barmesh_mesh_convergence` | SOM fingerprint distances (async job). |
|
|
50
53
|
| `barmesh_richardson` | Richardson/GCI on scalar QoIs (async job). |
|
|
51
|
-
| `barmesh_jobs` | Poll job status / list jobs. |
|
|
54
|
+
| `barmesh_jobs` | Poll job status / list jobs (auto-polls CFD prepare + finalize when applicable). |
|
|
52
55
|
| `barmesh_results` | Distances, convergence reading, and figures. |
|
|
53
56
|
| `barmesh_send_feedback` | Send a short note or bug report to the Barivia team. |
|
|
54
57
|
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { apiCall, pollUntilComplete } from "./shared.js";
|
|
2
|
+
/**
|
|
3
|
+
* When CFD compute finishes with defer_figures, cfd_finalize may still be rendering on worker-io.
|
|
4
|
+
*/
|
|
5
|
+
export async function pollCfdFinalizeIfPresent(jobId, data, timeoutMs = 600_000) {
|
|
6
|
+
const finalizeJobId = data.finalize_job_id;
|
|
7
|
+
if (!finalizeJobId)
|
|
8
|
+
return { finalizeJobId: null, note: null };
|
|
9
|
+
const poll = await pollUntilComplete(finalizeJobId, timeoutMs);
|
|
10
|
+
if (poll.status === "failed") {
|
|
11
|
+
throw new Error(`CFD job ${jobId}: cfd_finalize ${finalizeJobId} failed: ${poll.error ?? "unknown error"}`);
|
|
12
|
+
}
|
|
13
|
+
if (poll.status !== "completed") {
|
|
14
|
+
throw new Error(`CFD job ${jobId}: cfd_finalize ${finalizeJobId} did not complete (status=${poll.status})`);
|
|
15
|
+
}
|
|
16
|
+
return {
|
|
17
|
+
finalizeJobId,
|
|
18
|
+
note: `Finalize job ${finalizeJobId} completed (figures uploaded).`,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export async function refreshJobAfterFinalize(jobId) {
|
|
22
|
+
return (await apiCall("GET", `/v1/jobs/${jobId}`));
|
|
23
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { pollUntilComplete } from "./shared.js";
|
|
2
|
+
/**
|
|
3
|
+
* When the API enqueues cfd_prepare for mesh-convergence, poll it before the mesh job runs.
|
|
4
|
+
*/
|
|
5
|
+
export async function pollCfdPrepareIfPresent(data, label, timeoutMs = 600_000) {
|
|
6
|
+
const prepareJobId = data.prepare_job_id;
|
|
7
|
+
if (!prepareJobId)
|
|
8
|
+
return null;
|
|
9
|
+
const poll = await pollUntilComplete(prepareJobId, timeoutMs);
|
|
10
|
+
if (poll.status === "failed") {
|
|
11
|
+
throw new Error(`${label}: cfd_prepare job ${prepareJobId} failed: ${poll.error ?? "unknown error"}`);
|
|
12
|
+
}
|
|
13
|
+
if (poll.status !== "completed") {
|
|
14
|
+
throw new Error(`${label}: cfd_prepare job ${prepareJobId} did not complete (status=${poll.status})`);
|
|
15
|
+
}
|
|
16
|
+
return prepareJobId;
|
|
17
|
+
}
|
package/dist/shared.js
CHANGED
|
@@ -20,7 +20,7 @@ export const FETCH_TIMEOUT_MS = parseInt(process.env.BARIVIA_FETCH_TIMEOUT_MS ??
|
|
|
20
20
|
export const MAX_RETRIES = 2;
|
|
21
21
|
export const RETRYABLE_STATUS = new Set([502, 503, 504]);
|
|
22
22
|
/** Single source of truth for the proxy version. Keep in sync with package.json on bump. */
|
|
23
|
-
export const CLIENT_VERSION = "0.3.
|
|
23
|
+
export const CLIENT_VERSION = "0.3.1";
|
|
24
24
|
export const PUBLIC_SITE_ORIGIN = "https://barivia.se";
|
|
25
25
|
/** Large per-cell CSV uploads may exceed the default fetch timeout. */
|
|
26
26
|
export const UPLOAD_DATASET_TIMEOUT_MS = 180_000;
|
package/dist/tools/cfd.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { registerAuditedTool } from "../audit.js";
|
|
3
3
|
import { apiCall, textResult } from "../shared.js";
|
|
4
|
+
import { pollCfdPrepareIfPresent } from "../cfd_prepare.js";
|
|
4
5
|
export function registerCfdTools(server) {
|
|
5
6
|
registerAuditedTool(server, "barmesh_mesh_convergence", `Run SOM-based mesh-convergence analysis on an uploaded combined per-cell CSV.
|
|
6
7
|
|
|
@@ -38,9 +39,12 @@ COMMON MISTAKES: omitting feature_columns (required); choosing a reference_mesh
|
|
|
38
39
|
if (typeof label === "string" && label.length > 0)
|
|
39
40
|
body.label = label;
|
|
40
41
|
const data = (await apiCall("POST", "/v1/cfd/mesh-convergence", body));
|
|
42
|
+
await pollCfdPrepareIfPresent(data, "barmesh_mesh_convergence");
|
|
41
43
|
const id = data.id;
|
|
42
|
-
if (id != null)
|
|
43
|
-
data.
|
|
44
|
+
if (id != null) {
|
|
45
|
+
const prep = data.prepare_job_id != null ? " (dataset prepare complete)" : "";
|
|
46
|
+
data.suggested_next_step = `Poll barmesh_jobs(action=status, job_id=${id})${prep}; on completion call barmesh_results(action=get, job_id=${id}).`;
|
|
47
|
+
}
|
|
44
48
|
return textResult(data);
|
|
45
49
|
});
|
|
46
50
|
registerAuditedTool(server, "barmesh_richardson", `Run classical Richardson extrapolation / Grid Convergence Index (GCI) on scalar quantities of interest.
|
package/dist/tools/jobs.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { registerAuditedTool } from "../audit.js";
|
|
3
3
|
import { apiCall, textResult } from "../shared.js";
|
|
4
|
+
import { pollCfdFinalizeIfPresent, refreshJobAfterFinalize } from "../cfd_finalize.js";
|
|
4
5
|
export function registerJobsTool(server) {
|
|
5
6
|
registerAuditedTool(server, "barmesh_jobs", `Check job status or list jobs.
|
|
6
7
|
|
|
@@ -14,7 +15,20 @@ ESCALATION: status=failed returns an error message and (when available) a failur
|
|
|
14
15
|
if (action === "status") {
|
|
15
16
|
if (!job_id)
|
|
16
17
|
throw new Error("barmesh_jobs(status) requires job_id.");
|
|
17
|
-
|
|
18
|
+
let data = (await apiCall("GET", `/v1/jobs/${job_id}`));
|
|
19
|
+
const status = String(data.status ?? "");
|
|
20
|
+
if (status === "completed" && data.finalize_job_id) {
|
|
21
|
+
const { note } = await pollCfdFinalizeIfPresent(job_id, data);
|
|
22
|
+
data = await refreshJobAfterFinalize(job_id);
|
|
23
|
+
const lines = [
|
|
24
|
+
`Job ${job_id}: ${String(data.status ?? "unknown")}`,
|
|
25
|
+
data.label != null ? `Label: ${String(data.label)}` : null,
|
|
26
|
+
data.progress != null ? `Progress: ${String(data.progress)}` : null,
|
|
27
|
+
data.result_ref != null ? `Results: ${String(data.result_ref)}` : null,
|
|
28
|
+
note,
|
|
29
|
+
].filter(Boolean);
|
|
30
|
+
return textResult({ ...data, status_text: lines.join("\n") });
|
|
31
|
+
}
|
|
18
32
|
return textResult(data);
|
|
19
33
|
}
|
|
20
34
|
const data = await apiCall("GET", "/v1/jobs");
|