@loopstack/ai-module 0.19.0 → 0.20.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.
@@ -1,3 +1,12 @@
1
+ import { z } from 'zod';
2
+ export declare const AiMessageDocumentSchema: z.ZodObject<{
3
+ id: z.ZodOptional<z.ZodString>;
4
+ role: z.ZodUnion<readonly [z.ZodLiteral<"system">, z.ZodLiteral<"user">, z.ZodLiteral<"assistant">]>;
5
+ metadata: z.ZodOptional<z.ZodAny>;
6
+ parts: z.ZodArray<z.ZodAny>;
7
+ }, z.core.$strip>;
8
+ export type AiMessageDocumentContentType = z.infer<typeof AiMessageDocumentSchema>;
1
9
  export declare class AiMessageDocument {
10
+ content: z.infer<typeof AiMessageDocumentSchema>;
2
11
  }
3
12
  //# sourceMappingURL=ai-message-document.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ai-message-document.d.ts","sourceRoot":"","sources":["../../src/documents/ai-message-document.ts"],"names":[],"mappings":"AAWA,qBASa,iBAAiB;CAAG"}
1
+ {"version":3,"file":"ai-message-document.d.ts","sourceRoot":"","sources":["../../src/documents/ai-message-document.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,uBAAuB;;;;;iBAKlC,CAAC;AAEH,MAAM,MAAM,4BAA4B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAEnF,qBAQa,iBAAiB;IAI5B,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;CAClD"}
@@ -5,20 +5,30 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
5
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
6
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7
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
+ };
8
11
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.AiMessageDocument = void 0;
12
+ exports.AiMessageDocument = exports.AiMessageDocumentSchema = void 0;
10
13
  const common_1 = require("@nestjs/common");
11
14
  const zod_1 = require("zod");
12
15
  const common_2 = require("@loopstack/common");
13
- const AiMessageDocumentSchema = zod_1.z.object({
16
+ exports.AiMessageDocumentSchema = zod_1.z.object({
14
17
  id: zod_1.z.string().optional(),
15
18
  role: zod_1.z.union([zod_1.z.literal('system'), zod_1.z.literal('user'), zod_1.z.literal('assistant')]),
16
19
  metadata: zod_1.z.any().optional(),
17
20
  parts: zod_1.z.array(zod_1.z.any()),
18
21
  });
19
22
  let AiMessageDocument = class AiMessageDocument {
23
+ content;
20
24
  };
21
25
  exports.AiMessageDocument = AiMessageDocument;
26
+ __decorate([
27
+ (0, common_2.Input)({
28
+ schema: exports.AiMessageDocumentSchema,
29
+ }),
30
+ __metadata("design:type", Object)
31
+ ], AiMessageDocument.prototype, "content", void 0);
22
32
  exports.AiMessageDocument = AiMessageDocument = __decorate([
23
33
  (0, common_1.Injectable)(),
24
34
  (0, common_2.Document)({
@@ -27,7 +37,6 @@ exports.AiMessageDocument = AiMessageDocument = __decorate([
27
37
  description: 'Ai Message Document.',
28
38
  },
29
39
  configFile: __dirname + '/ai-message-document.yaml',
30
- }),
31
- (0, common_2.WithArguments)(AiMessageDocumentSchema)
40
+ })
32
41
  ], AiMessageDocument);
33
42
  //# sourceMappingURL=ai-message-document.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ai-message-document.js","sourceRoot":"","sources":["../../src/documents/ai-message-document.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA4C;AAC5C,6BAAwB;AACxB,8CAA4D;AAE5D,MAAM,uBAAuB,GAAG,OAAC,CAAC,MAAM,CAAC;IACvC,EAAE,EAAE,OAAC,CAAC,MAAM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AAC,GAAG,EAAE,CAAC;CACxB,CAAC,CAAC;AAYI,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAI5B,OAAO,CAA0C;CAClD,CAAA;AALY,8CAAiB;AAI5B;IAHC,IAAA,cAAK,EAAC;QACL,MAAM,EAAE,+BAAuB;KAChC,CAAC;;kDAC+C;4BAJtC,iBAAiB;IAR7B,IAAA,mBAAU,GAAE;IACZ,IAAA,iBAAQ,EAAC;QACR,MAAM,EAAE;YACN,IAAI,EAAE,UAAU;YAChB,WAAW,EAAE,sBAAsB;SACpC;QACD,UAAU,EAAE,SAAS,GAAG,2BAA2B;KACpD,CAAC;GACW,iBAAiB,CAK7B"}
@@ -1,9 +1,10 @@
1
- import { ToolInterface, ToolResult, WorkflowExecution, WorkflowInterface } from '@loopstack/common';
1
+ import { RunContext, ToolInterface, ToolResult, WorkflowInterface, WorkflowMetadataInterface } from '@loopstack/common';
2
2
  import { AiGenerateObjectArgsType } from './ai-generate-object.tool';
3
3
  export declare class AiGenerateDocument implements ToolInterface<AiGenerateObjectArgsType> {
4
4
  private aiGenerateObject;
5
5
  private createDocument;
6
+ args: AiGenerateObjectArgsType;
6
7
  private getRequiredTool;
7
- execute(args: AiGenerateObjectArgsType, ctx: WorkflowExecution<any>, parent: WorkflowInterface): Promise<ToolResult>;
8
+ execute(args: AiGenerateObjectArgsType, ctx: RunContext, parent: WorkflowInterface, metadata: WorkflowMetadataInterface): Promise<ToolResult>;
8
9
  }
9
10
  //# sourceMappingURL=ai-generate-document.tool.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ai-generate-document.tool.d.ts","sourceRoot":"","sources":["../../src/tools/ai-generate-document.tool.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,aAAa,EACb,UAAU,EAEV,iBAAiB,EACjB,iBAAiB,EAElB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAoB,wBAAwB,EAA0B,MAAM,2BAA2B,CAAC;AAE/G,qBAOa,kBAAmB,YAAW,aAAa,CAAC,wBAAwB,CAAC;IAClE,OAAO,CAAC,gBAAgB,CAAoB;IAC5C,OAAO,CAAC,cAAc,CAAkB;IAEtD,OAAO,CAAC,eAAe;IAQjB,OAAO,CACX,IAAI,EAAE,wBAAwB,EAC9B,GAAG,EAAE,iBAAiB,CAAC,GAAG,CAAC,EAC3B,MAAM,EAAE,iBAAiB,GACxB,OAAO,CAAC,UAAU,CAAC;CAcvB"}
1
+ {"version":3,"file":"ai-generate-document.tool.d.ts","sourceRoot":"","sources":["../../src/tools/ai-generate-document.tool.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,UAAU,EAEV,aAAa,EACb,UAAU,EACV,iBAAiB,EACjB,yBAAyB,EAE1B,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAoB,wBAAwB,EAA0B,MAAM,2BAA2B,CAAC;AAE/G,qBAMa,kBAAmB,YAAW,aAAa,CAAC,wBAAwB,CAAC;IAClE,OAAO,CAAC,gBAAgB,CAAoB;IAC5C,OAAO,CAAC,cAAc,CAAkB;IAKtD,IAAI,EAAE,wBAAwB,CAAC;IAE/B,OAAO,CAAC,eAAe;IAQjB,OAAO,CACX,IAAI,EAAE,wBAAwB,EAC9B,GAAG,EAAE,UAAU,EACf,MAAM,EAAE,iBAAiB,EACzB,QAAQ,EAAE,yBAAyB,GAClC,OAAO,CAAC,UAAU,CAAC;CAevB"}
@@ -17,6 +17,7 @@ const ai_generate_object_tool_1 = require("./ai-generate-object.tool");
17
17
  let AiGenerateDocument = class AiGenerateDocument {
18
18
  aiGenerateObject;
19
19
  createDocument;
20
+ args;
20
21
  getRequiredTool(name) {
21
22
  const tool = (0, common_2.getBlockTool)(this, name);
22
23
  if (tool === undefined) {
@@ -24,15 +25,15 @@ let AiGenerateDocument = class AiGenerateDocument {
24
25
  }
25
26
  return tool;
26
27
  }
27
- async execute(args, ctx, parent) {
28
- const result = await this.getRequiredTool('aiGenerateObject').execute(args, ctx, parent);
28
+ async execute(args, ctx, parent, metadata) {
29
+ const result = await this.getRequiredTool('aiGenerateObject').execute(args, ctx, parent, metadata);
29
30
  return this.getRequiredTool('createDocument').execute({
30
31
  id: args.response.id,
31
32
  document: args.response.document,
32
33
  update: {
33
34
  content: result.data,
34
35
  },
35
- }, ctx, parent);
36
+ }, ctx, parent, metadata);
36
37
  }
37
38
  };
38
39
  exports.AiGenerateDocument = AiGenerateDocument;
@@ -44,13 +45,18 @@ __decorate([
44
45
  (0, common_2.InjectTool)(),
45
46
  __metadata("design:type", core_ui_module_1.CreateDocument)
46
47
  ], AiGenerateDocument.prototype, "createDocument", void 0);
48
+ __decorate([
49
+ (0, common_2.Input)({
50
+ schema: ai_generate_object_tool_1.AiGenerateObjectSchema,
51
+ }),
52
+ __metadata("design:type", Object)
53
+ ], AiGenerateDocument.prototype, "args", void 0);
47
54
  exports.AiGenerateDocument = AiGenerateDocument = __decorate([
48
55
  (0, common_1.Injectable)(),
49
56
  (0, common_2.Tool)({
50
57
  config: {
51
58
  description: 'Generates a structured object using a LLM and creates it as document',
52
59
  },
53
- }),
54
- (0, common_2.WithArguments)(ai_generate_object_tool_1.AiGenerateObjectSchema)
60
+ })
55
61
  ], AiGenerateDocument);
