From 1cdfd3c82ceb48d0000671957a9ef2b18b6c2bec Mon Sep 17 00:00:00 2001 From: Hri7566 Date: Mon, 16 Oct 2023 13:14:02 -0400 Subject: [PATCH] Partial agent setup --- bun.lockb | Bin 3151 -> 9269 bytes package.json | 6 +++++- src/services/ServiceAgent.ts | 10 ++++++++++ src/services/index.ts | 19 +++++++++---------- src/services/mpp/index.ts | 19 +++++++++++++++++++ src/util/env.ts | 12 ++++++++++++ 6 files changed, 55 insertions(+), 11 deletions(-) create mode 100644 src/services/ServiceAgent.ts create mode 100644 src/util/env.ts diff --git a/bun.lockb b/bun.lockb index 51508de089d5eb8fba680e50de91182df796923d..e0f28ce9a57bd29e2ab88968d0f368d232833a89 100755 GIT binary patch literal 9269 zcmeHMXH-+!77h?Wv7ij7V53;xQuZ1U< zH?zF0pQ@j;scR>_W<5;{&9>P>Ban`D39I>^QjIn*APwkzOBPELCl9CJ6-qHB4P~)P zAZG&QK9IJCG=`$9S!sH8c@d=Tpqv6ju_^}4YXy0+qORSykT-^WAA`E~agd@Oe=ROt z6c!x`O{H31(!L**wSjg-9~bh73zw_FKP*;P$hU>OIixKhoj-43dt2|We2(+2Dj%=e zM+{O9CGhP2b5EUZ9UZva?&Qwu!1L__miZX5eP`}jHlX~`Z;5Ko_xqn+?xY_0HbJp% z4|SrwWsKi_*Xtwt4Bb~VziTWfFx{0?CVID{f0urE*>|TBjETPXF)95!3*)Qe^MX=l$DeyN zJ6Us~t4sd6_y>_E7MNDqfII${;H*ILhldCL05`MR!^4KBDMIiops^$1n?Z_LQr;K` zX?GSHy8aEkDLBFd@aPZhLsR`i^s52TSF0b(kfSL=@Hq_qi2Gdq)c_a*`ib8OZ(}x) zcHZ#92R!D{_RqCH5rFPm{m9W&A#ID`1^tKp#s}v?Q-t6j!^;4M{?GNF06Ode_@?S5 zwh{eFfXDeq<}TU!NV~sE3BCyMIDVMNhm7N2;Yc~bw*~-?AC4QA8IcB!qy+BZ89XSMVtYIzu)G62D41d%F9w)ez=Q2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i2$iUPp87f#*% mq>;Y=d4C2t*{VS)TzwkB>o$4->fY(S!Wofu$H)KQ?|%U^2PEwP delta 668 zcmdn$ab9AAo@TqV^~2uMcYP;5H($!LNIc*+!~fFm-G;3p-vhtZY_FQWpPK;;*e8a| zM`g1^I1myj(@;>9S)7~5z)%Sk;s^3IfixeGE-!|tkpog7b)rC;6G*qWb&4sw${8_F z+SjOW@a<*UI>pkcZ3gEiUtpA+{FBk2(RFeslRaw(P`TaYUM6eKV?dS*P$T1HK{j(H zF2>2H*zB1687FhG+cEV5dF)oHtUx6o%m~D6KnwyP8pH=Vmi!1V#j-OfEZPS#=aI$6od%yL^N`zr03T&KJp E0H?Q<@&Et; diff --git a/package.json b/package.json index 2882d02..090c180 100644 --- a/package.json +++ b/package.json @@ -9,8 +9,12 @@ "typescript": "^5.0.0" }, "dependencies": { + "@t3-oss/env-core": "^0.7.1", + "dotenv": "^16.3.1", "hyperimport": "^0.1.0", "mpp-client-net": "^1.1.3", - "prisma": "^5.4.2" + "mpp-client-xt": "^1.3.1", + "prisma": "^5.4.2", + "zod": "^3.22.4" } } \ No newline at end of file diff --git a/src/services/ServiceAgent.ts b/src/services/ServiceAgent.ts new file mode 100644 index 0000000..6f226ad --- /dev/null +++ b/src/services/ServiceAgent.ts @@ -0,0 +1,10 @@ +import EventEmitter from "events"; + +export abstract class ServiceAgent extends EventEmitter { + constructor(public client: T) { + super(); + } + + public abstract start(): void; + public abstract stop(): void; +} diff --git a/src/services/index.ts b/src/services/index.ts index 80160ed..16a9375 100644 --- a/src/services/index.ts +++ b/src/services/index.ts @@ -1,14 +1,13 @@ import EventEmitter from "events"; - -export abstract class ServiceAgent extends EventEmitter { - constructor() { - super(); - } - - public abstract start(): void; - public abstract stop(): void; -} +import { MPPAgent } from "./mpp"; +import env from "../util/env"; +import { ServiceAgent } from "./ServiceAgent"; export class ServiceLoader { - public static loadServices() {} + public static agents = new Array>(); + + public static loadServices() { + const testAgent = new MPPAgent("wss://mppclone.com", env.MPPNET_TOKEN); + testAgent.start(); + } } diff --git a/src/services/mpp/index.ts b/src/services/mpp/index.ts index e69de29..991a5e4 100644 --- a/src/services/mpp/index.ts +++ b/src/services/mpp/index.ts @@ -0,0 +1,19 @@ +import Client from "mpp-client-net"; +import { ServiceAgent } from "../ServiceAgent"; + +export class MPPAgent extends ServiceAgent { + constructor(uri: string, token: string) { + const cl = new Client(uri, token); + super(cl); + } + + public start() { + this.client.start(); + // TODO get rid of this gay shit + this.client.setChannel("Simon Says"); + } + + public stop() { + this.client.stop(); + } +} diff --git a/src/util/env.ts b/src/util/env.ts new file mode 100644 index 0000000..b5615c2 --- /dev/null +++ b/src/util/env.ts @@ -0,0 +1,12 @@ +import z from "zod"; +import { createEnv } from "@t3-oss/env-core"; + +export const env = createEnv({ + isServer: true, + server: { + MPPNET_TOKEN: z.string() + }, + runtimeEnv: process.env +}); + +export default env;