@loopstack/core 0.10.2 → 0.10.3
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 +8 -0
- package/dist/modules/workflow-processor/index.d.ts +1 -0
- package/dist/modules/workflow-processor/index.js +1 -0
- package/dist/modules/workflow-processor/index.js.map +1 -1
- package/dist/modules/workflow-processor/llm/ai-generate-object.tool.d.ts +23 -0
- package/dist/modules/workflow-processor/llm/ai-generate-object.tool.js +159 -0
- package/dist/modules/workflow-processor/llm/ai-generate-object.tool.js.map +1 -0
- package/dist/modules/workflow-processor/llm/index.d.ts +1 -0
- package/dist/modules/workflow-processor/llm/index.js +18 -0
- package/dist/modules/workflow-processor/llm/index.js.map +1 -0
- package/dist/modules/workflow-processor/schemas/completion-message.schema.d.ts +21 -0
- package/dist/modules/workflow-processor/schemas/completion-message.schema.js +13 -0
- package/dist/modules/workflow-processor/schemas/completion-message.schema.js.map +1 -0
- package/dist/modules/workflow-processor/workflow-processor.module.js +3 -0
- package/dist/modules/workflow-processor/workflow-processor.module.js.map +1 -1
- package/package.json +6 -2
package/CHANGELOG.md
CHANGED
|
@@ -18,5 +18,6 @@ __exportStar(require("./services"), exports);
|
|
|
18
18
|
__exportStar(require("./errors"), exports);
|
|
19
19
|
__exportStar(require("./abstract"), exports);
|
|
20
20
|
__exportStar(require("./blocks"), exports);
|
|
21
|
+
__exportStar(require("./llm"), exports);
|
|
21
22
|
__exportStar(require("./workflow-processor.module"), exports);
|
|
22
23
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/modules/workflow-processor/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA2B;AAC3B,2CAAyB;AACzB,6CAA2B;AAC3B,2CAAyB;AACzB,8DAA4C"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/modules/workflow-processor/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA2B;AAC3B,2CAAyB;AACzB,6CAA2B;AAC3B,2CAAyB;AACzB,wCAAsB;AACtB,8DAA4C"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { AiProviderOptions, HandlerCallResult } from '@loopstack/shared';
|
|
2
|
+
import { Logger } from '@nestjs/common';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
import { ModelMessage } from '@ai-sdk/provider-utils';
|
|
5
|
+
import { Tool } from '../abstract';
|
|
6
|
+
import { GenerateObjectResult } from 'ai';
|
|
7
|
+
import { BlockRegistryService } from '../../configuration';
|
|
8
|
+
export declare class AiGenerateObjectTool extends Tool {
|
|
9
|
+
private readonly blockRegistryService;
|
|
10
|
+
protected readonly logger: Logger;
|
|
11
|
+
constructor(blockRegistryService: BlockRegistryService);
|
|
12
|
+
private getApiKey;
|
|
13
|
+
private getModel;
|
|
14
|
+
private getProvider;
|
|
15
|
+
createClient(options: AiProviderOptions): import("@ai-sdk/openai").OpenAIProvider;
|
|
16
|
+
getModelClient(client: any, model: string): any;
|
|
17
|
+
getProviderModel(config: any): any;
|
|
18
|
+
handleGenerateObject(model: any, messages: ModelMessage[], schema: any): Promise<GenerateObjectResult<any>>;
|
|
19
|
+
getSchema(args: {
|
|
20
|
+
responseDocument: string;
|
|
21
|
+
}): z.ZodType | undefined;
|
|
22
|
+
execute(): Promise<HandlerCallResult>;
|
|
23
|
+
}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var AiGenerateObjectTool_1;
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.AiGenerateObjectTool = void 0;
|
|
14
|
+
const shared_1 = require("@loopstack/shared");
|
|
15
|
+
const common_1 = require("@nestjs/common");
|
|
16
|
+
const zod_1 = require("zod");
|
|
17
|
+
const lodash_1 = require("lodash");
|
|
18
|
+
const abstract_1 = require("../abstract");
|
|
19
|
+
const ai_1 = require("ai");
|
|
20
|
+
const completion_message_schema_1 = require("../schemas/completion-message.schema");
|
|
21
|
+
const configuration_1 = require("../../configuration");
|
|
22
|
+
const openai_1 = require("@ai-sdk/openai");
|
|
23
|
+
const config = zod_1.z
|
|
24
|
+
.object({
|
|
25
|
+
llm: zod_1.z
|
|
26
|
+
.object({
|
|
27
|
+
model: zod_1.z.string().optional(),
|
|
28
|
+
provider: zod_1.z.string().optional(),
|
|
29
|
+
envApiKey: zod_1.z.string().optional(),
|
|
30
|
+
cacheResponse: zod_1.z.boolean().optional(),
|
|
31
|
+
})
|
|
32
|
+
.optional(),
|
|
33
|
+
messages: zod_1.z.array(completion_message_schema_1.CompletionMessageConfigSchema).optional(),
|
|
34
|
+
messagesSearchTag: zod_1.z.string().optional(),
|
|
35
|
+
responseDocument: zod_1.z.union([
|
|
36
|
+
shared_1.TemplateExpression,
|
|
37
|
+
zod_1.z.string(),
|
|
38
|
+
]),
|
|
39
|
+
})
|
|
40
|
+
.strict();
|
|
41
|
+
const schema = zod_1.z
|
|
42
|
+
.object({
|
|
43
|
+
llm: zod_1.z
|
|
44
|
+
.object({
|
|
45
|
+
model: zod_1.z.string().optional(),
|
|
46
|
+
provider: zod_1.z.string().optional(),
|
|
47
|
+
envApiKey: zod_1.z.string().optional(),
|
|
48
|
+
cacheResponse: zod_1.z.boolean().optional(),
|
|
49
|
+
})
|
|
50
|
+
.optional(),
|
|
51
|
+
messages: zod_1.z.array(completion_message_schema_1.CompletionMessageSchema).optional(),
|
|
52
|
+
messagesSearchTag: zod_1.z.string().optional(),
|
|
53
|
+
responseDocument: zod_1.z.string(),
|
|
54
|
+
})
|
|
55
|
+
.strict();
|
|
56
|
+
let AiGenerateObjectTool = AiGenerateObjectTool_1 = class AiGenerateObjectTool extends abstract_1.Tool {
|
|
57
|
+
blockRegistryService;
|
|
58
|
+
logger = new common_1.Logger(AiGenerateObjectTool_1.name);
|
|
59
|
+
constructor(blockRegistryService) {
|
|
60
|
+
super();
|
|
61
|
+
this.blockRegistryService = blockRegistryService;
|
|
62
|
+
}
|
|
63
|
+
getApiKey(envApiKey, providerName) {
|
|
64
|
+
const defaultKey = `${providerName.toUpperCase()}_API_KEY`;
|
|
65
|
+
const apiKey = envApiKey ? process.env[envApiKey] : process.env[defaultKey];
|
|
66
|
+
if (!apiKey) {
|
|
67
|
+
throw new Error(`No API key found! Please make sure to provide "${envApiKey ?? defaultKey}" in your .env file.`);
|
|
68
|
+
}
|
|
69
|
+
return apiKey;
|
|
70
|
+
}
|
|
71
|
+
getModel(modelName) {
|
|
72
|
+
const model = modelName ?? process.env['DEFAULT_MODEL'];
|
|
73
|
+
if (!modelName) {
|
|
74
|
+
throw new Error(`No Model defined. Please provide DEFAULT_MODEL or set the model parameter in the completion service call.`);
|
|
75
|
+
}
|
|
76
|
+
return model;
|
|
77
|
+
}
|
|
78
|
+
getProvider(name) {
|
|
79
|
+
const provider = name ?? process.env['DEFAULT_PROVIDER'];
|
|
80
|
+
if (!provider) {
|
|
81
|
+
throw new Error(`No Provider defined. Please provide DEFAULT_PROVIDER or set the provider parameter in the completion service call.`);
|
|
82
|
+
}
|
|
83
|
+
return provider;
|
|
84
|
+
}
|
|
85
|
+
createClient(options) {
|
|
86
|
+
return (0, openai_1.createOpenAI)({
|
|
87
|
+
apiKey: options.apiKey,
|
|
88
|
+
baseURL: options.baseURL,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
getModelClient(client, model) {
|
|
92
|
+
return client(model);
|
|
93
|
+
}
|
|
94
|
+
getProviderModel(config) {
|
|
95
|
+
const modelName = this.getModel(config.model);
|
|
96
|
+
const providerName = this.getProvider(config.provider);
|
|
97
|
+
const apiKey = this.getApiKey(config.envApiKey, providerName);
|
|
98
|
+
const client = this.createClient({
|
|
99
|
+
apiKey: apiKey,
|
|
100
|
+
model: modelName || '',
|
|
101
|
+
});
|
|
102
|
+
return this.getModelClient(client, modelName || '');
|
|
103
|
+
}
|
|
104
|
+
async handleGenerateObject(model, messages, schema) {
|
|
105
|
+
const startTime = performance.now();
|
|
106
|
+
try {
|
|
107
|
+
return (0, ai_1.generateObject)({
|
|
108
|
+
model,
|
|
109
|
+
messages,
|
|
110
|
+
schema,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
catch (error) {
|
|
114
|
+
const errorResponseTime = performance.now() - startTime;
|
|
115
|
+
console.error(`Request failed after ${errorResponseTime}ms:`, error);
|
|
116
|
+
throw error;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
getSchema(args) {
|
|
120
|
+
let responseSchema = undefined;
|
|
121
|
+
if (args.responseDocument) {
|
|
122
|
+
const documentBlock = this.blockRegistryService.getBlock(args.responseDocument);
|
|
123
|
+
if (!documentBlock) {
|
|
124
|
+
throw new Error(`Document ${args.responseDocument} not found.`);
|
|
125
|
+
}
|
|
126
|
+
responseSchema = documentBlock.metadata.properties;
|
|
127
|
+
}
|
|
128
|
+
return responseSchema;
|
|
129
|
+
}
|
|
130
|
+
async execute() {
|
|
131
|
+
const model = this.getProviderModel(this.args.llm);
|
|
132
|
+
let messages = this.args.messages;
|
|
133
|
+
const responseSchema = this.getSchema((0, lodash_1.pick)(this.args, ['responseDocument']));
|
|
134
|
+
if (!responseSchema) {
|
|
135
|
+
throw new Error(`AI object generation must have a schema.`);
|
|
136
|
+
}
|
|
137
|
+
const response = await this.handleGenerateObject(model, messages, responseSchema);
|
|
138
|
+
console.log('response');
|
|
139
|
+
console.log(response);
|
|
140
|
+
return {
|
|
141
|
+
success: true,
|
|
142
|
+
data: response,
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
exports.AiGenerateObjectTool = AiGenerateObjectTool;
|
|
147
|
+
exports.AiGenerateObjectTool = AiGenerateObjectTool = AiGenerateObjectTool_1 = __decorate([
|
|
148
|
+
(0, common_1.Injectable)(),
|
|
149
|
+
(0, shared_1.Block)({
|
|
150
|
+
config: {
|
|
151
|
+
type: 'tool',
|
|
152
|
+
description: 'Create a template from a document schema.',
|
|
153
|
+
},
|
|
154
|
+
properties: schema,
|
|
155
|
+
configSchema: config,
|
|
156
|
+
}),
|
|
157
|
+
__metadata("design:paramtypes", [configuration_1.BlockRegistryService])
|
|
158
|
+
], AiGenerateObjectTool);
|
|
159
|
+
//# sourceMappingURL=ai-generate-object.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-generate-object.tool.js","sourceRoot":"","sources":["../../../../src/modules/workflow-processor/llm/ai-generate-object.tool.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,8CAK2B;AAC3B,2CAAoD;AACpD,6BAAwB;AAExB,mCAA4B;AAC5B,0CAAmC;AACnC,2BAA0D;AAC1D,oFAA8G;AAC9G,uDAA2D;AAC3D,2CAA8C;AAE9C,MAAM,MAAM,GAAG,OAAC;KACb,MAAM,CAAC;IACN,GAAG,EAAE,OAAC;SACH,MAAM,CAAC;QACN,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;QAC5B,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;QAC/B,SAAS,EAAE,OAAC,CAAC,MAAM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,CAAA;IACvB,CAAC;IAED,KAAK,CAAC,OAAO;QAEX,MAAM,KAAK,GAAG,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACnD,IAAI,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,QAA0B,CAAC;QAEpD,MAAM,cAAc,GAAG,IAAI,CAAC,SAAS,CAAC,IAAA,aAAI,EAAC,IAAI,CAAC,IAAI,EAAE,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC;QAE7E,IAAI,CAAC,cAAc,EAAE,CAAC;YACpB,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;QAC9D,CAAC;QAED,MAAM,QAAQ,GAA8B,MAAM,IAAI,CAAC,oBAAoB,CACzE,KAAK,EACL,QAAQ,EACR,cAAc,CACf,CAAC;QAEF,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAA;QACvB,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;QAErB,OAAO;YACL,OAAO,EAAE,IAAI;YACb,IAAI,EAAE,QAAQ;SACf,CAAC;IACJ,CAAC;CACF,CAAA;AA3HY,oDAAoB;+BAApB,oBAAoB;IAThC,IAAA,mBAAU,GAAE;IACZ,IAAA,cAAK,EAAC;QACL,MAAM,EAAE;YACN,IAAI,EAAE,MAAM;YACZ,WAAW,EAAE,2CAA2C;SACzD;QACD,UAAU,EAAE,MAAM;QAClB,YAAY,EAAE,MAAM;KACrB,CAAC;qCAKyC,oCAAoB;GAJlD,oBAAoB,CA2HhC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ai-generate-object.tool';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./ai-generate-object.tool"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/modules/workflow-processor/llm/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4DAAyC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const CompletionMessageConfigSchema: z.ZodObject<{
|
|
3
|
+
role: z.ZodString;
|
|
4
|
+
content: z.ZodAny;
|
|
5
|
+
}, "strip", z.ZodTypeAny, {
|
|
6
|
+
role: string;
|
|
7
|
+
content?: any;
|
|
8
|
+
}, {
|
|
9
|
+
role: string;
|
|
10
|
+
content?: any;
|
|
11
|
+
}>;
|
|
12
|
+
export declare const CompletionMessageSchema: z.ZodObject<{
|
|
13
|
+
role: z.ZodEnum<["system", "assistant", "user", "tool"]>;
|
|
14
|
+
content: z.ZodAny;
|
|
15
|
+
}, "strip", z.ZodTypeAny, {
|
|
16
|
+
role: "tool" | "system" | "assistant" | "user";
|
|
17
|
+
content?: any;
|
|
18
|
+
}, {
|
|
19
|
+
role: "tool" | "system" | "assistant" | "user";
|
|
20
|
+
content?: any;
|
|
21
|
+
}>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CompletionMessageSchema = exports.CompletionMessageConfigSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
exports.CompletionMessageConfigSchema = zod_1.z.object({
|
|
6
|
+
role: zod_1.z.string(),
|
|
7
|
+
content: zod_1.z.any(),
|
|
8
|
+
});
|
|
9
|
+
exports.CompletionMessageSchema = zod_1.z.object({
|
|
10
|
+
role: zod_1.z.enum(['system', 'assistant', 'user', 'tool']),
|
|
11
|
+
content: zod_1.z.any(),
|
|
12
|
+
});
|
|
13
|
+
//# sourceMappingURL=completion-message.schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"completion-message.schema.js","sourceRoot":"","sources":["../../../../src/modules/workflow-processor/schemas/completion-message.schema.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAEX,QAAA,6BAA6B,GAAG,OAAC,CAAC,MAAM,CAAC;IACpD,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE;IAChB,OAAO,EAAE,OAAC,CAAC,GAAG,EAAE;CACjB,CAAC,CAAC;AAEU,QAAA,uBAAuB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC9C,IAAI,EAAE,OAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACrD,OAAO,EAAE,OAAC,CAAC,GAAG,EAAE;CACjB,CAAC,CAAC"}
|
|
@@ -21,6 +21,7 @@ const tools_1 = require("../persistence/blocks/tools");
|
|
|
21
21
|
const create_document_service_1 = require("./blocks/services/create-document.service");
|
|
22
22
|
const service_state_factory_service_1 = require("./services/service-state-factory.service");
|
|
23
23
|
const batch_create_documents_service_1 = require("./blocks/services/batch-create-documents.service");
|
|
24
|
+
const llm_1 = require("./llm");
|
|
24
25
|
let WorkflowProcessorModule = class WorkflowProcessorModule {
|
|
25
26
|
};
|
|
26
27
|
exports.WorkflowProcessorModule = WorkflowProcessorModule;
|
|
@@ -73,12 +74,14 @@ exports.WorkflowProcessorModule = WorkflowProcessorModule = __decorate([
|
|
|
73
74
|
blocks_1.MarkdownMessageDocument,
|
|
74
75
|
blocks_1.PlainMessageDocument,
|
|
75
76
|
blocks_1.SetContext,
|
|
77
|
+
llm_1.AiGenerateObjectTool,
|
|
76
78
|
],
|
|
77
79
|
exports: [
|
|
78
80
|
services_1.RootProcessorService,
|
|
79
81
|
services_1.ToolExecutionService,
|
|
80
82
|
services_1.TemplateExpressionEvaluatorService,
|
|
81
83
|
services_2.CreatePipelineService,
|
|
84
|
+
llm_1.AiGenerateObjectTool,
|
|
82
85
|
],
|
|
83
86
|
})
|
|
84
87
|
], WorkflowProcessorModule);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow-processor.module.js","sourceRoot":"","sources":["../../../src/modules/workflow-processor/workflow-processor.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,oDAAuD;AACvD,gDAAmD;AACnD,uCAA+C;AAC/C,sCAAyC;AACzC,6CAIsB;AACtB,yCAWoB;AACpB,yCAAmD;AACnD,iEAA6D;AAC7D,qCAqBkB;AAClB,uDAAgE;AAChE,uFAAkF;AAClF,4FAA+E;AAC/E,qGAA+F;
|
|
1
|
+
{"version":3,"file":"workflow-processor.module.js","sourceRoot":"","sources":["../../../src/modules/workflow-processor/workflow-processor.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,oDAAuD;AACvD,gDAAmD;AACnD,uCAA+C;AAC/C,sCAAyC;AACzC,6CAIsB;AACtB,yCAWoB;AACpB,yCAAmD;AACnD,iEAA6D;AAC7D,qCAqBkB;AAClB,uDAAgE;AAChE,uFAAkF;AAClF,4FAA+E;AAC/E,qGAA+F;AAC/F,+BAA6C;AA6DtC,IAAM,uBAAuB,GAA7B,MAAM,uBAAuB;CAAG,CAAA;AAA1B,0DAAuB;kCAAvB,uBAAuB;IA3DnC,IAAA,eAAM,EAAC;QACN,OAAO,EAAE;YACP,sBAAe;YACf,qBAAY;YACZ,mCAAmB;YACnB,+BAAiB;SAClB;QACD,SAAS,EAAE;YACT,+BAAoB;YACpB,+BAAoB;YACpB,mCAAwB;YACxB,+BAAoB;YACpB,oCAAyB;YACzB,mCAAwB;YACxB,6CAAkC;YAClC,iCAAsB;YACtB,gCAAmB;YACnB,0CAA6B;YAC7B,oCAAuB;YACvB,wCAA6B;YAC7B,uCAA4B;YAC5B,mDAAmB;YACnB,6BAAkB;YAClB,gCAAqB;YACrB,0BAAiB;YACjB,qBAAY;YACZ,2BAAkB;YAClB,8BAAqB;YACrB,2BAAkB;YAClB,uBAAc;YACd,cAAK;YACL,4BAAmB;YACnB,yBAAiB;YACjB,+CAAqB;YACrB,4DAA2B;YAC3B,qBAAY;YACZ,0BAAW;YACX,mBAAU;YACV,qBAAY;YACZ,yBAAgB;YAChB,iBAAQ;YACR,mBAAU;YACV,uBAAc;YACd,wBAAe;YACf,6BAAoB;YACpB,gCAAuB;YACvB,6BAAoB;YACpB,mBAAU;YAEV,0BAAoB;SACrB;QACD,OAAO,EAAE;YACP,+BAAoB;YACpB,+BAAoB;YACpB,6CAAkC;YAClC,gCAAqB;YACrB,0BAAoB;SACrB;KACF,CAAC;GACW,uBAAuB,CAAG"}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@loopstack/core",
|
|
3
3
|
"displayName": "Loopstack Core Module",
|
|
4
4
|
"description": "The core module of the loopstack automation framework",
|
|
5
|
-
"version": "0.10.
|
|
5
|
+
"version": "0.10.3",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Jakob Klippel",
|
|
8
8
|
"url": "https://www.linkedin.com/in/jakob-klippel//"
|
|
@@ -20,11 +20,15 @@
|
|
|
20
20
|
"typeorm": "^0.3.20"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@
|
|
23
|
+
"@ai-sdk/anthropic": "^2.0.1",
|
|
24
|
+
"@ai-sdk/openai": "^2.0.4",
|
|
25
|
+
"@ai-sdk/provider-utils": "^3.0.9",
|
|
26
|
+
"@loopstack/shared": "^0.10.2",
|
|
24
27
|
"@nestjs/bullmq": "^11.0.3",
|
|
25
28
|
"@nestjs/config": "^4.0.0",
|
|
26
29
|
"@nestjs/event-emitter": "^3.0.1",
|
|
27
30
|
"@nestjs/schedule": "^6.0.0",
|
|
31
|
+
"ai": "^5.0.44",
|
|
28
32
|
"ajv": "^8.17.1",
|
|
29
33
|
"bullmq": "^5.56.8",
|
|
30
34
|
"class-transformer": "^0.5.1",
|