56
62
  //# sourceMappingURL=ai-generate-document.tool.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ai-generate-document.tool.js","sourceRoot":"","sources":["../../src/tools/ai-generate-document.tool.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,8CAS2B;AAC3B,8DAA2D;AAC3D,uEAA+G;AASxG,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IACP,gBAAgB,CAAoB;IACpC,cAAc,CAAkB;IAE9C,eAAe,CAAC,IAAY;QAClC,MAAM,IAAI,GAAG,IAAA,qBAAY,EAAgB,IAAI,EAAE,IAAI,CAAC,CAAC;QACrD,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACvB,MAAM,IAAI,KAAK,CAAC,SAAS,IAAI,oBAAoB,CAAC,CAAC;QACrD,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,OAAO,CACX,IAA8B,EAC9B,GAA2B,EAC3B,MAAyB;QAEzB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,kBAAkB,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;QACzF,OAAO,IAAI,CAAC,eAAe,CAAC,gBAAgB,CAAC,CAAC,OAAO,CACnD;YACE,EAAE,EAAE,IAAI,CAAC,QAAQ,CAAC,EAAE;YACpB,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,QAAQ;YAChC,MAAM,EAAE;gBACN,OAAO,EAAE,MAAM,CAAC,IAAe;aAChC;SACF,EACD,GAAG,EACH,MAAM,CACP,CAAC;IACJ,CAAC;CACF,CAAA;AA9BY,gDAAkB;AACP;IAArB,IAAA,mBAAU,GAAE;8BAA4B,0CAAgB;4DAAC;AACpC;IAArB,IAAA,mBAAU,GAAE;8BAA0B,+BAAc;0DAAC;6BAF3C,kBAAkB;IAP9B,IAAA,mBAAU,GAAE;IACZ,IAAA,aAAI,EAAC;QACJ,MAAM,EAAE;YACN,WAAW,EAAE,sEAAsE;SACpF;KACF,CAAC;IACD,IAAA,sBAAa,EAAC,gDAAsB,CAAC;GACzB,kBAAkB,CA8B9B"}
