@loopstack/accessing-tool-results-example-workflow 0.15.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/LICENSE +19 -0
- package/README.md +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/dist/workflow-tool-results.workflow.d.ts +7 -0
- package/dist/workflow-tool-results.workflow.js +46 -0
- package/dist/workflow-tool-results.workflow.js.map +1 -0
- package/dist/workflow-tool-results.workflow.yaml +42 -0
- package/package.json +79 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
Copyright 2025 Loopstack GmbH
|
|
8
|
+
|
|
9
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
10
|
+
you may not use this skeleton application except in compliance with the License.
|
|
11
|
+
You may obtain a copy of the License at
|
|
12
|
+
|
|
13
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
14
|
+
|
|
15
|
+
Unless required by applicable law or agreed to in writing, software
|
|
16
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
17
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
18
|
+
See the License for the specific language governing permissions and
|
|
19
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Loopstack Accessing Tool Results Example
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './workflow-tool-results.workflow';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./workflow-tool-results.workflow"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mEAAiD"}
|
|
@@ -0,0 +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 {
|
|
4
|
+
private createValue;
|
|
5
|
+
private createChatMessage;
|
|
6
|
+
extractMessage(metadata: WorkflowMetadataInterface): string;
|
|
7
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.WorkflowToolResultsWorkflow = void 0;
|
|
13
|
+
const core_1 = require("@loopstack/core");
|
|
14
|
+
const common_1 = require("@loopstack/common");
|
|
15
|
+
const common_2 = require("@nestjs/common");
|
|
16
|
+
const core_ui_module_1 = require("@loopstack/core-ui-module");
|
|
17
|
+
const create_value_tool_1 = require("@loopstack/create-value-tool");
|
|
18
|
+
let WorkflowToolResultsWorkflow = class WorkflowToolResultsWorkflow extends core_1.WorkflowBase {
|
|
19
|
+
createValue;
|
|
20
|
+
createChatMessage;
|
|
21
|
+
extractMessage(metadata) {
|
|
22
|
+
return metadata.tools.create_some_data.say_hello.data;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
exports.WorkflowToolResultsWorkflow = WorkflowToolResultsWorkflow;
|
|
26
|
+
__decorate([
|
|
27
|
+
(0, common_1.Tool)(),
|
|
28
|
+
__metadata("design:type", create_value_tool_1.CreateValue)
|
|
29
|
+
], WorkflowToolResultsWorkflow.prototype, "createValue", void 0);
|
|
30
|
+
__decorate([
|
|
31
|
+
(0, common_1.Tool)(),
|
|
32
|
+
__metadata("design:type", core_ui_module_1.CreateChatMessage)
|
|
33
|
+
], WorkflowToolResultsWorkflow.prototype, "createChatMessage", void 0);
|
|
34
|
+
__decorate([
|
|
35
|
+
(0, common_1.Helper)(),
|
|
36
|
+
__metadata("design:type", Function),
|
|
37
|
+
__metadata("design:paramtypes", [Object]),
|
|
38
|
+
__metadata("design:returntype", String)
|
|
39
|
+
], WorkflowToolResultsWorkflow.prototype, "extractMessage", null);
|
|
40
|
+
exports.WorkflowToolResultsWorkflow = WorkflowToolResultsWorkflow = __decorate([
|
|
41
|
+
(0, common_2.Injectable)(),
|
|
42
|
+
(0, common_1.BlockConfig)({
|
|
43
|
+
configFile: __dirname + '/workflow-tool-results.workflow.yaml',
|
|
44
|
+
})
|
|
45
|
+
], WorkflowToolResultsWorkflow);
|
|
46
|
+
//# sourceMappingURL=workflow-tool-results.workflow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow-tool-results.workflow.js","sourceRoot":"","sources":["../src/workflow-tool-results.workflow.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,0CAA+C;AAC/C,8CAA8D;AAC9D,2CAA4C;AAE5C,8DAA8D;AAC9D,oEAA2D;AAMpD,IAAM,2BAA2B,GAAjC,MAAM,2BAA4B,SAAQ,mBAAY;IAC3C,WAAW,CAAc;IACzB,iBAAiB,CAAoB;IAGrD,cAAc,CAAC,QAAmC;QAChD,OAAO,QAAQ,CAAC,KAAK,CAAC,gBAAgB,CAAC,SAAS,CAAC,IAAI,CAAC;IACxD,CAAC;CACF,CAAA;AARY,kEAA2B;AACtB;IAAf,IAAA,aAAI,GAAE;8BAAsB,+BAAW;gEAAC;AACzB;IAAf,IAAA,aAAI,GAAE;8BAA4B,kCAAiB;sEAAC;AAGrD;IADC,IAAA,eAAM,GAAE;;;;iEAGR;sCAPU,2BAA2B;IAJvC,IAAA,mBAAU,GAAE;IACZ,IAAA,oBAAW,EAAC;QACX,UAAU,EAAE,SAAS,GAAG,sCAAsC;KAC/D,CAAC;GACW,2BAA2B,CAQvC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
title: "Workflow Tool Result"
|
|
2
|
+
|
|
3
|
+
transitions:
|
|
4
|
+
- id: create_some_data
|
|
5
|
+
from: start
|
|
6
|
+
to: data_created
|
|
7
|
+
call:
|
|
8
|
+
|
|
9
|
+
# Create test data and return it in the tool result
|
|
10
|
+
- id: say_hello
|
|
11
|
+
tool: createValue
|
|
12
|
+
args:
|
|
13
|
+
input: 'Hello World.'
|
|
14
|
+
|
|
15
|
+
# Access the data using the call id as identifier
|
|
16
|
+
- tool: createChatMessage
|
|
17
|
+
args:
|
|
18
|
+
role: 'assistant'
|
|
19
|
+
content: "Data from specific call id: {{ metadata.tools.create_some_data.say_hello.data }}"
|
|
20
|
+
|
|
21
|
+
# Access the data using the call index
|
|
22
|
+
- tool: createChatMessage
|
|
23
|
+
args:
|
|
24
|
+
role: 'assistant'
|
|
25
|
+
content: "Data from first tool call: {{ metadata.tools.create_some_data.0.data }}"
|
|
26
|
+
|
|
27
|
+
- id: access_data
|
|
28
|
+
from: data_created
|
|
29
|
+
to: end
|
|
30
|
+
call:
|
|
31
|
+
|
|
32
|
+
# Access the data from a previous transition using transition and call id
|
|
33
|
+
- tool: createChatMessage
|
|
34
|
+
args:
|
|
35
|
+
role: 'assistant'
|
|
36
|
+
content: "Data from previous transition: {{ metadata.tools.create_some_data.say_hello.data }}"
|
|
37
|
+
|
|
38
|
+
# Access the data using a custom helper function of the workflow
|
|
39
|
+
- tool: createChatMessage
|
|
40
|
+
args:
|
|
41
|
+
role: 'assistant'
|
|
42
|
+
content: "Data access using custom helper: {{ extractMessage metadata }}"
|
package/package.json
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@loopstack/accessing-tool-results-example-workflow",
|
|
3
|
+
"displayName": "Loopstack Tool Results Example",
|
|
4
|
+
"description": "A simple workflow showing different methods of how to access tool results in a subsequent workflow step.",
|
|
5
|
+
"version": "0.15.0",
|
|
6
|
+
"author": {
|
|
7
|
+
"name": "Jakob Klippel",
|
|
8
|
+
"url": "https://www.linkedin.com/in/jakob-klippel/"
|
|
9
|
+
},
|
|
10
|
+
"keywords": [
|
|
11
|
+
"example",
|
|
12
|
+
"tool",
|
|
13
|
+
"results",
|
|
14
|
+
"workflow",
|
|
15
|
+
"helper",
|
|
16
|
+
"assign"
|
|
17
|
+
],
|
|
18
|
+
"license": "Apache-2.0",
|
|
19
|
+
"main": "dist/index.js",
|
|
20
|
+
"types": "dist/index.d.ts",
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "nest build",
|
|
23
|
+
"watch": "nest build --watch",
|
|
24
|
+
"compile": "tsc --noEmit",
|
|
25
|
+
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
|
|
26
|
+
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
|
|
27
|
+
"test": "jest",
|
|
28
|
+
"test:watch": "jest --watch",
|
|
29
|
+
"test:cov": "jest --coverage",
|
|
30
|
+
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
|
|
31
|
+
"test:e2e": "jest --config ./test/jest-e2e.json"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@loopstack/common": "^0.15.0",
|
|
35
|
+
"@loopstack/core": "^0.15.0",
|
|
36
|
+
"@loopstack/core-ui-module": "^0.15.0",
|
|
37
|
+
"@loopstack/create-value-tool": "^0.15.0",
|
|
38
|
+
"@nestjs/common": "^11.0.12",
|
|
39
|
+
"zod": "^3.24.1"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@eslint/eslintrc": "^3.3.0",
|
|
43
|
+
"@eslint/js": "^9.22.0",
|
|
44
|
+
"@nestjs/cli": "^11.0.5",
|
|
45
|
+
"@nestjs/testing": "^11.0.12",
|
|
46
|
+
"@swc/cli": "^0.6.0",
|
|
47
|
+
"@swc/core": "^1.11.11",
|
|
48
|
+
"@types/jest": "^29.5.14",
|
|
49
|
+
"@types/node": "^22.13.10",
|
|
50
|
+
"eslint": "^9.22.0",
|
|
51
|
+
"eslint-config-prettier": "^10.1.1",
|
|
52
|
+
"eslint-plugin-prettier": "^5.2.3",
|
|
53
|
+
"globals": "^16.0.0",
|
|
54
|
+
"jest": "^29.7.0",
|
|
55
|
+
"prettier": "^3.5.3",
|
|
56
|
+
"ts-jest": "^29.2.6",
|
|
57
|
+
"tsconfig-paths": "^4.2.0",
|
|
58
|
+
"typescript": "^5.8.3",
|
|
59
|
+
"typescript-eslint": "^8.38.0"
|
|
60
|
+
},
|
|
61
|
+
"jest": {
|
|
62
|
+
"moduleFileExtensions": [
|
|
63
|
+
"js",
|
|
64
|
+
"json",
|
|
65
|
+
"ts"
|
|
66
|
+
],
|
|
67
|
+
"rootDir": "src",
|
|
68
|
+
"testRegex": ".*\\.spec\\.ts$",
|
|
69
|
+
"transform": {
|
|
70
|
+
"^.+\\.ts$": "ts-jest"
|
|
71
|
+
},
|
|
72
|
+
"collectCoverageFrom": [
|
|
73
|
+
"**/*.(t|j)s"
|
|
74
|
+
],
|
|
75
|
+
"coverageDirectory": "../coverage",
|
|
76
|
+
"testEnvironment": "node",
|
|
77
|
+
"maxWorkers": 1
|
|
78
|
+
}
|
|
79
|
+
}
|