@workglow/ai 0.0.52

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.
Files changed (67) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +531 -0
  3. package/dist/browser.js +1371 -0
  4. package/dist/browser.js.map +30 -0
  5. package/dist/bun.js +1398 -0
  6. package/dist/bun.js.map +32 -0
  7. package/dist/common.d.ts +15 -0
  8. package/dist/common.d.ts.map +1 -0
  9. package/dist/job/AiJob.d.ts +28 -0
  10. package/dist/job/AiJob.d.ts.map +1 -0
  11. package/dist/model/Model.d.ts +26 -0
  12. package/dist/model/Model.d.ts.map +1 -0
  13. package/dist/model/ModelRegistry.d.ts +9 -0
  14. package/dist/model/ModelRegistry.d.ts.map +1 -0
  15. package/dist/model/ModelRepository.d.ts +146 -0
  16. package/dist/model/ModelRepository.d.ts.map +1 -0
  17. package/dist/model/storage/InMemoryModelRepository.d.ts +18 -0
  18. package/dist/model/storage/InMemoryModelRepository.d.ts.map +1 -0
  19. package/dist/model/storage/IndexedDbModelRepository.d.ts +18 -0
  20. package/dist/model/storage/IndexedDbModelRepository.d.ts.map +1 -0
  21. package/dist/model/storage/PostgresModelRepository.d.ts +19 -0
  22. package/dist/model/storage/PostgresModelRepository.d.ts.map +1 -0
  23. package/dist/model/storage/SqliteModelRepository.d.ts +18 -0
  24. package/dist/model/storage/SqliteModelRepository.d.ts.map +1 -0
  25. package/dist/node.js +1397 -0
  26. package/dist/node.js.map +32 -0
  27. package/dist/provider/AiProviderRegistry.d.ts +35 -0
  28. package/dist/provider/AiProviderRegistry.d.ts.map +1 -0
  29. package/dist/source/Document.d.ts +56 -0
  30. package/dist/source/Document.d.ts.map +1 -0
  31. package/dist/source/DocumentConverter.d.ts +15 -0
  32. package/dist/source/DocumentConverter.d.ts.map +1 -0
  33. package/dist/source/DocumentConverterMarkdown.d.ts +13 -0
  34. package/dist/source/DocumentConverterMarkdown.d.ts.map +1 -0
  35. package/dist/source/DocumentConverterText.d.ts +13 -0
  36. package/dist/source/DocumentConverterText.d.ts.map +1 -0
  37. package/dist/source/MasterDocument.d.ts +27 -0
  38. package/dist/source/MasterDocument.d.ts.map +1 -0
  39. package/dist/source/index.d.ts +10 -0
  40. package/dist/source/index.d.ts.map +1 -0
  41. package/dist/task/DocumentSplitterTask.d.ts +58 -0
  42. package/dist/task/DocumentSplitterTask.d.ts.map +1 -0
  43. package/dist/task/DownloadModelTask.d.ts +118 -0
  44. package/dist/task/DownloadModelTask.d.ts.map +1 -0
  45. package/dist/task/TextEmbeddingTask.d.ts +268 -0
  46. package/dist/task/TextEmbeddingTask.d.ts.map +1 -0
  47. package/dist/task/TextGenerationTask.d.ts +140 -0
  48. package/dist/task/TextGenerationTask.d.ts.map +1 -0
  49. package/dist/task/TextQuestionAnswerTask.d.ts +124 -0
  50. package/dist/task/TextQuestionAnswerTask.d.ts.map +1 -0
  51. package/dist/task/TextRewriterTask.d.ts +113 -0
  52. package/dist/task/TextRewriterTask.d.ts.map +1 -0
  53. package/dist/task/TextSummaryTask.d.ts +95 -0
  54. package/dist/task/TextSummaryTask.d.ts.map +1 -0
  55. package/dist/task/TextTranslationTask.d.ts +158 -0
  56. package/dist/task/TextTranslationTask.d.ts.map +1 -0
  57. package/dist/task/VectorSimilarityTask.d.ts +334 -0
  58. package/dist/task/VectorSimilarityTask.d.ts.map +1 -0
  59. package/dist/task/base/AiTask.d.ts +47 -0
  60. package/dist/task/base/AiTask.d.ts.map +1 -0
  61. package/dist/task/base/AiTaskSchemas.d.ts +156 -0
  62. package/dist/task/base/AiTaskSchemas.d.ts.map +1 -0
  63. package/dist/task/index.d.ts +17 -0
  64. package/dist/task/index.d.ts.map +1 -0
  65. package/dist/types.d.ts +11 -0
  66. package/dist/types.d.ts.map +1 -0
  67. package/package.json +67 -0