1
+ {"version":3,"file":"ai-generate-document.tool.js","sourceRoot":"","sources":["../../src/tools/ai-generate-document.tool.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,8CAU2B;AAC3B,8DAA2D;AAC3D,uEAA+G;AAQxG,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IACP,gBAAgB,CAAoB;IACpC,cAAc,CAAkB;IAKtD,IAAI,CAA2B;IAEvB,eAAe,CAAC,IAAY;QAClC,MAAM,IAAI,GAAG,IAAA,qBAAY,EAAgB,IAAI,EAAE,IAAI,CAAC,CAAC;QACrD,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACvB,MAAM,IAAI,KAAK,CAAC,SAAS,IAAI,oBAAoB,CAAC,CAAC;QACrD,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,OAAO,CACX,IAA8B,EAC9B,GAAe,EACf,MAAyB,EACzB,QAAmC;QAEnC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,kBAAkB,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;QACnG,OAAO,IAAI,CAAC,eAAe,CAAC,gBAAgB,CAAC,CAAC,OAAO,CACnD;YACE,EAAE,EAAE,IAAI,CAAC,QAAQ,CAAC,EAAE;YACpB,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,QAAQ;YAChC,MAAM,EAAE;gBACN,OAAO,EAAE,MAAM,CAAC,IAAe;aAChC;SACF,EACD,GAAG,EACH,MAAM,EACN,QAAQ,CACT,CAAC;IACJ,CAAC;CACF,CAAA;AArCY,gDAAkB;AACP;IAArB,IAAA,mBAAU,GAAE;8BAA4B,0CAAgB;4DAAC;AACpC;IAArB,IAAA,mBAAU,GAAE;8BAA0B,+BAAc;0DAAC;AAKtD;IAHC,IAAA,cAAK,EAAC;QACL,MAAM,EAAE,gDAAsB;KAC/B,CAAC;;gDAC6B;6BAPpB,kBAAkB;IAN9B,IAAA,mBAAU,GAAE;IACZ,IAAA,aAAI,EAAC;QACJ,MAAM,EAAE;YACN,WAAW,EAAE,sEAAsE;SACpF;KACF,CAAC;GACW,kBAAkB,CAqC9B"}
@@ -1,7 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { ToolInterface, ToolResult, WorkflowExecution, WorkflowInterface } from '@loopstack/common';
3
- import { AiMessagesHelperService } from '../services';
4
- import { AiProviderModelHelperService } from '../services';
2
+ import { RunContext, ToolInterface, ToolResult, WorkflowInterface, WorkflowMetadataInterface } from '@loopstack/common';
5
3
  export declare const AiGenerateObjectSchema: z.ZodObject<{
6
4
  llm: z.ZodOptional<z.ZodObject<{
7
5
  model: z.ZodOptional<z.ZodString>;
@@ -29,8 +27,8 @@ export type AiGenerateObjectArgsType = z.infer<typeof AiGenerateObjectSchema>;
29
27
  export declare class AiGenerateObject implements ToolInterface<AiGenerateObjectArgsType> {
30
28
  private readonly aiMessagesHelperService;
31
29
  private readonly aiProviderModelHelperService;
32
- constructor(aiMessagesHelperService: AiMessagesHelperService, aiProviderModelHelperService: AiProviderModelHelperService);
33
- execute(args: AiGenerateObjectArgsType, ctx: WorkflowExecution<any>, parent: WorkflowInterface): Promise<ToolResult>;
30
+ args: AiGenerateObjectArgsType;
31
+ execute(args: AiGenerateObjectArgsType, ctx: RunContext, parent: WorkflowInterface, metadata: WorkflowMetadataInterface): Promise<ToolResult>;
34
32
  private handleGenerateObject;
35
33
  }
36
34
  //# sourceMappingURL=ai-generate-object.tool.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ai-generate-object.tool.d.ts","sourceRoot":"","sources":["../../src/tools/ai-generate-object.tool.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAGL,aAAa,EACb,UAAU,EAEV,iBAAiB,EACjB,iBAAiB,EAGlB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAC;AAE3D,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;kBAKxB,CAAC;AAEZ,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAE9E,qBAOa,gBAAiB,YAAW,aAAa,CAAC,wBAAwB,CAAC;IAE5E,OAAO,CAAC,QAAQ,CAAC,uBAAuB;IACxC,OAAO,CAAC,QAAQ,CAAC,4BAA4B;gBAD5B,uBAAuB,EAAE,uBAAuB,EAChD,4BAA4B,EAAE,4BAA4B;IAGvE,OAAO,CACX,IAAI,EAAE,wBAAwB,EAC9B,GAAG,EAAE,iBAAiB,CAAC,GAAG,CAAC,EAC3B,MAAM,EAAE,iBAAiB,GACxB,OAAO,CAAC,UAAU,CAAC;YA4CR,oBAAoB;CAsBnC"}
1
+ {"version":3,"file":"ai-generate-object.tool.d.ts","sourceRoot":"","sources":["../../src/tools/ai-generate-object.tool.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAGL,UAAU,EAEV,aAAa,EACb,UAAU,EACV,iBAAiB,EACjB,yBAAyB,EAG1B,MAAM,mBAAmB,CAAC;AAK3B,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;kBAKxB,CAAC;AAEZ,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAE9E,qBAMa,gBAAiB,YAAW,aAAa,CAAC,wBAAwB,CAAC;IAE9E,OAAO,CAAC,QAAQ,CAAC,uBAAuB,CAA0B;IAGlE,OAAO,CAAC,QAAQ,CAAC,4BAA4B,CAA+B;IAK5E,IAAI,EAAE,wBAAwB,CAAC;IAEzB,OAAO,CACX,IAAI,EAAE,wBAAwB,EAC9B,GAAG,EAAE,UAAU,EACf,MAAM,EAAE,iBAAiB,EACzB,QAAQ,EAAE,yBAAyB,GAClC,OAAO,CAAC,UAAU,CAAC;YA0CR,oBAAoB;CAsBnC"}
@@ -26,11 +26,8 @@ exports.AiGenerateObjectSchema = ai_generate_tool_base_schema_1.AiGenerateToolBa
26
26
  let AiGenerateObject = class AiGenerateObject {
27
27
  aiMessagesHelperService;
28
28
  aiProviderModelHelperService;
29
- constructor(aiMessagesHelperService, aiProviderModelHelperService) {
30
- this.aiMessagesHelperService = aiMessagesHelperService;
31
- this.aiProviderModelHelperService = aiProviderModelHelperService;
32
- }
33
- async execute(args, ctx, parent) {
29
+ args;
30
+ async execute(args, ctx, parent, metadata) {
34
31
  const model = this.aiProviderModelHelperService.getProviderModel(args.llm);
35
32
  const options = {
36
33
  messages: [],
@@ -42,7 +39,7 @@ let AiGenerateObject = class AiGenerateObject {
42
39
  });
43
40
  }
44
41
  else {
45
- const messages = this.aiMessagesHelperService.getMessages(ctx.state.getMetadata('documents'), {
42
+ const messages = this.aiMessagesHelperService.getMessages(metadata.documents, {
46
43
  messages: args.messages,
47
44
  messagesSearchTag: args.messagesSearchTag,
48
45
  });
@@ -58,7 +55,6 @@ let AiGenerateObject = class AiGenerateObject {
58
55
  }
59
56
  options.schema = responseSchema;
60
57
  const response = await this.handleGenerateObject(model, options);
61
- console.log(response);
62
58
  return {
63
59
  data: response.output,
64
60
  };
@@ -81,15 +77,26 @@ let AiGenerateObject = class AiGenerateObject {
81
77
  }
82
78
  };
83
79
  exports.AiGenerateObject = AiGenerateObject;
80
+ __decorate([
81
+ (0, common_1.Inject)(),
82
+ __metadata("design:type", services_1.AiMessagesHelperService)
83
+ ], AiGenerateObject.prototype, "aiMessagesHelperService", void 0);
84
+ __decorate([
85
+ (0, common_1.Inject)(),
86
+ __metadata("design:type", services_2.AiProviderModelHelperService)
87
+ ], AiGenerateObject.prototype, "aiProviderModelHelperService", void 0);
88
+ __decorate([
89
+ (0, common_2.Input)({
90
+ schema: exports.AiGenerateObjectSchema,
91
+ }),
92
+ __metadata("design:type", Object)
93
+ ], AiGenerateObject.prototype, "args", void 0);
84
94
  exports.AiGenerateObject = AiGenerateObject = __decorate([
85
95
  (0, common_1.Injectable)(),
86
96
  (0, common_2.Tool)({
87
97
  config: {
88
98
  description: 'Generates a structured object using a LLM',
89
99
  },
90
- }),
91
- (0, common_2.WithArguments)(exports.AiGenerateObjectSchema),
92
- __metadata("design:paramtypes", [services_1.AiMessagesHelperService,
93
- services_2.AiProviderModelHelperService])
100
+ })
94
101
  ], AiGenerateObject);
95
102
  //# sourceMappingURL=ai-generate-object.tool.js.map
@@ -1 +1 @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ACpC,IAAI,CAAC;YACH,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YAE5B,OAAO,IAAA,iBAAY,EAAC;gBAClB,KAAK;gBACL,QAAQ,EAAE,OAAO,CAAC,QAAQ;gBAC1B,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,WAAM,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aACjF,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,iBAAiB,GAAG,WAAW,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC;YACxD,OAAO,CAAC,KAAK,CAAC,wBAAwB,iBAAiB,KAAK,EAAE,KAAK,CAAC,CAAC;YACrE,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF,CAAA;AAjFY,4CAAgB;AAEV;IADhB,IAAA,eAAM,GAAE;8BACiC,kCAAuB;iEAAC;AAGjD;IADhB,IAAA,eAAM,GAAE;8BACsC,uCAA4B;sEAAC;AAK5E;IAHC,IAAA,cAAK,EAAC;QACL,MAAM,EAAE,8BAAsB;KAC/B,CAAC;;8CAC6B;2BAVpB,gBAAgB;IAN5B,IAAA,mBAAU,GAAE;IACZ,IAAA,aAAI,EAAC;QACJ,MAAM,EAAE;YACN,WAAW,EAAE,2CAA2C;SACzD;KACF,CAAC;GACW,gBAAgB,CAiF5B"}
@@ -1,8 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { ToolInterface, ToolResult, WorkflowExecution, WorkflowInterface } from '@loopstack/common';
3
- import { AiMessagesHelperService } from '../services';
4
- import { AiProviderModelHelperService } from '../services';
5
- import { AiToolsHelperService } from '../services';
2
+ import { RunContext, ToolInterface, ToolResult, WorkflowInterface, WorkflowMetadataInterface } from '@loopstack/common';
6
3
  export declare const AiGenerateTextSchema: z.ZodObject<{
7
4
  llm: z.ZodOptional<z.ZodObject<{
8
5
  model: z.ZodOptional<z.ZodString>;
@@ -28,8 +25,8 @@ export declare class AiGenerateText implements ToolInterface<AiGenerateTextArgsT
28
25
  private readonly aiMessagesHelperService;
29
26
  private readonly aiToolsHelperService;
30
27
  private readonly aiProviderModelHelperService;
31
- constructor(aiMessagesHelperService: AiMessagesHelperService, aiToolsHelperService: AiToolsHelperService, aiProviderModelHelperService: AiProviderModelHelperService);
32
- execute(args: AiGenerateTextArgsType, ctx: WorkflowExecution<any>, parent: WorkflowInterface): Promise<ToolResult>;
28
+ args: AiGenerateTextArgsType;
29
+ execute(args: AiGenerateTextArgsType, ctx: RunContext, parent: WorkflowInterface, runtime: WorkflowMetadataInterface): Promise<ToolResult>;
33
30
  private handleGenerateText;
34
31
  }
35
32
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"ai-generate-text.tool.d.ts","sourceRoot":"","sources":["../../src/tools/ai-generate-text.tool.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAEL,aAAa,EACb,UAAU,EAEV,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEnD,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;kBAEtB,CAAC;AAEZ,KAAK,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAEnE,qBAOa,cAAe,YAAW,aAAa,CAAC,sBAAsB,CAAC;IAExE,OAAO,CAAC,QAAQ,CAAC,uBAAuB;IACxC,OAAO,CAAC,QAAQ,CAAC,oBAAoB;IACrC,OAAO,CAAC,QAAQ,CAAC,4BAA4B;gBAF5B,uBAAuB,EAAE,uBAAuB,EAChD,oBAAoB,EAAE,oBAAoB,EAC1C,4BAA4B,EAAE,4BAA4B;IAGvE,OAAO,CACX,IAAI,EAAE,sBAAsB,EAC5B,GAAG,EAAE,iBAAiB,CAAC,GAAG,CAAC,EAC3B,MAAM,EAAE,iBAAiB,GACxB,OAAO,CAAC,UAAU,CAAC;YAoCR,kBAAkB;CAgDjC"}
1
+ {"version":3,"file":"ai-generate-text.tool.d.ts","sourceRoot":"","sources":["../../src/tools/ai-generate-text.tool.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAEL,UAAU,EAEV,aAAa,EACb,UAAU,EACV,iBAAiB,EACjB,yBAAyB,EAC1B,MAAM,mBAAmB,CAAC;AAM3B,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;kBAEtB,CAAC;AAEZ,KAAK,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAEnE,qBAMa,cAAe,YAAW,aAAa,CAAC,sBAAsB,CAAC;IAE1E,OAAO,CAAC,QAAQ,CAAC,uBAAuB,CAA0B;IAElE,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAuB;IAE5D,OAAO,CAAC,QAAQ,CAAC,4BAA4B,CAA+B;IAK5E,IAAI,EAAE,sBAAsB,CAAC;IAEvB,OAAO,CACX,IAAI,EAAE,sBAAsB,EAC5B,GAAG,EAAE,UAAU,EACf,MAAM,EAAE,iBAAiB,EACzB,OAAO,EAAE,yBAAyB,GACjC,OAAO,CAAC,UAAU,CAAC;YAoCR,kBAAkB;CAgDjC"}
@@ -25,12 +25,8 @@ let AiGenerateText = class AiGenerateText {
25
25
  aiMessagesHelperService;
26
26
  aiToolsHelperService;
27
27
  aiProviderModelHelperService;
28
- constructor(aiMessagesHelperService, aiToolsHelperService, aiProviderModelHelperService) {
29
- this.aiMessagesHelperService = aiMessagesHelperService;
30
- this.aiToolsHelperService = aiToolsHelperService;
31
- this.aiProviderModelHelperService = aiProviderModelHelperService;
32
- }
33
- async execute(args, ctx, parent) {
28
+ args;
29
+ async execute(args, ctx, parent, runtime) {
34
30
  const model = this.aiProviderModelHelperService.getProviderModel(args.llm);
35
31
  const options = {
36
32
  messages: [],
@@ -43,7 +39,7 @@ let AiGenerateText = class AiGenerateText {
43
39
  });
44
40
  }
45
41
  else {
46
- const messages = this.aiMessagesHelperService.getMessages(ctx.state.getMetadata('documents'), {
42
+ const messages = this.aiMessagesHelperService.getMessages(runtime.documents, {
47
43
  messages: args.messages,
48
44
  messagesSearchTag: args.messagesSearchTag,
49
45
  });
@@ -97,16 +93,30 @@ let AiGenerateText = class AiGenerateText {
97
93
  }
98
94
  };
99
95
  exports.AiGenerateText = AiGenerateText;
96
+ __decorate([
97
+ (0, common_1.Inject)(),
98
+ __metadata("design:type", services_1.AiMessagesHelperService)
99
+ ], AiGenerateText.prototype, "aiMessagesHelperService", void 0);
100
+ __decorate([
101
+ (0, common_1.Inject)(),
102
+ __metadata("design:type", services_3.AiToolsHelperService)
103
+ ], AiGenerateText.prototype, "aiToolsHelperService", void 0);
104
+ __decorate([
105
+ (0, common_1.Inject)(),
106
+ __metadata("design:type", services_2.AiProviderModelHelperService)
107
+ ], AiGenerateText.prototype, "aiProviderModelHelperService", void 0);
108
+ __decorate([
109
+ (0, common_2.Input)({
110
+ schema: exports.AiGenerateTextSchema,
111
+ }),
112
+ __metadata("design:type", Object)
113
+ ], AiGenerateText.prototype, "args", void 0);
100
114
  exports.AiGenerateText = AiGenerateText = __decorate([
101
115
  (0, common_1.Injectable)(),
102
116
  (0, common_2.Tool)({
103
117
  config: {
104
118
  description: 'Generates text using a LLM',
105
119
  },
106
- }),
107
- (0, common_2.WithArguments)(exports.AiGenerateTextSchema),
108
- __metadata("design:paramtypes", [services_1.AiMessagesHelperService,
109
- services_3.AiToolsHelperService,
110
- services_2.AiProviderModelHelperService])
120
+ })
111
121
  ], AiGenerateText);
112
122
  //# sourceMappingURL=ai-generate-text.tool.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ai-generate-text.tool.js","sourceRoot":"","sources":["../../src/tools/ai-generate-text.tool.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,2CAA4C;AAC5C,2BAAkH;AAClH,6BAAwB;AACxB,8CAO2B;AAC3B,0FAAmF;AACnF,0CAAsD;AACtD,0CAA2D;AAC3D,0CAAmD;AAEtC,QAAA,oBAAoB,GAAG,uDAAwB,CAAC,MAAM,CAAC;IAClE,KAAK,EAAE,OAAC,CAAC,KAAK,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;CACtC,CAAC,CAAC,MAAM,EAAE,CAAC;AAWL,IAAM,cAAc,GAApB,MAAM,cAAc;IAEN;IACA;IACA;IAHnB,YACmB,uBAAgD,EAChD,oBAA0C,EAC1C,4BAA0D;QAF1D,4BAAuB,GAAvB,uBAAuB,CAAyB;QAChD,yBAAoB,GAApB,oBAAoB,CAAsB;QAC1C,iCAA4B,GAA5B,4BAA4B,CAA8B;IAC1E,CAAC;IAEJ,KAAK,CAAC,OAAO,CACX,IAA4B,EAC5B,GAA2B,EAC3B,MAAyB;QAEzB,MAAM,KAAK,GAAG,IAAI,CAAC,4BAA4B,CAAC,gBAAgB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAE3E,MAAM,OAAO,GAIT;YACF,QAAQ,EAAE,EAAE;SACb,CAAC;QAEF,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,oBAAoB,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAEhG,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC;gBACpB,IAAI,EAAE,MAAM;gBACZ,OAAO,EAAE,IAAI,CAAC,MAAM;aACL,C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AG,EAAE,GAAG,SAAS,CAAC;YACxD,OAAO,CAAC,KAAK,CAAC,wBAAwB,iBAAiB,KAAK,EAAE,KAAK,CAAC,CAAC;YACrE,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF,CAAA;AAtGY,wCAAc;AAER;IADhB,IAAA,eAAM,GAAE;8BACiC,kCAAuB;+DAAC;AAEjD;IADhB,IAAA,eAAM,GAAE;8BAC8B,+BAAoB;4DAAC;AAE3C;IADhB,IAAA,eAAM,GAAE;8BACsC,uCAA4B;oEAAC;AAK5E;IAHC,IAAA,cAAK,EAAC;QACL,MAAM,EAAE,4BAAoB;KAC7B,CAAC;;4CAC2B;yBAXlB,cAAc;IAN1B,IAAA,mBAAU,GAAE;IACZ,IAAA,aAAI,EAAC;QACJ,MAAM,EAAE;YACN,WAAW,EAAE,4BAA4B;SAC1C;KACF,CAAC;GACW,cAAc,CAsG1B"}
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { ToolInterface, ToolResult, WorkflowExecution, WorkflowInterface } from '@loopstack/common';
2
+ import { RunContext, ToolInterface, ToolResult, WorkflowInterface, WorkflowMetadataInterface } from '@loopstack/common';
3
3
  declare const DelegateToolCallsToolSchema: z.ZodObject<{
4
4
  message: z.ZodObject<{
5
5
  id: z.ZodString;
@@ -12,7 +12,8 @@ declare const DelegateToolCallsToolSchema: z.ZodObject<{
12
12
  }, z.core.$strip>;
13
13
  type DelegateToolCallsToolArgs = z.infer<typeof DelegateToolCallsToolSchema>;
14
14
  export declare class DelegateToolCall implements ToolInterface<DelegateToolCallsToolArgs> {
15
- execute(args: DelegateToolCallsToolArgs, ctx: WorkflowExecution<any>, parent: WorkflowInterface): Promise<ToolResult>;
15
+ args: DelegateToolCallsToolArgs;
16
+ execute(args: DelegateToolCallsToolArgs, ctx: RunContext, parent: WorkflowInterface, runtime: WorkflowMetadataInterface): Promise<ToolResult>;
16
17
  }
17
18
  export {};
18
19
  //# sourceMappingURL=delegate-tool-call.tool.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"delegate-tool-call.tool.d.ts","sourceRoot":"","sources":["../../src/tools/delegate-tool-call.tool.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAEL,aAAa,EACb,UAAU,EAEV,iBAAiB,EACjB,iBAAiB,EAElB,MAAM,mBAAmB,CAAC;AAE3B,QAAA,MAAM,2BAA2B;;;;;;;;;iBAW/B,CAAC;AAEH,KAAK,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAE7E,qBAOa,gBAAiB,YAAW,aAAa,CAAC,yBAAyB,CAAC;IACzE,OAAO,CACX,IAAI,EAAE,yBAAyB,EAC/B,GAAG,EAAE,iBAAiB,CAAC,GAAG,CAAC,EAC3B,MAAM,EAAE,iBAAiB,GACxB,OAAO,CAAC,UAAU,CAAC;CA2CvB"}
1
+ {"version":3,"file":"delegate-tool-call.tool.d.ts","sourceRoot":"","sources":["../../src/tools/delegate-tool-call.tool.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAEL,UAAU,EAEV,aAAa,EACb,UAAU,EACV,iBAAiB,EACjB,yBAAyB,EAE1B,MAAM,mBAAmB,CAAC;AAE3B,QAAA,MAAM,2BAA2B;;;;;;;;;iBAW/B,CAAC;AAEH,KAAK,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAE7E,qBAMa,gBAAiB,YAAW,aAAa,CAAC,yBAAyB,CAAC;IAI/E,IAAI,EAAE,yBAAyB,CAAC;IAE1B,OAAO,CACX,IAAI,EAAE,yBAAyB,EAC/B,GAAG,EAAE,UAAU,EACf,MAAM,EAAE,iBAAiB,EACzB,OAAO,EAAE,yBAAyB,GACjC,OAAO,CAAC,UAAU,CAAC;CA2CvB"}
@@ -5,6 +5,9 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
5
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
6
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7
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
+ };
8
11
  Object.defineProperty(exports, "__esModule", { value: true });
9
12
  exports.DelegateToolCall = void 0;
10
13
  const common_1 = require("@nestjs/common");
@@ -21,7 +24,8 @@ const DelegateToolCallsToolSchema = zod_1.z.object({
21
24
  }),
22
25
  });
23
26
  let DelegateToolCall = class DelegateToolCall {
24
- async execute(args, ctx, parent) {
27
+ args;
28
+ async execute(args, ctx, parent, runtime) {
25
29
  const parts = args.message.parts;
26
30
  const resultParts = [];
27
31
  for (const part of parts) {
@@ -36,7 +40,7 @@ let DelegateToolCall = class DelegateToolCall {
36
40
  if (!tool) {
37
41
  throw new Error(`Tool ${toolName} not found.`);
38
42
  }
39
- const result = await tool.execute(part.input, ctx, parent);
43
+ const result = await tool.execute(part.input, ctx, parent, runtime);
40
44
  resultParts.push({
41
45
  type: part.type,
42
46
  toolCallId: part.toolCallId,
@@ -59,13 +63,18 @@ let DelegateToolCall = class DelegateToolCall {
59
63
  }
60
64
  };
61
65
  exports.DelegateToolCall = DelegateToolCall;
66
+ __decorate([
67
+ (0, common_2.Input)({
68
+ schema: DelegateToolCallsToolSchema,
69
+ }),
70
+ __metadata("design:type", Object)
71
+ ], DelegateToolCall.prototype, "args", void 0);
62
72
  exports.DelegateToolCall = DelegateToolCall = __decorate([
63
73
  (0, common_1.Injectable)(),
64
74
  (0, common_2.Tool)({
65
75
  config: {
66
76
  description: 'Delegate a tool call.',
67
77
  },
68
- }),
69
- (0, common_2.WithArguments)(DelegateToolCallsToolSchema)
78
+ })
70
79
  ], DelegateToolCall);
71
80
  //# sourceMappingURL=del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;gBACrC,UAAU,EAAE,IAAI,CAAC,UAAU;gBAC3B,MAAM,EAAE;oBACN,IAAI,EAAE,MAAM,CAAC,IAAI,IAAI,MAAM;oBAC3B,KAAK,EAAE,MAAM,CAAC,IAAe;iBAC9B;gBACD,KAAK,EAAE,IAAI,CAAC,KAAgC;gBAC5C,KAAK,EAAE,kBAAkB;aACL,CAAC,CAAC;QAC1B,CAAC;QAED,MAAM,aAAa,GAAc;YAC/B,EAAE,EAAE,IAAI,CAAC,OAAO,CAAC,EAAE;YACnB,IAAI,EAAE,WAAW;YACjB,KAAK,EAAE,WAAW;SACnB,CAAC;QAEF,OAAO;YACL,IAAI,EAAE,aAAa;SACpB,CAAC;IACJ,CAAC;CACF,CAAA;AAtDY,4CAAgB;AAI3B;IAHC,IAAA,cAAK,EAAC;QACL,MAAM,EAAE,2BAA2B;KACpC,CAAC;;8CAC8B;2BAJrB,gBAAgB;IAN5B,IAAA,mBAAU,GAAE;IACZ,IAAA,aAAI,EAAC;QACJ,MAAM,EAAE;YACN,WAAW,EAAE,uBAAuB;SACrC;KACF,CAAC;GACW,gBAAgB,CAsD5B"}
package/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  "openai",
11
11
  "tool"
12
12
  ],
13
- "version": "0.19.0",
13
+ "version": "0.20.0",
14
14
  "license": "Apache-2.0",
15
15
  "author": {
16
16
  "name": "Jakob Klippel",
@@ -34,8 +34,8 @@
34
34
  "@ai-sdk/anthropic": "^3.0.23",
35
35
  "@ai-sdk/openai": "^3.0.19",
36
36
  "@ai-sdk/provider-utils": "^4.0.9",
37
- "@loopstack/common": "^0.19.0",
38
- "@loopstack/core-ui-module": "^0.19.0",
37
+ "@loopstack/common": "^0.20.0",
38
+ "@loopstack/core-ui-module": "^0.20.0",
39
39
  "@nestjs/common": "^11.1.12",
40
40
  "@nestjs/config": "^4.0.2",
41
41
  "@nestjs/core": "^11.1.12",
@@ -1,14 +1,16 @@
1
1
  import { Injectable } from '@nestjs/common';
2
2
  import { z } from 'zod';
3
- import { Document, WithArguments } from '@loopstack/common';
3
+ import { Document, Input } from '@loopstack/common';
4
4
 
5
- const AiMessageDocumentSchema = z.object({
5
+ export const AiMessageDocumentSchema = z.object({
6
6
  id: z.string().optional(),
7
7
  role: z.union([z.literal('system'), z.literal('user'), z.literal('assistant')]),
8
8
  metadata: z.any().optional(),
9
9
  parts: z.array(z.any()),
10
10
  });
11
11
 
12
+ export type AiMessageDocumentContentType = z.infer<typeof AiMessageDocumentSchema>;
13
+
12
14
  @Injectable()
13
15
  @Document({
14
16
  config: {
@@ -17,5 +19,9 @@ const AiMessageDocumentSchema = z.object({
17
19
  },
18
20
  configFile: __dirname + '/ai-message-document.yaml',
19
21
  })
20
- @WithArguments(AiMessageDocumentSchema)
21
- export class AiMessageDocument {}
22
+ export class AiMessageDocument {
23
+ @Input({
24
+ schema: AiMessageDocumentSchema,
25
+ })
26
+ content: z.infer<typeof AiMessageDocumentSchema>;
27
+ }
@@ -1,12 +1,13 @@
1
1
  import { Injectable } from '@nestjs/common';
2
2
  import {
3
3
  InjectTool,
4
+ Input,
5
+ RunContext,
4
6
  Tool,
5
7
  ToolInterface,
6
8
  ToolResult,
7
- WithArguments,
8
- WorkflowExecution,
9
9
  WorkflowInterface,
10
+ WorkflowMetadataInterface,
10
11
  getBlockTool,
11
12
  } from '@loopstack/common';
12
13
  import { CreateDocument } from '@loopstack/core-ui-module';
@@ -18,11 +19,15 @@ import { AiGenerateObject, AiGenerateObjectArgsType, AiGenerateObjectSchema } fr
18
19
  description: 'Generates a structured object using a LLM and creates it as document',
19
20
  },
20
21
  })
21
- @WithArguments(AiGenerateObjectSchema)
22
22
  export class AiGenerateDocument implements ToolInterface<AiGenerateObjectArgsType> {
23
23
  @InjectTool() private aiGenerateObject!: AiGenerateObject;
24
24
  @InjectTool() private createDocument!: CreateDocument;
25
25
 
26
+ @Input({
27
+ schema: AiGenerateObjectSchema,
28
+ })
29
+ args: AiGenerateObjectArgsType;
30
+
26
31
  private getRequiredTool(name: string): ToolInterface {
27
32
  const tool = getBlockTool<ToolInterface>(this, name);
28
33
  if (tool === undefined) {
@@ -33,10 +38,11 @@ export class AiGenerateDocument implements ToolInterface<AiGenerateObjectArgsTyp
33
38
 
34
39
  async execute(
35
40
  args: AiGenerateObjectArgsType,
36
- ctx: WorkflowExecution<any>,
41
+ ctx: RunContext,
37
42
  parent: WorkflowInterface,
43
+ metadata: WorkflowMetadataInterface,
38
44
  ): Promise<ToolResult> {
39
- const result = await this.getRequiredTool('aiGenerateObject').execute(args, ctx, parent);
45
+ const result = await this.getRequiredTool('aiGenerateObject').execute(args, ctx, parent, metadata);
40
46
  return this.getRequiredTool('createDocument').execute(
41
47
  {
42
48
  id: args.response.id,
@@ -47,6 +53,7 @@ export class AiGenerateDocument implements ToolInterface<AiGenerateObjectArgsTyp
47
53
  },
48
54
  ctx,
49
55
  parent,
56
+ metadata,
50
57
  );
51
58
  }
52
59
  }
@@ -1,5 +1,5 @@
1
1
  import { ModelMessage } from '@ai-sdk/provider-utils';
2
- import { Injectable } from '@nestjs/common';
2
+ import { Inject, Injectable } from '@nestjs/common';
3
3
  import {
4
4
  GenerateTextResult,
5
5
  LanguageModel,
@@ -12,12 +12,13 @@ import {
12
12
  import { z } from 'zod';
13
13
  import {
14
14
  DocumentInterface,
15
+ Input,
16
+ RunContext,
15
17
  Tool,
16
18
  ToolInterface,
17
19
  ToolResult,
18
- WithArguments,
19
- WorkflowExecution,
20
20
  WorkflowInterface,
21
+ WorkflowMetadataInterface,
21
22
  getBlockArgsSchema,
22
23
  getBlockDocument,
23
24
  } from '@loopstack/common';
@@ -40,17 +41,23 @@ export type AiGenerateObjectArgsType = z.infer<typeof AiGenerateObjectSchema>;
40
41
  description: 'Generates a structured object using a LLM',
41
42
  },
42
43
  })
43
- @WithArguments(AiGenerateObjectSchema)
44
44
  export class AiGenerateObject implements ToolInterface<AiGenerateObjectArgsType> {
45
- constructor(
46
- private readonly aiMessagesHelperService: AiMessagesHelperService,
47
- private readonly aiProviderModelHelperService: AiProviderModelHelperService,
48
- ) {}
45
+ @Inject()
46
+ private readonly aiMessagesHelperService: AiMessagesHelperService;
47
+
48
+ @Inject()
49
+ private readonly aiProviderModelHelperService: AiProviderModelHelperService;
50
+
51
+ @Input({
52
+ schema: AiGenerateObjectSchema,
53
+ })
54
+ args: AiGenerateObjectArgsType;
49
55
 
50
56
  async execute(
51
57
  args: AiGenerateObjectArgsType,
52
- ctx: WorkflowExecution<any>,
58
+ ctx: RunContext,
53
59
  parent: WorkflowInterface,
60
+ metadata: WorkflowMetadataInterface,
54
61
  ): Promise<ToolResult> {
55
62
  const model = this.aiProviderModelHelperService.getProviderModel(args.llm);
56
63
 
@@ -67,7 +74,7 @@ export class AiGenerateObject implements ToolInterface<AiGenerateObjectArgsType>
67
74
  content: args.prompt,
68
75
  } as ModelMessage);
69
76
  } else {
70
- const messages = this.aiMessagesHelperService.getMessages(ctx.state.getMetadata('documents'), {
77
+ const messages = this.aiMessagesHelperService.getMessages(metadata.documents, {
71
78
  messages: args.messages as unknown as UIMessage[],
72
79
  messagesSearchTag: args.messagesSearchTag,
73
80
  });
@@ -88,8 +95,6 @@ export class AiGenerateObject implements ToolInterface<AiGenerateObjectArgsType>
88
95
 
89
96
  const response = await this.handleGenerateObject(model, options);
90
97
 
91
- console.log(response);
92
-
93
98
  return {
94
99
  data: response.output,
95
100
  };
@@ -1,14 +1,15 @@
1
1
  import { ModelMessage } from '@ai-sdk/provider-utils';
2
- import { Injectable } from '@nestjs/common';
2
+ import { Inject, Injectable } from '@nestjs/common';
3
3
  import { LanguageModel, ToolSet, UIMessage, convertToModelMessages, createUIMessageStream, streamText } from 'ai';
4
4
  import { z } from 'zod';
5
5
  import {
6
+ Input,
7
+ RunContext,
6
8
  Tool,
7
9
  ToolInterface,
8
10
  ToolResult,
9
- WithArguments,
10
- WorkflowExecution,
11
11
  WorkflowInterface,
12
+ WorkflowMetadataInterface,
12
13
  } from '@loopstack/common';
13
14
  import { AiGenerateToolBaseSchema } from '../schemas/ai-generate-tool-base.schema';
14
15
  import { AiMessagesHelperService } from '../services';
@@ -27,18 +28,24 @@ type AiGenerateTextArgsType = z.infer<typeof AiGenerateTextSchema>;
27
28
  description: 'Generates text using a LLM',
28
29
  },
29
30
  })
30
- @WithArguments(AiGenerateTextSchema)
31
31
  export class AiGenerateText implements ToolInterface<AiGenerateTextArgsType> {
32
- constructor(
33
- private readonly aiMessagesHelperService: AiMessagesHelperService,
34
- private readonly aiToolsHelperService: AiToolsHelperService,
35
- private readonly aiProviderModelHelperService: AiProviderModelHelperService,
36
- ) {}
32
+ @Inject()
33
+ private readonly aiMessagesHelperService: AiMessagesHelperService;
34
+ @Inject()
35
+ private readonly aiToolsHelperService: AiToolsHelperService;
36
+ @Inject()
37
+ private readonly aiProviderModelHelperService: AiProviderModelHelperService;
38
+
39
+ @Input({
40
+ schema: AiGenerateTextSchema,
41
+ })
42
+ args: AiGenerateTextArgsType;
37
43
 
38
44
  async execute(
39
45
  args: AiGenerateTextArgsType,
40
- ctx: WorkflowExecution<any>,
46
+ ctx: RunContext,
41
47
  parent: WorkflowInterface,
48
+ runtime: WorkflowMetadataInterface,
42
49
  ): Promise<ToolResult> {
43
50
  const model = this.aiProviderModelHelperService.getProviderModel(args.llm);
44
51
 
@@ -58,7 +65,7 @@ export class AiGenerateText implements ToolInterface<AiGenerateTextArgsType> {
58
65
  content: args.prompt,
59
66
  } as ModelMessage);
60
67
  } else {
61
- const messages = this.aiMessagesHelperService.getMessages(ctx.state.getMetadata('documents'), {
68
+ const messages = this.aiMessagesHelperService.getMessages(runtime.documents, {
62
69
  messages: args.messages as unknown as UIMessage[],
63
70
  messagesSearchTag: args.messagesSearchTag,
64
71
  });
@@ -2,12 +2,13 @@ import { Injectable } from '@nestjs/common';
2
2
  import { ToolUIPart, UIMessage } from 'ai';
3
3
  import { z } from 'zod';
4
4
  import {
5
+ Input,
6
+ RunContext,
5
7
  Tool,
6
8
  ToolInterface,
7
9
  ToolResult,
8
- WithArguments,
9
- WorkflowExecution,
10
10
  WorkflowInterface,
11
+ WorkflowMetadataInterface,
11
12
  getBlockTool,
12
13
  } from '@loopstack/common';
13
14
 
@@ -32,12 +33,17 @@ type DelegateToolCallsToolArgs = z.infer<typeof DelegateToolCallsToolSchema>;
32
33
  description: 'Delegate a tool call.',
33
34
  },
34
35
  })
35
- @WithArguments(DelegateToolCallsToolSchema)
36
36
  export class DelegateToolCall implements ToolInterface<DelegateToolCallsToolArgs> {
37
+ @Input({
38
+ schema: DelegateToolCallsToolSchema,
39
+ })
40
+ args: DelegateToolCallsToolArgs;
41
+
37
42
  async execute(
38
43
  args: DelegateToolCallsToolArgs,
39
- ctx: WorkflowExecution<any>,
44
+ ctx: RunContext,
40
45
  parent: WorkflowInterface,
46
+ runtime: WorkflowMetadataInterface,
41
47
  ): Promise<ToolResult> {
42
48
  const parts = args.message.parts;
43
49
  const resultParts: ToolUIPart[] = [];
@@ -57,7 +63,7 @@ export class DelegateToolCall implements ToolInterface<DelegateToolCallsToolArgs
57
63
  if (!tool) {
58
64
  throw new Error(`Tool ${toolName} not found.`);
59
65
  }
60
- const result: ToolResult = await tool.execute(part.input as Record<string, unknown>, ctx, parent);
66
+ const result: ToolResult = await tool.execute(part.input as Record<string, unknown>, ctx, parent, runtime);
61
67
 
62
68
  resultParts.push({
63
69
  type: part.type as ToolUIPart['type'],