omics-os 0.0.1 → 1.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.
Files changed (82) hide show
  1. package/LICENSE +664 -0
  2. package/README.md +384 -4
  3. package/package.json +34 -12
  4. package/packages/cli/dist/index.js +154 -0
  5. package/packages/cloud-client/dist/agents.d.ts +20 -0
  6. package/packages/cloud-client/dist/agents.js +69 -0
  7. package/packages/cloud-client/dist/apiClient.d.ts +44 -0
  8. package/packages/cloud-client/dist/apiClient.js +368 -0
  9. package/packages/cloud-client/dist/auth.d.ts +76 -0
  10. package/packages/cloud-client/dist/auth.js +463 -0
  11. package/packages/cloud-client/dist/biovault/approval.d.ts +40 -0
  12. package/packages/cloud-client/dist/biovault/approval.js +38 -0
  13. package/packages/cloud-client/dist/biovault/assurance.d.ts +10 -0
  14. package/packages/cloud-client/dist/biovault/assurance.js +14 -0
  15. package/packages/cloud-client/dist/biovault/client.d.ts +76 -0
  16. package/packages/cloud-client/dist/biovault/client.js +212 -0
  17. package/packages/cloud-client/dist/biovault/compat.d.ts +29 -0
  18. package/packages/cloud-client/dist/biovault/compat.js +90 -0
  19. package/packages/cloud-client/dist/biovault/entries.d.ts +143 -0
  20. package/packages/cloud-client/dist/biovault/entries.js +359 -0
  21. package/packages/cloud-client/dist/biovault/errors.d.ts +18 -0
  22. package/packages/cloud-client/dist/biovault/errors.js +90 -0
  23. package/packages/cloud-client/dist/biovault/fields.d.ts +7 -0
  24. package/packages/cloud-client/dist/biovault/fields.js +42 -0
  25. package/packages/cloud-client/dist/biovault/identity.d.ts +10 -0
  26. package/packages/cloud-client/dist/biovault/identity.js +43 -0
  27. package/packages/cloud-client/dist/biovault/index.d.ts +15 -0
  28. package/packages/cloud-client/dist/biovault/index.js +16 -0
  29. package/packages/cloud-client/dist/biovault/instructionMatch.d.ts +32 -0
  30. package/packages/cloud-client/dist/biovault/instructionMatch.js +118 -0
  31. package/packages/cloud-client/dist/biovault/pending.d.ts +41 -0
  32. package/packages/cloud-client/dist/biovault/pending.js +208 -0
  33. package/packages/cloud-client/dist/biovault/preCommit.d.ts +10 -0
  34. package/packages/cloud-client/dist/biovault/preCommit.js +10 -0
  35. package/packages/cloud-client/dist/biovault/provenance.d.ts +45 -0
  36. package/packages/cloud-client/dist/biovault/provenance.js +55 -0
  37. package/packages/cloud-client/dist/biovault/vendor/packageDeliveryV1.generated.d.ts +3981 -0
  38. package/packages/cloud-client/dist/biovault/vendor/packageDeliveryV1.generated.js +3632 -0
  39. package/packages/cloud-client/dist/biovault/vendor/runV1.generated.d.ts +2326 -0
  40. package/packages/cloud-client/dist/biovault/vendor/runV1.generated.js +491 -0
  41. package/packages/cloud-client/dist/biovault/wireShape.d.ts +25 -0
  42. package/packages/cloud-client/dist/biovault/wireShape.js +88 -0
  43. package/packages/cloud-client/dist/bootstrap.d.ts +4 -0
  44. package/packages/cloud-client/dist/bootstrap.js +19 -0
  45. package/packages/cloud-client/dist/config.d.ts +44 -0
  46. package/packages/cloud-client/dist/config.js +309 -0
  47. package/packages/cloud-client/dist/credentials.d.ts +96 -0
  48. package/packages/cloud-client/dist/credentials.js +395 -0
  49. package/packages/cloud-client/dist/editor.d.ts +77 -0
  50. package/packages/cloud-client/dist/editor.js +278 -0
  51. package/packages/cloud-client/dist/errors.d.ts +27 -0
  52. package/packages/cloud-client/dist/errors.js +102 -0
  53. package/packages/cloud-client/dist/exports.d.ts +19 -0
  54. package/packages/cloud-client/dist/exports.js +85 -0
  55. package/packages/cloud-client/dist/featureFlags.d.ts +10 -0
  56. package/packages/cloud-client/dist/featureFlags.js +36 -0
  57. package/packages/cloud-client/dist/files.d.ts +35 -0
  58. package/packages/cloud-client/dist/files.js +109 -0
  59. package/packages/cloud-client/dist/index.d.ts +29 -0
  60. package/packages/cloud-client/dist/index.js +22 -0
  61. package/packages/cloud-client/dist/multipartUpload.d.ts +99 -0
  62. package/packages/cloud-client/dist/multipartUpload.js +624 -0
  63. package/packages/cloud-client/dist/projects.d.ts +42 -0
  64. package/packages/cloud-client/dist/projects.js +119 -0
  65. package/packages/cloud-client/dist/resources.d.ts +8 -0
  66. package/packages/cloud-client/dist/resources.js +26 -0
  67. package/packages/cloud-client/dist/sessions.d.ts +67 -0
  68. package/packages/cloud-client/dist/sessions.js +187 -0
  69. package/packages/cloud-client/dist/templates.d.ts +4 -0
  70. package/packages/cloud-client/dist/templates.js +12 -0
  71. package/packages/cloud-client/dist/types.d.ts +431 -0
  72. package/packages/cloud-client/dist/types.js +94 -0
  73. package/packages/cloud-client/dist/uploads.d.ts +93 -0
  74. package/packages/cloud-client/dist/uploads.js +61 -0
  75. package/packages/cloud-client/dist/vault.d.ts +20 -0
  76. package/packages/cloud-client/dist/vault.js +43 -0
  77. package/packages/cloud-client/dist/vectorSearch.d.ts +3 -0
  78. package/packages/cloud-client/dist/vectorSearch.js +12 -0
  79. package/packages/tui/dist/lobster.mjs +273 -0
  80. package/skills/omics-os-cloud/SKILL.md +24 -0
  81. package/skills/omics-os-lobster/SKILL.md +24 -0
  82. package/bin/omics-os.js +0 -5
