@genobank/biofs 3.20.5 → 3.20.7

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/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # v3.20.2 — wallet-keyed cache, fuse default host, samples verb, no hardcoded HLA/cassette paths
2
2
 
3
+ ## 3.20.7 (2026-10-23) biofs imaging register
4
+
5
+ New verbs `biofs imaging register --tp <label>=<study> ... [--reference <label>] [--anatomy chest|abdomen] [--protocol-mode auto|same|cross] [--series <label>=<series>] [--wait] [--json]` and `biofs imaging register-status <job> [--wait]`. They register N CT timepoints into one reference frame on the GPU executor through biofs-node (`POST /agent/submit_imaging_register`, `GET /agent/imaging_register_status`), coarse to fine: a rigid fit to the vertebrae that TotalSegmentator segmented consistently in both scans plus the sternum, rigid refinement on the vertebral column, then a piecewise deformable stage (ANTs SyN) in which the lungs, the viscera that move with the diaphragm (heart, inferior vena cava, liver, spleen, kidneys, pancreas; stomach and bowel follow without driving it) and the rest of the body are registered separately, so organs can slide against the rib cage as they do with breathing. Every stage is measured: surface distance of the whole bony spine (all vertebra labels merged, so a level-labeling difference between scans cannot bias it), of each lung, of the liver and of the spleen, per-structure Dice, centroid error of the consistently segmented vertebrae, Jacobian folding per region, bone rigidity, and A->B->C against A->C with three or more timepoints. The verdict (PASS, PASS_WITH_WARNINGS or FAIL) is computed against thresholds written into the result; a chest study is judged hard on the lungs and the spine, an abdominal study on the liver, the spleen and the spine. The executor container is `containers/imaging-register` (Dockerfile, `register.py`, unit and smoke tests). biofs-node checks that each study belongs to the signer and picks each series by comparability with the reference, recording why; cross-protocol pairs are registered for geometry and flagged as not comparable voxel to voxel. The result is registered as an `imaging-register` biocid whose parents are the source DICOM biocids. Status requires the owner signature.
6
+
7
+ ## 3.20.6 (2026-10-23) biofs carbonx
8
+
9
+ New verb `biofs carbonx` screens one biofile the signer owns for variant pathogenicity with Carbon-X (HuggingFaceBio/Carbon-X, a 14.8B DNA and text language model served by vLLM on a GenoBank.io GPU VM). `biofs carbonx score <biocid> [--window 4096] [--max-plp] [--max-vus] [--max-conflicting] [--max-blb] [--plan-only] [--wait]` calls biofs-node `POST /agent/carbonx_score` for a germline VCF (GRCh38 or GRCh37) or a SOMOS/23andMe genotype file; the node resolves the biocid, refuses it unless the signer owns it, keeps the alternate-allele calls that match a pinned ClinVar release exactly, asks Carbon-X about each one without the gene name or the ClinVar label, measures the answers against those labels and ranks the uncertain calls. `biofs carbonx status <job>` reports progress and metrics; `biofs carbonx report <job> [--format json] [--out file]` reads the registered report through the owner-only `derived_read`. Research output, not a clinical test. Needs biofs-node with the carbonx endpoints.
10
+
3
11
  ## 3.20.5 (2026-10-23) biofs imaging reconcile
4
12
 
5
13
  New verb `biofs imaging reconcile [--apply] [--json]` repairs the registry rows of DICOM studies already in the signer's vault. It calls biofs-node `POST /agent/imaging_reconcile`, which asks the api_imaging executor which studies it ingested for the signer and, for each one, inserts a missing `bioroutes.inventory` or `biorouter.biocid_registry` row with the same shape `biofs imaging pull` writes and fills a metadata field (study UID, modality, description, date, series and image counts) only where the row has none. Existing values are never overwritten: chain status stays as it is, a consent status of active, revoked or erased is never changed, and a registry row with no consent status at all gets `active`, the value a pull writes; a study whose row is held by another owner in either collection is reported as a conflict and left untouched in both. Dry run unless `--apply`. Needs biofs-node with the IMAGING_RECONCILE_20261023 endpoint.
