@loopstack/ai-module 0.19.0 → 0.20.1

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/README.md CHANGED
@@ -69,7 +69,6 @@ See here for more information about working with [Modules](https://loopstack.ai/
69
69
  Inject the tools and documents in your workflow class:
70
70
 
71
71
  ```typescript
72
- import { Injectable } from '@nestjs/common';
73
72
  import {
74
73
  AiGenerateDocument,
75
74
  AiGenerateObject,
@@ -77,14 +76,12 @@ import {
77
76
  AiMessageDocument,
78
77
  DelegateToolCall,
79
78
  } from '@loopstack/ai-module';
80
- import { BlockConfig, DefineHelper, InjectDocument, InjectTool } from '@loopstack/common';
81
- import { WorkflowBase } from '@loopstack/core';
79
+ import { BlockConfig, DefineHelper, InjectDocument, InjectTool, Workflow } from '@loopstack/common';
82
80
 
83
- @Injectable()
84
- @BlockConfig({
81
+ @Workflow({
85
82
  configFile: __dirname + '/my.workflow.yaml',
86
83
  })
87
- export class MyWorkflow extends WorkflowBase {
84
+ export class MyWorkflow {
88
85
  // Tools
89
86
  @InjectTool() aiGenerateText: AiGenerateText;
90
87
  @InjectTool() aiGenerateObject: AiGenerateObject;
@@ -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,EAAE,CAAC,QAAQ,EAAE;IACzB,IAAI,EAAE,OAAC,CAAC,KAAK,CAAC,CAAC,OAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,OAAC,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,OAAC,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC;IAC/E,QAAQ,EAAE,OAAC,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IAC5B,KAAK,EAAE,OAAC,CAAC,KAAK,CAAC,OAAC,CAAC,GAAG,EAAE,CAAC;CACxB,CAAC,CAAC;AAWI,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;CAAG,CAAA;AAApB,8CAAiB;4BAAjB,iBAAiB;IAT7B,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;IACD,IAAA,sBAAa,EAAC,uBAAuB,CAAC;GAC1B,iBAAiB,CAAG"}
1
+ {"version":3,"file":"ai-message-document.js","sourceRoot":"","sources":["../../src/documents/ai-message-document.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,6BAAwB;AACxB,8CAAoD;AAEvC,QAAA,uBAAuB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC9C,EAAE,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACzB,IAAI,EAAE,OAAC,CAAC,KAAK,CAAC,CAAC,OAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,OAAC,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,OAAC,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC;IAC/E,QAAQ,EAAE,OAAC,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IAC5B,KAAK,EAAE,OAAC,CAAC,KAAK,CAAC,OAAC,CAAC,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":"AAAA,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,qBAKa,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"}
@@ -10,47 +10,51 @@ var __metadata = (this && this.__metadata) || function (k, v) {
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.AiGenerateDocument = void 0;
13
- const common_1 = require("@nestjs/common");
14
- const common_2 = require("@loopstack/common");
13
+ const common_1 = require("@loopstack/common");
15
14
  const core_ui_module_1 = require("@loopstack/core-ui-module");
16
15
  const ai_generate_object_tool_1 = require("./ai-generate-object.tool");
17
16
  let AiGenerateDocument = class AiGenerateDocument {
18
17
  aiGenerateObject;
19
18
  createDocument;
19
+ args;
20
20
  getRequiredTool(name) {
21
- const tool = (0, common_2.getBlockTool)(this, name);
21
+ const tool = (0, common_1.getBlockTool)(this, name);
22
22
  if (tool === undefined) {
23
23
  throw new Error(`Tool "${name}" is not available`);
24
24
  }
25
25
  return tool;
26
26
  }
27
- async execute(args, ctx, parent) {
28
- const result = await this.getRequiredTool('aiGenerateObject').execute(args, ctx, parent);
27
+ async execute(args, ctx, parent, metadata) {
28
+ const result = await this.getRequiredTool('aiGenerateObject').execute(args, ctx, parent, metadata);
29
29
  return this.getRequiredTool('createDocument').execute({
30
30
  id: args.response.id,
31
31
  document: args.response.document,
32
32
  update: {
33
33
  content: result.data,
34
34
  },
35
- }, ctx, parent);
35
+ }, ctx, parent, metadata);
36
36
  }
37
37
  };
38
38
  exports.AiGenerateDocument = AiGenerateDocument;
39
39
  __decorate([
40
- (0, common_2.InjectTool)(),
40
+ (0, common_1.InjectTool)(),
41
41
  __metadata("design:type", ai_generate_object_tool_1.AiGenerateObject)
42
42
  ], AiGenerateDocument.prototype, "aiGenerateObject", void 0);
43
43
  __decorate([
44
- (0, common_2.InjectTool)(),
44
+ (0, common_1.InjectTool)(),
45
45
  __metadata("design:type", core_ui_module_1.CreateDocument)
46
46
  ], AiGenerateDocument.prototype, "createDocument", void 0);
47
+ __decorate([
48
+ (0, common_1.Input)({
49
+ schema: ai_generate_object_tool_1.AiGenerateObjectSchema,
50
+ }),
51
+ __metadata("design:type", Object)
52
+ ], AiGenerateDocument.prototype, "args", void 0);
47
53
  exports.AiGenerateDocument = AiGenerateDocument = __decorate([
48
- (0, common_1.Injectable)(),
49
- (0, common_2.Tool)({
54
+ (0, common_1.Tool)({
50
55
  config: {
51
56
  description: 'Generates a structured object using a LLM and creates it as document',
52
57
  },
53
- }),
54
- (0, common_2.WithArguments)(ai_generate_object_tool_1.AiGenerateObjectSchema)
58
+ })
55
59
  ], AiGenerateDocument);
56
60
  //# 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,8CAU2B;AAC3B,8DAA2D;AAC3D,uEAA+G;AAOxG,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;IAL9B,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,qBAKa,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,25 @@ 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
- (0, common_1.Injectable)(),
86
95
  (0, common_2.Tool)({
87
96
  config: {
88
97
  description: 'Generates a structured object using a LLM',
89
98
  },
90
- }),
91
- (0, common_2.WithArguments)(exports.AiGenerateObjectSchema),
92
- __metadata("design:paramtypes", [services_1.AiMessagesHelperService,
93
- services_2.AiProviderModelHelperService])
99
+ })
94
100
  ], AiGenerateObject);
95
101
  //# sourceMappingURL=ai-generate-object.tool.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ai-generate-object.tool.js","sourceRoot":"","sources":["../../src/tools/ai-generate-object.tool.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,2CAA4C;AAC5C,2BAQY;AACZ,6BAAwB;AACxB,8CAU2B;AAC3B,0FAAmF;AACnF,0CAAsD;AACtD,0CAA2D;AAE9C,QAAA,sBAAsB,GAAG,uDAAwB,CAAC,M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AAM,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;IAL5B,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,qBAKa,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,29 @@ 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
- (0, common_1.Injectable)(),
102
115
  (0, common_2.Tool)({
103
116
  config: {
104
117
  description: 'Generates text using a LLM',
105
118
  },
106
- }),
107
- (0, common_2.WithArguments)(exports.AiGenerateTextSchema),
108
- __metadata("design:paramtypes", [services_1.AiMessagesHelperService,
109
- services_3.AiToolsHelperService,
110
- services_2.AiProviderModelHelperService])
119
+ })
111
120
  ], AiGenerateText);
112
121
  //# 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;AAEt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DAAC;AAE3C;IADhB,IAAA,eAAM,GAAE;8BACsC,uCAA4B;oEAAC;AAK5E;IAHC,IAAA,cAAK,EAAC;QACL,MAAM,EAAE,4BAAoB;KAC7B,CAAC;;4CAC2B;yBAXlB,cAAc;IAL1B,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":"AACA,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,qBAKa,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,11 +5,13 @@ 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
- const common_1 = require("@nestjs/common");
11
13
  const zod_1 = require("zod");
12
- const common_2 = require("@loopstack/common");
14
+ const common_1 = require("@loopstack/common");
13
15
  const DelegateToolCallsToolSchema = zod_1.z.object({
14
16
  message: zod_1.z.object({
15
17
  id: zod_1.z.string(),
@@ -21,7 +23,8 @@ const DelegateToolCallsToolSchema = zod_1.z.object({
21
23
  }),
22
24
  });
23
25
  let DelegateToolCall = class DelegateToolCall {
24
- async execute(args, ctx, parent) {
26
+ args;
27
+ async execute(args, ctx, parent, runtime) {
25
28
  const parts = args.message.parts;
26
29
  const resultParts = [];
27
30
  for (const part of parts) {
@@ -32,11 +35,11 @@ let DelegateToolCall = class DelegateToolCall {
32
35
  throw new Error(`No toolCallId provided`);
33
36
  }
34
37
  const toolName = part.type.replace(/^tool-/, '');
35
- const tool = (0, common_2.getBlockTool)(parent, toolName);
38
+ const tool = (0, common_1.getBlockTool)(parent, toolName);
36
39
  if (!tool) {
37
40
  throw new Error(`Tool ${toolName} not found.`);
38
41
  }
39
- const result = await tool.execute(part.input, ctx, parent);
42
+ const result = await tool.execute(part.input, ctx, parent, runtime);
40
43
  resultParts.push({
41
44
  type: part.type,
42
45
  toolCallId: part.toolCallId,
@@ -59,13 +62,17 @@ let DelegateToolCall = class DelegateToolCall {
59
62
  }
60
63
  };
61
64
  exports.DelegateToolCall = DelegateToolCall;
65
+ __decorate([
66
+ (0, common_1.Input)({
67
+ schema: DelegateToolCallsToolSchema,
68
+ }),
69
+ __metadata("design:type", Object)
70
+ ], DelegateToolCall.prototype, "args", void 0);
62
71
  exports.DelegateToolCall = DelegateToolCall = __decorate([
63
- (0, common_1.Injectable)(),
64
- (0, common_2.Tool)({
72
+ (0, common_1.Tool)({
65
73
  config: {
66
74
  description: 'Delegate a tool call.',
67
75
  },
68
- }),
69
- (0, common_2.WithArguments)(DelegateToolCallsToolSchema)
76
+ })
70
77
  ], DelegateToolCall);
71
78
  //# sourceMappingURL=delegate-tool-call.tool.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"delegate-tool-call.tool.js","sourceRoot":"","sources":["../../src/tools/delegate-tool-call.tool.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA4C;AAE5C,6BAAwB;AACxB,8CAQ2B;AAE3B,MAAM,2BAA2B,GAAG,OAAC,CAAC,MAAM,CAAC;IAC3C,OAAO,EAAE,OAAC,CAAC,MAAM,CAAC;QAChB,EAAE,EAAE,OAAC,CAAC,MAAM,EAAE;QACd,KAAK,EAAE,OAAC,CAAC,KAAK,CACZ,OAAC,CAAC,MAAM,CAAC;YACP,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE;YAChB,KAAK,EAAE,OAAC,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;YACzB,UAAU,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;SAClC,CAAC,CACH;KACF,CAAC;CACH,CAAC,CAAC;AAWI,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAC3B,KAAK,CAAC,OAAO,CACX,IAA+B,EAC/B,GAA2B,EAC3B,MAAyB;QAEzB,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;QACjC,MAAM,WAAW,GAAiB,EAAE,CAAC;QAErC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;gBACnC,SAAS;YACX,CAAC;YAED,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;gBACrB,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;YAC5C,CAAC;YAED,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;YAEjD,MAAM,IAAI,GAAG,IAAA,qBAAY,EAAgB,MAAM,EAAE,QAAQ,CAAC,CAAC;YAC3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AAE,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;IAL5B,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.1",
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.1",
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,28 +1,31 @@
1
- import { Injectable } from '@nestjs/common';
2
1
  import {
3
2
  InjectTool,
3
+ Input,
4
+ RunContext,
4
5
  Tool,
5
6
  ToolInterface,
6
7
  ToolResult,
7
- WithArguments,
8
- WorkflowExecution,
9
8
  WorkflowInterface,
9
+ WorkflowMetadataInterface,
10
10
  getBlockTool,
11
11
  } from '@loopstack/common';
12
12
  import { CreateDocument } from '@loopstack/core-ui-module';
13
13
  import { AiGenerateObject, AiGenerateObjectArgsType, AiGenerateObjectSchema } from './ai-generate-object.tool';
14
14
 
15
- @Injectable()
16
15
  @Tool({
17
16
  config: {
18
17
  description: 'Generates a structured object using a LLM and creates it as document',
19
18
  },
20
19
  })
21
- @WithArguments(AiGenerateObjectSchema)
22
20
  export class AiGenerateDocument implements ToolInterface<AiGenerateObjectArgsType> {
23
21
  @InjectTool() private aiGenerateObject!: AiGenerateObject;
24
22
  @InjectTool() private createDocument!: CreateDocument;
25
23
 
24
+ @Input({
25
+ schema: AiGenerateObjectSchema,
26
+ })
27
+ args: AiGenerateObjectArgsType;
28
+
26
29
  private getRequiredTool(name: string): ToolInterface {
27
30
  const tool = getBlockTool<ToolInterface>(this, name);
28
31
  if (tool === undefined) {
@@ -33,10 +36,11 @@ export class AiGenerateDocument implements ToolInterface<AiGenerateObjectArgsTyp
33
36
 
34
37
  async execute(
35
38
  args: AiGenerateObjectArgsType,
36
- ctx: WorkflowExecution<any>,
39
+ ctx: RunContext,
37
40
  parent: WorkflowInterface,
41
+ metadata: WorkflowMetadataInterface,
38
42
  ): Promise<ToolResult> {
39
- const result = await this.getRequiredTool('aiGenerateObject').execute(args, ctx, parent);
43
+ const result = await this.getRequiredTool('aiGenerateObject').execute(args, ctx, parent, metadata);
40
44
  return this.getRequiredTool('createDocument').execute(
41
45
  {
42
46
  id: args.response.id,
@@ -47,6 +51,7 @@ export class AiGenerateDocument implements ToolInterface<AiGenerateObjectArgsTyp
47
51
  },
48
52
  ctx,
49
53
  parent,
54
+ metadata,
50
55
  );
51
56
  }
52
57
  }
@@ -1,5 +1,5 @@
1
1
  import { ModelMessage } from '@ai-sdk/provider-utils';
2
- import { Injectable } from '@nestjs/common';
2
+ import { Inject } 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';
@@ -34,23 +35,28 @@ export const AiGenerateObjectSchema = AiGenerateToolBaseSchema.extend({
34
35
 
35
36
  export type AiGenerateObjectArgsType = z.infer<typeof AiGenerateObjectSchema>;
36
37
 
37
- @Injectable()
38
38
  @Tool({
39
39
  config: {
40
40
  description: 'Generates a structured object using a LLM',
41
41
  },
42
42
  })
43
- @WithArguments(AiGenerateObjectSchema)
44
43
  export class AiGenerateObject implements ToolInterface<AiGenerateObjectArgsType> {
45
- constructor(
46
- private readonly aiMessagesHelperService: AiMessagesHelperService,
47
- private readonly aiProviderModelHelperService: AiProviderModelHelperService,
48
- ) {}
44
+ @Inject()
45
+ private readonly aiMessagesHelperService: AiMessagesHelperService;
46
+
47
+ @Inject()
48
+ private readonly aiProviderModelHelperService: AiProviderModelHelperService;
49
+
50
+ @Input({
51
+ schema: AiGenerateObjectSchema,
52
+ })
53
+ args: AiGenerateObjectArgsType;
49
54
 
50
55
  async execute(
51
56
  args: AiGenerateObjectArgsType,
52
- ctx: WorkflowExecution<any>,
57
+ ctx: RunContext,
53
58
  parent: WorkflowInterface,
59
+ metadata: WorkflowMetadataInterface,
54
60
  ): Promise<ToolResult> {
55
61
  const model = this.aiProviderModelHelperService.getProviderModel(args.llm);
56
62
 
@@ -67,7 +73,7 @@ export class AiGenerateObject implements ToolInterface<AiGenerateObjectArgsType>
67
73
  content: args.prompt,
68
74
  } as ModelMessage);
69
75
  } else {
70
- const messages = this.aiMessagesHelperService.getMessages(ctx.state.getMetadata('documents'), {
76
+ const messages = this.aiMessagesHelperService.getMessages(metadata.documents, {
71
77
  messages: args.messages as unknown as UIMessage[],
72
78
  messagesSearchTag: args.messagesSearchTag,
73
79
  });
@@ -88,8 +94,6 @@ export class AiGenerateObject implements ToolInterface<AiGenerateObjectArgsType>
88
94
 
89
95
  const response = await this.handleGenerateObject(model, options);
90
96
 
91
- console.log(response);
92
-
93
97
  return {
94
98
  data: response.output,
95
99
  };
@@ -1,14 +1,15 @@
1
1
  import { ModelMessage } from '@ai-sdk/provider-utils';
2
- import { Injectable } from '@nestjs/common';
2
+ import { Inject } 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';
@@ -21,24 +22,29 @@ export const AiGenerateTextSchema = AiGenerateToolBaseSchema.extend({
21
22
 
22
23
  type AiGenerateTextArgsType = z.infer<typeof AiGenerateTextSchema>;
23
24
 
24
- @Injectable()
25
25
  @Tool({
26
26
  config: {
27
27
  description: 'Generates text using a LLM',
28
28
  },
29
29
  })
30
- @WithArguments(AiGenerateTextSchema)
31
30
  export class AiGenerateText implements ToolInterface<AiGenerateTextArgsType> {
32
- constructor(
33
- private readonly aiMessagesHelperService: AiMessagesHelperService,
34
- private readonly aiToolsHelperService: AiToolsHelperService,
35
- private readonly aiProviderModelHelperService: AiProviderModelHelperService,
36
- ) {}
31
+ @Inject()
32
+ private readonly aiMessagesHelperService: AiMessagesHelperService;
33
+ @Inject()
34
+ private readonly aiToolsHelperService: AiToolsHelperService;
35
+ @Inject()
36
+ private readonly aiProviderModelHelperService: AiProviderModelHelperService;
37
+
38
+ @Input({
39
+ schema: AiGenerateTextSchema,
40
+ })
41
+ args: AiGenerateTextArgsType;
37
42
 
38
43
  async execute(
39
44
  args: AiGenerateTextArgsType,
40
- ctx: WorkflowExecution<any>,
45
+ ctx: RunContext,
41
46
  parent: WorkflowInterface,
47
+ runtime: WorkflowMetadataInterface,
42
48
  ): Promise<ToolResult> {
43
49
  const model = this.aiProviderModelHelperService.getProviderModel(args.llm);
44
50
 
@@ -58,7 +64,7 @@ export class AiGenerateText implements ToolInterface<AiGenerateTextArgsType> {
58
64
  content: args.prompt,
59
65
  } as ModelMessage);
60
66
  } else {
61
- const messages = this.aiMessagesHelperService.getMessages(ctx.state.getMetadata('documents'), {
67
+ const messages = this.aiMessagesHelperService.getMessages(runtime.documents, {
62
68
  messages: args.messages as unknown as UIMessage[],
63
69
  messagesSearchTag: args.messagesSearchTag,
64
70
  });
@@ -1,13 +1,13 @@
1
- import { Injectable } from '@nestjs/common';
2
1
  import { ToolUIPart, UIMessage } from 'ai';
3
2
  import { z } from 'zod';
4
3
  import {
4
+ Input,
5
+ RunContext,
5
6
  Tool,
6
7
  ToolInterface,
7
8
  ToolResult,
8
- WithArguments,
9
- WorkflowExecution,
10
9
  WorkflowInterface,
10
+ WorkflowMetadataInterface,
11
11
  getBlockTool,
12
12
  } from '@loopstack/common';
13
13
 
@@ -26,18 +26,22 @@ const DelegateToolCallsToolSchema = z.object({
26
26
 
27
27
  type DelegateToolCallsToolArgs = z.infer<typeof DelegateToolCallsToolSchema>;
28
28
 
29
- @Injectable()
30
29
  @Tool({
31
30
  config: {
32
31
  description: 'Delegate a tool call.',
33
32
  },
34
33
  })
35
- @WithArguments(DelegateToolCallsToolSchema)
36
34
  export class DelegateToolCall implements ToolInterface<DelegateToolCallsToolArgs> {
35
+ @Input({
36
+ schema: DelegateToolCallsToolSchema,
37
+ })
38
+ args: DelegateToolCallsToolArgs;
39
+
37
40
  async execute(
38
41
  args: DelegateToolCallsToolArgs,
39
- ctx: WorkflowExecution<any>,
42
+ ctx: RunContext,
40
43
  parent: WorkflowInterface,
44
+ runtime: WorkflowMetadataInterface,
41
45
  ): Promise<ToolResult> {
42
46
  const parts = args.message.parts;
43
47
  const resultParts: ToolUIPart[] = [];
@@ -57,7 +61,7 @@ export class DelegateToolCall implements ToolInterface<DelegateToolCallsToolArgs
57
61
  if (!tool) {
58
62
  throw new Error(`Tool ${toolName} not found.`);
59
63
  }
60
- const result: ToolResult = await tool.execute(part.input as Record<string, unknown>, ctx, parent);
64
+ const result: ToolResult = await tool.execute(part.input as Record<string, unknown>, ctx, parent, runtime);
61
65
 
62
66
  resultParts.push({
63
67
  type: part.type as ToolUIPart['type'],