@rotifer/playground 0.28.0 → 0.29.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,180 @@
1
+ /** Blueprint format number; an importer refuses a larger one. */
2
+ export declare const BLUEPRINT_FORMAT = 1;
3
+ /** Protocol version whose Blueprint layout this command writes. */
4
+ export declare const BLUEPRINT_PROTOCOL_VERSION: {
5
+ readonly major: 0;
6
+ readonly minor: 9;
7
+ readonly patch: 2;
8
+ };
9
+ /** Default `minFitness` for a CapabilityQuery: the recommended τ of §5.1. */
10
+ export declare const DEFAULT_MIN_FITNESS = 0.3;
11
+ /** §5.1: V_min MUST lie in [0.5, 1.0). */
12
+ export declare const MIN_VG_FLOOR = 0.5;
13
+ /** Key under `bindingExtensions` for semantics only this binding defines. */
14
+ export declare const BINDING_NAME = "rotifer-playground";
15
+ export declare const GENE_ID_V2: RegExp;
16
+ export interface GeneReference {
17
+ geneId: string;
18
+ role: string;
19
+ optional: boolean;
20
+ }
21
+ export type CompareOp = "EQ" | "NEQ" | "GT" | "GTE" | "LT" | "LTE" | "CONTAINS" | "MATCHES";
22
+ export interface Predicate {
23
+ field: string;
24
+ operator: CompareOp;
25
+ value: unknown;
26
+ }
27
+ /** §15.2 AlgebraExpr, externally tagged. v0.9.2 never writes RemoteGene. */
28
+ export type AlgebraExpr = {
29
+ Gene: {
30
+ geneRef: GeneReference;
31
+ };
32
+ } | {
33
+ Seq: {
34
+ steps: AlgebraExpr[];
35
+ };
36
+ } | {
37
+ Par: {
38
+ left: AlgebraExpr;
39
+ right: AlgebraExpr;
40
+ };
41
+ } | {
42
+ Cond: {
43
+ predicate: Predicate;
44
+ ifTrue: AlgebraExpr;
45
+ ifFalse: AlgebraExpr;
46
+ };
47
+ } | {
48
+ TryCatch: {
49
+ body: AlgebraExpr;
50
+ handler: AlgebraExpr;
51
+ };
52
+ };
53
+ export interface GenomeSnapshot {
54
+ genes: GeneReference[];
55
+ composition?: AlgebraExpr;
56
+ snapshotAt: string;
57
+ }
58
+ export interface CapabilityQuery {
59
+ domain: string;
60
+ inputSchemaCompat: unknown;
61
+ outputSchemaCompat: unknown;
62
+ minFitness: number;
63
+ excludeGeneIds?: string[];
64
+ }
65
+ export interface ResolutionHint {
66
+ owner: string;
67
+ name: string;
68
+ version: string;
69
+ cloudId?: string;
70
+ fidelity: string;
71
+ }
72
+ export interface GenomeBlueprint {
73
+ blueprintFormat: number;
74
+ protocolVersion: {
75
+ major: number;
76
+ minor: number;
77
+ patch: number;
78
+ supportedFeatures: string[];
79
+ };
80
+ snapshot: GenomeSnapshot;
81
+ metadata: {
82
+ name: string;
83
+ description?: string;
84
+ author?: string;
85
+ createdAt: string;
86
+ };
87
+ capabilities?: Record<string, CapabilityQuery>;
88
+ resolutionHints?: Record<string, ResolutionHint>;
89
+ bindingExtensions?: Record<string, Record<string, unknown>>;
90
+ }
91
+ /** Rust executor CompareOp (what `agent run` accepts) → §15.2 CompareOp. */
92
+ export declare const COMPARE_OPS: Readonly<Record<string, CompareOp>>;
93
+ export type CredentialLayer = "key-name" | "value-pattern" | "entropy";
94
+ export interface CredentialFinding {
95
+ pointer: string;
96
+ layer: CredentialLayer;
97
+ rule: string;
98
+ }
99
+ /** Field names that hold a credential. Matched after lower-casing and dropping `_`/`-`, as the whole name or its suffix. */
100
+ export declare const CREDENTIAL_KEY_NAMES: readonly string[];
101
+ export declare const BARE_HEX_RULE = "Bare 32-byte hex key";
102
+ /** Shannon entropy in bits per character. */
103
+ export declare function shannonEntropy(s: string): number;
104
+ export interface ScanOptions {
105
+ /** Positions that may hold a 64-hex hash; only the bare-hex rule is lifted there. */
106
+ isHexExempt?: (pointer: string, value: string) => boolean;
107
+ /** Positions whose strings must not look like code. */
108
+ isCodeForbidden?: (pointer: string) => boolean;
109
+ }
110
+ /** Whether a string, on its own, trips any value rule — for masking it wherever it is about to be printed. */
111
+ export declare function looksLikeCredential(text: string): boolean;
112
+ /**
113
+ * Scan any JSON value.
114
+ *
115
+ * Pointers are built for humans to find the problem, so they must not become
116
+ * the leak: an object key that itself looks like a credential is replaced by
117
+ * `<redacted key #i>` (i = its position among that object's keys) in its own
118
+ * pointer and in every pointer below it.
119
+ */
120
+ export declare function scanForCredentials(doc: unknown, options?: ScanOptions): CredentialFinding[];
121
+ /**
122
+ * Scan a Blueprint. The bare-hex rule is lifted only where a gene ID belongs,
123
+ * and only for a value shaped like one (`v2:` + 64 lowercase hex):
124
+ * `/snapshot/genes/N/geneId`, `/capabilities/ROLE/excludeGeneIds/N`, and a
125
+ * composition leaf's `geneRef/geneId` when it repeats an ID from
126
+ * `snapshot.genes`. The same hex anywhere else is blocked. Strings under
127
+ * `bindingExtensions` must not look like code.
128
+ */
129
+ export interface ScanBlueprintOptions {
130
+ /**
131
+ * Import only: a composition gene ID is exempt from the bare-hex rule only at
132
+ * a real leaf of the §15.2 subset (what the structural check reads), not at
133
+ * any path that merely ends in `geneRef/geneId` — extra fields inside a Gene
134
+ * body would otherwise smuggle a `v2:`-prefixed key past the scan. Export
135
+ * builds the composition itself and keeps its rule.
136
+ */
137
+ isLeafPositionExact?: boolean;
138
+ }
139
+ /** Pointers of the `geneRef/geneId` of every real leaf in a §15.2 subset composition. */
140
+ export declare function compositionLeafIdPointers(expr: unknown, base?: string): Set<string>;
141
+ export declare function scanBlueprint(blueprint: GenomeBlueprint, options?: ScanBlueprintOptions): CredentialFinding[];
142
+ export declare class GenomeImportError extends Error {
143
+ readonly hint?: string | undefined;
144
+ constructor(message: string, hint?: string | undefined);
145
+ }
146
+ /** What `agent create` needs to rebuild the composition. */
147
+ export interface CompositionPlan {
148
+ type: "Single" | "Seq" | "Par" | "Cond" | "Try";
149
+ /** Roles in execution order (= the agent's genome order). */
150
+ roles: string[];
151
+ parMerge?: string;
152
+ predicate?: {
153
+ field: string;
154
+ op: string;
155
+ value: unknown;
156
+ };
157
+ }
158
+ export interface ParsedBlueprint {
159
+ blueprint: GenomeBlueprint;
160
+ plan: CompositionPlan;
161
+ /** RFC §4.4 (B4): what runs, computed before anything is resolved or written. */
162
+ genomeId: string;
163
+ /** The author's suggested V(g) threshold, if any. */
164
+ suggestedMinVg?: number;
165
+ }
166
+ export declare function compositionPlan(blueprint: GenomeBlueprint): CompositionPlan;
167
+ /**
168
+ * RFC 8785 canonical JSON. For finite numbers and well-formed strings,
169
+ * JSON.stringify gives the RFC 8785 form of every scalar, and keys sort by
170
+ * UTF-16 code unit as RFC 8785 says; anything else throws. parseBlueprint has
171
+ * already refused both in a Blueprint; schemas read from a Registry row have not
172
+ * been through it.
173
+ */
174
+ export declare function jcs(value: unknown): string;
175
+ /** "bp1:" + SHA-256 of the canonical execution projection. Call only on a Blueprint parseBlueprint accepted. */
176
+ export declare function computeGenomeId(blueprint: GenomeBlueprint): string;
177
+ export declare function checkMinVg(value: unknown, where: string): number;
178
+ /** Parse a Blueprint, keep only what v0.9.2 can rebuild faithfully, and run the credential scan. */
179
+ export declare function parseBlueprint(text: string): ParsedBlueprint;
180
+ //# sourceMappingURL=genome-format.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"genome-format.d.ts","sourceRoot":"","sources":["../../src/commands/genome-format.ts"],"names":[],"mappings":"AAgBA,iEAAiE;AACjE,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAElC,mEAAmE;AACnE,eAAO,MAAM,0BAA0B;;;;CAA4C,CAAC;AAEpF,6EAA6E;AAC7E,eAAO,MAAM,mBAAmB,MAAM,CAAC;AAEvC,0CAA0C;AAC1C,eAAO,MAAM,YAAY,MAAM,CAAC;AAEhC,6EAA6E;AAC7E,eAAO,MAAM,YAAY,uBAAuB,CAAC;AAEjD,eAAO,MAAM,UAAU,QAAsB,CAAC;AAE9C,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,MAAM,SAAS,GAAG,IAAI,GAAG,KAAK,GAAG,IA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