@@ -0,0 +1,22 @@
1
+ export interface CarbonxScoreOptions {
2
+ window?: string;
3
+ maxPlp?: string;
4
+ maxVus?: string;
5
+ maxConflicting?: string;
6
+ maxBlb?: string;
7
+ planOnly?: boolean;
8
+ noRationale?: boolean;
9
+ label?: string;
10
+ wait?: boolean;
11
+ json?: boolean;
12
+ }
13
+ export declare function carbonxScoreCommand(inputBiocid: string, options: CarbonxScoreOptions): Promise<void>;
14
+ export declare function carbonxStatusCommand(id: string, options: {
15
+ wait?: boolean;
16
+ json?: boolean;
17
+ }): Promise<void>;
18
+ export declare function carbonxReportCommand(id: string, options: {
19
+ format?: string;
20
+ out?: string;
21
+ }): Promise<void>;
22
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/carbonx/index.ts"],"names":[],"mappings":"AAqBA,MAAM,WAAW,mBAAmB;IAClC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AA6CD,wBAAsB,mBAAmB,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAiB1G;AAED,wBAAsB,oBAAoB,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE;IAAE,IAAI,CAAC,EAAE,OAAO,CAAC;IAAC,IAAI,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAKjH;AAED,wBAAsB,oBAAoB,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAoBhH"}
@@ -0,0 +1,173 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.carbonxScoreCommand = carbonxScoreCommand;
40
+ exports.carbonxStatusCommand = carbonxStatusCommand;
41
+ exports.carbonxReportCommand = carbonxReportCommand;
42
+ /**
43
+ * biofs carbonx score <input_biocid> [--window 4096] [--max-vus 400] [--max-blb 300] [--plan-only] [--wait]
44
+ * biofs carbonx status <carbonx_job_id> [--wait]
45
+ *
46
+ * CLIENT verb. Screens one biofile you own for variant pathogenicity with Carbon-X
47
+ * (HuggingFaceBio/Carbon-X, a 14.8B DNA/text model served by vLLM on a GenoBank.io GPU VM).
48
+ * Input is a biocid: a germline VCF (exome or genome, GRCh38 or GRCh37) or a SOMOS/23andMe
49
+ * genotype file. biofs-node resolves it through biocid_registry and refuses it unless the
50
+ * signer owns it. The executor keeps the alternate-allele calls that match a pinned ClinVar
51
+ * release exactly, asks Carbon-X about each one without the gene name or the ClinVar label,
52
+ * measures the answers against those labels, ranks the VUS, and registers a JSON and a
53
+ * Markdown report as biocids (biodata_type carbonx-report) in the signer's biowallet.
54
+ * No genomic bytes reach this machine. Research output, not a clinical test.
55
+ */
56
+ const axios_1 = __importDefault(require("axios"));
57
+ const chalk_1 = __importDefault(require("chalk"));
58
+ const credentials_1 = require("../../lib/auth/credentials");
59
+ const BIOFS_NODE_BASE = process.env.BIOFS_NODE_URL
60
+ || `${process.env.GENOBANK_API_URL || 'https://genobank.app'}/api_biofs_node`;
61
+ async function auth() {
62
+ const credentials = await (0, credentials_1.getCredentials)();
63
+ if (!credentials)
64
+ throw new Error('Not authenticated. Run "biofs login" first.');
65
+ return {
66
+ wallet: credentials.wallet_address,
67
+ signature: credentials.user_signature,
68
+ headers: { 'X-Biofs-Wallet': credentials.wallet_address, 'X-Biofs-Signature': credentials.user_signature },
69
+ };
70
+ }
71
+ async function fetchStatus(id, headers) {
72
+ const r = await axios_1.default.get(`${BIOFS_NODE_BASE}/carbonx_status`, {
73
+ params: { carbonx_job_id: id }, headers, timeout: 60000, validateStatus: (s) => s < 500,
74
+ });
75
+ if (r.status >= 400)
76
+ throw new Error(`status ${r.status}: ${r.data?.error || 'unknown'}`);
77
+ return r.data;
78
+ }
79
+ function printSummary(row) {
80
+ console.log(`${chalk_1.default.cyan('Job:')} ${row.carbonx_job_id} ${row.status}${row.stage ? ` (${row.stage})` : ''}`);
81
+ if (row.input_kind)
82
+ console.log(`${chalk_1.default.cyan('Input:')} ${row.input_biocid} ${row.input_kind} ${row.build || ''}`);
83
+ if (row.selection)
84
+ console.log(`${chalk_1.default.cyan('Selection:')} ${JSON.stringify(row.selection)}`);
85
+ if (row.progress)
86
+ console.log(`${chalk_1.default.cyan('Progress:')} ${row.progress.done}/${row.progress.total}`);
87
+ if (row.summary)
88
+ console.log(`${chalk_1.default.cyan('Summary:')} ${JSON.stringify(row.summary)}`);
89
+ for (const f of row.files || [])
90
+ console.log(`${chalk_1.default.cyan('Report:')} ${f.biocid}`);
91
+ if (row.error)
92
+ console.log(`${chalk_1.default.red('Error:')} ${row.error}`);
93
+ }
94
+ async function waitFor(id, headers, json) {
95
+ let last = '';
96
+ for (;;) {
97
+ const row = await fetchStatus(id, headers);
98
+ if (row.status === 'done' || row.status === 'failed') {
99
+ if (json)
100
+ console.log(JSON.stringify(row, null, 2));
101
+ else
102
+ printSummary(row);
103
+ if (row.status === 'failed')
104
+ process.exit(1);
105
+ return;
106
+ }
107
+ const line = `${row.stage || row.status} ${row.progress ? `${row.progress.done}/${row.progress.total}` : ''}`;
108
+ if (!json && line !== last) {
109
+ console.log(chalk_1.default.gray(` ${line}`));
110
+ last = line;
111
+ }
112
+ await new Promise((r) => setTimeout(r, 15000));
113
+ }
114
+ }
115
+ async function carbonxScoreCommand(inputBiocid, options) {
116
+ if (!/^(biocid:\/\/|Biocid:)/.test(inputBiocid || ''))
117
+ throw new Error('input must be a biocid');
118
+ const a = await auth();
119
+ const num = (v) => (v === undefined ? undefined : Number(v));
120
+ const body = {
121
+ wallet: a.wallet, signature: a.signature, input_biocid: inputBiocid,
122
+ window: num(options.window), max_plp: num(options.maxPlp), max_vus: num(options.maxVus),
123
+ max_conflicting: num(options.maxConflicting), max_blb: num(options.maxBlb),
124
+ plan_only: !!options.planOnly, verdict: !options.noRationale, label: options.label,
125
+ };
126
+ const r = await axios_1.default.post(`${BIOFS_NODE_BASE}/carbonx_score`, body, {
127
+ headers: a.headers, timeout: 60000, validateStatus: (s) => s < 500,
128
+ });
129
+ if (r.status >= 400)
130
+ throw new Error(`carbonx_score ${r.status}: ${r.data?.error || 'unknown'}`);
131
+ if (!options.json)
132
+ console.log(`${chalk_1.default.green('submitted')} ${r.data.carbonx_job_id}`);
133
+ if (options.wait)
134
+ return waitFor(r.data.carbonx_job_id, a.headers, options.json);
135
+ if (options.json)
136
+ console.log(JSON.stringify(r.data, null, 2));
137
+ }
138
+ async function carbonxStatusCommand(id, options) {
139
+ const a = await auth();
140
+ if (options.wait)
141
+ return waitFor(id, a.headers, options.json);
142
+ const row = await fetchStatus(id, a.headers);
143
+ if (options.json)
144
+ console.log(JSON.stringify(row, null, 2));
145
+ else
146
+ printSummary(row);
147
+ }
148
+ async function carbonxReportCommand(id, options) {
149
+ const a = await auth();
150
+ const row = await fetchStatus(id, a.headers);
151
+ if (row.status !== 'done')
152
+ throw new Error(`job ${id} is ${row.status}${row.error ? `: ${row.error}` : ''}`);
153
+ const ext = options.format === 'json' ? '.json' : '.md';
154
+ const f = (row.files || []).find((x) => String(x.filename || '').endsWith(ext));
155
+ if (!f)
156
+ throw new Error(`job ${id} has no ${ext} report`);
157
+ const r = await axios_1.default.get(`${BIOFS_NODE_BASE}/derived_read`, {
158
+ params: { biocid: f.biocid }, headers: a.headers, timeout: 120000,
159
+ responseType: 'arraybuffer', validateStatus: (s) => s < 500,
160
+ });
161
+ if (r.status >= 400)
162
+ throw new Error(`derived_read ${r.status}: ${Buffer.from(r.data).toString('utf8').slice(0, 200)}`);
163
+ const body = Buffer.from(r.data);
164
+ if (options.out) {
165
+ const fs = await Promise.resolve().then(() => __importStar(require('fs')));
166
+ fs.writeFileSync(options.out, body, { mode: 0o600 });
167
+ console.log(`${chalk_1.default.green('saved')} ${options.out} ${f.biocid} sha256 ${r.headers['x-sha256']}`);
168
+ }
169
+ else {
170
+ process.stdout.write(body.toString('utf8'));
171
+ }
172
+ }
173
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/carbonx/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6EA,kDAiBC;AAED,oDAKC;AAED,oDAoBC;AA3HD;;;;;;;;;;;;;GAaG;AACH,kDAA0B;AAC1B,kDAA0B;AAC1B,4DAA4D;AAE5D,MAAM,eAAe,GAAG,OAAO,CAA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AC,KAAK,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC,GAAG,KAAK,CAAC,CAAC,MAAM,YAAY,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;IACtG,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;IAC9C,CAAC;AACH,CAAC"}
@@ -0,0 +1,87 @@
1
+ /**
2
+ * biofs imaging register | register-status
3
+ *
4
+ * Staged 3D registration of N CT timepoints into one reference frame, with a quality
5
+ * gate, dispatched through biofs-node to the GPU executor. For every non-reference
6
+ * timepoint the executor aligns coarse to fine: a rigid fit to the vertebrae segmented
7
+ * consistently in both scans, rigid refinement on the vertebral column, then a piecewise
8
+ * deformable stage in which the lungs, the viscera that move with the diaphragm (heart and
9
+ * abdominal organs) and the rest of the body are registered separately, so organs can slide
10
+ * against the rib cage. Each stage is
11
+ * measured: surface distance of the whole spine, of each lung, of the liver and of the
12
+ * spleen, per-structure Dice from TotalSegmentator masks,
13
+ * vertebral landmark error, Jacobian folding, bone rigidity, and, with three or more
14
+ * timepoints, agreement of A->B->C with A->C. The gate verdict (PASS, PASS_WITH_WARNINGS,
15
+ * FAIL) is computed against thresholds written into the result, so a later lesion or
16
+ * organ comparison knows how far the alignment can be trusted.
17
+ *
18
+ * biofs-node checks that every study belongs to the signer and picks each series by
19
+ * comparability with the reference (axial, original, soft-tissue kernel, closest
20
+ * thickness, same kernel family), recording why. Pass --series to override.
21
+ *
22
+ * Flow:
23
+ * POST /api_biofs_node/submit_imaging_register {signature, timepoints, reference, anatomy, protocol_mode}
24
+ * GET /api_biofs_node/imaging_register_status?register_job_id=... (owner signature in a header)
25
+ */
26
+ export interface ImagingRegisterOptions {
27
+ tp?: string[];
28
+ series?: string[];
29
+ reference?: string;
30
+ anatomy?: string;
31
+ protocolMode?: string;
32
+ wait?: boolean;
33
+ quiet?: boolean;
34
+ json?: boolean;
35
+ }
36
+ export interface ImagingRegisterStatusOptions {
37
+ wait?: boolean;
38
+ quiet?: boolean;
39
+ json?: boolean;
40
+ }
41
+ interface RegisterPair {
42
+ pair: string;
43
+ verdict: string;
44
+ hard_failures?: string[];
45
+ warnings?: string[];
46
+ deformable?: Record<string, number | null>;
47
+ }
48
+ interface RegisterResult {
49
+ status?: string;
50
+ schema?: string;
51
+ output_gcs?: string;
52
+ reference?: string;
53
+ protocol_mode?: string;
54
+ gate?: {
55
+ verdict: string;
56
+ by_pair?: Record<string, string>;
57
+ note?: string;
58
+ };
59
+ pairs?: RegisterPair[];
60
+ transitivity?: number | null;
61
+ elapsed_sec?: number;
62
+ error?: string;
63
+ }
64
+ interface RegisterRow {
65
+ register_job_id: string;
66
+ status: string;
67
+ reference?: string;
68
+ error?: string;
69
+ output_biocid?: string;
70
+ timepoints?: {
71
+ label: string;
72
+ study: string;
73
+ study_date?: string;
74
+ series: string;
75
+ selection?: {
76
+ description?: string;
77
+ kernel?: string;
78
+ thickness_mm?: number;
79
+ rationale?: string[];
80
+ };
81
+ }[];
82
+ result?: RegisterResult;
83
+ }
84
+ export declare function imagingRegisterCommand(options?: ImagingRegisterOptions): Promise<string | null>;
85
+ export declare function imagingRegisterStatusCommand(jobId: string, options?: ImagingRegisterStatusOptions): Promise<RegisterRow | null>;
86
+ export {};
87
+ //# sourceMappingURL=register.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../../../src/commands/imaging/register.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAQH,MAAM,WAAW,sBAAsB;IACrC,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,IAAI,CAA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;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE;YAAE,WAAW,CAAC,EAAE,MAAM,CAAC;YAAC,MAAM,CAAC,EAAE,MAAM,CAAC;YAAC,YAAY,CAAC,EAAE,MAAM,CAAC;YAAC,SAAS,CAAC,EAAE,MAAM,EAAE,CAAA;SAAE,CAAA;KAAE,EAAE,CAAC;IACzL,MAAM,CAAC,EAAE,cAAc,CAAC;CACzB;AAsFD,wBAAsB,sBAAsB,CAAC,OAAO,GAAE,sBAA2B,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CA8CzG;AAED,wBAAsB,4BAA4B,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE,4BAAiC,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAkBzI"}
@@ -0,0 +1,240 @@
1
+ "use strict";
2
+ /**
3
+ * biofs imaging register | register-status
4
+ *
5
+ * Staged 3D registration of N CT timepoints into one reference frame, with a quality
6
+ * gate, dispatched through biofs-node to the GPU executor. For every non-reference
7
+ * timepoint the executor aligns coarse to fine: a rigid fit to the vertebrae segmented
8
+ * consistently in both scans, rigid refinement on the vertebral column, then a piecewise
9
+ * deformable stage in which the lungs, the viscera that move with the diaphragm (heart and
10
+ * abdominal organs) and the rest of the body are registered separately, so organs can slide
11
+ * against the rib cage. Each stage is
12
+ * measured: surface distance of the whole spine, of each lung, of the liver and of the
13
+ * spleen, per-structure Dice from TotalSegmentator masks,
14
+ * vertebral landmark error, Jacobian folding, bone rigidity, and, with three or more
15
+ * timepoints, agreement of A->B->C with A->C. The gate verdict (PASS, PASS_WITH_WARNINGS,
16
+ * FAIL) is computed against thresholds written into the result, so a later lesion or
17
+ * organ comparison knows how far the alignment can be trusted.
18
+ *
19
+ * biofs-node checks that every study belongs to the signer and picks each series by
20
+ * comparability with the reference (axial, original, soft-tissue kernel, closest
21
+ * thickness, same kernel family), recording why. Pass --series to override.
22
+ *
23
+ * Flow:
24
+ * POST /api_biofs_node/submit_imaging_register {signature, timepoints, reference, anatomy, protocol_mode}
25
+ * GET /api_biofs_node/imaging_register_status?register_job_id=... (owner signature in a header)
26
+ */
27
+ var __importDefault = (this && this.__importDefault) || function (mod) {
28
+ return (mod && mod.__esModule) ? mod : { "default": mod };
29
+ };
30
+ Object.defineProperty(exports, "__esModule", { value: true });
31
+ exports.imagingRegisterCommand = imagingRegisterCommand;
32
+ exports.imagingRegisterStatusCommand = imagingRegisterStatusCommand;
33
+ const chalk_1 = __importDefault(require("chalk"));
34
+ const ora_1 = __importDefault(require("ora"));
35
+ const axios_1 = __importDefault(require("axios"));
36
+ const credentials_1 = require("../../lib/auth/credentials");
37
+ const logger_1 = require("../../lib/utils/logger");
38
+ const BIOFS_NODE_BASE = process.env.BIOFS_NODE_URL
39
+ || `${process.env.GENOBANK_API_URL || 'https://genobank.app'}/api_biofs_node`;
40
+ /** Parse repeated `label=value` options in the order given. */
41
+ function parsePairs(values, what) {
42
+ return (values || []).map((v) => {
43
+ const i = v.indexOf('=');
44
+ if (i <= 0 || i === v.length - 1)
45
+ throw new Error(`${what} must be label=value (got "${v}")`);
46
+ return { label: v.slice(0, i).trim(), value: v.slice(i + 1).trim() };
47
+ });
48
+ }
49
+ function printRow(row) {
50
+ console.log(chalk_1.default.bold(`register job ${row.register_job_id}: ${row.status}`));
51
+ for (const t of row.timepoints || []) {
52
+ const sel = t.selection || {};
53
+ console.log(` ${t.label.padEnd(10)} ${t.study_date || '????????'} ${(sel.description || '').padEnd(26).slice(0, 26)} ${sel.kernel || ''} ${sel.thickness_mm ?? ''} mm`
54
+ + (t.label === row.reference ? chalk_1.default.cyan(' (reference)') : ''));
55
+ }
56
+ const r = row.result;
57
+ if (!r)
58
+ return;
59
+ if (r.error) {
60
+ console.log(chalk_1.default.red(` error: ${r.error}`));
61
+ return;
62
+ }
63
+ const verdict = r.gate?.verdict || '?';
64
+ const color = verdict === 'PASS' ? chalk_1.default.green : verdict === 'FAIL' ? chalk_1.default.red : chalk_1.default.yellow;
65
+ console.log(` gate: ${color(verdict)} protocol: ${r.protocol_mode} transitivity Dice: ${r.transitivity ?? '-'}`);
66
+ for (const p of r.pairs || []) {
67
+ const d = p.deformable || {};
68
+ const pc = p.verdict === 'PASS' ? chalk_1.default.green : p.verdict === 'FAIL' ? chalk_1.default.red : chalk_1.default.yellow;
69
+ console.log(` ${p.pair.padEnd(18)} ${pc(p.verdict.padEnd(18))} spine ${d.spine_assd_mm ?? '-'} mm (HD95 ${d.spine_hd95_mm ?? '-'}) `
70
+ + `lungs Dice ${d.lung_dice_min ?? '-'}, HD95 ${d.lung_hd95_max_mm ?? '-'} mm liver/spleen HD95 ${d.abdominal_organ_hd95_max_mm ?? '-'} mm `
71
+ + `heart ${d.heart_dice ?? '-'} folds ${d.jacobian_fold_fraction ?? '-'}`);
72
+ for (const h of p.hard_failures || [])
73
+ console.log(chalk_1.default.red(` fail: ${h}`));
74
+ for (const w of p.warnings || [])
75
+ console.log(chalk_1.default.yellow(` warn: ${w}`));
76
+ }
77
+ if (r.gate?.note)
78
+ console.log(chalk_1.default.yellow(` ${r.gate.note}`));
79
+ if (row.output_biocid)
80
+ console.log(chalk_1.default.gray(` biocid: ${row.output_biocid}`));
81
+ }
82
+ async function fetchStatus(jobId, signature) {
83
+ const resp = await axios_1.default.get(`${BIOFS_NODE_BASE}/imaging_register_status`, {
84
+ params: { register_job_id: jobId },
85
+ headers: { 'x-biofs-signature': signature },
86
+ timeout: 30000, validateStatus: (s) => s < 500,
87
+ });
88
+ return { status: resp.status, data: resp.data };
89
+ }
90
+ async function waitFor(jobId, signature, quiet) {
91
+ const spin = quiet ? null : (0, ora_1.default)(`waiting for register job ${jobId} on the GPU executor ...`).start();
92
+ // A wrong id or a job of another wallet fails at once; after the job has answered once, a dropped
93
+ // connection or an error reply (the node also answers 403 when it briefly cannot recover the signer)
94
+ // is retried for about 10 minutes before the wait gives up.
95
+ const first = await fetchStatus(jobId, signature);
96
+ if (first.status >= 400) {
97
+ spin?.fail(`imaging_register_status ${first.status}: ${first.data?.error || 'unknown'}`);
98
+ return null;
99
+ }
100
+ if (first.data.status === 'done' || first.data.status === 'error') {
101
+ if (first.data.status === 'done')
102
+ spin?.succeed(`register job done: gate ${first.data.result?.gate?.verdict}`);
103
+ else
104
+ spin?.fail(`register job error: ${first.data.error || first.data.result?.error || 'unknown'}`);
105
+ return first.data;
106
+ }
107
+ const deadline = Date.now() + 3 * 60 * 60000; // 3 h ceiling
108
+ let failures = 0;
109
+ while (Date.now() < deadline) {
110
+ await new Promise((r) => setTimeout(r, 20000));
111
+ let status = 0;
112
+ let data = {};
113
+ let problem = '';
114
+ try {
115
+ ({ status, data } = await fetchStatus(jobId, signature));
116
+ if (status >= 400)
117
+ problem = `imaging_register_status ${status}: ${data?.error || 'unknown'}`;
118
+ }
119
+ catch (e) {
120
+ problem = `imaging_register_status unreachable: ${e?.message || e}`;
121
+ }
122
+ if (problem) {
123
+ if (++failures >= 30) {
124
+ spin?.fail(problem);
125
+ return null;
126
+ }
127
+ if (spin)
128
+ spin.text = `register job ${jobId}: ${problem}, retrying`;
129
+ continue;
130
+ }
131
+ failures = 0;
132
+ if (data.status === 'done' || data.status === 'error') {
133
+ if (data.status === 'done')
134
+ spin?.succeed(`register job done: gate ${data.result?.gate?.verdict}`);
135
+ else
136
+ spin?.fail(`register job error: ${data.error || data.result?.error || 'unknown'}`);
137
+ return data;
138
+ }
139
+ if (spin)
140
+ spin.text = `register job ${jobId}: ${data.status}`;
141
+ }
142
+ spin?.warn('wait timeout; the job may still be running. Check with: biofs imaging register-status ' + jobId);
143
+ return null;
144
+ }
145
+ async function imagingRegisterCommand(options = {}) {
146
+ const spinner = options.quiet || options.json ? null : (0, ora_1.default)('biofs imaging register → biofs-node').start();
147
+ try {
148
+ const tps = parsePairs(options.tp, '--tp');
149
+ if (tps.length < 2) {
150
+ spinner?.fail('give at least two timepoints: --tp <label>=<StudyInstanceUID or dicom biocid> (in time order)');
151
+ process.exit(1);
152
+ }
153
+ const series = new Map(parsePairs(options.series, '--series').map((s) => [s.label, s.value]));
154
+ for (const l of series.keys())
155
+ if (!tps.some((t) => t.label === l))
156
+ throw new Error(`--series ${l}=... names no --tp label`);
157
+ const credentials = await (0, credentials_1.getCredentials)();
158
+ if (!credentials) {
159
+ spinner?.fail('Not authenticated. Run: biofs login');
160
+ process.exit(1);
161
+ }
162
+ const body = {
163
+ wallet: credentials.wallet_address,
164
+ signature: credentials.user_signature,
165
+ anatomy: options.anatomy || 'chest',
166
+ reference: options.reference || tps[0].label,
167
+ protocol_mode: options.protocolMode || 'auto',
168
+ timepoints: tps.map((t) => ({ label: t.label, study: t.value, ...(series.get(t.label) ? { series: series.get(t.label) } : {}) })),
169
+ };
170
+ const resp = await axios_1.default.post(`${BIOFS_NODE_BASE}/submit_imaging_register`, body, { timeout: 120000, validateStatus: (s) => s < 500 });
171
+ if (resp.status >= 400) {
172
+ spinner?.fail(`submit_imaging_register ${resp.status}: ${resp.data?.error || 'unknown'}`);
173
+ if (options.json)
174
+ console.log(JSON.stringify(resp.data, null, 2));
175
+ return null;
176
+ }
177
+ const sub = resp.data;
178
+ spinner?.succeed(`register_job_id=${sub.register_job_id} (${(sub.timepoints || []).length} timepoints, reference ${sub.reference})`);
179
+ if (!options.json && !options.quiet) {
180
+ for (const t of sub.timepoints || []) {
181
+ const why = (t.selection?.rationale || []).join('; ');
182
+ console.log(chalk_1.default.gray(` ${t.label}: ${t.selection?.description} (${t.selection?.kernel}, ${t.selection?.thickness_mm} mm): ${why}`));
183
+ }
184
+ }
185
+ if (!options.wait) {
186
+ if (options.json)
187
+ console.log(JSON.stringify(sub, null, 2));
188
+ else if (!options.quiet)
189
+ console.log(chalk_1.default.cyan(` follow with: biofs imaging register-status ${sub.register_job_id} --wait`));
190
+ return sub.register_job_id;
191
+ }
192
+ const row = await waitFor(sub.register_job_id, credentials.user_signature, options.quiet || options.json);
193
+ if (row) {
194
+ if (options.json)
195
+ console.log(JSON.stringify(row, null, 2));
196
+ else if (!options.quiet)
197
+ printRow(row);
198
+ }
199
+ return sub.register_job_id;
200
+ }
201
+ catch (err) {
202
+ const msg = err?.response?.data?.error || err?.message || String(err);
203
+ spinner?.fail(`imaging register failed: ${msg}`);
204
+ logger_1.Logger.error(`imaging register failed: ${msg}`);
205
+ return null;
206
+ }
207
+ }
208
+ async function imagingRegisterStatusCommand(jobId, options = {}) {
209
+ try {
210
+ const credentials = await (0, credentials_1.getCredentials)();
211
+ if (!credentials) {
212
+ console.error('Not authenticated. Run: biofs login');
213
+ process.exit(1);
214
+ }
215
+ let row;
216
+ if (options.wait)
217
+ row = await waitFor(jobId, credentials.user_signature, options.quiet || options.json);
218
+ else {
219
+ const { status, data } = await fetchStatus(jobId, credentials.user_signature);
220
+ if (status >= 400) {
221
+ console.error(chalk_1.default.red(`imaging_register_status ${status}: ${data?.error || 'unknown'}`));
222
+ return null;
223
+ }
224
+ row = data;
225
+ }
226
+ if (row) {
227
+ if (options.json)
228
+ console.log(JSON.stringify(row, null, 2));
229
+ else if (!options.quiet)
230
+ printRow(row);
231
+ }
232
+ return row;
233
+ }
234
+ catch (err) {
235
+ const msg = err?.response?.data?.error || err?.message || String(err);
236
+ logger_1.Logger.error(`imaging register-status failed: ${msg}`);
237
+ return null;
238
+ }
239
+ }
240
+ //# sourceMappingURL=register.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"register.js","sourceRoot":"","sources":["../../../src/commands/imaging/register.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;;;;;AAgIH,wDA8CC;AAED,oEAkBC;AAhMD,kDAA0B;AAC1B,8CAAsB;AACtB,kDAA0B;AAC1B,4DAA4D;AAC5D,mDAAgD;AAmBhD,MAAM,eAAe,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc;OAC7C,GAAG,OAAO,CAAC,GA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