@loopstack/accessing-tool-results-example-workflow 0.18.0 → 0.19.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -19,73 +19,39 @@ This example is useful for developers learning to build data-driven workflows th
19
19
 
20
20
  ## Installation
21
21
 
22
- ### Prerequisites
22
+ You can add this module using the `loopstack` cli or via `npm`.
23
23
 
24
- Create a new Loopstack project if you haven't already:
24
+ ### a) Add Sources via `loopstack add` (recommended)
25
25
 
26
26
  ```bash
27
- npx create-loopstack-app my-project
28
- cd my-project
27
+ loopstack add @loopstack/accessing-tool-results-example-workflow
29
28
  ```
30
29
 
31
- Start Environment
30
+ This command copies the source files into your `src` directory.
32
31
 
33
- ```bash
34
- cd my-project
35
- docker compose up -d
36
- ```
32
+ - It is a great way to explore the code to learn new concepts or add own customizations
33
+ - It will set up the module for you, so you do not need to manually update your application
37
34
 
38
- ### Add the Module
35
+ ### b) Install via `npm install`
39
36
 
40
37
  ```bash
41
- loopstack add @loopstack/accessing-tool-results-example-workflow
38
+ npm install --save @loopstack/accessing-tool-results-example-workflow
42
39
  ```
43
40
 
44
- This copies the source files into your `src` directory.
41
+ Use npm install if you want to use and maintain the module as node dependency.
45
42
 
46
- > Using the `loopstack add` command is a great way to explore the code to learn new concepts or add own customizations.
43
+ - Use this, if you do not need to make changes to the code or want to review the source code.
47
44
 
48
45
  ## Setup
49
46
 
50
- ### 1. Import the Module
47
+ ### 1. Manual setup (optional)
51
48
 
52
- Add `AccessingToolResultsExampleModule` to your `default.module.ts` (included in the skeleton app) or to your own module:
49
+ > This step is automatically done for you when using the `loopstack add` command.
53
50
 
54
- ```typescript
55
- import { Module } from '@nestjs/common';
56
- import { LoopCoreModule } from '@loopstack/core';
57
- import { CoreUiModule } from '@loopstack/core-ui-module';
58
- import { AccessingToolResultsExampleModule } from './accessing-tool-results-example-workflow';
59
- import { DefaultWorkspace } from './default.workspace';
60
-
61
- @Module({
62
- imports: [LoopCoreModule, CoreUiModule, AccessingToolResultsExampleModule],
63
- providers: [DefaultWorkspace],
64
- })
65
- export class DefaultModule {}
66
- ```
51
+ - Add `AccessingToolResultsExampleModule` to the imports of `default.module.ts` or any other custom module.
52
+ - Inject the `WorkflowToolResultsWorkflow` workflow to your workspace class using the `@InjectWorkflow()` decorator.
67
53
 
