@slopmachine/core 0.1.26 → 0.3.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,13 @@
1
+ # @slopmachine/core
2
+
3
+ ## 0.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - fbdeaec: Omit default duration in buildVideoUrl so requests fall back to the bucket version's configured duration on the server
8
+
9
+ ## 0.2.0
10
+
11
+ ### Minor Changes
12
+
13
+ - 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,11 +1,120 @@
1
1
  import { AspectRatio, VideoAspectRatio } from '@pixerate/schemas';
2
2
  export { AspectRatio as ImageAspectRatio, VideoAspectRatio } from '@pixerate/schemas';
3
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
+ }
4
95
  interface SlopImageOptions {
5
96
  /**
6
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.
104
+ */
105
+ pipelineId?: string;
106
+ /**
107
+ * Optional silo identifier.
7
108
  */
8
- bucketId: string;
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>;
9
118
  /**
10
119
  * The specific version of the prompt/settings to use.
11
120
  * If omitted, the latest version will be used.
@@ -51,6 +160,8 @@ declare function interpolatePrompt(prompt?: string, variables?: Record<string, s
51
160
  /**
52
161
  * Builds a URL to render or retrieve an image from Slop Machine.
53
162
  *
163
+ * Supports both standard Buckets (via `bucketId`) and multi-step Pipelines (via `pipelineId`).
164
+ *
54
165
  * @param options - Configuration options for the image generation.
55
166
  * @returns A string containing the fully constructed URL.
56
167
  */
@@ -63,12 +174,29 @@ declare function buildImageUrl(options: SlopImageOptions): string;
63
174
  * @returns A promise that resolves when the image has been loaded.
64
175
  */
65
176
  declare function preloadImage(options: SlopImageOptions): Promise<void>;
66
-
67
177
  interface SlopVideoOptions {
68
178
  /**
69
179
  * The unique identifier of your Slop Machine bucket.
180
+ * Required when using a bucket unless pipelineId is provided.
181
+ */
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.
70
198
  */
71
- bucketId: string;
199
+ metadata?: Record<string, any>;
72
200
  /**
73
201
  * The specific version of the prompt/settings to use.
74
202
  * If omitted, the latest version will be used.
@@ -91,7 +219,7 @@ interface SlopVideoOptions {
91
219
  variables?: Record<string, string | number | undefined | null>;
92
220
  /**
93
221
  * The duration of the generated video in seconds.
94
- * Must be between 4 and 8. Defaults to 4.
222
+ * If not specified, defaults to the bucket version's configured duration (or 4).
95
223
  */
96
224
  duration?: number;
97
225
  /**
@@ -106,17 +234,18 @@ interface SlopVideoOptions {
106
234
  */
107
235
  baseUrl?: string;
108
236
  /**
109
- * If `true` (or `?raw=true`), bypasses the WebP optimized media and returns the original generated file.
110
- * Defaults to false.
237
+ * If true, serves the original generated uncompressed asset directly from storage.
111
238
  */
112
239
  original?: boolean;
113
240
  /**
114
- * Array of attachment URLs to include with the request.
241
+ * Array of runtime image attachments (URLs) to use with the video model.
242
+ * Only allowed if the bucket version has runtime attachments enabled.
115
243
  */
116
244
  attachments?: string[];
117
245
  }
118
246
  /**
119
- * Builds a URL to render or retrieve a video from Slop Machine.
247
+ * Builds the URL to render or stream an AI-generated video.
248
+ * Supports both standard Buckets (via `bucketId`) and multi-step Pipelines (via `pipelineId`).
120
249
  *
121
250
  * @param options - Configuration options for the video generation.
122
251
  * @returns A string containing the fully constructed URL.
@@ -133,8 +262,26 @@ declare function preloadVideo(options: SlopVideoOptions): Promise<void>;
133
262
  interface SlopTextOptions {
134
263
  /**
135
264
  * The unique identifier of your Slop Machine bucket.
265
+ * Required when using a bucket unless pipelineId is provided.
266
+ */
267
+ bucketId?: string;
268
+ /**
269
+ * The unique identifier of your Slop Machine pipeline.
270
+ * Required when targeting a pipeline instead of a bucket.
271
+ */
272
+ pipelineId?: string;
273
+ /**
274
+ * Optional silo identifier.
275
+ */
276
+ siloId?: string;
277
+ /**
278
+ * Dynamic runtime prompt (used when targeting a pipeline).
279
+ */
280
+ prompt?: string;
281
+ /**
282
+ * Arbitrary user metadata to attach to the generation request / result document.
136
283
  */
137
- bucketId: string;
284
+ metadata?: Record<string, any>;
138
285
  /**
139
286
  * The specific version of the prompt/settings to use.
140
287
  * If omitted, the latest version will be used.
@@ -163,6 +310,8 @@ interface SlopTextOptions {
163
310
  /**
164
311
  * Builds a URL to render or retrieve text from Slop Machine.
165
312
  *
313
+ * Supports both standard Buckets (via `bucketId`) and multi-step Pipelines (via `pipelineId`).
314
+ *
166
315
  * @param options - Configuration options for the text generation.
167
316
  * @returns A string containing the fully constructed URL.
168
317
  */
@@ -175,6 +324,20 @@ declare function buildTextUrl(options: SlopTextOptions): string;
175
324
  * @returns A promise that resolves when the text preload request has been initiated.
176
325
  */
177
326
  declare function preloadText(options: SlopTextOptions): Promise<void>;
327
+ /**
328
+ * Builds a URL to execute or inspect a multi-step Pipeline from Slop Machine.
329
+ *
330
+ * @param options - Configuration options for the pipeline execution.
331
+ * @returns A string containing the fully constructed URL.
332
+ */
333
+ declare function buildPipelineUrl(options: SlopPipelineOptions): string;
334
+ /**
335
+ * Executes a Slop Machine multi-step Pipeline programmatically and returns the full typed result payload.
336
+ *
337
+ * @param options - Execution parameters including the pipelineId and runtime prompt/variables/metadata.
338
+ * @returns A promise resolving to the completed PipelineResult document.
339
+ */
340
+ declare function executePipeline(options: ExecutePipelineOptions): Promise<PipelineResult>;
178
341
  /**
179
342
  * Uploads a base64 encoded file as a temporary attachment to be used in generation requests.
180
343
  *
@@ -186,4 +349,4 @@ declare function uploadTempAttachment(base64: string, mimeType: string): Promise
186
349
  url: string;
187
350
  }>;
188
351
 
189
- export { type SlopImageOptions, type SlopTextOptions, type SlopVideoOptions, buildImageUrl, buildTextUrl, buildVideoUrl, interpolatePrompt, preloadImage, preloadText, preloadVideo, uploadTempAttachment };
352
+ 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,11 +1,120 @@
1
1
  import { AspectRatio, VideoAspectRatio } from '@pixerate/schemas';
2
2
  export { AspectRatio as ImageAspectRatio, VideoAspectRatio } from '@pixerate/schemas';
3
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
+ }
4
95
  interface SlopImageOptions {
5
96
  /**
6
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.
104
+ */
105
+ pipelineId?: string;
106
+ /**
107
+ * Optional silo identifier.
7
108
  */
8
- bucketId: string;
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>;
9
118
  /**
10
119
  * The specific version of the prompt/settings to use.
11
120
  * If omitted, the latest version will be used.
@@ -51,6 +160,8 @@ declare function interpolatePrompt(prompt?: string, variables?: Record<string, s
51
160
  /**
52
161
  * Builds a URL to render or retrieve an image from Slop Machine.
53
162
  *
163
+ * Supports both standard Buckets (via `bucketId`) and multi-step Pipelines (via `pipelineId`).
164
+ *
54
165
  * @param options - Configuration options for the image generation.
55
166
  * @returns A string containing the fully constructed URL.
56
167
  */
@@ -63,12 +174,29 @@ declare function buildImageUrl(options: SlopImageOptions): string;
63
174
  * @returns A promise that resolves when the image has been loaded.
64
175
  */
65
176
  declare function preloadImage(options: SlopImageOptions): Promise<void>;
66
-
67
177
  interface SlopVideoOptions {
68
178
  /**
69
179
  * The unique identifier of your Slop Machine bucket.
180
+ * Required when using a bucket unless pipelineId is provided.
181
+ */
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.
70
198
  */
71
- bucketId: string;
199
+ metadata?: Record<string, any>;
72
200
  /**
73
201
  * The specific version of the prompt/settings to use.
74
202
  * If omitted, the latest version will be used.
@@ -91,7 +219,7 @@ interface SlopVideoOptions {
91
219
  variables?: Record<string, string | number | undefined | null>;
92
220
  /**
93
221
  * The duration of the generated video in seconds.
94
- * Must be between 4 and 8. Defaults to 4.
222
+ * If not specified, defaults to the bucket version's configured duration (or 4).
95
223
  */
96
224
  duration?: number;
97
225
  /**
@@ -106,17 +234,18 @@ interface SlopVideoOptions {
106
234
  */
107
235
  baseUrl?: string;
108
236
  /**
109
- * If `true` (or `?raw=true`), bypasses the WebP optimized media and returns the original generated file.
110
- * Defaults to false.
237
+ * If true, serves the original generated uncompressed asset directly from storage.
111
238
  */
112
239
  original?: boolean;
113
240
  /**
114
- * Array of attachment URLs to include with the request.
241
+ * Array of runtime image attachments (URLs) to use with the video model.
242
+ * Only allowed if the bucket version has runtime attachments enabled.
115
243
  */
116
244
  attachments?: string[];
117
245
  }
118
246
  /**
119
- * Builds a URL to render or retrieve a video from Slop Machine.
247
+ * Builds the URL to render or stream an AI-generated video.
248
+ * Supports both standard Buckets (via `bucketId`) and multi-step Pipelines (via `pipelineId`).
120
249
  *
121
250
  * @param options - Configuration options for the video generation.
122
251
  * @returns A string containing the fully constructed URL.
@@ -133,8 +262,26 @@ declare function preloadVideo(options: SlopVideoOptions): Promise<void>;
133
262
  interface SlopTextOptions {
134
263
  /**
135
264
  * The unique identifier of your Slop Machine bucket.
265
+ * Required when using a bucket unless pipelineId is provided.
266
+ */
267
+ bucketId?: string;
268
+ /**
269
+ * The unique identifier of your Slop Machine pipeline.
270
+ * Required when targeting a pipeline instead of a bucket.
271
+ */
272
+ pipelineId?: string;
273
+ /**
274
+ * Optional silo identifier.
275
+ */
276
+ siloId?: string;
277
+ /**
278
+ * Dynamic runtime prompt (used when targeting a pipeline).
279
+ */
280
+ prompt?: string;
281
+ /**
282
+ * Arbitrary user metadata to attach to the generation request / result document.
136
283
  */
137
- bucketId: string;
284
+ metadata?: Record<string, any>;
138
285
  /**
139
286
  * The specific version of the prompt/settings to use.
140
287
  * If omitted, the latest version will be used.
@@ -163,6 +310,8 @@ interface SlopTextOptions {
163
310
  /**
164
311
  * Builds a URL to render or retrieve text from Slop Machine.
165
312
  *
313
+ * Supports both standard Buckets (via `bucketId`) and multi-step Pipelines (via `pipelineId`).
314
+ *
166
315
  * @param options - Configuration options for the text generation.
167
316
  * @returns A string containing the fully constructed URL.
168
317
  */
@@ -175,6 +324,20 @@ declare function buildTextUrl(options: SlopTextOptions): string;
175
324
  * @returns A promise that resolves when the text preload request has been initiated.
176
325
  */
177
326
  declare function preloadText(options: SlopTextOptions): Promise<void>;
327
+ /**
328
+ * Builds a URL to execute or inspect a multi-step Pipeline from Slop Machine.
329
+ *
330
+ * @param options - Configuration options for the pipeline execution.
331
+ * @returns A string containing the fully constructed URL.
332
+ */
333
+ declare function buildPipelineUrl(options: SlopPipelineOptions): string;
334
+ /**
335
+ * Executes a Slop Machine multi-step Pipeline programmatically and returns the full typed result payload.
336
+ *
337
+ * @param options - Execution parameters including the pipelineId and runtime prompt/variables/metadata.
338
+ * @returns A promise resolving to the completed PipelineResult document.
339
+ */
340
+ declare function executePipeline(options: ExecutePipelineOptions): Promise<PipelineResult>;
178
341
  /**
179
342
  * Uploads a base64 encoded file as a temporary attachment to be used in generation requests.
180
343
  *
@@ -186,4 +349,4 @@ declare function uploadTempAttachment(base64: string, mimeType: string): Promise
186
349
  url: string;
187
350
  }>;
188
351
 
189
- export { type SlopImageOptions, type SlopTextOptions, type SlopVideoOptions, buildImageUrl, buildTextUrl, buildVideoUrl, interpolatePrompt, preloadImage, preloadText, preloadVideo, uploadTempAttachment };
352
+ 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 };