@@ -0,0 +1,212 @@
1
+ /** BioVault read-only HTTP client. Transport errors stay intact so callers can
2
+ * distinguish exhausted safe GET retries from malformed, non-retryable reads.
3
+ * Classification/presentation belongs to the command's route-aware adapter.
4
+ */
5
+ import { apiFetch } from '../apiClient.js';
6
+ import { ApiError, UnreadableResponseError } from '../types.js';
7
+ import { featuresNonconformity, draftNonconformity, entriesNonconformity, entryNonconformity, jobNonconformity, legacyJobsNonconformity, deliveryNonconformity, jobPromptNonconformity, } from './entries.js';
8
+ import { APPROVAL_GENERATION } from './approval.js';
9
+ import { displayRunsNonconformity, displayJobNonconformity, withCompatibility, withoutCompatibility } from './compat.js';
10
+ function locator(id) {
11
+ if (!/^[A-Za-z0-9_-]{1,128}$/.test(id)) {
12
+ const error = new ApiError('', 0, '');
13
+ error.kind = 'usage';
14
+ error.publicMessage = 'The ID must contain 1–128 letters, numbers, underscores or hyphens.';
15
+ error.exitCode = 2;
16
+ throw error;
17
+ }
18
+ return id;
19
+ }
20
+ function query(values) {
21
+ const params = new URLSearchParams();
22
+ for (const [key, value] of Object.entries(values))
23
+ if (value !== undefined)
24
+ params.set(key, String(value));
25
+ return params.size ? `?${params}` : '';
26
+ }
27
+ async function read(config, path, guard, options) {
28
+ const body = await apiFetch(config, path, { signal: options.signal });
29
+ const issue = guard(body);
30
+ if (issue)
31
+ throw new UnreadableResponseError(path, 200, 'OK', issue);
32
+ return body;
33
+ }
34
+ export function features(config, options = {}) {
35
+ return read(config, '/vault/features', featuresNonconformity, options);
36
+ }
37
+ export function getDraft(config, entryId, options = {}) {
38
+ const id = locator(entryId);
39
+ return read(config, `/vault/runs/${id}`, body => draftNonconformity(body, id), options);
40
+ }
41
+ export function listEntries(config, options = {}) {
42
+ return read(config, '/vault/entries?limit=100', entriesNonconformity, options);
43
+ }
44
+ export function getEntry(config, entryId, options = {}) {
45
+ const id = locator(entryId);
46
+ return read(config, `/vault/entries/${id}`, body => entryNonconformity(body, id), options);
47
+ }
48
+ export function listRuns(config, options) {
49
+ // An explicit view is required even for JavaScript callers, never a fallback.
50
+ if (options.view !== 'v1' && options.view !== 'legacy')
51
+ throw new TypeError('BioVault listRuns requires view "v1" or "legacy".');
52
+ const path = '/vault/jobs' + query({ view: options.view, status: options.status, outcome: options.outcome, limit: options.limit, cursor: options.cursor });
53
+ return read(config, path, options.view === 'v1' ? body => deliveryNonconformity('RunListV1', body) : legacyJobsNonconformity, options);
54
+ }
55
+ export function getRun(config, jobId, options = {}) {
56
+ const id = locator(jobId);
57
+ // jobNonconformity discriminates before validation; unsupported v1 markers
58
+ // must never downgrade to the legacy genes-based renderer.
59
+ return read(config, `/vault/jobs/${id}`, body => jobNonconformity(body, id), options);
60
+ }
61
+ export async function listRunsForDisplay(config, options = {}) {
62
+ const path = '/vault/jobs' + query({ view: 'v1', status: options.status, outcome: options.outcome, limit: options.limit, cursor: options.cursor });
63
+ const body = await read(config, path, displayRunsNonconformity, options);
64
+ return { ...body, jobs: body.jobs.map(job => withCompatibility(job)) };
65
+ }
66
+ export async function getRunForDisplay(config, jobId, options = {}) {
67
+ const id = locator(jobId);
68
+ const body = await read(config, `/vault/jobs/${id}`, answer => displayJobNonconformity(answer, id), options);
69
+ return { ...body, job: body.job.approval_generation === APPROVAL_GENERATION ? withCompatibility(body.job) : withoutCompatibility(body.job) };
70
+ }
71
+ export function getPrompt(config, jobId, options = {}) {
72
+ return read(config, `/vault/jobs/${locator(jobId)}/prompt`, jobPromptNonconformity, options);
73
+ }
74
+ export function getSamples(config, jobId, options = {}) {
75
+ const id = locator(jobId), path = `/vault/jobs/${id}/samples` + query({ limit: options.limit, cursor: options.cursor });
76
+ return read(config, path, body => deliveryNonconformity('SamplesPage', body, id), options);
77
+ }
78
+ export function getPackage(config, jobId, options = {}) {
79
+ const id = locator(jobId);
80
+ return read(config, `/vault/jobs/${id}/package`, body => deliveryNonconformity('PackageResponseV1', body, id), options);
81
+ }
82
+ export function getProblems(config, jobId, options = {}) {
83
+ const id = locator(jobId), path = `/vault/jobs/${id}/problems` + query({ status: options.status, severity: options.severity, limit: options.limit, cursor: options.cursor });
84
+ return read(config, path, body => deliveryNonconformity('ProblemsPageV1', body, id), options);
85
+ }
86
+ export function getDecisions(config, jobId, options = {}) {
87
+ const id = locator(jobId), path = `/vault/jobs/${id}/decisions` + query({ limit: options.limit, cursor: options.cursor });
88
+ return read(config, path, body => deliveryNonconformity('DecisionsPageV1', body, id), options);
89
+ }
90
+ // Draft writes. No mutation opts into transport retries. Reads above keep
91
+ // their original behavior; every write response guard runs before returning.
92
+ import * as draftFiles from 'node:fs/promises';
93
+ import { basename, extname } from 'node:path';
94
+ import { classifyVaultError } from './errors.js';
95
+ function draftUsage(message) {
96
+ const error = new ApiError('', 0, '');
97
+ error.kind = 'usage';
98
+ error.publicMessage = message;
99
+ error.exitCode = 2;
100
+ return error;
101
+ }
102
+ function draftRevision(revision) {
103
+ if (!Number.isInteger(revision) || revision <= 0)
104
+ throw draftUsage('The expected revision must be a positive integer.');
105
+ }
106
+ async function writeDraft(config, route, path, method, body, guard, id) {
107
+ try {
108
+ const answer = await apiFetch(config, path, { method, ...(body === undefined ? {} : { body }) });
109
+ const issue = guard(answer);
110
+ if (issue)
111
+ throw new UnreadableResponseError(path, 200, 'OK', issue);
112
+ return answer;
113
+ }
114
+ catch (error) {
115
+ throw classifyVaultError(route, error, id);
116
+ }
117
+ }
118
+ export function createDraft(config, command) {
119
+ return writeDraft(config, 'R2', '/vault/runs', 'POST', command, body => draftNonconformity(body));
120
+ }
121
+ export function saveDraft(config, entryId, command) {
122
+ const id = locator(entryId);
123
+ return writeDraft(config, 'R4', `/vault/runs/${id}`, 'PUT', command, body => draftNonconformity(body, id), id);
124
+ }
125
+ /** Qualify the local RIS before any HTTP. stat follows a symlink only when its
126
+ * resolved target is a regular file; read bytes are rechecked for file races.
127
+ */
128
+ export async function uploadLiterature(config, entryId, expectedRevision, path) {
129
+ const id = locator(entryId);
130
+ draftRevision(expectedRevision);
131
+ if (extname(path) !== '.ris')
132
+ throw draftUsage('Literature must be a .ris file.');
133
+ let bytes;
134
+ try {
135
+ const stat = await draftFiles.stat(path);
136
+ if (!stat.isFile() || stat.size < 1 || stat.size > 2 * 1024 * 1024)
137
+ throw draftUsage('Literature must be a regular .ris file of 1 byte to 2 MiB.');
138
+ bytes = await draftFiles.readFile(path);
139
+ }
140
+ catch (error) {
141
+ if (error instanceof ApiError)
142
+ throw error;
143
+ throw draftUsage('The literature file could not be read.');
144
+ }
145
+ if (bytes.byteLength < 1 || bytes.byteLength > 2 * 1024 * 1024)
146
+ throw draftUsage('Literature must be a regular .ris file of 1 byte to 2 MiB.');
147
+ const form = new FormData();
148
+ form.append('file', new Blob([new Uint8Array(bytes)]), basename(path));
149
+ form.append('expected_revision', String(expectedRevision));
150
+ return writeDraft(config, 'R5', `/vault/runs/${id}/literature`, 'POST', form, body => draftNonconformity(body, id), id);
151
+ }
152
+ export function removeLiterature(config, entryId, fileId, expectedRevision) {
153
+ const id = locator(entryId);
154
+ draftRevision(expectedRevision);
155
+ if (!fileId)
156
+ throw draftUsage('A literature file ID is required.');
157
+ return writeDraft(config, 'R6', `/vault/runs/${id}/literature/${encodeURIComponent(fileId)}?expected_revision=${expectedRevision}`, 'DELETE', undefined, body => draftNonconformity(body, id), id);
158
+ }
159
+ export function discardDraft(config, entryId) {
160
+ const id = locator(entryId);
161
+ return writeDraft(config, 'R10', `/vault/entries/${id}/cancel`, 'POST', undefined, body => entryNonconformity(body, id), id);
162
+ }
163
+ function packageLinkNonconformity(body) {
164
+ const issue = deliveryNonconformity('PackageDownloadV1', body);
165
+ if (issue)
166
+ return issue;
167
+ try {
168
+ if (new URL(body.url).protocol === 'https:')
169
+ return null;
170
+ }
171
+ catch { /* no URL or response data in the public error */ }
172
+ return 'PackageDownloadV1.url: expected an HTTPS URL';
173
+ }
174
+ export function getFileLink(config, jobId, path, options = {}) {
175
+ const id = locator(jobId);
176
+ return read(config, `/vault/jobs/${id}/package/file` + query({ path }), packageLinkNonconformity, options);
177
+ }
178
+ export function getArchiveLink(config, jobId, options = {}) {
179
+ return read(config, `/vault/jobs/${locator(jobId)}/package/archive`, packageLinkNonconformity, options);
180
+ }
181
+ /** Pure comparison against copied ORIGINAL R15 bindings. For R19 the path is
182
+ * package.zip; call again for every renewal. The reason contains no URLs/data.
183
+ */
184
+ export function packageLinkMismatch(link, expected) {
185
+ for (const field of ['job_id', 'path', 'sha256', 'size_bytes']) {
186
+ if (link[field] !== expected[field])
187
+ return `PackageDownloadV1.${field}: does not match the original folder manifest`;
188
+ }
189
+ return null;
190
+ }
191
+ import { cancelNonconformity } from './entries.js';
192
+ async function control(config, route, id, body, guard, options) {
193
+ const path = route === 'R9' ? `/vault/entries/${id}/confirm` : `/vault/jobs/${id}/cancel`;
194
+ try {
195
+ const value = await apiFetch(config, path, { method: 'POST', ...(body === undefined ? {} : { body }), retry: 'none', signal: options.signal });
196
+ const issue = guard(value);
197
+ if (issue)
198
+ throw new UnreadableResponseError(path, 200, 'OK', issue);
199
+ return value;
200
+ }
201
+ catch (error) {
202
+ throw classifyVaultError(route, error, id);
203
+ }
204
+ }
205
+ export function executeRun(config, entryId, tuple, options = {}) {
206
+ const id = locator(entryId);
207
+ return control(config, 'R9', id, tuple, value => entryNonconformity(value, id), options);
208
+ }
209
+ export function cancelRun(config, jobId, options = {}) {
210
+ const id = locator(jobId);
211
+ return control(config, 'R20', id, undefined, value => cancelNonconformity(value, id), options);
212
+ }
@@ -0,0 +1,29 @@
1
+ import type { WireShapes } from './wireShape.js';
2
+ export declare const NEWER_SERVER_NOTICE = "Made by a newer server; this CLI can't verify or execute it. Update the CLI (npm install -g omics-os@latest).";
3
+ export type NewerServerField = 'restricted_profile.profile_id' | 'prompt_builder.version';
4
+ export interface RunCompatibility {
5
+ newer_server: true;
6
+ can_verify: false;
7
+ can_execute: false;
8
+ notice: string;
9
+ fields: {
10
+ field: NewerServerField;
11
+ value: string;
12
+ }[];
13
+ }
14
+ /** The delivery contract with any restricted profile id accepted as a string; the caller checks it. */
15
+ export declare const DISPLAY_SHAPES: WireShapes;
16
+ /** Why a run already shape-checked against DISPLAY_SHAPES cannot be shown, or null. */
17
+ export declare function displayProfileNonconformity(run: unknown, path: string): string | null;
18
+ /** What in a v1 run this CLI does not list, or null when it can read the run in full. */
19
+ export declare function runCompatibility(run: unknown): RunCompatibility | null;
20
+ /** R11 for display: the delivery contract with DISPLAY_SHAPES, then printable profile ids. */
21
+ export declare function displayRunsNonconformity(body: unknown): string | null;
22
+ /** R12 for display: the strict discriminator and echo, DISPLAY_SHAPES for v1 runs. */
23
+ export declare function displayJobNonconformity(body: unknown, requestedJobId: string): string | null;
24
+ /** `cli_compatibility` is local metadata: any value the server sent is dropped. */
25
+ export declare function withoutCompatibility<T extends object>(run: T): T;
26
+ /** Adds a locally derived `cli_compatibility` only when this CLI cannot read the run in full. */
27
+ export declare function withCompatibility<T extends object>(run: T): T & {
28
+ cli_compatibility?: RunCompatibility;
29
+ };
@@ -0,0 +1,90 @@
1
+ /** Runs made by a newer BioVault server, read for display only.
2
+ *
3
+ * `vault runs` and `vault run show` read a run whose manifest names a restricted
4
+ * profile or a prompt builder version this CLI does not list, and mark it: this
5
+ * CLI can neither check nor execute it. Every other read keeps the strict
6
+ * contract, and so do execute, approval, pending records and package download,
7
+ * which refuse such a run.
8
+ */
9
+ import { WIRE_SHAPES } from './vendor/packageDeliveryV1.generated.js';
10
+ import { PROMPT_VERSIONS } from './entries.js';
11
+ export const NEWER_SERVER_NOTICE = "Made by a newer server; this CLI can't verify or execute it. Update the CLI (npm install -g omics-os@latest).";
12
+ const KNOWN_PROFILES = WIRE_SHAPES.RestrictedProfile.profile_id.values;
13
+ /** An unlisted value is printed only when it is plain text of this form. */
14
+ const PRINTABLE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;
15
+ /** Manifests written before prompt version 5 record '4'; runs carrying it stay readable. */
16
+ const HISTORICAL_PROMPT_VERSIONS = ['4'];
17
+ /** The delivery contract with any restricted profile id accepted as a string; the caller checks it. */
18
+ export const DISPLAY_SHAPES = {
19
+ ...WIRE_SHAPES,
20
+ RestrictedProfile: { ...WIRE_SHAPES.RestrictedProfile, profile_id: { t: 'string', required: true } },
21
+ };
22
+ const isObject = (v) => typeof v === 'object' && v !== null && !Array.isArray(v);
23
+ function manifestOf(run) {
24
+ if (!isObject(run) || !isObject(run.run_config) || !isObject(run.run_config.execution_contract))
25
+ return null;
26
+ const manifest = run.run_config.execution_contract.manifest;
27
+ return isObject(manifest) ? manifest : null;
28
+ }
29
+ /** Exact identities only: '07' or '3' is not a version this CLI lists. */
30
+ function unlistedPrompt(version) {
31
+ return !PROMPT_VERSIONS.includes(version) && !HISTORICAL_PROMPT_VERSIONS.includes(version);
32
+ }
33
+ /** Why a run already shape-checked against DISPLAY_SHAPES cannot be shown, or null. */
34
+ export function displayProfileNonconformity(run, path) {
35
+ const profile = manifestOf(run)?.restricted_profile;
36
+ if (!isObject(profile) || typeof profile.profile_id !== 'string' || KNOWN_PROFILES.includes(profile.profile_id))
37
+ return null;
38
+ return PRINTABLE.test(profile.profile_id) ? null : `${path}.run_config.execution_contract.manifest.restricted_profile.profile_id: unsupported value`;
39
+ }
40
+ /** What in a v1 run this CLI does not list, or null when it can read the run in full. */
41
+ export function runCompatibility(run) {
42
+ const manifest = manifestOf(run);
43
+ if (!manifest)
44
+ return null;
45
+ const fields = [];
46
+ const profile = manifest.restricted_profile;
47
+ if (isObject(profile) && typeof profile.profile_id === 'string' && !KNOWN_PROFILES.includes(profile.profile_id))
48
+ fields.push({ field: 'restricted_profile.profile_id', value: PRINTABLE.test(profile.profile_id) ? profile.profile_id : '(not shown)' });
49
+ const builder = manifest.prompt_builder;
50
+ if (isObject(builder) && typeof builder.version === 'string' && unlistedPrompt(builder.version))
51
+ fields.push({ field: 'prompt_builder.version', value: PRINTABLE.test(builder.version) ? builder.version : '(not shown)' });
52
+ return fields.length ? { newer_server: true, can_verify: false, can_execute: false, notice: NEWER_SERVER_NOTICE, fields } : null;
53
+ }
54
+ import { nonconformity } from './wireShape.js';
55
+ import { jobNonconformity } from './entries.js';
56
+ import { APPROVAL_GENERATION } from './approval.js';
57
+ /** R11 for display: the delivery contract with DISPLAY_SHAPES, then printable profile ids. */
58
+ export function displayRunsNonconformity(body) {
59
+ const problem = nonconformity('RunListV1', body, DISPLAY_SHAPES);
60
+ if (problem)
61
+ return problem;
62
+ const jobs = body.jobs;
63
+ for (let i = 0; i < jobs.length; i++) {
64
+ const issue = displayProfileNonconformity(jobs[i], `RunListV1.jobs[${i}]`);
65
+ if (issue)
66
+ return issue;
67
+ }
68
+ return null;
69
+ }
70
+ /** R12 for display: the strict discriminator and echo, DISPLAY_SHAPES for v1 runs. */
71
+ export function displayJobNonconformity(body, requestedJobId) {
72
+ const issue = jobNonconformity(body, requestedJobId, DISPLAY_SHAPES);
73
+ if (issue)
74
+ return issue;
75
+ const job = body.job;
76
+ return job.approval_generation === APPROVAL_GENERATION ? displayProfileNonconformity(job, 'JobResponse.job') : null;
77
+ }
78
+ /** `cli_compatibility` is local metadata: any value the server sent is dropped. */
79
+ export function withoutCompatibility(run) {
80
+ if (!Object.hasOwn(run, 'cli_compatibility'))
81
+ return run;
82
+ const { cli_compatibility: _server, ...rest } = run;
83
+ return rest;
84
+ }
85
+ /** Adds a locally derived `cli_compatibility` only when this CLI cannot read the run in full. */
86
+ export function withCompatibility(run) {
87
+ const local = withoutCompatibility(run);
88
+ const compatibility = runCompatibility(local);
89
+ return compatibility ? { ...local, cli_compatibility: compatibility } : local;
90
+ }
@@ -0,0 +1,143 @@
1
+ /** Hand response guards for the BioVault read contract. These validate reads, not user
2
+ * DraftCommand schemas or server policy. Like the generated checker, extras are
3
+ * ignored. A diagnostic means the caller must not use the projected value.
4
+ */
5
+ import type { DraftPreview, ExecuteCommand, Explicit, Inherit, InstructionPreview, PromptSection } from './vendor/runV1.generated.js';
6
+ import type { JobDetailResponse } from './vendor/packageDeliveryV1.generated.js';
7
+ import { WIRE_SHAPES } from './vendor/packageDeliveryV1.generated.js';
8
+ import { type WireShapes } from './wireShape.js';
9
+ import { APPROVAL_GENERATION } from './approval.js';
10
+ export type ModelSelection = Inherit | Explicit;
11
+ /** Prompt versions the vendored execute contract admits. A re-vendor carries the set; there is no hand list. */
12
+ export declare const PROMPT_VERSIONS: readonly ExecuteCommand['prompt_version'][];
13
+ export declare const isPromptVersion: (v: unknown) => v is ExecuteCommand["prompt_version"];
14
+ export interface Features {
15
+ biovault_run_config: boolean;
16
+ }
17
+ export interface EntrySummary {
18
+ entry_id: string;
19
+ title: string;
20
+ status: string;
21
+ work_plan: {
22
+ preview?: DraftPreview;
23
+ model_selection?: ModelSelection;
24
+ approval?: Record<string, unknown>;
25
+ [key: string]: unknown;
26
+ };
27
+ job_ids: string[];
28
+ error_message?: string | null;
29
+ created_at?: string | null;
30
+ updated_at?: string | null;
31
+ }
32
+ export interface EntryResponse {
33
+ success: boolean;
34
+ message: string;
35
+ entry: EntrySummary | null;
36
+ }
37
+ export interface EntryListResponse {
38
+ success: boolean;
39
+ message: string;
40
+ entries: EntrySummary[];
41
+ total: number;
42
+ }
43
+ export interface LegacyJob {
44
+ job_id: string;
45
+ status: string;
46
+ genes: string[];
47
+ disease: string;
48
+ control: string;
49
+ approval_generation?: null;
50
+ created_at?: string | null;
51
+ evidence_id?: string | null;
52
+ error_message?: string | null;
53
+ run_terminal?: boolean | null;
54
+ cancel_cleanup_status?: 'pending' | 'complete' | null;
55
+ [key: string]: unknown;
56
+ }
57
+ export interface LegacyJobResponse {
58
+ success: boolean;
59
+ message: string;
60
+ job: LegacyJob;
61
+ }
62
+ export interface LegacyJobListResponse {
63
+ success: boolean;
64
+ message: string;
65
+ jobs: LegacyJob[];
66
+ total: number;
67
+ next_cursor?: string | null;
68
+ }
69
+ export type JobResponse = JobDetailResponse | LegacyJobResponse;
70
+ export interface JobPrompt {
71
+ success: boolean;
72
+ prompt: string;
73
+ prompt_sha256: string;
74
+ approved_prompt_sha256: string | null;
75
+ matches_approved: boolean;
76
+ config_sha256: string;
77
+ prompt_version: ExecuteCommand['prompt_version'];
78
+ approval_generation: typeof APPROVAL_GENERATION;
79
+ instructions: InstructionPreview | null;
80
+ prompt_sections: PromptSection[];
81
+ }
82
+ export interface CancelAck {
83
+ success: true;
84
+ message: string;
85
+ job: {
86
+ job_id: string;
87
+ status: 'cancelled';
88
+ run_terminal: true;
89
+ cancel_cleanup_status: 'pending' | 'complete';
90
+ };
91
+ }
92
+ export interface ApprovalIdentity {
93
+ user_id: string;
94
+ org_id: string;
95
+ }
96
+ export type ExecuteReadinessReason = 'not_executable' | 'blocking' | 'omni_editing' | 'turn_active' | 'no_instructions' | 'unknown_version' | 'instructions_mismatch' | 'hash_mismatch';
97
+ export type ExecuteReadiness = {
98
+ ok: true;
99
+ command: ExecuteCommand;
100
+ } | {
101
+ ok: false;
102
+ reason: ExecuteReadinessReason;
103
+ };
104
+ export declare function featuresNonconformity(body: unknown): string | null;
105
+ /** R2 requires a nonempty locator; R3–R6 also require the requested id echo. */
106
+ export declare function draftNonconformity(body: unknown, requestedEntryId?: string): string | null;
107
+ /** R7 entry row: no lifecycle inference or approval judgement here. */
108
+ export declare function entrySummaryNonconformity(entry: unknown): string | null;
109
+ export declare function entriesNonconformity(body: unknown): string | null;
110
+ /** R8/R9/R10 envelope + locator/plan shape only. Approval identity is a separate
111
+ * guard below; it must run before the unchanged ported judge(), never after it.
112
+ */
113
+ export declare function entryNonconformity(body: unknown, requestedEntryId: string): string | null;
114
+ /** Legacy rows cannot disguise an unsupported or malformed v1 response. */
115
+ export declare function legacyJobNonconformity(job: unknown): string | null;
116
+ export declare function legacyJobsNonconformity(body: unknown): string | null;
117
+ /** R12 discriminator, with no legacy downgrade for unknown non-null generations. */
118
+ export declare function jobNonconformity(body: unknown, requestedJobId: string, shapes?: WireShapes): string | null;
119
+ /** Delivery R11/R14–R19, plus requested job/path echoes where present. */
120
+ export declare function deliveryNonconformity(name: keyof typeof WIRE_SHAPES, body: unknown, requestedJobId?: string, requestedPath?: string): string | null;
121
+ /** R13 targets the corrected v1 prompt version, not the pin's known "4" bug. */
122
+ export declare function jobPromptNonconformity(body: unknown): string | null;
123
+ export declare function cancelNonconformity(body: unknown, requestedJobId: string): string | null;
124
+ export declare function modelSelectionNonconformity(value: unknown): string | null;
125
+ /** Input 2 is R8's entry summary, NOT the envelope. Diagnostic prefixes are the
126
+ * public caller distinction: "mismatch:" = coherent shapes, stale R3/R8 pair
127
+ * (exit 5); "unreadable:" = malformed/missing shape or selection (exit 1).
128
+ * Both-null instructions permit blocked drafts to be shown/exported. Callers
129
+ * must perform this check before displaying a prompt or doing any write.
130
+ */
131
+ export declare function snapshotNonconformity(r3Preview: unknown, r8Entry: unknown): string | null;
132
+ /** Read contract: non-null MUST map to unknown, never different. This guard
133
+ * deliberately does not compare the clicked tuple: judge() owns that verdict.
134
+ * A valid different tuple is evidence only after locator, membership and both
135
+ * live/pending identities have passed this guard.
136
+ */
137
+ export declare function approvalNonconformity(entry: unknown, requestedEntryId: string, identity: ApprovalIdentity, pending?: ApprovalIdentity): string | null;
138
+ /** Read contract: the first failure in the authorized API order. Preview must first
139
+ * pass draftNonconformity. Unknown versions are fenced before the structural
140
+ * and hash checks; malformed bundle JSON remains instructions_mismatch. No
141
+ * hashing normalizes or reserializes returned config/prompt/bundle strings.
142
+ */
143
+ export declare function executeReadiness(preview: DraftPreview): Promise<ExecuteReadiness>;