@pipelex/mthds-ui 0.12.0 → 0.13.0

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.
@@ -0,0 +1,118 @@
1
+ import { C as ConceptInfo, P as PipeBlueprintUnion, G as GraphSpec, V as ValidationIssue } from '../types-Cm4147S5.js';
2
+
3
+ type DiagnosticSeverity = "error" | "warning";
4
+ type DiagnosticCode = "toml-parse-error" | "missing-domain" | "invalid-bundle-shape" | "invalid-concept-entry" | "invalid-pipe-entry" | "unknown-pipe-type" | "invalid-concept-ref" | "missing-pipe-output" | "invalid-sub-pipe" | "incomplete-batch-spec" | "duplicate-concept" | "duplicate-pipe" | "unresolved-pipe-ref" | "cyclic-pipe-ref" | "missing-main-pipe" | "no-entry-pipe" | "conflicting-input-concept";
5
+ /**
6
+ * A non-fatal note collected while parsing or merging. `error` means a whole
7
+ * unit could not be interpreted (unparseable TOML, a skipped pipe); `warning`
8
+ * means something was tolerated with a fallback (missing output, bad ref).
9
+ */
10
+ interface Diagnostic {
11
+ severity: DiagnosticSeverity;
12
+ code: DiagnosticCode;
13
+ message: string;
14
+ /** TOML-style locator for the offending entry, e.g. `pipe.analyze_candidate.output`. */
15
+ path?: string;
16
+ }
17
+ /**
18
+ * One `.mthds` file, parsed and normalized. Pipes are narrowed to the same
19
+ * `PipeBlueprintUnion` shapes the pipelex runtime serializes into GraphSpec
20
+ * `pipe_registry`, and concepts to `ConceptInfo` — no parallel type universe.
21
+ * Field names mirror the TOML bundle header keys.
22
+ */
23
+ interface ParsedBundle {
24
+ domain: string | null;
25
+ description: string | null;
26
+ main_pipe: string | null;
27
+ system_prompt: string | null;
28
+ /** Concepts declared in this bundle, keyed by bare concept code. */
29
+ concepts: Record<string, ConceptInfo>;
30
+ /** Pipes declared in this bundle, keyed by bare pipe code. */
31
+ pipes: Record<string, PipeBlueprintUnion>;
32
+ }
33
+ interface ParseMthdsBundleResult {
34
+ bundle: ParsedBundle;
35
+ diagnostics: Diagnostic[];
36
+ }
37
+ /** Namespace of one domain after merging bundles: concepts and pipes by bare code. */
38
+ interface DomainNamespace {
39
+ domain: string;
40
+ concepts: Record<string, ConceptInfo>;
41
+ pipes: Record<string, PipeBlueprintUnion>;
42
+ }
43
+ /**
44
+ * The merged namespace of a method package: every parsed bundle grouped by
45
+ * domain, with duplicate codes resolved keep-first (plus a diagnostic).
46
+ * `mainDomain` / `mainPipe` come as a pair from the first bundle declaring
47
+ * `main_pipe` (falling back to the first domained bundle when none does) —
48
+ * the walk entry point for the static graph builder. `description` comes from
49
+ * the first bundle that declares it.
50
+ */
51
+ interface MergedMethodSet {
52
+ domains: Record<string, DomainNamespace>;
53
+ mainDomain: string | null;
54
+ mainPipe: string | null;
55
+ description: string | null;
56
+ diagnostics: Diagnostic[];
57
+ }
58
+ /** Namespace used for bundles that declare no `domain` (a legal WIP state). */
59
+ declare const UNKNOWN_DOMAIN = "unknown";
60
+
61
+ declare const NATIVE_DOMAIN = "native";
62
+ declare const NATIVE_CONCEPT_CODES: ReadonlySet<string>;
63
+ interface ConceptRefParts {
64
+ /** Explicit domain qualifier (`recruitment` in `recruitment.Profile`), or null for bare refs. */
65
+ domain: string | null;
66
+ code: string;
67
+ /** `[]` → true (many), `[N]` → N, no suffix → null (single). */
68
+ multiplicity: number | boolean | null;
69
+ }
70
+ /** Parse a concept ref string into its parts. Returns null when the ref is not interpretable. */
71
+ declare function parseConceptRef(raw: unknown): ConceptRefParts | null;
72
+
73
+ /**
74
+ * Parse one `.mthds` TOML string. Returns whatever could be interpreted plus
75
+ * the diagnostics collected along the way — never throws.
76
+ */
77
+ declare function parseMthdsBundle(tomlText: string): ParseMthdsBundleResult;
78
+
79
+ /**
80
+ * Merge parsed bundles into one namespace per domain. Order matters: on
81
+ * duplicate codes the first bundle wins. `mainDomain` and `mainPipe` are taken
82
+ * together from the first bundle declaring `main_pipe`, so a bare entry ref
83
+ * always resolves in its declaring bundle's namespace; when no bundle declares
84
+ * one, `mainDomain` falls back to the first domained bundle. `description`
85
+ * comes from the first bundle that declares it.
86
+ */
87
+ declare function mergeBundles(bundles: ParsedBundle[]): MergedMethodSet;
88
+
89
+ interface StaticGraphOptions {
90
+ /**
91
+ * Pipe ref to walk from (`code` or `domain.code`). Defaults to the merged
92
+ * set's `main_pipe`, falling back to a root heuristic (first pipe no other
93
+ * pipe references) when none is declared.
94
+ */
95
+ entryPipe?: string;
96
+ }
97
+ interface StaticGraphResult {
98
+ spec: GraphSpec;
99
+ diagnostics: Diagnostic[];
100
+ }
101
+ /** Build a static GraphSpec from an already-parsed, merged method set. */
102
+ declare function buildStaticGraphSpec(set: MergedMethodSet, options?: StaticGraphOptions): StaticGraphResult;
103
+ /**
104
+ * Convenience wrapper: parse one or more `.mthds` TOML strings, merge them,
105
+ * and build the static GraphSpec. Diagnostics from all three stages are
106
+ * concatenated in order (parse, merge, build).
107
+ */
108
+ declare function buildStaticGraphSpecFromToml(tomlTexts: string | string[], options?: StaticGraphOptions): StaticGraphResult;
109
+
110
+ /**
111
+ * Project static-graph {@link Diagnostic}s onto the viewer's presentation shape
112
+ * so a host can feed them straight into `GraphViewer`'s `validationIssues`.
113
+ * The TOML-style `path` becomes the locator chip; `origin: "static"` lets the
114
+ * panel (and the host's issue policy) distinguish them from validator verdicts.
115
+ */
116
+ declare function staticDiagnosticsToValidationIssues(diagnostics: Diagnostic[]): ValidationIssue[];
117
+
118
+ export { type ConceptRefParts, type Diagnostic, type DiagnosticCode, type DiagnosticSeverity, type DomainNamespace, type MergedMethodSet, NATIVE_CONCEPT_CODES, NATIVE_DOMAIN, type ParseMthdsBundleResult, type ParsedBundle, type StaticGraphOptions, type StaticGraphResult, UNKNOWN_DOMAIN, buildStaticGraphSpec, buildStaticGraphSpecFromToml, mergeBundles, parseConceptRef, parseMthdsBundle, staticDiagnosticsToValidationIssues };