@sverka/compiler 0.0.0 → 0.1.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.
@@ -0,0 +1,235 @@
1
+ import { DefinitionGraph } from "@sverka/workflow";
2
+ //#region src/plugin/types.d.ts
3
+ type CapabilitySupport = "native" | "lowered" | "emulated" | "connector" | "partial" | "unsupported";
4
+ interface CapabilityDetail {
5
+ readonly support: CapabilitySupport;
6
+ readonly via?: string;
7
+ readonly notes?: string;
8
+ }
9
+ type CapabilityManifest = Record<string, CapabilitySupport | CapabilityDetail>;
10
+ interface CapabilityDiagnostic {
11
+ readonly capability: string;
12
+ readonly support: CapabilitySupport;
13
+ readonly severity: "error" | "warning" | "info";
14
+ readonly message: string;
15
+ readonly stepId?: string;
16
+ }
17
+ interface ModelContribution {
18
+ readonly kind: string;
19
+ readonly description?: string;
20
+ }
21
+ interface GraphTransform {
22
+ readonly name: string;
23
+ transform(graph: DefinitionGraph): DefinitionGraph;
24
+ }
25
+ interface GraphValidator {
26
+ readonly name: string;
27
+ validate(graph: DefinitionGraph): readonly CapabilityDiagnostic[];
28
+ }
29
+ interface Target {
30
+ readonly name: string;
31
+ compile(graph: DefinitionGraph): CompilationResult$2;
32
+ }
33
+ interface CompilationResult$2 {
34
+ readonly artifacts: readonly {
35
+ readonly path: string;
36
+ readonly content: string;
37
+ }[];
38
+ readonly diagnostics: readonly CapabilityDiagnostic[];
39
+ }
40
+ interface Importer {
41
+ readonly name: string;
42
+ parse(input: string): DefinitionGraph;
43
+ }
44
+ interface Engine {
45
+ readonly name: string;
46
+ execute(plan: unknown): unknown;
47
+ }
48
+ interface ConnectorFactory {
49
+ readonly name: string;
50
+ create(config: unknown): unknown;
51
+ }
52
+ interface NativeExtension {
53
+ readonly plugin: string;
54
+ readonly schemaVersion: string;
55
+ readonly capabilities: readonly string[];
56
+ readonly fallback?: string;
57
+ }
58
+ interface ToolDefinition {
59
+ /** Globally unique within plugin: "<server>.<tool>". */
60
+ readonly name: string;
61
+ readonly description?: string;
62
+ /** JSON Schema describing accepted arguments. */
63
+ readonly inputSchema?: Readonly<Record<string, unknown>>;
64
+ }
65
+ type ToolResultContent = {
66
+ readonly type: "text";
67
+ readonly text: string;
68
+ } | {
69
+ readonly type: "image";
70
+ readonly data: string;
71
+ readonly mimeType: string;
72
+ } | {
73
+ readonly type: "resource";
74
+ readonly resource: {
75
+ readonly uri: string;
76
+ readonly mimeType?: string;
77
+ };
78
+ };
79
+ interface ToolResult {
80
+ readonly content: readonly ToolResultContent[];
81
+ readonly isError?: boolean;
82
+ }
83
+ /**
84
+ * Runtime facet for listing and calling tools. Added by Spec 23 to enable
85
+ * MCP plugin transport; consumed by AgentStep (sv-wthn.2.2). Tools are
86
+ * called at runtime, not synthesized into the Definition Graph.
87
+ */
88
+ interface ToolProvider {
89
+ listTools(): Promise<readonly ToolDefinition[]>;
90
+ callTool(name: string, args?: Readonly<Record<string, unknown>>): Promise<ToolResult>;
91
+ dispose?(): Promise<void>;
92
+ }
93
+ interface SverkaPlugin {
94
+ readonly name: string;
95
+ readonly apiVersion: string;
96
+ readonly capabilities?: CapabilityManifest;
97
+ readonly model?: readonly ModelContribution[];
98
+ readonly transforms?: readonly GraphTransform[];
99
+ readonly validators?: readonly GraphValidator[];
100
+ readonly targets?: readonly Target[];
101
+ readonly importers?: readonly Importer[];
102
+ readonly engines?: readonly Engine[];
103
+ readonly connectors?: readonly ConnectorFactory[];
104
+ readonly extensions?: readonly NativeExtension[];
105
+ /** Tools facet (Spec 23): runtime tool listing/calling (e.g. MCP). */
106
+ readonly tools?: ToolProvider;
107
+ }
108
+ interface PluginOptions {
109
+ readonly [key: string]: unknown;
110
+ }
111
+ interface PluginMeta {
112
+ readonly version: string;
113
+ }
114
+ interface PluginRegistry {
115
+ register(plugin: SverkaPlugin): void;
116
+ readonly plugins: readonly SverkaPlugin[];
117
+ getCapabilities(): CapabilityManifest[];
118
+ }
119
+ //#endregion
120
+ //#region src/plugin/factory.d.ts
121
+ /**
122
+ * Define a Sverka plugin. The factory function receives optional options
123
+ * and meta, and returns a SverkaPlugin object.
124
+ *
125
+ * @example
126
+ * const plugin = defineSverkaPlugin(() => ({
127
+ * name: "github",
128
+ * apiVersion: "sverka.dev/v1",
129
+ * capabilities: { "trigger.push": "native" },
130
+ * }));
131
+ */
132
+ export declare function defineSverkaPlugin(factory: (options?: PluginOptions, meta?: PluginMeta) => SverkaPlugin, options?: PluginOptions): SverkaPlugin;
133
+ /**
134
+ * Create a plugin registry.
135
+ */
136
+ export declare function createPluginRegistry(): PluginRegistry;
137
+ //#endregion
138
+ //#region src/plugin/capabilities.d.ts
139
+ /**
140
+ * Detect capabilities used by a Definition Graph.
141
+ * Returns a set of capability identifiers (e.g., "trigger.push").
142
+ */
143
+ export declare function detectCapabilities(graph: DefinitionGraph): Set<string>;
144
+ /**
145
+ * Analyze a Definition Graph against capability manifests.
146
+ * Returns diagnostics for capabilities that are not natively or lowered
147
+ * supported.
148
+ */
149
+ export declare function analyzeCapabilities(graph: DefinitionGraph, manifests: readonly CapabilityManifest[]): readonly CapabilityDiagnostic[];
150
+ //#endregion
151
+ //#region src/plugin/errors.d.ts
152
+ type PluginErrorCode = "INVALID_PLUGIN" | "DUPLICATE_PLUGIN" | "INVALID_CAPABILITY";
153
+ export declare class PluginError extends Error {
154
+ readonly code: PluginErrorCode;
155
+ readonly cause: unknown;
156
+ constructor(message: string, code: PluginErrorCode, cause?: unknown);
157
+ }
158
+ //#endregion
159
+ //#region src/github/pinning.d.ts
160
+ /** Registry mapping `org/name@vN` refs to 40-char commit SHAs. */
161
+ interface PinRegistry {
162
+ readonly [ref: string]: string;
163
+ }
164
+ /** Pinning configuration for {@link GithubTarget}. */
165
+ interface PinningConfig {
166
+ /** `"strict"` pins known refs and errors on missing entries; `"off"` leaves refs unchanged. */
167
+ readonly mode: "strict" | "off";
168
+ /** Custom registry; defaults to the bundled `pinned-actions.json`. */
169
+ readonly registry?: PinRegistry;
170
+ }
171
+ /**
172
+ * Pin a single `uses:` ref to its commit SHA.
173
+ *
174
+ * Rules (spec 22 §"Data models"):
175
+ * 1. Local action (`./…`) → unchanged.
176
+ * 2. Already pinned (`@<40 hex>`) → unchanged.
177
+ * 3. `org/name@vN` in registry → `org/name@<sha> # vN`.
178
+ * 4. `org/name@vN` not in registry → unchanged (caller emits a diagnostic).
179
+ *
180
+ * Refs without `@` (malformed) are returned unchanged.
181
+ */
182
+ export declare function pinActionRef(ref: string, registry: PinRegistry): string;
183
+ /**
184
+ * Load the bundled `pinned-actions.json` registry.
185
+ */
186
+ export declare function loadBundledRegistry(): PinRegistry;
187
+ //#endregion
188
+ //#region src/github/types.d.ts
189
+ interface GeneratedArtifact {
190
+ readonly path: string;
191
+ readonly content: string;
192
+ }
193
+ interface TargetDiagnostic {
194
+ readonly capability: string;
195
+ readonly support: CapabilitySupport;
196
+ readonly severity: "error" | "warning" | "info";
197
+ readonly message: string;
198
+ readonly stepId?: string;
199
+ }
200
+ interface CompilationResult {
201
+ readonly artifacts: readonly GeneratedArtifact[];
202
+ readonly diagnostics: readonly TargetDiagnostic[];
203
+ }
204
+ //#endregion
205
+ //#region src/github/target.d.ts
206
+ /**
207
+ * Convenience function: analyze → lower → emit in one call.
208
+ */
209
+ export declare function compileGithub(graph: DefinitionGraph): CompilationResult;
210
+ //#endregion
211
+ //#region src/gitlab/types.d.ts
212
+ interface GeneratedArtifact$1 {
213
+ readonly path: string;
214
+ readonly content: string;
215
+ }
216
+ interface TargetDiagnostic$1 {
217
+ readonly capability: string;
218
+ readonly support: CapabilitySupport;
219
+ readonly severity: "error" | "warning" | "info";
220
+ readonly message: string;
221
+ readonly stepId?: string;
222
+ }
223
+ interface CompilationResult$1 {
224
+ readonly artifacts: readonly GeneratedArtifact$1[];
225
+ readonly diagnostics: readonly TargetDiagnostic$1[];
226
+ }
227
+ //#endregion
228
+ //#region src/gitlab/target.d.ts
229
+ /**
230
+ * Convenience function: analyze → lower → emit in one call.
231
+ */
232
+ export declare function compileGitlab(graph: DefinitionGraph): CompilationResult$1;
233
+ //#endregion
234
+ export type { CapabilityDetail, CapabilityDiagnostic, CapabilityManifest, CapabilitySupport, CompilationResult, ConnectorFactory, Engine, GeneratedArtifact, GraphTransform, GraphValidator, Importer, ModelContribution, NativeExtension, PinRegistry, PinningConfig, PluginErrorCode, PluginMeta, PluginOptions, PluginRegistry, SverkaPlugin, Target, TargetDiagnostic, ToolDefinition, ToolProvider, ToolResult, ToolResultContent };
235
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/plugin/types.ts","../src/plugin/factory.ts","../src/plugin/capabilities.ts","../src/plugin/errors.ts","../src/github/pinning.ts","../src/github/types.ts","../src/github/target.ts","../src/gitlab/types.ts","../src/gitlab/target.ts"],"mappings":";;KAQY;UAQK;WACN,SAAS;WACT;WACA;;KAGC,qBAAqB,eAAe,oBAAoB;UAEnD;WACN;WACA,SAAS;WACT;WACA;WACA;;UAOM;WACN;WACA;;UAGM;WACN;EACT,UAAU,OAAO,kBAAkB;;UAGpB;WACN;EACT,SAAS,OAAO,2BAA2B;;UAG5B;WACN;EACT,QAAQ,OAAO,kBAAkB;;UAGlB;WACN;aAA+B;aAAuB;;WACtD,sBAAsB;;UAGhB;WACN;EACT,MAAM,gBAAgB;;UAGP;WACN;EACT,QAAQ;;UAGO;WACN;EACT,OAAO;;UAGQ;WACN;WACA;WACA;WACA;;UAOM;;WAEN;WACA;;WAEA,cAAc,SAAS;;KAGtB;WACG;WAAuB;;WACvB;WAAwB;WAAuB;;WAE/C;WACA;aAAqB;aAAsB;;;UAGzC;WACN,kBAAkB;WAClB;;;;;;;UAQM;EACf,aAAa,iBAAiB;EAC9B,SACE,cACA,OAAO,SAAS,2BACf,QAAQ;EACX,YAAY;;UAOG;WACN;WACA;WACA,eAAe;WACf,iBAAiB;WACjB,sBAAsB;WACtB,sBAAsB;WACtB,mBAAmB;WACnB,qBAAqB;WACrB,mB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