@slopmachine/core 0.1.25 → 0.2.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.
package/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # @slopmachine/core
2
+
3
+ ## 0.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 15b923d: Switch pipeline execution parameters to use pipelineId (with optional siloId) instead of pipelineKey.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @slopmachine/core
2
2
 
3
- The core logic and shared utilities for the Slop Machine SDK.
3
+ The core logic, URL builders, preloader utilities, and type definitions for the Slop Machine SDK.
4
4
 
5
5
  ## Installation
6
6
 
@@ -12,9 +12,28 @@ yarn add @slopmachine/core
12
12
  pnpm add @slopmachine/core
13
13
  ```
14
14
 
15
- ## Usage
15
+ ## Features
16
16
 
17
- This package provides the core functions and type definitions used by the Slop Machine framework integrations (like `@slopmachine/react` and `@slopmachine/svelte`).
17
+ - **URL Builders**: `buildImageUrl`, `buildVideoUrl`, `buildTextUrl`, and `buildPipelineUrl` for safe, deterministic API URL generation.
18
+ - **Preloaders**: `preloadImage`, `preloadVideo`, and `preloadText` to cache assets ahead of time in client applications.
19
+ - **Multi-Step Pipelines**: Programmatic execution via `executePipeline({ pipelineId, prompt, variables, metadata })`.
20
+ - **Buckets & Pipelines Support**: Seamlessly switch between pre-templated Buckets and dynamic runtime Pipelines.
21
+
22
+ ## Programmatic Pipeline Execution
23
+
24
+ ```typescript
25
+ import { executePipeline } from "@slopmachine/core";
26
+
27
+ const result = await executePipeline({
28
+ pipelineId: "pipe_live_abc123",
29
+ prompt: "A cinematic tracking shot through a cyberpunk alleyway",
30
+ metadata: { userId: "usr_42" },
31
+ });
32
+
33
+ console.log("Output URL:", result.url);
34
+ console.log("Fuel Cost:", result.totalFuelCost);
35
+ console.log("Steps executed:", result.stepResults.length);
36
+ ```
18
37
 
19
38
  ## License
20
39
 
package/dist/index.d.mts CHANGED
@@ -1,9 +1,120 @@
1
- type ImageAspectRatio = "1:1" | "2:3" | "3:2" | "3:4" | "4:3" | "4:5" | "5:4" | "9:16" | "16:9" | "21:9";
1
+ import { AspectRatio, VideoAspectRatio } from '@pixerate/schemas';
2
+ export { AspectRatio as ImageAspectRatio, VideoAspectRatio } from '@pixerate/schemas';
3
+
4
+ interface PipelineStepResult {
5
+ stepId: string;
6
+ stepName?: string;
7
+ type: string;
8
+ outputUrl?: string;
9
+ outputText?: string;
10
+ outputData?: any;
11
+ computeTimeMs?: number;
12
+ fuelCost?: number;
13
+ error?: string;
14
+ }
15
+ interface PipelineResult {
16
+ id: string;
17
+ pipelineId: string;
18
+ siloId: string;
19
+ url?: string;
20
+ text?: string;
21
+ data?: any;
22
+ resultType: string;
23
+ status: "completed" | "failed" | "pending";
24
+ stepResults: PipelineStepResult[];
25
+ totalComputeTimeMs: number;
26
+ totalFuelCost: number;
27
+ metadata?: Record<string, any>;
28
+ timestamp: any;
29
+ error?: string;
30
+ }
31
+ interface SlopPipelineOptions {
32
+ /**
33
+ * The unique identifier of the pipeline to execute.
34
+ */
35
+ pipelineId: string;
36
+ /**
37
+ * Optional silo identifier for direct pipeline path resolution.
38
+ */
39
+ siloId?: string;
40
+ /**
41
+ * Dynamic runtime prompt to feed into the pipeline.
42
+ */
43
+ prompt?: string;
44
+ /**
45
+ * Variables to interpolate into prompt or step configs.
46
+ */
47
+ variables?: Record<string, string | number | undefined | null>;
48
+ /**
49
+ * Arbitrary user metadata to attach to the pipeline result document.
50
+ */
51
+ metadata?: Record<string, any>;
52
+ /**
53
+ * Whether to wait for full execution (default true) or return a job ID immediately.
54
+ */
55
+ sync?: boolean;
56
+ /**
57
+ * Whether to redirect to the primary media output URL upon completion.
58
+ */
59
+ redirect?: boolean;
60
+ /**
61
+ * Result ID to retrieve a specific previously generated result.
62
+ */
63
+ resultId?: string;
64
+ /**
65
+ * Base URL for the renderPipeline cloud function endpoint.
66
+ */
67
+ baseUrl?: string;
68
+ }
69
+ interface ExecutePipelineOptions {
70
+ /**
71
+ * The unique identifier of the pipeline to execute.
72
+ */
73
+ pipelineId: string;
74
+ /**
75
+ * Optional silo identifier for direct pipeline path resolution.
76
+ */
77
+ siloId?: string;
78
+ /**
79
+ * Dynamic runtime prompt to feed into the pipeline.
80
+ */
81
+ prompt?: string;
82
+ /**
83
+ * Variables to interpolate into prompt or step configs.
84
+ */
85
+ variables?: Record<string, string | number | undefined | null>;
86
+ /**
87
+ * Arbitrary user metadata to attach to the pipeline result document.
88
+ */
89
+ metadata?: Record<string, any>;
90
+ /**
91
+ * Base URL for the renderPipeline cloud function endpoint.
92
+ */
93
+ baseUrl?: string;
94
+ }
2
95
  interface SlopImageOptions {
3
96
  /**
4
97
  * The unique identifier of your Slop Machine bucket.
98
+ * Required when using a bucket unless pipelineId is provided.
99
+ */
100
+ bucketId?: string;
101
+ /**
102
+ * The unique identifier of your Slop Machine pipeline.
103
+ * Required when targeting a pipeline instead of a bucket.
5
104
  */
6
- bucketId: string;
105
+ pipelineId?: string;
106
+ /**
107
+ * Optional silo identifier.
108
+ */
109
+ siloId?: string;
110
+ /**
111
+ * Dynamic runtime prompt (used when targeting a pipeline).
112
+ */
113
+ prompt?: string;
114
+ /**
115
+ * Arbitrary user metadata to attach to the generation request / result document.
116
+ */
117
+ metadata?: Record<string, any>;
7
118
  /**
8
119
  * The specific version of the prompt/settings to use.
9
120
  * If omitted, the latest version will be used.
@@ -18,7 +129,7 @@ interface SlopImageOptions {
18
129
  * The aspect ratio of the generated image. Defaults to "1:1".
19
130
  * Common values: "1:1", "16:9", "9:16", "4:3", "3:4".
20
131
  */
21
- aspectRatio?: ImageAspectRatio;
132
+ aspectRatio?: AspectRatio;
22
133
  /**
23
134
  * Dynamic variables to interpolate into the prompt.
24
135
  * E.g., if prompt is "A photo of a {color} dog", pass { color: "brown" }.
@@ -49,6 +160,8 @@ declare function interpolatePrompt(prompt?: string, variables?: Record<string, s
49
160
  /**
50
161
  * Builds a URL to render or retrieve an image from Slop Machine.
51
162
  *
163
+ * Supports both standard Buckets (via `bucketId`) and multi-step Pipelines (via `pipelineId`).
164
+ *
52
165
  * @param options - Configuration options for the image generation.
53
166
  * @returns A string containing the fully constructed URL.
54
167
  */
@@ -61,12 +174,29 @@ declare function buildImageUrl(options: SlopImageOptions): string;
61
174
  * @returns A promise that resolves when the image has been loaded.
62
175
  */
63
176
  declare function preloadImage(options: SlopImageOptions): Promise<void>;
64
- type VideoAspectRatio = "9:16" | "16:9";
65
177
  interface SlopVideoOptions {
66
178
  /**
67
179
  * The unique identifier of your Slop Machine bucket.
180
+ * Required when using a bucket unless pipelineId is provided.
68
181
  */
69
- bucketId: string;
182
+ bucketId?: string;
183
+ /**
184
+ * The unique identifier of your Slop Machine pipeline.
185
+ * Required when targeting a pipeline instead of a bucket.
186
+ */
187
+ pipelineId?: string;
188
+ /**
189
+ * Optional silo identifier.
190
+ */
191
+ siloId?: string;
192
+ /**
193
+ * Dynamic runtime prompt (used when targeting a pipeline).
194
+ */
195
+ prompt?: string;
196
+ /**
197
+ * Arbitrary user metadata to attach to the generation request / result document.
198
+ */
199
+ metadata?: Record<string, any>;
70
200
  /**
71
201
  * The specific version of the prompt/settings to use.
72
202
  * If omitted, the latest version will be used.
@@ -116,6 +246,8 @@ interface SlopVideoOptions {
116
246
  /**
117
247
  * Builds a URL to render or retrieve a video from Slop Machine.
118
248
  *
249
+ * Supports both standard Buckets (via `bucketId`) and multi-step Pipelines (via `pipelineId`).
250
+ *
119
251
  * @param options - Configuration options for the video generation.
120
252
  * @returns A string containing the fully constructed URL.
121
253
  */
@@ -131,8 +263,26 @@ declare function preloadVideo(options: SlopVideoOptions): Promise<void>;
131
263
  interface SlopTextOptions {
132
264
  /**
133
265
  * The unique identifier of your Slop Machine bucket.
266
+ * Required when using a bucket unless pipelineId is provided.
267
+ */
268
+ bucketId?: string;
269
+ /**
270
+ * The unique identifier of your Slop Machine pipeline.
271
+ * Required when targeting a pipeline instead of a bucket.
272
+ */
273
+ pipelineId?: string;
274
+ /**
275
+ * Optional silo identifier.
276
+ */
277
+ siloId?: string;
278
+ /**
279
+ * Dynamic runtime prompt (used when targeting a pipeline).
280
+ */
281
+ prompt?: string;
282
+ /**
283
+ * Arbitrary user metadata to attach to the generation request / result document.
134
284
  */
135
- bucketId: string;
285
+ metadata?: Record<string, any>;
136
286
  /**
137
287
  * The specific version of the prompt/settings to use.
138
288
  * If omitted, the latest version will be used.
@@ -161,6 +311,8 @@ interface SlopTextOptions {
161
311
  /**
162
312
  * Builds a URL to render or retrieve text from Slop Machine.
163
313
  *
314
+ * Supports both standard Buckets (via `bucketId`) and multi-step Pipelines (via `pipelineId`).
315
+ *
164
316
  * @param options - Configuration options for the text generation.
165
317
  * @returns A string containing the fully constructed URL.
166
318
  */
@@ -173,6 +325,20 @@ declare function buildTextUrl(options: SlopTextOptions): string;
173
325
  * @returns A promise that resolves when the text preload request has been initiated.
174
326
  */
175
327
  declare function preloadText(options: SlopTextOptions): Promise<void>;
328
+ /**
329
+ * Builds a URL to execute or inspect a multi-step Pipeline from Slop Machine.
330
+ *
331
+ * @param options - Configuration options for the pipeline execution.
332
+ * @returns A string containing the fully constructed URL.
333
+ */
334
+ declare function buildPipelineUrl(options: SlopPipelineOptions): string;
335
+ /**
336
+ * Executes a Slop Machine multi-step Pipeline programmatically and returns the full typed result payload.
337
+ *
338
+ * @param options - Execution parameters including the pipelineId and runtime prompt/variables/metadata.
339
+ * @returns A promise resolving to the completed PipelineResult document.
340
+ */
341
+ declare function executePipeline(options: ExecutePipelineOptions): Promise<PipelineResult>;
176
342
  /**
177
343
  * Uploads a base64 encoded file as a temporary attachment to be used in generation requests.
178
344
  *
@@ -184,4 +350,4 @@ declare function uploadTempAttachment(base64: string, mimeType: string): Promise
184
350
  url: string;
185
351
  }>;
186
352
 
187
- export { type ImageAspectRatio, type SlopImageOptions, type SlopTextOptions, type SlopVideoOptions, type VideoAspectRatio, buildImageUrl, buildTextUrl, buildVideoUrl, interpolatePrompt, preloadImage, preloadText, preloadVideo, uploadTempAttachment };
353
+ export { type ExecutePipelineOptions, type PipelineResult, type PipelineStepResult, type SlopImageOptions, type SlopPipelineOptions, type SlopTextOptions, type SlopVideoOptions, buildImageUrl, buildPipelineUrl, buildTextUrl, buildVideoUrl, executePipeline, interpolatePrompt, preloadImage, preloadText, preloadVideo, uploadTempAttachment };
package/dist/index.d.ts CHANGED
@@ -1,9 +1,120 @@
1
- type ImageAspectRatio = "1:1" | "2:3" | "3:2" | "3:4" | "4:3" | "4:5" | "5:4" | "9:16" | "16:9" | "21:9";
1
+ import { AspectRatio, VideoAspectRatio } from '@pixerate/schemas';
2
+ export { AspectRatio as ImageAspectRatio, VideoAspectRatio } from '@pixerate/schemas';
3
+
4
+ interface PipelineStepResult {
5
+ stepId: string;
6
+ stepName?: string;
7
+ type: string;
8
+ outputUrl?: string;
9
+ outputText?: string;
10
+ outputData?: any;
11
+ computeTimeMs?: number;
12
+ fuelCost?: number;
13
+ error?: string;
14
+ }
15
+ interface PipelineResult {
16
+ id: string;
17
+ pipelineId: string;
18
+ siloId: string;
19
+ url?: string;
20
+ text?: string;
21
+ data?: any;
22
+ resultType: string;
23
+ status: "completed" | "failed" | "pending";
24
+ stepResults: PipelineStepResult[];
25
+ totalComputeTimeMs: number;
26
+ totalFuelCost: number;
27
+ metadata?: Record<string, any>;
28
+ timestamp: any;
29
+ error?: string;
30
+ }
31
+ interface SlopPipelineOptions {
32
+ /**
33
+ * The unique identifier of the pipeline to execute.
34
+ */
35
+ pipelineId: string;
36
+ /**
37
+ * Optional silo identifier for direct pipeline path resolution.
38
+ */
39
+ siloId?: string;
40
+ /**
41
+ * Dynamic runtime prompt to feed into the pipeline.
42
+ */
43
+ prompt?: string;
44
+ /**
45
+ * Variables to interpolate into prompt or step configs.
46
+ */
47
+ variables?: Record<string, string | number | undefined | null>;
48
+ /**
49
+ * Arbitrary user metadata to attach to the pipeline result document.
50
+ */
51
+ metadata?: Record<string, any>;
52
+ /**
53
+ * Whether to wait for full execution (default true) or return a job ID immediately.
54
+ */
55
+ sync?: boolean;
56
+ /**
57
+ * Whether to redirect to the primary media output URL upon completion.
58
+ */
59
+ redirect?: boolean;
60
+ /**
61
+ * Result ID to retrieve a specific previously generated result.
62
+ */
63
+ resultId?: string;
64
+ /**
65
+ * Base URL for the renderPipeline cloud function endpoint.
66
+ */
67
+ baseUrl?: string;
68
+ }
69
+ interface ExecutePipelineOptions {
70
+ /**
71
+ * The unique identifier of the pipeline to execute.
72
+ */
73
+ pipelineId: string;
74
+ /**
75
+ * Optional silo identifier for direct pipeline path resolution.
76
+ */
77
+ siloId?: string;
78
+ /**
79
+ * Dynamic runtime prompt to feed into the pipeline.
80
+ */
81
+ prompt?: string;
82
+ /**
83
+ * Variables to interpolate into prompt or step configs.
84
+ */
85
+ variables?: Record<string, string | number | undefined | null>;
86
+ /**
87
+ * Arbitrary user metadata to attach to the pipeline result document.
88
+ */
89
+ metadata?: Record<string, any>;
90
+ /**
91
+ * Base URL for the renderPipeline cloud function endpoint.
92
+ */
93
+ baseUrl?: string;
94
+ }
2
95
  interface SlopImageOptions {
3
96
  /**
4
97
  * The unique identifier of your Slop Machine bucket.
98
+ * Required when using a bucket unless pipelineId is provided.
99
+ */
100
+ bucketId?: string;
101
+ /**
102
+ * The unique identifier of your Slop Machine pipeline.
103
+ * Required when targeting a pipeline instead of a bucket.
5
104
  */
6
- bucketId: string;
105
+ pipelineId?: string;
106
+ /**
107
+ * Optional silo identifier.
108
+ */
109
+ siloId?: string;
110
+ /**
111
+ * Dynamic runtime prompt (used when targeting a pipeline).
112
+ */
113
+ prompt?: string;
114
+ /**
115
+ * Arbitrary user metadata to attach to the generation request / result document.
116
+ */
117
+ metadata?: Record<string, any>;
7
118
  /**
8
119
  * The specific version of the prompt/settings to use.
9
120
  * If omitted, the latest version will be used.
@@ -18,7 +129,7 @@ interface SlopImageOptions {
18
129
  * The aspect ratio of the generated image. Defaults to "1:1".
19
130
  * Common values: "1:1", "16:9", "9:16", "4:3", "3:4".
20
131
  */
21
- aspectRatio?: ImageAspectRatio;
132
+ aspectRatio?: AspectRatio;
22
133
  /**
23
134
  * Dynamic variables to interpolate into the prompt.
24
135
  * E.g., if prompt is "A photo of a {color} dog", pass { color: "brown" }.
@@ -49,6 +160,8 @@ declare function interpolatePrompt(prompt?: string, variables?: Record<string, s
49
160
  /**
50
161
  * Builds a URL to render or retrieve an image from Slop Machine.
51
162
  *
163
+ * Supports both standard Buckets (via `bucketId`) and multi-step Pipelines (via `pipelineId`).
164
+ *
52
165
  * @param options - Configuration options for the image generation.
53
166
  * @returns A string containing the fully constructed URL.
54
167
  */
@@ -61,12 +174,29 @@ declare function buildImageUrl(options: SlopImageOptions): string;
61
174
  * @returns A promise that resolves when the image has been loaded.
62
175
  */
63
176
  declare function preloadImage(options: SlopImageOptions): Promise<void>;
64
- type VideoAspectRatio = "9:16" | "16:9";
65
177
  interface SlopVideoOptions {
66
178
  /**
67
179
  * The unique identifier of your Slop Machine bucket.
180
+ * Required when using a bucket unless pipelineId is provided.
68
181
  */
69
- bucketId: string;
182
+ bucketId?: string;
183
+ /**
184
+ * The unique identifier of your Slop Machine pipeline.
185
+ * Required when targeting a pipeline instead of a bucket.
186
+ */
187
+ pipelineId?: string;
188
+ /**
189
+ * Optional silo identifier.
190
+ */
191
+ siloId?: string;
192
+ /**
193
+ * Dynamic runtime prompt (used when targeting a pipeline).
194
+ */
195
+ prompt?: string;
196
+ /**
197
+ * Arbitrary user metadata to attach to the generation request / result document.
198
+ */
199
+ metadata?: Record<string, any>;
70
200
  /**
71
201
  * The specific version of the prompt/settings to use.
72
202
  * If omitted, the latest version will be used.
@@ -116,6 +246,8 @@ interface SlopVideoOptions {
116
246
  /**
117
247
  * Builds a URL to render or retrieve a video from Slop Machine.
118
248
  *
249
+ * Supports both standard Buckets (via `bucketId`) and multi-step Pipelines (via `pipelineId`).
250
+ *
119
251
  * @param options - Configuration options for the video generation.
120
252
  * @returns A string containing the fully constructed URL.
121
253
  */
@@ -131,8 +263,26 @@ declare function preloadVideo(options: SlopVideoOptions): Promise<void>;
131
263
  interface SlopTextOptions {
132
264
  /**
133
265
  * The unique identifier of your Slop Machine bucket.
266
+ * Required when using a bucket unless pipelineId is provided.
267
+ */
268
+ bucketId?: string;
269
+ /**
270
+ * The unique identifier of your Slop Machine pipeline.
271
+ * Required when targeting a pipeline instead of a bucket.
272
+ */
273
+ pipelineId?: string;
274
+ /**
275
+ * Optional silo identifier.
276
+ */
277
+ siloId?: string;
278
+ /**
279
+ * Dynamic runtime prompt (used when targeting a pipeline).
280
+ */
281
+ prompt?: string;
282
+ /**
283
+ * Arbitrary user metadata to attach to the generation request / result document.
134
284
  */
135
- bucketId: string;
285
+ metadata?: Record<string, any>;
136
286
  /**
137
287
  * The specific version of the prompt/settings to use.
138
288
  * If omitted, the latest version will be used.
@@ -161,6 +311,8 @@ interface SlopTextOptions {
161
311
  /**
162
312
  * Builds a URL to render or retrieve text from Slop Machine.
163
313
  *
314
+ * Supports both standard Buckets (via `bucketId`) and multi-step Pipelines (via `pipelineId`).
315
+ *
164
316
  * @param options - Configuration options for the text generation.
165
317
  * @returns A string containing the fully constructed URL.
166
318
  */
@@ -173,6 +325,20 @@ declare function buildTextUrl(options: SlopTextOptions): string;
173
325
  * @returns A promise that resolves when the text preload request has been initiated.
174
326
  */
175
327
  declare function preloadText(options: SlopTextOptions): Promise<void>;
328
+ /**
329
+ * Builds a URL to execute or inspect a multi-step Pipeline from Slop Machine.
330
+ *
331
+ * @param options - Configuration options for the pipeline execution.
332
+ * @returns A string containing the fully constructed URL.
333
+ */
334
+ declare function buildPipelineUrl(options: SlopPipelineOptions): string;
335
+ /**
336
+ * Executes a Slop Machine multi-step Pipeline programmatically and returns the full typed result payload.
337
+ *
338
+ * @param options - Execution parameters including the pipelineId and runtime prompt/variables/metadata.
339
+ * @returns A promise resolving to the completed PipelineResult document.
340
+ */
341
+ declare function executePipeline(options: ExecutePipelineOptions): Promise<PipelineResult>;
176
342
  /**
177
343
  * Uploads a base64 encoded file as a temporary attachment to be used in generation requests.
178
344
  *
@@ -184,4 +350,4 @@ declare function uploadTempAttachment(base64: string, mimeType: string): Promise
184
350
  url: string;
185
351
  }>;
186
352
 
187
- export { type ImageAspectRatio, type SlopImageOptions, type SlopTextOptions, type SlopVideoOptions, type VideoAspectRatio, buildImageUrl, buildTextUrl, buildVideoUrl, interpolatePrompt, preloadImage, preloadText, preloadVideo, uploadTempAttachment };
353
+ export { type ExecutePipelineOptions, type PipelineResult, type PipelineStepResult, type SlopImageOptions, type SlopPipelineOptions, type SlopTextOptions, type SlopVideoOptions, buildImageUrl, buildPipelineUrl, buildTextUrl, buildVideoUrl, executePipeline, interpolatePrompt, preloadImage, preloadText, preloadVideo, uploadTempAttachment };