@loopstack/agent-example-workflow 0.1.1 → 0.2.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 +1 @@
1
- {"version":3,"file":"agent-example.module.d.ts","sourceRoot":"","sources":["../src/agent-example.module.ts"],"names":[],"mappings":"AAOA,qBAKa,kBAAkB;CAAG"}
1
+ {"version":3,"file":"agent-example.module.d.ts","sourceRoot":"","sources":["../src/agent-example.module.ts"],"names":[],"mappings":"AAMA,qBAKa,kBAAkB;CAAG"}
@@ -9,7 +9,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.AgentExampleModule = void 0;
10
10
  const common_1 = require("@nestjs/common");
11
11
  const agent_1 = require("@loopstack/agent");
12
- const core_1 = require("@loopstack/core");
13
12
  const agent_example_workflow_1 = require("./agent-example.workflow");
14
13
  const calculator_tool_1 = require("./tools/calculator.tool");
15
14
  const weather_lookup_tool_1 = require("./tools/weather-lookup.tool");
@@ -18,7 +17,7 @@ let AgentExampleModule = class AgentExampleModule {
18
17
  exports.AgentExampleModule = AgentExampleModule;
19
18
  exports.AgentExampleModule = AgentExampleModule = __decorate([
20
19
  (0, common_1.Module)({
21
- imports: [core_1.LoopCoreModule, agent_1.AgentModule],
20
+ imports: [agent_1.AgentModule],
22
21
  providers: [agent_example_workflow_1.AgentExampleWorkflow, calculator_tool_1.CalculatorTool, weather_lookup_tool_1.WeatherLookupTool],
23
22
  exports: [agent_example_workflow_1.AgentExampleWorkflow, calculator_tool_1.CalculatorTool, weather_lookup_tool_1.WeatherLookupTool],
24
23
  })
@@ -1 +1 @@
1
- {"version":3,"file":"agent-example.module.js","sourceRoot":"","sources":["../src/agent-example.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,4CAA+C;AAC/C,0CAAiD;AACjD,qEAAgE;AAChE,6DAAyD;AACzD,qEAAgE;AAOzD,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;CAAG,CAAA;AAArB,gDAAkB;6BAAlB,kBAAkB;IAL9B,IAAA,eAAM,EAAC;QACN,OAAO,EAAE,CAAC,qBAAc,EAAE,mBAAW,CAAC;QACtC,SAAS,EAAE,CAAC,6CAAoB,EAAE,gCAAc,EAAE,uCAAiB,CAAC;QACpE,OAAO,EAAE,CAAC,6CAAoB,EAAE,gCAAc,EAAE,uCAAiB,CAAC;KACnE,CAAC;GACW,kBAAkB,CAAG"}
1
+ {"version":3,"file":"agent-example.module.js","sourceRoot":"","sources":["../src/agent-example.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,4CAA+C;AAC/C,qEAAgE;AAChE,6DAAyD;AACzD,qEAAgE;AAOzD,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;CAAG,CAAA;AAArB,gDAAkB;6BAAlB,kBAAkB;IAL9B,IAAA,eAAM,EAAC;QACN,OAAO,EAAE,CAAC,mBAAW,CAAC;QACtB,SAAS,EAAE,CAAC,6CAAoB,EAAE,gCAAc,EAAE,uCAAiB,CAAC;QACpE,OAAO,EAAE,CAAC,6CAAoB,EAAE,gCAAc,EAAE,uCAAiB,CAAC;KACnE,CAAC;GACW,kBAAkB,CAAG"}
@@ -1 +1 @@
1
- {"version":3,"file":"agent-example.workflow.d.ts","sourceRoot":"","sources":["../src/agent-example.workflow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EACL,YAAY,EASb,MAAM,mBAAmB,CAAC;AAE3B,QAAA,MAAM,mBAAmB;;;;;;iBAEvB,CAAC;AAEH,KAAK,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAOzD,qBAGa,oBAAqB,SAAQ,YAAY;IAClC,OAAO,CAAC,KAAK,CAAgB;IAGzC,KAAK;IAsBL,aAAa,CAAC,OAAO,EAAE,aAAa;CAY3C"}
1
+ {"version":3,"file":"agent-example.workflow.d.ts","sourceRoot":"","sources":["../src/agent-example.workflow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EACL,YAAY,EASb,MAAM,mBAAmB,CAAC;AAE3B,QAAA,MAAM,mBAAmB;;;;;;iBAEvB,CAAC;AAEH,KAAK,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEzD,qBAGa,oBAAqB,SAAQ,YAAY;IAClC,OAAO,CAAC,KAAK,CAAgB;IAGzC,KAAK;IAsBL,aAAa,CAAC,OAAO,EAAE,aAAa;CAY3C"}
@@ -16,15 +16,11 @@ const common_1 = require("@loopstack/common");
16
16
  const AgentCallbackSchema = common_1.CallbackSchema.extend({
17
17
  data: zod_1.z.object({ response: zod_1.z.string() }),
18
18
  });
19
- const SYSTEM_PROMPT = `You are a helpful assistant with access to a weather lookup tool and a calculator.
20
- When the user asks about weather, use the weatherLookup tool.
21
- When the user asks for calculations, use the calculator tool.
22
- Provide a concise, helpful response summarizing the results.`;
23
19
  let AgentExampleWorkflow = class AgentExampleWorkflow extends common_1.BaseWorkflow {
24
20
  agent;
25
21
  async start() {
26
22
  const result = await this.agent.run({
27
- system: SYSTEM_PROMPT,
23
+ system: this.render(__dirname + '/templates/system.md'),
28
24
  tools: ['weatherLookup', 'calculator'],
29
25
  userMessage: "What's the weather in Tokyo? Also, what is 42 * 17?",
30
26
  }, { alias: 'agent', callback: { transition: 'agentComplete' } });
@@ -1 +1 @@
1
- {"version":3,"file":"agent-example.workflow.js","sourceRoot":"","sources":["../src/agent-example.workflow.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6BAAwB;AACxB,4CAAiD;AACjD,8CAU2B;AAE3B,MAAM,mBAAmB,GAAG,uBAAc,CAAC,MAAM,CAAC;IAChD,IAAI,EAAE,OAAC,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,EAAE,CAAC;CACzC,CAAC,CAAC;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,CAAC,UAAU,EAAE,EAAE,CACpC,CAAC;IACJ,CAAC;IAOK,AAAN,KAAK,CAAC,aAAa,CAAC,OAAsB;QACxC,MAAM,IAAI,CAAC,UAAU,CAAC,IAAI,CACxB,qBAAY,EACZ,EAAE,KAAK,EAAE,gBAAgB,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,CAAC,UAAU,EAAE,EAC9E,EAAE,EAAE,EAAE,QAAQ,OAAO,CAAC,UAAU,EAAE,EAAE,CACrC,CAAC;QAEF,MAAM,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,wBAAe,EAAE;YAC1C,IAAI,EAAE,WAAW;YACjB,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,QAAQ;SAC/B,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AAtCY,oDAAoB;AACL;IAAzB,IAAA,uBAAc,GAAE;8BAAgB,qBAAa;mDAAC;AAGzC;IADL,IAAA,gBAAO,EAAC,EAAE,EAAE,EAAE,SAAS,EAAE,CAAC;;;;iDAgB1B;AAOK;IALL,IAAA,cAAK,EAAC;QACL,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,IAAI;QACV,MAAM,EAAE,mBAAmB;KAC5B,CAAC;;;;yDAYD;+BArCU,oBAAoB;IAHhC,IAAA,iBAAQ,EAAC;QACR,QAAQ,EAAE,SAAS,GAAG,wBAAwB;KAC/C,CAAC;GACW,oBAAoB,CAsChC"}
@@ -0,0 +1,4 @@
1
+ You are a helpful assistant with access to a weather lookup tool and a calculator.
2
+ When the user asks about weather, use the weatherLookup tool.
3
+ When the user asks for calculations, use the calculator tool.
4
+ Provide a concise, helpful response summarizing the results.
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "claude",
10
10
  "sub-workflow"
11
11
  ],
12
- "version": "0.1.1",
12
+ "version": "0.2.0",
13
13
  "license": "MIT",
14
14
  "author": {
15
15
  "name": "Jakob Klippel",
@@ -26,13 +26,13 @@
26
26
  "compile": "tsc --noEmit",
27
27
  "format": "prettier --write .",
28
28
  "lint": "eslint .",
29
- "test": "jest --passWithNoTests",
29
+ "test": "vitest run",
30
30
  "watch": "nest build --watch"
31
31
  },
32
32
  "dependencies": {
33
- "@loopstack/agent": "^0.2.0",
34
- "@loopstack/common": "^0.28.0",
35
- "@loopstack/core": "^0.28.0",
33
+ "@loopstack/agent": "^0.4.0",
34
+ "@loopstack/common": "^0.30.0",
35
+ "@loopstack/core": "^0.30.0",
36
36
  "@nestjs/common": "^11.1.19",
37
37
  "zod": "^4.3.6"
38
38
  },
@@ -40,46 +40,9 @@
40
40
  "dist",
41
41
  "src"
42
42
  ],
43
- "jest": {
44
- "testEnvironment": "node",
45
- "rootDir": "src",
46
- "testRegex": ".*\\.spec\\.ts$",
47
- "transform": {
48
- "^.+\\.ts$": "ts-jest"
49
- },
50
- "testTimeout": 10000,
51
- "forceExit": true,
52
- "maxWorkers": 1
53
- },
54
- "loopstack": {
55
- "modules": [
56
- {
57
- "path": "src/agent-example.module.ts",
58
- "className": "AgentExampleModule"
59
- }
60
- ],
61
- "workflows": [
62
- {
63
- "path": "src/agent-example.workflow.ts",
64
- "className": "AgentExampleWorkflow",
65
- "propertyName": "agentExample"
66
- }
67
- ],
68
- "tools": [
69
- {
70
- "path": "src/tools/calculator.tool.ts",
71
- "className": "CalculatorTool",
72
- "propertyName": "calculator"
73
- },
74
- {
75
- "path": "src/tools/weather-lookup.tool.ts",
76
- "className": "WeatherLookupTool",
77
- "propertyName": "weatherLookup"
78
- }
79
- ],
80
- "installModes": [
81
- "add",
82
- "install"
83
- ]
43
+ "devDependencies": {
44
+ "vitest": "^4.1.6",
45
+ "@swc/core": "^1.15.33",
46
+ "unplugin-swc": "^1.5.9"
84
47
  }
85
48
  }
@@ -1,7 +1,8 @@
1
1
  import { TestingModule } from '@nestjs/testing';
2
+ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
2
3
  import { AgentWorkflow } from '@loopstack/agent';
3
4
  import { RunContext, WorkflowEntity } from '@loopstack/common';
4
- import { LoopCoreModule, WorkflowProcessorService } from '@loopstack/core';
5
+ import { WorkflowProcessorService } from '@loopstack/core';
5
6
  import { createStatelessContext, createWorkflowTest } from '@loopstack/testing';
6
7
  import { AgentExampleWorkflow } from '../agent-example.workflow';
7
8
  import { CalculatorTool } from '../tools/calculator.tool';
@@ -13,15 +14,14 @@ describe('AgentExampleWorkflow', () => {
13
14
  let processor: WorkflowProcessorService;
14
15
 
15
16
  const mockAgent = {
16
- run: jest.fn(),
17
+ run: vi.fn(),
17
18
  };
18
19
 
19
20
  beforeEach(async () => {
20
- jest.clearAllMocks();
21
+ vi.clearAllMocks();
21
22
 
22
23
  module = await createWorkflowTest()
23
24
  .forWorkflow(AgentExampleWorkflow)
24
- .withImports(LoopCoreModule)
25
25
  .withProviders(CalculatorTool, WeatherLookupTool)
26
26
  .withMock(AgentWorkflow, mockAgent)
27
27
  .compile();
@@ -1,12 +1,11 @@
1
1
  import { Module } from '@nestjs/common';
2
2
  import { AgentModule } from '@loopstack/agent';
3
- import { LoopCoreModule } from '@loopstack/core';
4
3
  import { AgentExampleWorkflow } from './agent-example.workflow';
5
4
  import { CalculatorTool } from './tools/calculator.tool';
6
5
  import { WeatherLookupTool } from './tools/weather-lookup.tool';
7
6
 
8
7
  @Module({
9
- imports: [LoopCoreModule, AgentModule],
8
+ imports: [AgentModule],
10
9
  providers: [AgentExampleWorkflow, CalculatorTool, WeatherLookupTool],
11
10
  exports: [AgentExampleWorkflow, CalculatorTool, WeatherLookupTool],
12
11
  })
@@ -18,11 +18,6 @@ const AgentCallbackSchema = CallbackSchema.extend({
18
18
 
19
19
  type AgentCallback = z.infer<typeof AgentCallbackSchema>;
20
20
 
21
- const SYSTEM_PROMPT = `You are a helpful assistant with access to a weather lookup tool and a calculator.
22
- When the user asks about weather, use the weatherLookup tool.
23
- When the user asks for calculations, use the calculator tool.
24
- Provide a concise, helpful response summarizing the results.`;
25
-
26
21
  @Workflow({
27
22
  uiConfig: __dirname + '/agent-example.ui.yaml',
28
23
  })
@@ -33,7 +28,7 @@ export class AgentExampleWorkflow extends BaseWorkflow {
33
28
  async start() {
34
29
  const result: QueueResult = await this.agent.run(
35
30
  {
36
- system: SYSTEM_PROMPT,
31
+ system: this.render(__dirname + '/templates/system.md'),
37
32
  tools: ['weatherLookup', 'calculator'],
38
33
  userMessage: "What's the weather in Tokyo? Also, what is 42 * 17?",
39
34
  },
@@ -0,0 +1,4 @@
1
+ You are a helpful assistant with access to a weather lookup tool and a calculator.
2
+ When the user asks about weather, use the weatherLookup tool.
3
+ When the user asks for calculations, use the calculator tool.
4
+ Provide a concise, helpful response summarizing the results.