68
- ### 2. Register in Your Workspace
69
-
70
- Add the workflow to your workspace class using the `@Workflow()` decorator:
71
-
72
- ```typescript
73
- import { Injectable } from '@nestjs/common';
74
- import { BlockConfig, Workflow } from '@loopstack/common';
75
- import { WorkspaceBase } from '@loopstack/core';
76
- import { WorkflowToolResultsWorkflow } from './accessing-tool-results-example-workflow';
77
-
78
- @Injectable()
79
- @BlockConfig({
80
- config: {
81
- title: 'My Workspace',
82
- description: 'A workspace with the tool results example workflow',
83
- },
84
- })
85
- export class MyWorkspace extends WorkspaceBase {
86
- @Workflow() workflowToolResults: WorkflowToolResultsWorkflow;
87
- }
88
- ```
54
+ See here for more information about working with [Modules](https://loopstack.ai/docs/building-with-loopstack/creating-a-module) and [Workspaces](https://loopstack.ai/docs/building-with-loopstack/creating-workspaces)
89
55
 
90
56
  ## How It Works
91
57
 
@@ -132,7 +98,7 @@ Tool results persist and can be accessed from subsequent transitions using the s
132
98
  Define custom helper functions in your workflow class for complex data extraction:
133
99
 
134
100
  ```typescript
135
- @Helper()
101
+ @DefineHelper()
136
102
  extractMessage(metadata: WorkflowMetadataInterface): string {
137
103
  return metadata.tools.create_some_data.say_hello.data;
138
104
  }
package/dist/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from './workflow-tool-results.workflow';
2
2
  export * from './tool-results-example.module';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kCAAkC,CAAC;AACjD,cAAc,+BAA+B,CAAC"}
@@ -1,2 +1,3 @@
1
1
  export declare class ToolResultsExampleModule {
2
2
  }
3
+ //# sourceMappingURL=tool-results-example.module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-results-example.module.d.ts","sourceRoot":"","sources":["../src/tool-results-example.module.ts"],"names":[],"mappings":"AAMA,qBAKa,wBAAwB;CAAG"}
@@ -8,7 +8,6 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.ToolResultsExampleModule = void 0;
10
10
  const common_1 = require("@nestjs/common");
11
- const core_1 = require("@loopstack/core");
12
11
  const core_ui_module_1 = require("@loopstack/core-ui-module");
13
12
  const create_chat_message_tool_1 = require("@loopstack/create-chat-message-tool");
14
13
  const create_value_tool_1 = require("@loopstack/create-value-tool");
@@ -18,7 +17,7 @@ let ToolResultsExampleModule = class ToolResultsExampleModule {
18
17
  exports.ToolResultsExampleModule = ToolResultsExampleModule;
19
18
  exports.ToolResultsExampleModule = ToolResultsExampleModule = __decorate([
20
19
  (0, common_1.Module)({
21
- imports: [core_1.LoopCoreModule, core_ui_module_1.CoreUiModule, create_value_tool_1.CreateValueToolModule, create_chat_message_tool_1.CreateChatMessageToolModule],
20
+ imports: [core_ui_module_1.CoreUiModule, create_value_tool_1.CreateValueToolModule, create_chat_message_tool_1.CreateChatMessageToolModule],
22
21
  providers: [workflow_tool_results_workflow_1.WorkflowToolResultsWorkflow],
23
22
  exports: [workflow_tool_results_workflow_1.WorkflowToolResultsWorkflow],
24
23
  })
@@ -1 +1 @@
1
- {"version":3,"file":"tool-results-example.module.js","sourceRoot":"","sources":["../src/tool-results-example.module.ts"],"names":[],"mappings":";;;;;;;;;AAeA,2CAAwC;AACxC,0CAAiD;AACjD,8DAAyD;AACzD,kFAAkF;AAClF,oEAAqE;AACrE,qFAA+E;AAOxE,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;CAAG,CAAA;AAA3B,4DAAwB;mCAAxB,wBAAwB;IALpC,IAAA,eAAM,EAAC;QACN,OAAO,EAAE,CAAC,qBAAc,EAAE,6BAAY,EAAE,yCAAqB,EAAE,sDAA2B,CAAC;QAC3F,SAAS,EAAE,CAAC,4DAA2B,CAAC;QACxC,OAAO,EAAE,CAAC,4DAA2B,CAAC;KACvC,CAAC;GACW,wBAAwB,CAAG"}
1
+ {"version":3,"file":"tool-results-example.module.js","sourceRoot":"","sources":["../src/tool-results-example.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,8DAAyD;AACzD,kFAAkF;AAClF,oEAAqE;AACrE,qFAA+E;AAOxE,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;CAAG,CAAA;AAA3B,4DAAwB;mCAAxB,wBAAwB;IALpC,IAAA,eAAM,EAAC;QACN,OAAO,EAAE,CAAC,6BAAY,EAAE,yCAAqB,EAAE,sDAA2B,CAAC;QAC3E,SAAS,EAAE,CAAC,4DAA2B,CAAC;QACxC,OAAO,EAAE,CAAC,4DAA2B,CAAC;KACvC,CAAC;GACW,wBAAwB,CAAG"}
@@ -1,7 +1,7 @@
1
- import { WorkflowBase } from '@loopstack/core';
2
- import { WorkflowMetadataInterface } from '@loopstack/core/dist/workflow-processor/interfaces/workflow-metadata.interface';
3
- export declare class WorkflowToolResultsWorkflow extends WorkflowBase {
1
+ import { WorkflowMetadataInterface } from '@loopstack/common';
2
+ export declare class WorkflowToolResultsWorkflow {
4
3
  private createValue;
5
4
  private createChatMessage;
6
5
  extractMessage(metadata: WorkflowMetadataInterface): string;
7
6
  }
7
+ //# sourceMappingURL=workflow-tool-results.workflow.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow-tool-results.workflow.d.ts","sourceRoot":"","sources":["../src/workflow-tool-results.workflow.ts"],"names":[],"mappings":"AACA,OAAO,EAAsC,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAYlG,qBAIa,2BAA2B;IACxB,OAAO,CAAC,WAAW,CAAc;IACjC,OAAO,CAAC,iBAAiB,CAAoB;IAG3D,cAAc,CAAC,QAAQ,EAAE,yBAAyB,GAAG,MAAM;CAI5D"}
@@ -12,10 +12,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.WorkflowToolResultsWorkflow = void 0;
13
13
  const common_1 = require("@nestjs/common");
14
14
  const common_2 = require("@loopstack/common");
15
- const core_1 = require("@loopstack/core");
16
15
  const create_chat_message_tool_1 = require("@loopstack/create-chat-message-tool");
17
16
  const create_value_tool_1 = require("@loopstack/create-value-tool");
18
- let WorkflowToolResultsWorkflow = class WorkflowToolResultsWorkflow extends core_1.WorkflowBase {
17
+ let WorkflowToolResultsWorkflow = class WorkflowToolResultsWorkflow {
19
18
  createValue;
20
19
  createChatMessage;
21
20
  extractMessage(metadata) {
@@ -25,22 +24,22 @@ let WorkflowToolResultsWorkflow = class WorkflowToolResultsWorkflow extends core
25
24
  };
26
25
  exports.WorkflowToolResultsWorkflow = WorkflowToolResultsWorkflow;
27
26
  __decorate([
28
- (0, common_2.Tool)(),
27
+ (0, common_2.InjectTool)(),
29
28
  __metadata("design:type", create_value_tool_1.CreateValue)
30
29
  ], WorkflowToolResultsWorkflow.prototype, "createValue", void 0);
31
30
  __decorate([
32
- (0, common_2.Tool)(),
31
+ (0, common_2.InjectTool)(),
33
32
  __metadata("design:type", create_chat_message_tool_1.CreateChatMessage)
34
33
  ], WorkflowToolResultsWorkflow.prototype, "createChatMessage", void 0);
35
34
  __decorate([
36
- (0, common_2.Helper)(),
35
+ (0, common_2.DefineHelper)(),
37
36
  __metadata("design:type", Function),
38
37
  __metadata("design:paramtypes", [Object]),
39
38
  __metadata("design:returntype", String)
40
39
  ], WorkflowToolResultsWorkflow.prototype, "extractMessage", null);
41
40
  exports.WorkflowToolResultsWorkflow = WorkflowToolResultsWorkflow = __decorate([
42
41
  (0, common_1.Injectable)(),
43
- (0, common_2.BlockConfig)({
42
+ (0, common_2.Workflow)({
44
43
  configFile: __dirname + '/workflow-tool-results.workflow.yaml',
45
44
  })
46
45
  ], WorkflowToolResultsWorkflow);
@@ -1 +1 @@
1
- {"version":3,"file":"workflow-tool-results.workflow.js","sourceRoot":"","sources":["../src/workflow-tool-results.workflow.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,8CAA8D;AAC9D,0CAA+C;AAE/C,kFAAwE;AACxE,oEAA2D;AAcpD,IAAM,2BAA2B,GAAjC,MAAM,2BAA4B,SAAQ,mBAAY;IAC3C,WAAW,CAAc;IACzB,iBAAiB,CAAoB;IAGrD,cAAc,CAAC,QAAmC;QAChD,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAyC,CAAC;QACjE,OAAO,KAAK,CAAC,gBAAgB,CAAC,SAAS,CAAC,IAAI,CAAC;IAC/C,CAAC;CACF,CAAA;AATY,kEAA2B;AACtB;IAAf,IAAA,aAAI,GAAE;8BAAsB,+BAAW;gEAAC;AACzB;IAAf,IAAA,aAAI,GAAE;8BAA4B,4CAAiB;sEAAC;AAGrD;IADC,IAAA,eAAM,GAAE;;;;iEAIR;sCARU,2BAA2B;IAJvC,IAAA,mBAAU,GAAE;IACZ,IAAA,oBAAW,EAAC;QACX,UAAU,EAAE,SAAS,GAAG,sCAAsC;KAC/D,CAAC;GACW,2BAA2B,CASvC"}
1
+ {"version":3,"file":"workflow-tool-results.workflow.js","sourceRoot":"","sources":["../src/workflow-tool-results.workflow.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,8CAAkG;AAClG,kFAAwE;AACxE,oEAA2D;AAcpD,IAAM,2BAA2B,GAAjC,MAAM,2BAA2B;IAChB,WAAW,CAAc;IACzB,iBAAiB,CAAoB;IAG3D,cAAc,CAAC,QAAmC;QAChD,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAyC,CAAC;QACjE,OAAO,KAAK,CAAC,gBAAgB,CAAC,SAAS,CAAC,IAAI,CAAC;IAC/C,CAAC;CACF,CAAA;AATY,kEAA2B;AAChB;IAArB,IAAA,mBAAU,GAAE;8BAAsB,+BAAW;gEAAC;AACzB;IAArB,IAAA,mBAAU,GAAE;8BAA4B,4CAAiB;sEAAC;AAG3D;IADC,IAAA,qBAAY,GAAE;;;;iEAId;sCARU,2BAA2B;IAJvC,IAAA,mBAAU,GAAE;IACZ,IAAA,iBAAQ,EAAC;QACR,UAAU,EAAE,SAAS,GAAG,sCAAsC;KAC/D,CAAC;GACW,2BAA2B,CASvC"}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@loopstack/accessing-tool-results-example-workflow",
3
3
  "displayName": "Loopstack Tool Results Example",
4
4
  "description": "A simple workflow showing different methods of how to access tool results in a subsequent workflow step.",
5
- "version": "0.18.0",
5
+ "version": "0.19.0-rc.0",
6
6
  "author": {
7
7
  "name": "Jakob Klippel",
8
8
  "url": "https://www.linkedin.com/in/jakob-klippel/"
@@ -31,11 +31,10 @@
31
31
  "watch": "nest build --watch"
32
32
  },
33
33
  "dependencies": {
34
- "@loopstack/common": "^0.18.0",
35
- "@loopstack/core": "^0.18.0",
36
- "@loopstack/core-ui-module": "^0.18.0",
37
- "@loopstack/create-chat-message-tool": "^0.18.0",
38
- "@loopstack/create-value-tool": "^0.18.0",
34
+ "@loopstack/common": "^0.19.0-rc.0",
35
+ "@loopstack/core-ui-module": "^0.19.0-rc.0",
36
+ "@loopstack/create-chat-message-tool": "^0.19.0-rc.0",
37
+ "@loopstack/create-value-tool": "^0.19.0-rc.0",
39
38
  "@nestjs/common": "^11.1.12",
40
39
  "zod": "^4.3.5"
41
40
  },
@@ -1,5 +1,6 @@
1
1
  import { TestingModule } from '@nestjs/testing';
2
- import { BlockExecutionContextDto, LoopCoreModule, WorkflowProcessorService } from '@loopstack/core';
2
+ import { BlockExecutionContextDto, getBlockHelpers } from '@loopstack/common';
3
+ import { WorkflowProcessorService } from '@loopstack/core';
3
4
  import { CoreUiModule } from '@loopstack/core-ui-module';
4
5
  import { CreateChatMessage, CreateChatMessageToolModule } from '@loopstack/create-chat-message-tool';
5
6
  import { CreateValue, CreateValueToolModule } from '@loopstack/create-value-tool';
@@ -17,7 +18,7 @@ describe('WorkflowToolResultsWorkflow', () => {
17
18
  beforeEach(async () => {
18
19
  module = await createWorkflowTest()
19
20
  .forWorkflow(WorkflowToolResultsWorkflow)
20
- .withImports(LoopCoreModule, CoreUiModule, CreateValueToolModule, CreateChatMessageToolModule)
21
+ .withImports(CoreUiModule, CreateValueToolModule, CreateChatMessageToolModule)
21
22
  .withToolOverride(CreateValue)
22
23
  .withToolOverride(CreateChatMessage)
23
24
  .compile();
@@ -38,7 +39,7 @@ describe('WorkflowToolResultsWorkflow', () => {
38
39
  });
39
40
 
40
41
  it('should have extractMessage helper', () => {
41
- expect(workflow.helpers).toContain('extractMessage');
42
+ expect(getBlockHelpers(workflow)).toContain('extractMessage');
42
43
  });
43
44
 
44
45
  describe('tool result access', () => {
@@ -84,7 +85,7 @@ describe('WorkflowToolResultsWorkflow', () => {
84
85
  const result = await processor.process(workflow, {}, context);
85
86
 
86
87
  // Should complete both transitions
87
- const history = result.state.caretaker.getHistory();
88
+ const history = result.state.getHistory();
88
89
  expect(history.some((h) => h.metadata.transition?.transition === 'create_some_data')).toBe(true);
89
90
  expect(history.some((h) => h.metadata.transition?.transition === 'access_data')).toBe(true);
90
91
 
@@ -1,27 +1,11 @@
1
- /*
2
- Copyright 2025 Jakob Klippel.
3
-
4
- Licensed under the Apache License, Version 2.0 (the "License");
5
- you may not use this file except in compliance with the License.
6
- You may obtain a copy of the License at
7
-
8
- http://www.apache.org/licenses/LICENSE-2.0
9
-
10
- Unless required by applicable law or agreed to in writing, software
11
- distributed under the License is distributed on an "AS IS" BASIS,
12
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- See the License for the specific language governing permissions and
14
- limitations under the License.
15
- */
16
1
  import { Module } from '@nestjs/common';
17
- import { LoopCoreModule } from '@loopstack/core';
18
2
  import { CoreUiModule } from '@loopstack/core-ui-module';
19
3
  import { CreateChatMessageToolModule } from '@loopstack/create-chat-message-tool';
20
4
  import { CreateValueToolModule } from '@loopstack/create-value-tool';
21
5
  import { WorkflowToolResultsWorkflow } from './workflow-tool-results.workflow';
22
6
 
23
7
  @Module({
24
- imports: [LoopCoreModule, CoreUiModule, CreateValueToolModule, CreateChatMessageToolModule],
8
+ imports: [CoreUiModule, CreateValueToolModule, CreateChatMessageToolModule],
25
9
  providers: [WorkflowToolResultsWorkflow],
26
10
  exports: [WorkflowToolResultsWorkflow],
27
11
  })
@@ -1,7 +1,5 @@
1
1
  import { Injectable } from '@nestjs/common';
2
- import { BlockConfig, Helper, Tool } from '@loopstack/common';
3
- import { WorkflowBase } from '@loopstack/core';
4
- import { WorkflowMetadataInterface } from '@loopstack/core/dist/workflow-processor/interfaces/workflow-metadata.interface';
2
+ import { DefineHelper, InjectTool, Workflow, WorkflowMetadataInterface } from '@loopstack/common';
5
3
  import { CreateChatMessage } from '@loopstack/create-chat-message-tool';
6
4
  import { CreateValue } from '@loopstack/create-value-tool';
7
5
 
@@ -14,14 +12,14 @@ interface WorkflowToolsMetadata {
14
12
  }
15
13
 
16
14
  @Injectable()
17
- @BlockConfig({
15
+ @Workflow({
18
16
  configFile: __dirname + '/workflow-tool-results.workflow.yaml',
19
17
  })
20
- export class WorkflowToolResultsWorkflow extends WorkflowBase {
21
- @Tool() private createValue: CreateValue;
22
- @Tool() private createChatMessage: CreateChatMessage;
18
+ export class WorkflowToolResultsWorkflow {
19
+ @InjectTool() private createValue: CreateValue;
20
+ @InjectTool() private createChatMessage: CreateChatMessage;
23
21
 
24
- @Helper()
22
+ @DefineHelper()
25
23
  extractMessage(metadata: WorkflowMetadataInterface): string {
26
24
  const tools = metadata.tools as unknown as WorkflowToolsMetadata;
27
25
  return tools.create_some_data.say_hello.data;