@inflexa-ai/harness 0.44.0 → 0.45.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/dist/agents/conversation-agent.d.ts +10 -0
- package/dist/agents/conversation-agent.js +19 -1
- package/dist/agents/sandbox/shared.d.ts +23 -2
- package/dist/agents/sandbox/shared.js +51 -18
- package/dist/agents/sandbox/translational-safety-agent.js +26 -0
- package/dist/agents/sandbox/types.d.ts +24 -1
- package/dist/agents/sandbox-catalog.d.ts +14 -0
- package/dist/agents/sandbox-catalog.js +19 -0
- package/dist/app/approve-plan.d.ts +51 -0
- package/dist/app/approve-plan.js +84 -0
- package/dist/app/chat-turn.js +6 -3
- package/dist/app/data-profile-view.d.ts +1 -1
- package/dist/app/run-activity.js +4 -6
- package/dist/config/environment-stores.d.ts +4 -2
- package/dist/contracts/chat-events.d.ts +14 -2
- package/dist/contracts/chat-events.js +1 -1
- package/dist/contracts/chat-frame.d.ts +7 -0
- package/dist/contracts/chat-frame.js +24 -6
- package/dist/contracts/chat-parts.d.ts +73 -2
- package/dist/contracts/chat-parts.js +3 -1
- package/dist/contracts/index.d.ts +4 -2
- package/dist/contracts/index.js +1 -0
- package/dist/contracts/part-registry.js +3 -0
- package/dist/contracts/schemas/chat-events.d.ts +38 -0
- package/dist/contracts/schemas/chat-events.js +8 -0
- package/dist/contracts/schemas/chat-parts.d.ts +239 -15
- package/dist/contracts/schemas/chat-parts.js +80 -12
- package/dist/contracts/schemas/index.d.ts +2 -2
- package/dist/contracts/schemas/index.js +2 -2
- package/dist/contracts/subagent-activity.d.ts +12 -0
- package/dist/contracts/subagent-activity.js +76 -0
- package/dist/execution/artifact-metadata.js +1 -3
- package/dist/execution/dbos-workflow-purger.d.ts +2 -0
- package/dist/execution/dbos-workflow-purger.js +21 -14
- package/dist/execution/run-canceler.d.ts +33 -11
- package/dist/execution/run-canceler.js +130 -28
- package/dist/execution/run-end-record.d.ts +30 -0
- package/dist/execution/run-end-record.js +27 -0
- package/dist/execution/run-event-parts.d.ts +6 -5
- package/dist/execution/run-event-parts.js +6 -5
- package/dist/execution/run-event-stream.d.ts +18 -6
- package/dist/execution/run-event-stream.js +67 -17
- package/dist/execution/run-synthesis.d.ts +21 -0
- package/dist/execution/run-synthesis.js +77 -3
- package/dist/index.d.ts +28 -10
- package/dist/index.js +26 -2
- package/dist/lib/hooks.d.ts +1 -1
- package/dist/lib/metrics.d.ts +2 -2
- package/dist/loop/call-guard.d.ts +50 -0
- package/dist/loop/call-guard.js +90 -0
- package/dist/loop/compaction.d.ts +5 -0
- package/dist/loop/compaction.js +17 -0
- package/dist/loop/run-agent.d.ts +9 -0
- package/dist/loop/run-agent.js +16 -1
- package/dist/loop/run-to-terminal.js +4 -1
- package/dist/loop/types.d.ts +8 -0
- package/dist/memory/card-builders.d.ts +11 -0
- package/dist/memory/card-builders.js +35 -21
- package/dist/memory/conversation-display-recorder.d.ts +2 -2
- package/dist/memory/conversation-display-recorder.js +38 -4
- package/dist/memory/conversation-display-storage.d.ts +9 -2
- package/dist/memory/conversation-display-storage.js +18 -3
- package/dist/memory/thread-history.d.ts +42 -8
- package/dist/memory/thread-history.js +164 -45
- package/dist/memory/thread-store.d.ts +13 -0
- package/dist/memory/thread-store.js +15 -1
- package/dist/prompts/briefing.d.ts +57 -3
- package/dist/prompts/briefing.js +129 -2
- package/dist/prompts/conversation.d.ts +1 -1
- package/dist/prompts/conversation.js +3 -1
- package/dist/prompts/planner.js +13 -2
- package/dist/provenance/seam.d.ts +39 -20
- package/dist/provenance/seam.js +7 -5
- package/dist/providers/ai-sdk.js +93 -11
- package/dist/providers/types.d.ts +6 -0
- package/dist/reference-data/catalog.js +141 -2
- package/dist/report-model/authoring-grammar.d.ts +26 -26
- package/dist/report-model/pin-snapshot.d.ts +1 -1
- package/dist/report-model/pin-snapshot.js +2 -50
- package/dist/runtime/assemble.d.ts +8 -1
- package/dist/runtime/assemble.js +11 -0
- package/dist/runtime/boot.d.ts +3 -0
- package/dist/runtime/boot.js +10 -1
- package/dist/sandbox/image-packages.d.ts +26 -4
- package/dist/sandbox/image-packages.js +18 -4
- package/dist/sandbox/sandbox-step-translate.d.ts +23 -0
- package/dist/sandbox/sandbox-step-translate.js +24 -0
- package/dist/schemas/artifact-manifest.d.ts +1 -1
- package/dist/schemas/artifact-manifest.js +11 -9
- package/dist/schemas/data-profile-schemas.d.ts +12 -12
- package/dist/schemas/plan-schemas.d.ts +75 -21
- package/dist/schemas/plan-schemas.js +1 -1
- package/dist/schemas/run-synthesis.d.ts +2 -2
- package/dist/schemas/workflow-state.d.ts +113 -0
- package/dist/schemas/workflow-state.js +54 -0
- package/dist/state/analyses-metrics.d.ts +79 -7
- package/dist/state/analyses-metrics.js +141 -6
- package/dist/state/artifacts.d.ts +66 -3
- package/dist/state/artifacts.js +85 -7
- package/dist/state/data-profile.d.ts +4 -2
- package/dist/state/data-profile.js +7 -5
- package/dist/state/index.d.ts +9 -8
- package/dist/state/index.js +5 -5
- package/dist/state/migrations/20261012120000_index_the_runs_by_start.d.ts +8 -0
- package/dist/state/migrations/20261012120000_index_the_runs_by_start.js +12 -0
- package/dist/state/migrations/20261013120000_index_the_ended_runs_and_the_recent_threads.d.ts +8 -0
- package/dist/state/migrations/20261013120000_index_the_ended_runs_and_the_recent_threads.js +13 -0
- package/dist/state/migrations/20261013180000_narrow_the_active_run_index.d.ts +8 -0
- package/dist/state/migrations/20261013180000_narrow_the_active_run_index.js +13 -0
- package/dist/state/migrations/20261014120000_index_the_plans_by_parent_and_the_runs_by_plan.d.ts +8 -0
- package/dist/state/migrations/20261014120000_index_the_plans_by_parent_and_the_runs_by_plan.js +13 -0
- package/dist/state/migrations/index.js +8 -0
- package/dist/state/plans.d.ts +21 -0
- package/dist/state/plans.js +25 -0
- package/dist/state/runs.d.ts +79 -14
- package/dist/state/runs.js +150 -33
- package/dist/state/schema.d.ts +2 -0
- package/dist/state/step-executions.d.ts +9 -0
- package/dist/state/step-executions.js +22 -0
- package/dist/tasks/data-profile-activity.d.ts +7 -1
- package/dist/tasks/data-profile-activity.js +18 -9
- package/dist/tasks/data-profile.d.ts +15 -1
- package/dist/tasks/data-profile.js +16 -11
- package/dist/tools/ad-hoc-router.d.ts +2 -0
- package/dist/tools/ad-hoc-router.js +18 -2
- package/dist/tools/approval/gateway.js +28 -5
- package/dist/tools/capability-data.d.ts +36 -0
- package/dist/tools/capability-data.js +73 -0
- package/dist/tools/display/show-user.d.ts +1 -1
- package/dist/tools/execute-analysis.d.ts +80 -1
- package/dist/tools/execute-analysis.js +352 -110
- package/dist/tools/knowledge/check.d.ts +60 -0
- package/dist/tools/knowledge/check.js +92 -0
- package/dist/tools/knowledge/client.d.ts +382 -0
- package/dist/tools/knowledge/client.js +302 -0
- package/dist/tools/knowledge/environment.d.ts +78 -0
- package/dist/tools/knowledge/environment.js +105 -0
- package/dist/tools/knowledge/index.d.ts +49 -0
- package/dist/tools/knowledge/index.js +70 -0
- package/dist/tools/knowledge/local-slots.d.ts +62 -0
- package/dist/tools/knowledge/local-slots.js +177 -0
- package/dist/tools/knowledge/pin.d.ts +14 -0
- package/dist/tools/knowledge/pin.js +17 -0
- package/dist/tools/knowledge/recommend.d.ts +92 -0
- package/dist/tools/knowledge/recommend.js +98 -0
- package/dist/tools/knowledge/situation.d.ts +143 -0
- package/dist/tools/knowledge/situation.js +164 -0
- package/dist/tools/knowledge/skeleton.d.ts +69 -0
- package/dist/tools/knowledge/skeleton.js +202 -0
- package/dist/tools/knowledge/template.d.ts +137 -0
- package/dist/tools/knowledge/template.js +267 -0
- package/dist/tools/research/generate-plan.d.ts +23 -0
- package/dist/tools/research/generate-plan.js +203 -12
- package/dist/tools/research/guarded-address.d.ts +20 -0
- package/dist/tools/research/guarded-address.js +148 -0
- package/dist/tools/research/inspect-data-profile.d.ts +1 -1
- package/dist/tools/research/inspect-run.d.ts +1 -1
- package/dist/tools/research/inspect-run.js +7 -7
- package/dist/tools/research/searxng-engine.d.ts +40 -0
- package/dist/tools/research/searxng-engine.js +120 -0
- package/dist/tools/research/web-fetch.d.ts +124 -0
- package/dist/tools/research/web-fetch.js +627 -0
- package/dist/tools/research/web-search.d.ts +75 -0
- package/dist/tools/research/web-search.js +112 -0
- package/dist/tools/sandbox/list-available-packages.d.ts +7 -4
- package/dist/tools/sandbox/list-available-packages.js +12 -4
- package/dist/tools/sandbox/list-available-refs.d.ts +21 -0
- package/dist/tools/sandbox/list-available-refs.js +60 -3
- package/dist/tools/sandbox/report-blocker.js +5 -1
- package/dist/tools/terminal-text.d.ts +11 -0
- package/dist/tools/terminal-text.js +19 -0
- package/dist/tools/workspace/decision-record.d.ts +81 -0
- package/dist/tools/workspace/decision-record.js +117 -0
- package/dist/tools/workspace/edit-file.d.ts +3 -1
- package/dist/tools/workspace/edit-file.js +20 -2
- package/dist/tools/workspace/execute-command.d.ts +17 -0
- package/dist/tools/workspace/execute-command.js +28 -1
- package/dist/tools/workspace/index.d.ts +1 -0
- package/dist/tools/workspace/index.js +1 -0
- package/dist/tools/workspace/mutator.d.ts +1 -1
- package/dist/workflows/execute-analysis.d.ts +62 -21
- package/dist/workflows/execute-analysis.js +307 -79
- package/dist/workflows/plan/graph.d.ts +16 -0
- package/dist/workflows/plan/graph.js +36 -0
- package/dist/workflows/sandbox-step.d.ts +12 -0
- package/dist/workflows/sandbox-step.js +14 -12
- package/package.json +5 -1
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `knowledge_check` — the drafted steps against the rules, once, before
|
|
3
|
+
* `submit_plan`. A violation names the rule and the permitted alternatives.
|
|
4
|
+
* The planner revises once. There is no loop: the host counts the calls of
|
|
5
|
+
* one plan generation, and past `CHECK_CALL_LIMIT` the tool answers with a
|
|
6
|
+
* typed refusal and never reaches the service. A small model that cannot
|
|
7
|
+
* satisfy a finding otherwise rephrases the step until the plan times out.
|
|
8
|
+
*/
|
|
9
|
+
import { ok } from "neverthrow";
|
|
10
|
+
import { z } from "zod";
|
|
11
|
+
import { defineTool } from "../define-tool.js";
|
|
12
|
+
import { SituationFieldsSchema, toSituation } from "./situation.js";
|
|
13
|
+
/** The checks one plan generation may run. Two is a draft and one revision; the third is slack. */
|
|
14
|
+
export const CHECK_CALL_LIMIT = 3;
|
|
15
|
+
const DraftedStepSchema = z.object({
|
|
16
|
+
step_type: z
|
|
17
|
+
.enum([
|
|
18
|
+
"cohort_assembly",
|
|
19
|
+
"qc_sample_structure",
|
|
20
|
+
"filter_low_counts",
|
|
21
|
+
"normalize",
|
|
22
|
+
"model_design",
|
|
23
|
+
"differential_expression",
|
|
24
|
+
"shrink_lfc",
|
|
25
|
+
"multiple_testing",
|
|
26
|
+
"enrichment",
|
|
27
|
+
"variance_partition",
|
|
28
|
+
"tf_activity",
|
|
29
|
+
"pathway_activity",
|
|
30
|
+
"signature_scoring",
|
|
31
|
+
"deconvolution",
|
|
32
|
+
"coexpression",
|
|
33
|
+
"clustering",
|
|
34
|
+
"survival",
|
|
35
|
+
"transcript_level",
|
|
36
|
+
"annotation",
|
|
37
|
+
"report",
|
|
38
|
+
])
|
|
39
|
+
.describe("The kind of work the drafted step does."),
|
|
40
|
+
method: z.string().min(1).describe("The method as the step names it, for example `DESeq2 Wald test` or `edgeR quasi-likelihood`."),
|
|
41
|
+
method_id: z
|
|
42
|
+
.string()
|
|
43
|
+
.regex(/^M-\d{4}$/)
|
|
44
|
+
.optional()
|
|
45
|
+
.describe("The `method.id` of the step in the `knowledge_recommend` answer (for example `M-0001`), copied when the step uses that method. With it the check matches the method exactly and ignores the wording."),
|
|
46
|
+
package: z.string().optional().describe("The main package of the step, for example `DESeq2`."),
|
|
47
|
+
parameters: z
|
|
48
|
+
.array(z.object({ name: z.string().min(1), value: z.union([z.string(), z.number(), z.boolean()]) }))
|
|
49
|
+
.optional()
|
|
50
|
+
.describe("The key parameters of the step, for example `alpha`, `min_count`, `lfc_shrink`, `rank_metric`."),
|
|
51
|
+
outcome: z
|
|
52
|
+
.string()
|
|
53
|
+
.optional()
|
|
54
|
+
.describe("The outcome the step states when a flag of `knowledge_recommend` removes inference, copied from the flag, for example `descriptive_only`."),
|
|
55
|
+
});
|
|
56
|
+
/** `ok`, or the counts of the findings, plus the steps the check did not assess when there are any. */
|
|
57
|
+
function describeFindings(result) {
|
|
58
|
+
const findings = result.ok ? "ok" : `${result.violations.length} violation(s), ${result.warnings.length} warning(s)`;
|
|
59
|
+
const notAssessed = result.not_assessed?.length ?? 0;
|
|
60
|
+
return notAssessed > 0 ? `${findings}, ${notAssessed} not assessed` : findings;
|
|
61
|
+
}
|
|
62
|
+
export function createKnowledgeCheckTool(deps) {
|
|
63
|
+
let calls = 0;
|
|
64
|
+
return defineTool({
|
|
65
|
+
id: "knowledge_check",
|
|
66
|
+
description: "Check the method steps you drafted for a bulk RNA-seq analysis against the rules of the Inflexa knowledge service, once, after the draft and before `submit_plan`. " +
|
|
67
|
+
"Send the same situation you sent to `knowledge_recommend` and the drafted steps: the step type, the method as the step names it, its package, and its key parameters. " +
|
|
68
|
+
"The answer lists `violations` (a forbidden method, or an inferential test on a design that a flag limits) and `warnings` (a method outside the set the rules name, a parameter that differs from a sourced default, or a required parameter that the step does not state), each with the rule id and the permitted alternatives. " +
|
|
69
|
+
"Revise a violated step once, then submit. A warning is advice: keep the step when the data gives a reason, and state the reason in the step. `ok: true` means no finding on the assessed steps. " +
|
|
70
|
+
"`not_assessed` lists the steps that no rule covers; the check neither passed nor failed them, so submit them as drafted. " +
|
|
71
|
+
"`match: unavailable` means the service did not answer, and `match: snapshot_mismatch` means the service moved to another release than the one your recommend answer came from; in both cases submit the draft as it is. " +
|
|
72
|
+
`The host accepts ${CHECK_CALL_LIMIT} checks per plan; after that the tool refuses and you submit with the findings you have.`,
|
|
73
|
+
inputSchema: SituationFieldsSchema.extend({
|
|
74
|
+
steps: z.array(DraftedStepSchema).min(1).describe("The drafted method steps, one entry per step type."),
|
|
75
|
+
}),
|
|
76
|
+
describeCall: ({ steps }) => `${steps.length} drafted step(s)`,
|
|
77
|
+
describeResult: (_input, result) => ("ok" in result ? describeFindings(result) : result.match),
|
|
78
|
+
execute: async (input) => {
|
|
79
|
+
calls += 1;
|
|
80
|
+
if (calls > CHECK_CALL_LIMIT) {
|
|
81
|
+
return ok({
|
|
82
|
+
match: "rejected",
|
|
83
|
+
message: `The host accepts ${CHECK_CALL_LIMIT} checks per plan, and this is call ${calls}. Submit the plan with the findings of the last check.`,
|
|
84
|
+
issues: [],
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
const { steps, ...fields } = input;
|
|
88
|
+
const answer = await deps.client.check(toSituation(fields), steps, deps.pin?.get());
|
|
89
|
+
return ok(answer);
|
|
90
|
+
},
|
|
91
|
+
});
|
|
92
|
+
}
|
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The knowledge service interface of the harness.
|
|
3
|
+
*
|
|
4
|
+
* `KnowledgeClient` is the one contract between the harness and the remote
|
|
5
|
+
* knowledge service: four typed operations and the snapshot they answer
|
|
6
|
+
* from. The harness never knows about a license. It sees a client, or it sees
|
|
7
|
+
* nothing, and an absent client is a normal state in which no knowledge tool
|
|
8
|
+
* attaches. `createHttpKnowledgeClient` is the shipped realization over plain
|
|
9
|
+
* HTTPS with the retry and timeout policy of the other external tools.
|
|
10
|
+
*
|
|
11
|
+
* Every operation answers a data variant. A service that is configured but
|
|
12
|
+
* unreachable gives `{ match: "unavailable" }` after the retry policy, and the
|
|
13
|
+
* caller continues from the prose skills. A 400 names the field and the
|
|
14
|
+
* permitted values, thus a model corrects itself in one turn. A 404 on the
|
|
15
|
+
* contract lookup names the `template` field the same way. The response
|
|
16
|
+
* shapes below are the harness copy of the wire contract of the service, kept
|
|
17
|
+
* lenient with `looseObject`, thus a richer answer of a later snapshot still
|
|
18
|
+
* parses.
|
|
19
|
+
*/
|
|
20
|
+
import { z } from "zod";
|
|
21
|
+
/** The role of the blocking factor. A role and never a column name, because the situation leaves the machine. */
|
|
22
|
+
export type BlockingRole = "individual" | "cell_line" | "litter" | "site" | "pair" | "other";
|
|
23
|
+
/** The role of a covariate of the design. A role and never a column name. */
|
|
24
|
+
export type CovariateRole = "sex" | "age" | "clinical" | "technical" | "other";
|
|
25
|
+
/** The role of the numeric variable of interest when the question is a trend, not a comparison of groups. */
|
|
26
|
+
export type PredictorRole = "dose" | "time" | "age" | "score" | "other";
|
|
27
|
+
/** The typed description of one analysis situation. Never a sample row, never an identifier, and never a column name. */
|
|
28
|
+
export interface KnowledgeSituation {
|
|
29
|
+
readonly question: "differential_expression" | "enrichment" | "qc" | "full_plan";
|
|
30
|
+
readonly modality: "bulk_rna_seq";
|
|
31
|
+
readonly data_state: "fastq" | "counts" | "tpm_or_fpkm" | "log_normalized";
|
|
32
|
+
readonly count_source?: "salmon" | "kallisto" | "star_featurecounts" | "rsem" | "unknown";
|
|
33
|
+
/** Whether the length correction of a quantifier occurred. Never required: the service sets `unknown` on counts. */
|
|
34
|
+
readonly import_state?: "quantifications" | "estimated_counts_with_lengths" | "corrected_counts" | "integer_counts" | "unknown";
|
|
35
|
+
readonly organism: "human" | "mouse" | "other";
|
|
36
|
+
readonly n_groups: number;
|
|
37
|
+
readonly n_per_group_min: number;
|
|
38
|
+
readonly n_per_group_max: number;
|
|
39
|
+
/** The total number of biological samples. Never required. */
|
|
40
|
+
readonly n_samples?: number;
|
|
41
|
+
/** The number of samples with an observed event, for a survival question. Never required. */
|
|
42
|
+
readonly n_events?: number;
|
|
43
|
+
readonly paired: boolean;
|
|
44
|
+
/** The role of the blocking factor, or null. The column name stays on the machine. */
|
|
45
|
+
readonly blocking_factor?: BlockingRole | null;
|
|
46
|
+
/** How the blocking factor relates to the condition: crossed, or nested inside one condition. */
|
|
47
|
+
readonly block_structure?: "crossed" | "nested";
|
|
48
|
+
readonly batch: "none" | "known_balanced" | "known_confounded" | "known_unbalanced" | "suspected";
|
|
49
|
+
/** The role of each covariate of the design, one entry per covariate. The column names stay on the machine. */
|
|
50
|
+
readonly covariates?: readonly CovariateRole[];
|
|
51
|
+
readonly n_timepoints?: number | null;
|
|
52
|
+
/** The role of the numeric variable of interest when the question is a trend over it; then `n_groups` is 1. The column name stays on the machine. */
|
|
53
|
+
readonly continuous_predictor?: PredictorRole | null;
|
|
54
|
+
/** True when some columns of the count table are technical replicates of one biological sample. */
|
|
55
|
+
readonly technical_replicates?: boolean;
|
|
56
|
+
/** The row unit of the count table. Absent for a gene-level table. */
|
|
57
|
+
readonly feature_level?: "gene" | "exon" | "transcript";
|
|
58
|
+
readonly library_type?: "polyA" | "total" | "three_prime" | "unknown";
|
|
59
|
+
readonly strandedness?: "verified" | "declared_unverified" | "unknown";
|
|
60
|
+
readonly interaction?: boolean;
|
|
61
|
+
/** True for a classifier of the samples into classes; absent for a per-sample score. */
|
|
62
|
+
readonly classifier?: boolean;
|
|
63
|
+
readonly quality_flags?: readonly ("low_depth_sample" | "outlier_sample" | "sample_identity_doubt" | "high_duplication" | "degraded_rna")[];
|
|
64
|
+
}
|
|
65
|
+
export declare const RecommendResponseSchema: z.ZodObject<{
|
|
66
|
+
match: z.ZodEnum<{
|
|
67
|
+
none: "none";
|
|
68
|
+
applicable: "applicable";
|
|
69
|
+
flag: "flag";
|
|
70
|
+
}>;
|
|
71
|
+
snapshot: z.ZodObject<{
|
|
72
|
+
date: z.ZodString;
|
|
73
|
+
digest: z.ZodString;
|
|
74
|
+
}, z.core.$strip>;
|
|
75
|
+
procedure: z.ZodArray<z.ZodObject<{
|
|
76
|
+
step: z.ZodString;
|
|
77
|
+
method: z.ZodOptional<z.ZodObject<{
|
|
78
|
+
id: z.ZodString;
|
|
79
|
+
label: z.ZodString;
|
|
80
|
+
}, z.core.$loose>>;
|
|
81
|
+
template: z.ZodOptional<z.ZodString>;
|
|
82
|
+
rules: z.ZodArray<z.ZodString>;
|
|
83
|
+
flags: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
84
|
+
rule: z.ZodString;
|
|
85
|
+
severity: z.ZodString;
|
|
86
|
+
message: z.ZodString;
|
|
87
|
+
outcome: z.ZodOptional<z.ZodString>;
|
|
88
|
+
}, z.core.$loose>>>;
|
|
89
|
+
alternatives: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
90
|
+
method: z.ZodString;
|
|
91
|
+
label: z.ZodString;
|
|
92
|
+
when: z.ZodString;
|
|
93
|
+
rules: z.ZodArray<z.ZodString>;
|
|
94
|
+
}, z.core.$loose>>>;
|
|
95
|
+
disputed: z.ZodOptional<z.ZodObject<{
|
|
96
|
+
rule: z.ZodString;
|
|
97
|
+
sides: z.ZodArray<z.ZodString>;
|
|
98
|
+
}, z.core.$loose>>;
|
|
99
|
+
parameters: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
100
|
+
name: z.ZodString;
|
|
101
|
+
value: z.ZodUnknown;
|
|
102
|
+
default_source: z.ZodOptional<z.ZodString>;
|
|
103
|
+
}, z.core.$loose>>>;
|
|
104
|
+
conflicts: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
105
|
+
parameter: z.ZodString;
|
|
106
|
+
entries: z.ZodArray<z.ZodObject<{
|
|
107
|
+
rule: z.ZodString;
|
|
108
|
+
value: z.ZodUnknown;
|
|
109
|
+
}, z.core.$loose>>;
|
|
110
|
+
}, z.core.$loose>>>;
|
|
111
|
+
substitution: z.ZodOptional<z.ZodObject<{
|
|
112
|
+
for: z.ZodString;
|
|
113
|
+
label: z.ZodString;
|
|
114
|
+
template: z.ZodString;
|
|
115
|
+
}, z.core.$loose>>;
|
|
116
|
+
limit: z.ZodOptional<z.ZodObject<{
|
|
117
|
+
requested_language: z.ZodEnum<{
|
|
118
|
+
R: "R";
|
|
119
|
+
python: "python";
|
|
120
|
+
}>;
|
|
121
|
+
reason: z.ZodString;
|
|
122
|
+
skipped: z.ZodArray<z.ZodObject<{
|
|
123
|
+
template: z.ZodString;
|
|
124
|
+
missing: z.ZodArray<z.ZodString>;
|
|
125
|
+
refused: z.ZodOptional<z.ZodString>;
|
|
126
|
+
}, z.core.$loose>>;
|
|
127
|
+
}, z.core.$loose>>;
|
|
128
|
+
unrealized: z.ZodOptional<z.ZodObject<{
|
|
129
|
+
reason: z.ZodString;
|
|
130
|
+
templates: z.ZodArray<z.ZodObject<{
|
|
131
|
+
template: z.ZodString;
|
|
132
|
+
why: z.ZodString;
|
|
133
|
+
}, z.core.$loose>>;
|
|
134
|
+
}, z.core.$loose>>;
|
|
135
|
+
}, z.core.$loose>>;
|
|
136
|
+
uncovered: z.ZodArray<z.ZodString>;
|
|
137
|
+
unrealized: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
138
|
+
flags: z.ZodArray<z.ZodObject<{
|
|
139
|
+
rule: z.ZodString;
|
|
140
|
+
severity: z.ZodString;
|
|
141
|
+
message: z.ZodString;
|
|
142
|
+
outcome: z.ZodOptional<z.ZodString>;
|
|
143
|
+
}, z.core.$loose>>;
|
|
144
|
+
claims: z.ZodArray<z.ZodObject<{
|
|
145
|
+
id: z.ZodString;
|
|
146
|
+
statement: z.ZodString;
|
|
147
|
+
strength: z.ZodString;
|
|
148
|
+
evidence: z.ZodArray<z.ZodObject<{
|
|
149
|
+
doi: z.ZodOptional<z.ZodString>;
|
|
150
|
+
pmid: z.ZodOptional<z.ZodString>;
|
|
151
|
+
title: z.ZodString;
|
|
152
|
+
year: z.ZodNumber;
|
|
153
|
+
direction: z.ZodString;
|
|
154
|
+
}, z.core.$loose>>;
|
|
155
|
+
}, z.core.$loose>>;
|
|
156
|
+
nearest: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
157
|
+
claim: z.ZodString;
|
|
158
|
+
title: z.ZodString;
|
|
159
|
+
failed: z.ZodArray<z.ZodString>;
|
|
160
|
+
}, z.core.$loose>>>;
|
|
161
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
162
|
+
}, z.core.$loose>;
|
|
163
|
+
export type RecommendResponse = z.infer<typeof RecommendResponseSchema>;
|
|
164
|
+
export declare const CheckResponseSchema: z.ZodObject<{
|
|
165
|
+
ok: z.ZodBoolean;
|
|
166
|
+
snapshot: z.ZodObject<{
|
|
167
|
+
date: z.ZodString;
|
|
168
|
+
digest: z.ZodString;
|
|
169
|
+
}, z.core.$strip>;
|
|
170
|
+
violations: z.ZodArray<z.ZodObject<{
|
|
171
|
+
step_type: z.ZodString;
|
|
172
|
+
severity: z.ZodString;
|
|
173
|
+
rule: z.ZodString;
|
|
174
|
+
message: z.ZodString;
|
|
175
|
+
permitted: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
176
|
+
}, z.core.$loose>>;
|
|
177
|
+
warnings: z.ZodArray<z.ZodObject<{
|
|
178
|
+
step_type: z.ZodString;
|
|
179
|
+
severity: z.ZodString;
|
|
180
|
+
rule: z.ZodString;
|
|
181
|
+
message: z.ZodString;
|
|
182
|
+
permitted: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
183
|
+
}, z.core.$loose>>;
|
|
184
|
+
not_assessed: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
185
|
+
step_type: z.ZodString;
|
|
186
|
+
reason: z.ZodString;
|
|
187
|
+
message: z.ZodString;
|
|
188
|
+
}, z.core.$loose>>>;
|
|
189
|
+
}, z.core.$loose>;
|
|
190
|
+
export type CheckResponse = z.infer<typeof CheckResponseSchema>;
|
|
191
|
+
export declare const RenderResponseSchema: z.ZodObject<{
|
|
192
|
+
ok: z.ZodLiteral<true>;
|
|
193
|
+
snapshot: z.ZodObject<{
|
|
194
|
+
date: z.ZodString;
|
|
195
|
+
digest: z.ZodString;
|
|
196
|
+
}, z.core.$strip>;
|
|
197
|
+
template: z.ZodObject<{
|
|
198
|
+
id: z.ZodString;
|
|
199
|
+
version: z.ZodString;
|
|
200
|
+
label: z.ZodString;
|
|
201
|
+
method: z.ZodObject<{
|
|
202
|
+
id: z.ZodString;
|
|
203
|
+
label: z.ZodString;
|
|
204
|
+
}, z.core.$loose>;
|
|
205
|
+
substitute_for: z.ZodOptional<z.ZodObject<{
|
|
206
|
+
id: z.ZodString;
|
|
207
|
+
label: z.ZodString;
|
|
208
|
+
}, z.core.$loose>>;
|
|
209
|
+
language: z.ZodString;
|
|
210
|
+
}, z.core.$loose>;
|
|
211
|
+
script: z.ZodString;
|
|
212
|
+
slots: z.ZodArray<z.ZodObject<{
|
|
213
|
+
name: z.ZodString;
|
|
214
|
+
value: z.ZodOptional<z.ZodUnknown>;
|
|
215
|
+
source: z.ZodString;
|
|
216
|
+
adaptable: z.ZodBoolean;
|
|
217
|
+
lines: z.ZodArray<z.ZodNumber>;
|
|
218
|
+
read: z.ZodOptional<z.ZodBoolean>;
|
|
219
|
+
}, z.core.$loose>>;
|
|
220
|
+
local_slots: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
221
|
+
environment: z.ZodObject<{
|
|
222
|
+
match: z.ZodString;
|
|
223
|
+
}, z.core.$loose>;
|
|
224
|
+
syntax: z.ZodObject<{
|
|
225
|
+
status: z.ZodString;
|
|
226
|
+
}, z.core.$loose>;
|
|
227
|
+
outputs: z.ZodArray<z.ZodObject<{
|
|
228
|
+
name: z.ZodString;
|
|
229
|
+
path: z.ZodString;
|
|
230
|
+
description: z.ZodOptional<z.ZodString>;
|
|
231
|
+
}, z.core.$loose>>;
|
|
232
|
+
decision_record: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
233
|
+
}, z.core.$loose>;
|
|
234
|
+
export type RenderResponse = z.infer<typeof RenderResponseSchema>;
|
|
235
|
+
/**
|
|
236
|
+
* One slot of a template with the constraint a caller value must obey.
|
|
237
|
+
* `adaptable: false` marks a pinned slot: the render refuses a caller value
|
|
238
|
+
* for it. An adaptable slot without a default is required unless `required`
|
|
239
|
+
* is false.
|
|
240
|
+
*/
|
|
241
|
+
declare const TemplateParameterSchema: z.ZodObject<{
|
|
242
|
+
name: z.ZodString;
|
|
243
|
+
type: z.ZodString;
|
|
244
|
+
description: z.ZodString;
|
|
245
|
+
adaptable: z.ZodBoolean;
|
|
246
|
+
local: z.ZodOptional<z.ZodBoolean>;
|
|
247
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
248
|
+
default: z.ZodOptional<z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>]>>;
|
|
249
|
+
default_source: z.ZodOptional<z.ZodString>;
|
|
250
|
+
enum: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
251
|
+
pattern: z.ZodOptional<z.ZodString>;
|
|
252
|
+
minimum: z.ZodOptional<z.ZodNumber>;
|
|
253
|
+
maximum: z.ZodOptional<z.ZodNumber>;
|
|
254
|
+
}, z.core.$loose>;
|
|
255
|
+
export type TemplateParameter = z.infer<typeof TemplateParameterSchema>;
|
|
256
|
+
/**
|
|
257
|
+
* The contract of one template as `GET /v1/templates/{id}` serves it: every
|
|
258
|
+
* slot, pinned ones included, the inputs, and the outputs. The service adds
|
|
259
|
+
* fields such as `step_types` and `environment`; they pass through the loose
|
|
260
|
+
* remainder.
|
|
261
|
+
*/
|
|
262
|
+
export declare const TemplateContractSchema: z.ZodObject<{
|
|
263
|
+
id: z.ZodString;
|
|
264
|
+
version: z.ZodString;
|
|
265
|
+
label: z.ZodString;
|
|
266
|
+
method: z.ZodString;
|
|
267
|
+
substitute_for: z.ZodOptional<z.ZodString>;
|
|
268
|
+
language: z.ZodString;
|
|
269
|
+
honors: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
270
|
+
parameters: z.ZodArray<z.ZodObject<{
|
|
271
|
+
name: z.ZodString;
|
|
272
|
+
type: z.ZodString;
|
|
273
|
+
description: z.ZodString;
|
|
274
|
+
adaptable: z.ZodBoolean;
|
|
275
|
+
local: z.ZodOptional<z.ZodBoolean>;
|
|
276
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
277
|
+
default: z.ZodOptional<z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>]>>;
|
|
278
|
+
default_source: z.ZodOptional<z.ZodString>;
|
|
279
|
+
enum: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
280
|
+
pattern: z.ZodOptional<z.ZodString>;
|
|
281
|
+
minimum: z.ZodOptional<z.ZodNumber>;
|
|
282
|
+
maximum: z.ZodOptional<z.ZodNumber>;
|
|
283
|
+
}, z.core.$loose>>;
|
|
284
|
+
inputs: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
285
|
+
name: z.ZodString;
|
|
286
|
+
path: z.ZodString;
|
|
287
|
+
description: z.ZodOptional<z.ZodString>;
|
|
288
|
+
}, z.core.$loose>>>;
|
|
289
|
+
outputs: z.ZodArray<z.ZodObject<{
|
|
290
|
+
name: z.ZodString;
|
|
291
|
+
path: z.ZodString;
|
|
292
|
+
description: z.ZodOptional<z.ZodString>;
|
|
293
|
+
}, z.core.$loose>>;
|
|
294
|
+
notes: z.ZodOptional<z.ZodString>;
|
|
295
|
+
}, z.core.$loose>;
|
|
296
|
+
export type TemplateContract = z.infer<typeof TemplateContractSchema>;
|
|
297
|
+
/** The preferences of the caller: the language of the template the answer names. */
|
|
298
|
+
export interface KnowledgePreferences {
|
|
299
|
+
readonly language?: "R" | "python";
|
|
300
|
+
}
|
|
301
|
+
/** What a drafted step carries into the check. */
|
|
302
|
+
export interface DraftedStep {
|
|
303
|
+
readonly step_type: string;
|
|
304
|
+
readonly method: string;
|
|
305
|
+
/** The catalog id of the method (`M-dddd`), copied from the recommendation. An exact match wins over the wording. */
|
|
306
|
+
readonly method_id?: string;
|
|
307
|
+
readonly package?: string;
|
|
308
|
+
readonly parameters?: readonly {
|
|
309
|
+
readonly name: string;
|
|
310
|
+
readonly value: string | number | boolean;
|
|
311
|
+
}[];
|
|
312
|
+
/** The outcome the step states when the design forbids inference, for example `descriptive_only`. */
|
|
313
|
+
readonly outcome?: string;
|
|
314
|
+
}
|
|
315
|
+
export interface FarmPackage {
|
|
316
|
+
readonly name: string;
|
|
317
|
+
readonly version: string;
|
|
318
|
+
}
|
|
319
|
+
/** The service could not answer after the retry policy. The run continues from the prose skills. */
|
|
320
|
+
export interface KnowledgeUnavailable {
|
|
321
|
+
readonly match: "unavailable";
|
|
322
|
+
readonly reason: string;
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* The service serves another release than the one the plan pinned, and it
|
|
326
|
+
* did no work. A plan is not moved to a new release in silence: the caller
|
|
327
|
+
* proceeds as with an unavailable service, and it states the two digests.
|
|
328
|
+
*/
|
|
329
|
+
export interface KnowledgeSnapshotMismatch {
|
|
330
|
+
readonly match: "snapshot_mismatch";
|
|
331
|
+
readonly message: string;
|
|
332
|
+
readonly expected: string;
|
|
333
|
+
readonly served: {
|
|
334
|
+
readonly date: string;
|
|
335
|
+
readonly digest: string;
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
/** The service refused the request and named the field or the slot and the permitted values. */
|
|
339
|
+
export interface KnowledgeRejected {
|
|
340
|
+
readonly match: "rejected";
|
|
341
|
+
readonly message: string;
|
|
342
|
+
readonly issues: readonly {
|
|
343
|
+
readonly field?: string;
|
|
344
|
+
readonly slot?: string;
|
|
345
|
+
readonly message?: string;
|
|
346
|
+
readonly reason?: string;
|
|
347
|
+
readonly permitted?: readonly string[];
|
|
348
|
+
}[];
|
|
349
|
+
}
|
|
350
|
+
/** What a render call carries beside the template and the slots. */
|
|
351
|
+
export interface RenderCallOptions {
|
|
352
|
+
/** The id of the plan step that runs the script. */
|
|
353
|
+
readonly step?: string;
|
|
354
|
+
/** The claims of the plan step that selected the template. Each must resolve in the served snapshot. */
|
|
355
|
+
readonly claims?: readonly string[];
|
|
356
|
+
/** The release digest the plan pinned. The service refuses another release with `snapshot_mismatch`. */
|
|
357
|
+
readonly expectedSnapshot?: string;
|
|
358
|
+
}
|
|
359
|
+
export interface KnowledgeClient {
|
|
360
|
+
/** `expectedSnapshot` pins the release of an earlier answer of the same plan; the first call of a plan has none. */
|
|
361
|
+
recommend(situation: KnowledgeSituation, responseFormat?: "concise" | "detailed", preferences?: KnowledgePreferences, expectedSnapshot?: string): Promise<RecommendResponse | KnowledgeUnavailable | KnowledgeRejected | KnowledgeSnapshotMismatch>;
|
|
362
|
+
check(situation: KnowledgeSituation, steps: readonly DraftedStep[], expectedSnapshot?: string): Promise<CheckResponse | KnowledgeUnavailable | KnowledgeRejected | KnowledgeSnapshotMismatch>;
|
|
363
|
+
/** `slots` never holds a local slot: the host binds those after the render, on the machine. */
|
|
364
|
+
render(template: string, slots: Readonly<Record<string, unknown>>, farm?: readonly FarmPackage[], options?: RenderCallOptions): Promise<RenderResponse | KnowledgeUnavailable | KnowledgeRejected | KnowledgeSnapshotMismatch>;
|
|
365
|
+
/**
|
|
366
|
+
* The slot contract of a template, by reference (`tpl-x@1.0.0`) or by id.
|
|
367
|
+
* The service serves one version per snapshot, thus the answer carries the
|
|
368
|
+
* version it serves and the caller compares it with the reference. An
|
|
369
|
+
* unknown template is `rejected` with the field `template`.
|
|
370
|
+
*/
|
|
371
|
+
contract(template: string): Promise<TemplateContract | KnowledgeUnavailable | KnowledgeRejected>;
|
|
372
|
+
}
|
|
373
|
+
export interface HttpKnowledgeClientConfig {
|
|
374
|
+
/** The service origin, for example `https://knowledge.inflexa.ai`. */
|
|
375
|
+
readonly baseUrl: string;
|
|
376
|
+
/** The bearer key. The license of the service. */
|
|
377
|
+
readonly apiKey: string;
|
|
378
|
+
readonly timeoutMs?: number;
|
|
379
|
+
readonly maxRetries?: number;
|
|
380
|
+
}
|
|
381
|
+
export declare function createHttpKnowledgeClient(config: HttpKnowledgeClientConfig): KnowledgeClient;
|
|
382
|
+
export {};
|