@@ -0,0 +1,334 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Steven Roussey <sroussey@gmail.com>
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { ArrayTask, CreateWorkflow, JobQueueTaskConfig } from "@workglow/task-graph";
7
+ import { DataPortSchema, FromSchema } from "@workglow/util";
8
+ import { TypedArray, TypedArraySchemaOptions } from "./base/AiTaskSchemas";
9
+ export declare const SimilarityFn: {
10
+ readonly COSINE: "cosine";
11
+ readonly JACCARD: "jaccard";
12
+ readonly HAMMING: "hamming";
13
+ };
14
+ export type SimilarityFn = (typeof SimilarityFn)[keyof typeof SimilarityFn];
15
+ declare const SimilarityInputSchema: {
16
+ readonly type: "object";
17
+ readonly properties: {
18
+ readonly query: {
19
+ readonly oneOf: readonly [{
20
+ readonly type: "array";
21
+ readonly items: {
22
+ readonly type: "number";
23
+ readonly format: "Float64";
24
+ };
25
+ readonly title: "Float64Array";
26
+ readonly description: "A 64-bit floating point array";
27
+ readonly format: "Float64Array";
28
+ }, {
29
+ readonly type: "array";
30
+ readonly items: {
31
+ readonly type: "number";
32
+ readonly format: "Float32";
33
+ };
34
+ readonly title: "Float32Array";
35
+ readonly description: "A 32-bit floating point array";
36
+ readonly format: "Float32Array";
37
+ }, {
38
+ readonly type: "array";
39
+ readonly items: {
40
+ readonly type: "number";
41
+ readonly format: "Int32";
42
+ };
43
+ readonly title: "Int32Array";
44
+ readonly description: "A 32-bit integer array";
45
+ readonly format: "Int32Array";
46
+ }, {
47
+ readonly type: "array";
48
+ readonly items: {
49
+ readonly type: "number";
50
+ readonly format: "Int16";
51
+ };
52
+ readonly title: "Int16Array";
53
+ readonly description: "A 16-bit integer array";
54
+ readonly format: "Int16Array";
55
+ }, {
56
+ readonly type: "array";
57
+ readonly items: {
58
+ readonly type: "number";
59
+ readonly format: "Int8";
60
+ };
61
+ readonly title: "Int8Array";
62
+ }, {
63
+ readonly type: "array";
64
+ readonly items: {
65
+ readonly type: "number";
66
+ readonly format: "Uint8";
67
+ };
68
+ readonly title: "Uint8Array";
69
+ readonly description: "A 8-bit unsigned integer array";
70
+ readonly format: "Uint8Array";
71
+ }, {
72
+ readonly type: "array";
73
+ readonly items: {
74
+ readonly type: "number";
75
+ readonly format: "Uint16";
76
+ };
77
+ readonly title: "Uint16Array";
78
+ readonly description: "A 16-bit unsigned integer array";
79
+ readonly format: "Uint16Array";
80
+ }, {
81
+ readonly type: "array";
82
+ readonly items: {
83
+ readonly type: "number";
84
+ readonly format: "Uint32";
85
+ };
86
+ readonly title: "Uint32Array";
87
+ readonly description: "A 32-bit unsigned integer array";
88
+ readonly format: "Uint32Array";
89
+ }, {
90
+ readonly type: "array";
91
+ readonly items: {
92
+ readonly type: "number";
93
+ readonly format: "Uint8Clamped";
94
+ };
95
+ readonly title: "Uint8ClampedArray";
96
+ readonly description: "A 8-bit unsigned integer array with values clamped to 0-255";
97
+ readonly format: "Uint8ClampedArray";
98
+ }];
99
+ readonly format: "TypedArray";
100
+ };
101
+ readonly input: {
102
+ readonly type: "array";
103
+ readonly items: {
104
+ readonly oneOf: readonly [{
105
+ readonly type: "array";
106
+ readonly items: {
107
+ readonly type: "number";
108
+ readonly format: "Float64";
109
+ };
110
+ readonly title: "Float64Array";
111
+ readonly description: "A 64-bit floating point array";
112
+ readonly format: "Float64Array";
113
+ }, {
114
+ readonly type: "array";
115
+ readonly items: {
116
+ readonly type: "number";
117
+ readonly format: "Float32";
118
+ };
119
+ readonly title: "Float32Array";
120
+ readonly description: "A 32-bit floating point array";
121
+ readonly format: "Float32Array";
122
+ }, {
123
+ readonly type: "array";
124
+ readonly items: {
125
+ readonly type: "number";
126
+ readonly format: "Int32";
127
+ };
128
+ readonly title: "Int32Array";
129
+ readonly description: "A 32-bit integer array";
130
+ readonly format: "Int32Array";
131
+ }, {
132
+ readonly type: "array";
133
+ readonly items: {
134
+ readonly type: "number";
135
+ readonly format: "Int16";
136
+ };
137
+ readonly title: "Int16Array";
138
+ readonly description: "A 16-bit integer array";
139
+ readonly format: "Int16Array";
140
+ }, {
141
+ readonly type: "array";
142
+ readonly items: {
143
+ readonly type: "number";
144
+ readonly format: "Int8";
145
+ };
146
+ readonly title: "Int8Array";
147
+ }, {
148
+ readonly type: "array";
149
+ readonly items: {
150
+ readonly type: "number";
151
+ readonly format: "Uint8";
152
+ };
153
+ readonly title: "Uint8Array";
154
+ readonly description: "A 8-bit unsigned integer array";
155
+ readonly format: "Uint8Array";
156
+ }, {
157
+ readonly type: "array";
158
+ readonly items: {
159
+ readonly type: "number";
160
+ readonly format: "Uint16";
161
+ };
162
+ readonly title: "Uint16Array";
163
+ readonly description: "A 16-bit unsigned integer array";
164
+ readonly format: "Uint16Array";
165
+ }, {
166
+ readonly type: "array";
167
+ readonly items: {
168
+ readonly type: "number";
169
+ readonly format: "Uint32";
170
+ };
171
+ readonly title: "Uint32Array";
172
+ readonly description: "A 32-bit unsigned integer array";
173
+ readonly format: "Uint32Array";
174
+ }, {
175
+ readonly type: "array";
176
+ readonly items: {
177
+ readonly type: "number";
178
+ readonly format: "Uint8Clamped";
179
+ };
180
+ readonly title: "Uint8ClampedArray";
181
+ readonly description: "A 8-bit unsigned integer array with values clamped to 0-255";
182
+ readonly format: "Uint8ClampedArray";
183
+ }];
184
+ readonly format: "TypedArray";
185
+ };
186
+ };
187
+ readonly topK: {
188
+ readonly type: "number";
189
+ readonly title: "Top K";
190
+ readonly description: "Number of top results to return";
191
+ readonly minimum: 1;
192
+ readonly default: 10;
193
+ };
194
+ readonly similarity: {
195
+ readonly type: "string";
196
+ readonly enum: ("cosine" | "jaccard" | "hamming")[];
197
+ readonly title: "Similarity 𝑓";
198
+ readonly description: "Similarity function to use for comparisons";
199
+ readonly default: "cosine";
200
+ };
201
+ };
202
+ readonly required: readonly ["query", "input", "similarity"];
203
+ readonly additionalProperties: false;
204
+ };
205
+ declare const SimilarityOutputSchema: {
206
+ readonly type: "object";
207
+ readonly properties: {
208
+ readonly output: {
209
+ readonly type: "array";
210
+ readonly items: {
211
+ readonly oneOf: readonly [{
212
+ readonly type: "array";
213
+ readonly items: {
214
+ readonly type: "number";
215
+ readonly format: "Float64";
216
+ };
217
+ readonly title: "Float64Array";
218
+ readonly description: "A 64-bit floating point array";
219
+ readonly format: "Float64Array";
220
+ }, {
221
+ readonly type: "array";
222
+ readonly items: {
223
+ readonly type: "number";
224
+ readonly format: "Float32";
225
+ };
226
+ readonly title: "Float32Array";
227
+ readonly description: "A 32-bit floating point array";
228
+ readonly format: "Float32Array";
229
+ }, {
230
+ readonly type: "array";
231
+ readonly items: {
232
+ readonly type: "number";
233
+ readonly format: "Int32";
234
+ };
235
+ readonly title: "Int32Array";
236
+ readonly description: "A 32-bit integer array";
237
+ readonly format: "Int32Array";
238
+ }, {
239
+ readonly type: "array";
240
+ readonly items: {
241
+ readonly type: "number";
242
+ readonly format: "Int16";
243
+ };
244
+ readonly title: "Int16Array";
245
+ readonly description: "A 16-bit integer array";
246
+ readonly format: "Int16Array";
247
+ }, {
248
+ readonly type: "array";
249
+ readonly items: {
250
+ readonly type: "number";
251
+ readonly format: "Int8";
252
+ };
253
+ readonly title: "Int8Array";
254
+ }, {
255
+ readonly type: "array";
256
+ readonly items: {
257
+ readonly type: "number";
258
+ readonly format: "Uint8";
259
+ };
260
+ readonly title: "Uint8Array";
261
+ readonly description: "A 8-bit unsigned integer array";
262
+ readonly format: "Uint8Array";
263
+ }, {
264
+ readonly type: "array";
265
+ readonly items: {
266
+ readonly type: "number";
267
+ readonly format: "Uint16";
268
+ };
269
+ readonly title: "Uint16Array";
270
+ readonly description: "A 16-bit unsigned integer array";
271
+ readonly format: "Uint16Array";
272
+ }, {
273
+ readonly type: "array";
274
+ readonly items: {
275
+ readonly type: "number";
276
+ readonly format: "Uint32";
277
+ };
278
+ readonly title: "Uint32Array";
279
+ readonly description: "A 32-bit unsigned integer array";
280
+ readonly format: "Uint32Array";
281
+ }, {
282
+ readonly type: "array";
283
+ readonly items: {
284
+ readonly type: "number";
285
+ readonly format: "Uint8Clamped";
286
+ };
287
+ readonly title: "Uint8ClampedArray";
288
+ readonly description: "A 8-bit unsigned integer array with values clamped to 0-255";
289
+ readonly format: "Uint8ClampedArray";
290
+ }];
291
+ readonly format: "TypedArray";
292
+ };
293
+ };
294
+ readonly score: {
295
+ readonly type: "array";
296
+ readonly items: {
297
+ readonly type: "number";
298
+ readonly title: "Score";
299
+ readonly description: "Similarity scores for each output vector";
300
+ };
301
+ };
302
+ };
303
+ readonly required: readonly ["output", "score"];
304
+ readonly additionalProperties: false;
305
+ };
306
+ export type VectorSimilarityTaskInput = FromSchema<typeof SimilarityInputSchema, TypedArraySchemaOptions>;
307
+ export type VectorSimilarityTaskOutput = FromSchema<typeof SimilarityOutputSchema, TypedArraySchemaOptions>;
308
+ export declare class VectorSimilarityTask extends ArrayTask<VectorSimilarityTaskInput, VectorSimilarityTaskOutput, JobQueueTaskConfig> {
309
+ static readonly type = "VectorSimilarityTask";
310
+ static readonly category = "Analysis";
311
+ static readonly title = "Vector Similarity";
312
+ static description: string;
313
+ static readonly cacheable = true;
314
+ static inputSchema(): DataPortSchema;
315
+ static outputSchema(): DataPortSchema;
316
+ executeReactive({ query, input, similarity, topK }: VectorSimilarityTaskInput, oldOutput: VectorSimilarityTaskOutput): Promise<{
317
+ output: TypedArray[];
318
+ score: number[];
319
+ }>;
320
+ }
321
+ export declare const Similarity: (input: VectorSimilarityTaskInput, config?: JobQueueTaskConfig) => Promise<{
322
+ output: TypedArray[];
323
+ score: number[];
324
+ }>;
325
+ declare module "@workglow/task-graph" {
326
+ interface Workflow {
327
+ Similarity: CreateWorkflow<VectorSimilarityTaskInput, VectorSimilarityTaskOutput, JobQueueTaskConfig>;
328
+ }
329
+ }
330
+ export declare function inner(arr1: TypedArray, arr2: TypedArray): number;
331
+ export declare function magnitude(arr: TypedArray): number;
332
+ export declare function normalize(vector: TypedArray): TypedArray;
333
+ export {};
334
+ //# sourceMappingURL=VectorSimilarityTask.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VectorSimilarityTask.d.ts","sourceRoot":"","sources":["../../src/task/VectorSimilarityTask.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACH,SAAS,EACT,cAAc,EACd,kBAAkB,EAIrB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAoB,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAE7F,eAAO,MAAM,YAAY;;;;CAIf,CAAC;AAEX,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,OAAO,YAAY,CAAC,CAAC;AAE5E,QAAA,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+BQ,CAAC;AAEpC,QAAA,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqBO,CAAC;AAEpC,MAAM,MAAM,yBAAyB,GAAG,UAAU,CAChD,OAAO,qBAAqB,EAC5B,uBAAuB,CACxB,CAAC;AACF,MAAM,MAAM,0BAA0B,GAAG,UAAU,CACjD,OAAO,sBAAsB,EAC7B,uBAAuB,CACxB,CAAC;AAEF,qBAAa,oBAAqB,SAAQ,SAAS,CACjD,yBAAyB,EACzB,0BAA0B,EAC1B,kBAAkB,CACnB;IACC,MAAM,CAAC,QAAQ,CAAC,IAAI,0BAA0B;IAC9C,MAAM,CAAC,QAAQ,CAAC,QAAQ,cAAc;IACtC,MAAM,CAAC,QAAQ,CAAC,KAAK,uBAAuB;IAC5C,OAAc,WAAW,SACwD;IACjF,MAAM,CAAC,QAAQ,CAAC,SAAS,QAAQ;WAEV,WAAW,IAAI,cAAc;WAG7B,YAAY,IAAI,cAAc;IAK/C,eAAe,CACnB,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,EAAE,yBAAyB,EAC7D,SAAS,EAAE,0BAA0B;;;;CAsBxC;AAID,eAAO,MAAM,UAAU,GAAI,OAAO,yBAAyB,EAAE,SAAS,kBAAkB;;;EAEvF,CAAC;AAEF,OAAO,QAAQ,sBAAsB,CAAC;IACpC,UAAU,QAAQ;QAChB,UAAU,EAAE,cAAc,CACxB,yBAAyB,EACzB,0BAA0B,EAC1B,kBAAkB,CACnB,CAAC;KACH;CACF;AAMD,wBAAgB,KAAK,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,GAAG,MAAM,CAGhE;AAED,wBAAgB,SAAS,CAAC,GAAG,EAAE,UAAU,UAGxC;AASD,wBAAgB,SAAS,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CAiBxD"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Steven Roussey <sroussey@gmail.com>
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ /**
7
+ * @description This file contains the implementation of the JobQueueTask class and its derived classes.
8
+ */
9
+ import { Job, JobQueue } from "@workglow/job-queue";
10
+ import { JobQueueTask, JobQueueTaskConfig, TaskInput, type TaskOutput } from "@workglow/task-graph";
11
+ import { AiJobInput } from "../../job/AiJob";
12
+ import type { Model } from "../../model/Model";
13
+ export interface AiSingleTaskInput extends TaskInput {
14
+ model: string;
15
+ }
16
+ export interface AiArrayTaskInput extends TaskInput {
17
+ model: string | string[];
18
+ }
19
+ /**
20
+ * A base class for AI related tasks that run in a job queue.
21
+ * Extends the JobQueueTask class to provide LLM-specific functionality.
22
+ */
23
+ export declare class AiTask<Input extends AiArrayTaskInput = AiArrayTaskInput, Output extends TaskOutput = TaskOutput, Config extends JobQueueTaskConfig = JobQueueTaskConfig> extends JobQueueTask<Input, Output, Config> {
24
+ static type: string;
25
+ private modelCache?;
26
+ /**
27
+ * Creates a new AiTask instance
28
+ * @param config - Configuration object for the task
29
+ */
30
+ constructor(input?: Input, config?: Config);
31
+ /**
32
+ * Creates a new Job instance for the task
33
+ * @returns Promise<Job> - The created job
34
+ */
35
+ createJob(input: Input, queue?: JobQueue<Input, Output>): Promise<Job<AiJobInput<Input>, Output>>;
36
+ protected getModelForInput(input: AiSingleTaskInput): Promise<Model>;
37
+ protected getDefaultQueueName(input: Input): Promise<string | undefined>;
38
+ /**
39
+ * Validates that a model name really exists
40
+ * @param schema The schema to validate against
41
+ * @param item The item to validate
42
+ * @returns True if the item is valid, false otherwise
43
+ */
44
+ validateInput(input: Input): Promise<boolean>;
45
+ narrowInput(input: Input): Promise<Input>;
46
+ }
47
+ //# sourceMappingURL=AiTask.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AiTask.d.ts","sourceRoot":"","sources":["../../../src/task/base/AiTask.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AAEH,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EACH,YAAY,EACZ,kBAAkB,EAElB,SAAS,EACT,KAAK,UAAU,EAClB,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EAAS,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAS/C,MAAM,WAAW,iBAAkB,SAAQ,SAAS;IAClD,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,gBAAiB,SAAQ,SAAS;IACjD,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CAC1B;AAED;;;GAGG;AACH,qBAAa,MAAM,CACjB,KAAK,SAAS,gBAAgB,GAAG,gBAAgB,EACjD,MAAM,SAAS,UAAU,GAAG,UAAU,EACtC,MAAM,SAAS,kBAAkB,GAAG,kBAAkB,CACtD,SAAQ,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC;IAC3C,OAAc,IAAI,EAAE,MAAM,CAAY;IACtC,OAAO,CAAC,UAAU,CAAC,CAAiC;IAEpD;;;OAGG;gBACS,KAAK,GAAE,KAAmB,EAAE,MAAM,GAAE,MAAqB;IAWrE;;;OAGG;IACY,SAAS,CACtB,KAAK,EAAE,KAAK,EACZ,KAAK,CAAC,EAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,GAC9B,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,CAAC;cAyB1B,gBAAgB,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,KAAK,CAAC;cAcjD,mBAAmB,CAAC,KAAK,EAAE,KAAK;IAQzD;;;;;OAKG;IACG,aAAa,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC;IA8C7C,WAAW,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;CA2BhD"}
@@ -0,0 +1,156 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Steven Roussey <sroussey@gmail.com>
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { DataPortSchemaNonBoolean, FromSchema, JsonSchema } from "@workglow/util";
7
+ export type TypedArray = Float64Array | Float32Array | Int32Array | Int16Array | Int8Array | Uint32Array | Uint16Array | Uint8Array | Uint8ClampedArray;
8
+ declare const TypedArraySchemaOptions: {
9
+ readonly deserialize: [{
10
+ readonly pattern: {
11
+ readonly format: "TypedArray";
12
+ };
13
+ readonly output: TypedArray;
14
+ }];
15
+ readonly parseNotKeyword: true;
16
+ readonly parseIfThenElseKeywords: false;
17
+ readonly keepDefaultedPropertiesOptional: true;
18
+ readonly references: false;
19
+ };
20
+ export type TypedArraySchemaOptions = typeof TypedArraySchemaOptions;
21
+ export declare const TypedArraySchema: (annotations?: Record<string, unknown>) => {
22
+ readonly oneOf: readonly [{
23
+ readonly type: "array";
24
+ readonly items: {
25
+ readonly type: "number";
26
+ readonly format: "Float64";
27
+ };
28
+ readonly title: "Float64Array";
29
+ readonly description: "A 64-bit floating point array";
30
+ readonly format: "Float64Array";
31
+ }, {
32
+ readonly type: "array";
33
+ readonly items: {
34
+ readonly type: "number";
35
+ readonly format: "Float32";
36
+ };
37
+ readonly title: "Float32Array";
38
+ readonly description: "A 32-bit floating point array";
39
+ readonly format: "Float32Array";
40
+ }, {
41
+ readonly type: "array";
42
+ readonly items: {
43
+ readonly type: "number";
44
+ readonly format: "Int32";
45
+ };
46
+ readonly title: "Int32Array";
47
+ readonly description: "A 32-bit integer array";
48
+ readonly format: "Int32Array";
49
+ }, {
50
+ readonly type: "array";
51
+ readonly items: {
52
+ readonly type: "number";
53
+ readonly format: "Int16";
54
+ };
55
+ readonly title: "Int16Array";
56
+ readonly description: "A 16-bit integer array";
57
+ readonly format: "Int16Array";
58
+ }, {
59
+ readonly type: "array";
60
+ readonly items: {
61
+ readonly type: "number";
62
+ readonly format: "Int8";
63
+ };
64
+ readonly title: "Int8Array";
65
+ }, {
66
+ readonly type: "array";
67
+ readonly items: {
68
+ readonly type: "number";
69
+ readonly format: "Uint8";
70
+ };
71
+ readonly title: "Uint8Array";
72
+ readonly description: "A 8-bit unsigned integer array";
73
+ readonly format: "Uint8Array";
74
+ }, {
75
+ readonly type: "array";
76
+ readonly items: {
77
+ readonly type: "number";
78
+ readonly format: "Uint16";
79
+ };
80
+ readonly title: "Uint16Array";
81
+ readonly description: "A 16-bit unsigned integer array";
82
+ readonly format: "Uint16Array";
83
+ }, {
84
+ readonly type: "array";
85
+ readonly items: {
86
+ readonly type: "number";
87
+ readonly format: "Uint32";
88
+ };
89
+ readonly title: "Uint32Array";
90
+ readonly description: "A 32-bit unsigned integer array";
91
+ readonly format: "Uint32Array";
92
+ }, {
93
+ readonly type: "array";
94
+ readonly items: {
95
+ readonly type: "number";
96
+ readonly format: "Uint8Clamped";
97
+ };
98
+ readonly title: "Uint8ClampedArray";
99
+ readonly description: "A 8-bit unsigned integer array with values clamped to 0-255";
100
+ readonly format: "Uint8ClampedArray";
101
+ }];
102
+ readonly format: "TypedArray";
103
+ };
104
+ export declare const TypeLanguage: (annotations?: Record<string, unknown>) => {
105
+ readonly type: "string";
106
+ readonly title: "Language";
107
+ readonly description: "The language to use";
108
+ readonly maxLength: 2;
109
+ readonly minLength: 2;
110
+ };
111
+ export type TypeModelSemantic = "model" | `model:${string}`;
112
+ export type TTypeModel = DataPortSchemaNonBoolean & {
113
+ readonly type: "string";
114
+ readonly format: TypeModelSemantic;
115
+ };
116
+ export declare function TypeModel<S extends TypeModelSemantic = "model", O extends Record<string, unknown> = {}>(semantic?: S, options?: O): {
117
+ readonly title: "Model";
118
+ readonly description: `The model ${string}`;
119
+ } & O & {
120
+ readonly format: S;
121
+ readonly type: "string";
122
+ };
123
+ export declare const TypeReplicateArray: <T extends DataPortSchemaNonBoolean>(type: T, annotations?: Record<string, unknown>) => {
124
+ readonly "x-replicate": true;
125
+ readonly format?: string | undefined;
126
+ readonly oneOf: readonly [T, {
127
+ readonly type: "array";
128
+ readonly items: T;
129
+ }];
130
+ readonly title: string | undefined;
131
+ readonly description: string | undefined;
132
+ };
133
+ export type TypedArrayFromSchema<SCHEMA extends JsonSchema> = FromSchema<SCHEMA, TypedArraySchemaOptions>;
134
+ /**
135
+ * Removes array types from a union, leaving only non-array types.
136
+ * For example, `string | string[]` becomes `string`.
137
+ * Used to extract the single-value type from schemas with x-replicate annotation.
138
+ * Uses distributive conditional types to filter out arrays from unions.
139
+ * Checks for both array types and types with numeric index signatures (FromSchema array output).
140
+ * Preserves TypedArray types like Float64Array which also have numeric indices.
141
+ */
142
+ type UnwrapArrayUnion<T> = T extends readonly any[] ? T extends TypedArray ? T : never : number extends keyof T ? "push" extends keyof T ? never : T : T;
143
+ /**
144
+ * Transforms a schema by removing array variants from properties marked with x-replicate.
145
+ * Properties with x-replicate use {@link TypeReplicateArray} which creates a union of
146
+ * `T | T[]`, and this type extracts just `T`.
147
+ */
148
+ export type DeReplicateFromSchema<S extends {
149
+ properties: Record<string, any>;
150
+ }> = {
151
+ [K in keyof S["properties"]]: S["properties"][K] extends {
152
+ "x-replicate": true;
153
+ } ? UnwrapArrayUnion<TypedArrayFromSchema<S["properties"][K]>> : TypedArrayFromSchema<S["properties"][K]>;
154
+ };
155
+ export {};
156
+ //# sourceMappingURL=AiTaskSchemas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AiTaskSchemas.d.ts","sourceRoot":"","sources":["../../../src/task/base/AiTaskSchemas.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACH,wBAAwB,EACxB,UAAU,EAGV,UAAU,EACb,MAAM,gBAAgB,CAAC;AAExB,MAAM,MAAM,UAAU,GAClB,YAAY,GACZ,YAAY,GACZ,UAAU,GACV,UAAU,GACV,SAAS,GACT,WAAW,GACX,WAAW,GACX,UAAU,GACV,iBAAiB,CAAC;AAKtB,QAAA,MAAM,uBAAuB;;;;;;;;;;;CA2ES,CAAC;AAEvC,MAAM,MAAM,uBAAuB,GAAG,OAAO,uBAAuB,CAAC;AAErE,eAAO,MAAM,gBAAgB,GAAI,cAAa,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmExC,CAAC;AAEnC,eAAO,MAAM,YAAY,GAAI,cAAa,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM;;;;;;CAQzD,CAAC;AAEd,MAAM,MAAM,iBAAiB,GAAG,OAAO,GAAG,SAAS,MAAM,EAAE,CAAC;AAE5D,MAAM,MAAM,UAAU,GAAG,wBAAwB,GAAG;IAClD,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,iBAAiB,CAAC;CACpC,CAAC;AAEF,wBAAgB,SAAS,CACvB,CAAC,SAAS,iBAAiB,GAAG,OAAO,EACrC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,EAAE,EACtC,QAAQ,GAAE,CAAgB,EAAE,OAAO,GAAE,CAAW;;;;;;EAkBjD;AAED,eAAO,MAAM,kBAAkB,GAAI,CAAC,SAAS,wBAAwB,EACnE,MAAM,CAAC,EACP,cAAa,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM;;;;;;;;;CAS9B,CAAC;AAEd,MAAM,MAAM,oBAAoB,CAAC,MAAM,SAAS,UAAU,IAAI,UAAU,CACtE,MAAM,EACN,uBAAuB,CACxB,CAAC;AAEF;;;;;;;GAOG;AACH,KAAK,gBAAgB,CAAC,CAAC,IAAI,CAAC,SAAS,SAAS,GAAG,EAAE,GAC/C,CAAC,SAAS,UAAU,GAClB,CAAC,GACD,KAAK,GACP,MAAM,SAAS,MAAM,CAAC,GACpB,MAAM,SAAS,MAAM,CAAC,GACpB,KAAK,GACL,CAAC,GACH,CAAC,CAAC;AAER;;;;GAIG;AACH,MAAM,MAAM,qBAAqB,CAAC,CAAC,SAAS;IAAE,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;CAAE,IAAI;KAChF,CAAC,IAAI,MAAM,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,SAAS;QAAE,aAAa,EAAE,IAAI,CAAA;KAAE,GAC5E,gBAAgB,CAAC,oBAAoB,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAC1D,oBAAoB,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;CAC7C,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Steven Roussey <sroussey@gmail.com>
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ export * from "./base/AiTask";
7
+ export * from "./base/AiTaskSchemas";
8
+ export * from "./DocumentSplitterTask";
9
+ export * from "./DownloadModelTask";
10
+ export * from "./TextEmbeddingTask";
11
+ export * from "./TextGenerationTask";
12
+ export * from "./TextQuestionAnswerTask";
13
+ export * from "./TextRewriterTask";
14
+ export * from "./TextSummaryTask";
15
+ export * from "./TextTranslationTask";
16
+ export * from "./VectorSimilarityTask";
17
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/task/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Steven Roussey <sroussey@gmail.com>
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ export * from "./common";
7
+ export * from "./model/storage/IndexedDbModelRepository";
8
+ export * from "./model/storage/InMemoryModelRepository";
9
+ export * from "./model/storage/PostgresModelRepository";
10
+ export * from "./model/storage/SqliteModelRepository";
11
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,UAAU,CAAC;AAEzB,cAAc,0CAA0C,CAAC;AACzD,cAAc,yCAAyC,CAAC;AACxD,cAAc,yCAAyC,CAAC;AACxD,cAAc,uCAAuC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,67 @@
1
+ {
2
+ "name": "@workglow/ai",
3
+ "type": "module",
4
+ "version": "0.0.52",
5
+ "description": "Core AI functionality for Workglow, including task execution, model management, and AI pipeline orchestration.",
6
+ "scripts": {
7
+ "watch": "concurrently -c 'auto' 'bun:watch-*'",
8
+ "watch-browser": "bun build --watch --no-clear-screen --target=browser --sourcemap=external --packages=external --outdir ./dist ./src/browser.ts",
9
+ "watch-node": "bun build --watch --no-clear-screen --target=node --sourcemap=external --packages=external --outdir ./dist ./src/node.ts",
10
+ "watch-bun": "bun build --watch --no-clear-screen --target=bun --sourcemap=external --packages=external --outdir ./dist ./src/bun.ts",
11
+ "watch-types": "tsc --watch --preserveWatchOutput",
12
+ "build-package": "bun run build-clean && concurrently -c 'auto' -n 'browser,node,bun,types' 'bun run build-browser' 'bun run build-node' 'bun run build-bun' 'bun run build-types'",
13
+ "build-clean": "rm -fr dist/*",
14
+ "build-browser": "bun build --target=browser --sourcemap=external --packages=external --outdir ./dist ./src/browser.ts",
15
+ "build-node": "bun build --target=node --sourcemap=external --packages=external --outdir ./dist ./src/node.ts",
16
+ "build-bun": "bun build --target=bun --sourcemap=external --packages=external --outdir ./dist ./src/bun.ts",
17
+ "build-types": "rm -f tsconfig.tsbuildinfo && tsc",
18
+ "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
19
+ "test": "bun test",
20
+ "prepare": "node -e \"const pkg=require('./package.json');pkg.exports['.'].bun='./dist/bun.js';pkg.exports['.'].types='./dist/types.d.ts';require('fs').writeFileSync('package.json',JSON.stringify(pkg,null,2))\""
21
+ },
22
+ "exports": {
23
+ ".": {
24
+ "react-native": "./dist/browser.js",
25
+ "browser": "./dist/browser.js",
26
+ "bun": "./dist/bun.js",
27
+ "types": "./dist/types.d.ts",
28
+ "node": "./dist/node.js"
29
+ }
30
+ },
31
+ "files": [
32
+ "dist",
33
+ "src/**/*.md"
34
+ ],
35
+ "publishConfig": {
36
+ "access": "public"
37
+ },
38
+ "peerDependencies": {
39
+ "@workglow/job-queue": "0.0.52",
40
+ "@workglow/storage": "0.0.52",
41
+ "@workglow/task-graph": "0.0.52",
42
+ "@workglow/util": "0.0.52",
43
+ "pg": "^8.16.3"
44
+ },
45
+ "peerDependenciesMeta": {
46
+ "@workglow/job-queue": {
47
+ "optional": false
48
+ },
49
+ "@workglow/storage": {
50
+ "optional": false
51
+ },
52
+ "@workglow/task-graph": {
53
+ "optional": false
54
+ },
55
+ "@workglow/util": {
56
+ "optional": false
57
+ }
58
+ },
59
+ "devDependencies": {
60
+ "@workglow/job-queue": "0.0.52",
61
+ "@workglow/storage": "0.0.52",
62
+ "@workglow/task-graph": "0.0.52",
63
+ "@workglow/util": "0.0.52",
64
+ "@types/pg": "^8.15.5",
65
+ "pg": "^8.16.3"
66
+ }
67
+ }