Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
107e5f6
feat: added gmx agent config
JustUzair Dec 29, 2025
6805ca0
feat: partial agent setup for copilotkit route.ts
JustUzair Dec 29, 2025
e972289
feat: init langgraph project and setup basic agent
JustUzair Dec 30, 2025
6d5682d
feat: added GMX Order Type Schem; added public and wallet client; add…
JustUzair Dec 30, 2025
cfa6623
fix: added constants file export
JustUzair Dec 30, 2025
50dc116
feat: added workflow context; updated constants ;updated .env.example
JustUzair Dec 30, 2025
0828e43
feat: added gmx agent context
JustUzair Dec 31, 2025
a48c934
feat: added command codes to hire and fire agent
JustUzair Dec 31, 2025
4bb98f8
feat: added hire and fire node to the graph; configured graph in lang…
JustUzair Jan 1, 2026
f84e3d3
fix: fixed agent config
JustUzair Jan 1, 2026
f6e9513
fix: fixed edges in the graph; fixed bugs in the agent context file
JustUzair Jan 1, 2026
d3590e9
feat: added bootstrap node to show initial state after hiring
JustUzair Jan 1, 2026
01b54e5
feat: added polling; open positionl hold position; close position nodes
JustUzair Jan 4, 2026
5627e6a
fix: removed boilerplate state
JustUzair Jan 6, 2026
d88bad4
feat: added onchain-actions client to create long and short position tx
JustUzair Jan 6, 2026
de7667d
fix: moved the gmx agent to a separate port to prevent clashes
JustUzair Jan 7, 2026
8aa41e9
feat: added boostrap context caching
JustUzair Jan 7, 2026
4c71bcc
feat: added gmx actions, telemetry and states
JustUzair Jan 7, 2026
e42ff35
feat: registered gmx agent to a separate port to prevent clashes
JustUzair Jan 7, 2026
eac0f53
todo: remove open close and hold commands and use decision engine ins…
JustUzair Jan 7, 2026
847f575
feat: added conditional bootstrapping to commands in case of missing …
JustUzair Jan 7, 2026
7460930
partial-feat: added helper scripts to create gmx order calldatas (due…
JustUzair Jan 7, 2026
fe11f8e
feat: added summarize node
JustUzair Jan 8, 2026
a00e6d7
fix: updated create-delegation-calldata script to work with zod; adde…
JustUzair Jan 8, 2026
92391b7
fix: removed open, close and hold position nodes and moved the logic …
JustUzair Jan 8, 2026
84b45ce
modify: modified context, types and constants
JustUzair Jan 8, 2026
21ed263
feat: added decision evaluation and calldata creation to open positio…
JustUzair Jan 8, 2026
ce44116
fix: removed unwanted states and commands from runCommand node
JustUzair Jan 8, 2026
34fab36
fix: error handling for polling node, code cleanup
JustUzair Jan 8, 2026
891840b
fix: fixed agent context types and properties
JustUzair Jan 8, 2026
33afdf9
fix: minor bug fixes
JustUzair Jan 8, 2026
9a9ba21
feat: added close position logic
JustUzair Jan 8, 2026
ee7702b
feat: added execution logic for agent after polling and decision
JustUzair Jan 9, 2026
6bde6b3
feat: added standalone scripts to mock approval and token transfers f…
JustUzair Jan 12, 2026
4c82e06
feat: added required constants for approval and intermediate transfer…
JustUzair Jan 12, 2026
02dba87
fix: fixed logic bugs to construct correct calldata for opening/closi…
JustUzair Jan 12, 2026
cefd684
feat: added tx telemetry for the on-chain executions by agent
JustUzair Jan 12, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file.
2 changes: 2 additions & 0 deletions typescript/clients/web-ag-ui/apps/agent-gmx/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
dist
10 changes: 10 additions & 0 deletions typescript/clients/web-ag-ui/apps/agent-gmx/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true

[*.{js,json,yml}]
charset = utf-8
indent_style = space
indent_size = 2
11 changes: 11 additions & 0 deletions typescript/clients/web-ag-ui/apps/agent-gmx/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
GMX_DEFAULT_POSITION_SIZE_USD=
GMX_MAX_LEVERAGE=
A2A_TEST_AGENT_NODE_PRIVATE_KEY=
GMX_MODE=debug | production
GMX_DELEGATIONS_BYPASS=true | false
ARBITRUM_RPC_URL=

## Local Helper

## User PK to facilitate transfer and approval before actual flow of delegations to test GMX flow
USER_PK=
62 changes: 62 additions & 0 deletions typescript/clients/web-ag-ui/apps/agent-gmx/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
module.exports = {
extends: [
"eslint:recommended",
"prettier",
"plugin:@typescript-eslint/recommended",
],
parserOptions: {
ecmaVersion: 12,
parser: "@typescript-eslint/parser",
project: "./tsconfig.json",
sourceType: "module",
},
plugins: ["import", "@typescript-eslint", "no-instanceof"],
ignorePatterns: [
".eslintrc.cjs",
"scripts",
"src/utils/lodash/*",
"node_modules",
"dist",
"dist-cjs",
"*.js",
"*.cjs",
"*.d.ts",
],
rules: {
"no-process-env": 2,
"no-instanceof/no-instanceof": 2,
"@typescript-eslint/explicit-module-boundary-types": 0,
"@typescript-eslint/no-empty-function": 0,
"@typescript-eslint/no-shadow": 0,
"@typescript-eslint/no-empty-interface": 0,
"@typescript-eslint/no-use-before-define": ["error", "nofunc"],
"@typescript-eslint/no-unused-vars": ["warn", { args: "none" }],
"@typescript-eslint/no-floating-promises": "error",
"@typescript-eslint/no-misused-promises": "error",
camelcase: 0,
"class-methods-use-this": 0,
"import/extensions": [2, "ignorePackages"],
"import/no-extraneous-dependencies": [
"error",
{ devDependencies: ["**/*.test.ts"] },
],
"import/no-unresolved": 0,
"import/prefer-default-export": 0,
"keyword-spacing": "error",
"max-classes-per-file": 0,
"max-len": 0,
"no-await-in-loop": 0,
"no-bitwise": 0,
"no-console": 0,
"no-restricted-syntax": 0,
"no-shadow": 0,
"no-continue": 0,
"no-underscore-dangle": 0,
"no-use-before-define": 0,
"no-useless-constructor": 0,
"no-return-await": 0,
"consistent-return": 0,
"no-else-return": 0,
"new-cap": ["error", { properties: false, capIsNew: false }],
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# This workflow will run integration tests for the current project once per day

name: Integration Tests

on:
schedule:
- cron: "37 14 * * *" # Run at 7:37 AM Pacific Time (14:37 UTC) every day
workflow_dispatch: # Allows triggering the workflow manually in GitHub UI

# If another scheduled run starts while this workflow is still running,
# cancel the earlier run in favor of the next run.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
integration-tests:
name: Integration Tests
strategy:
matrix:
os: [ubuntu-latest]
node-version: [18.x, 20.x]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: "yarn"
- name: Install dependencies
run: yarn install --immutable
- name: Build project
run: yarn build
- name: Run integration tests
run: yarn test:int
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# This workflow will run unit tests for the current project

name: CI

on:
push:
branches: ["main"]
pull_request:
workflow_dispatch: # Allows triggering the workflow manually in GitHub UI

# If another push to the same PR or branch happens while this workflow is still running,
# cancel the earlier run in favor of the next run.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
unit-tests:
name: Unit Tests
strategy:
matrix:
os: [ubuntu-latest]
node-version: [18.x, 20.x]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: "yarn"
- name: Install dependencies
run: yarn install --immutable
- name: Build project
run: yarn build

- name: Lint project
run: yarn lint:all

- name: Check README spelling
uses: codespell-project/actions-codespell@v2
with:
ignore_words_file: .codespellignore
path: README.md

- name: Check code spelling
uses: codespell-project/actions-codespell@v2
with:
ignore_words_file: .codespellignore
path: src/

- name: Run tests
run: yarn test
22 changes: 22 additions & 0 deletions typescript/clients/web-ag-ui/apps/agent-gmx/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
index.cjs
index.js
index.d.ts
node_modules
dist
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions

.turbo
**/.turbo
**/.eslintcache

.env
.ipynb_checkpoints


# LangGraph API
.langgraph_api
21 changes: 21 additions & 0 deletions typescript/clients/web-ag-ui/apps/agent-gmx/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 LangChain

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
102 changes: 102 additions & 0 deletions typescript/clients/web-ag-ui/apps/agent-gmx/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# New LangGraph.js Project

[![CI](https://github.com/langchain-ai/new-langgraphjs-project/actions/workflows/unit-tests.yml/badge.svg)](https://github.com/langchain-ai/new-langgraphjs-project/actions/workflows/unit-tests.yml)
[![Integration Tests](https://github.com/langchain-ai/new-langgraphjs-project/actions/workflows/integration-tests.yml/badge.svg)](https://github.com/langchain-ai/new-langgraphjs-project/actions/workflows/integration-tests.yml)

This template demonstrates a simple chatbot implemented using [LangGraph.js](https://github.com/langchain-ai/langgraphjs), showing how to get started with [LangGraph Server](https://langchain-ai.github.io/langgraph/concepts/langgraph_server/#langgraph-server) and using [LangGraph Studio](https://langchain-ai.github.io/langgraph/concepts/langgraph_studio/), a visual debugging IDE.

<p align="center">
<img src="./static/studio.png" alt="Graph view in LangGraph studio UI" width="75%">
</p>

The core logic, defined in `src/agent/graph.ts`, showcases a straightforward chatbot that responds to user queries while maintaining context from previous messages.

## What it does

The simple chatbot:

1. Takes a user **message** as input
2. Maintains a history of the conversation
3. Returns a placeholder response, updating the conversation history

This template provides a foundation that can be easily customized and extended to create more complex conversational agents.

## Getting Started

1. Install the [LangGraph CLI](https://langchain-ai.github.io/langgraph/concepts/langgraph_cli/).

```bash
npx @langchain/langgraph-cli
```

2. Create a `.env` file. While this starter app does not require any secrets, if you later decide to connect to LLM providers and other integrations, you will likely need to provide API keys.

```bash
cp .env.example .env
```

3. If desired, add your LangSmith API key in your `.env` file.

```
LANGSMITH_API_KEY=lsv2...
```

<!--
Setup instruction auto-generated by `langgraph template lock`. DO NOT EDIT MANUALLY.
-->

<!--
End setup instructions
-->

4. Install dependencies

```
yarn install
```

5. Customize the code as needed.
6. Start the LangGraph Server.

```bash
npx @langchain/langgraph-cli dev
```

For more information on getting started with LangGraph Server, [see here](https://langchain-ai.github.io/langgraph/tutorials/langgraph-platform/local-server/).

## How to customize

1. **Add an LLM call**: You can select and install a chat model wrapper from [the LangChain.js ecosystem](https://js.langchain.com/docs/integrations/chat/), or use LangGraph.js without LangChain.js.
2. **Extend the graph**: The core logic of the chatbot is defined in [graph.ts](./src/agent/graph.ts). You can modify this file to add new nodes, edges, or change the flow of the conversation.

You can also extend this template by:

- Adding [custom tools or functions](https://js.langchain.com/docs/how_to/tool_calling) to enhance the chatbot's capabilities.
- Implementing additional logic for handling specific types of user queries or tasks.
- Add retrieval-augmented generation (RAG) capabilities by integrating [external APIs or databases](https://langchain-ai.github.io/langgraphjs/tutorials/rag/langgraph_agentic_rag/) to provide more customized responses.

## Development

While iterating on your graph, you can edit past state and rerun your app from previous states to debug specific nodes. Local changes will be automatically applied via hot reload. Try experimenting with:

- Modifying the system prompt to give your chatbot a unique personality.
- Adding new nodes to the graph for more complex conversation flows.
- Implementing conditional logic to handle different types of user inputs.

Follow-up requests will be appended to the same thread. You can create an entirely new thread, clearing previous history, using the `+` button in the top right.

For more advanced features and examples, refer to the [LangGraph.js documentation](https://langchain-ai.github.io/langgraphjs/). These resources can help you adapt this template for your specific use case and build more sophisticated conversational agents.

LangGraph Studio also integrates with [LangSmith](https://smith.langchain.com/) for more in-depth tracing and collaboration with teammates, allowing you to analyze and optimize your chatbot's performance.

<!--
Configuration auto-generated by `langgraph template lock`. DO NOT EDIT MANUALLY.
{
"config_schemas": {
"agent": {
"type": "object",
"properties": {}
}
}
}
-->
18 changes: 18 additions & 0 deletions typescript/clients/web-ag-ui/apps/agent-gmx/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export default {
preset: "ts-jest/presets/default-esm",
moduleNameMapper: {
"^(\\.{1,2}/.*)\\.js$": "$1",
},
transform: {
"^.+\\.tsx?$": [
"ts-jest",
{
useESM: true,
},
],
},
extensionsToTreatAsEsm: [".ts"],
setupFiles: ["dotenv/config"],
passWithNoTests: true,
testTimeout: 20_000,
};
9 changes: 9 additions & 0 deletions typescript/clients/web-ag-ui/apps/agent-gmx/langgraph.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"node_version": "22",
"dockerfile_lines": [],
"dependencies": ["."],
"graphs": {
"agent-gmx": "./src/agent.ts:gmxGraph"
},
"env": ".env"
}
Loading
Loading