diff --git a/packages/autospade/Worker.ts b/packages/autospade/Worker.ts index 946333b..6b99286 100644 --- a/packages/autospade/Worker.ts +++ b/packages/autospade/Worker.ts @@ -1,5 +1,16 @@ import { Client } from "kol.js"; +export function parseWorkers(environment: Record) { + return Object.entries(environment).filter(([k,]) => k.startsWith("WORKER_") && v !== undefined).map(([, v]) => { + const [username, password, ...capabilities] = v!.split(","); + + return new Worker(username, password, capabilities.map((capability) => { + const [type, name] = capability.split(":"); + return { type, name } as Capability; + })); + }); +} + export type Capability = | { type: "familiar"; name: string } | { type: "skill"; name: string } diff --git a/packages/autospade/index.ts b/packages/autospade/index.ts index 9c0e649..401bb6f 100644 --- a/packages/autospade/index.ts +++ b/packages/autospade/index.ts @@ -1,19 +1,7 @@ import { compile } from "./compiler.js"; -import { Capability, Worker } from "./Worker.js"; +import { Capability, parseWorkers, Worker } from "./Worker.js"; -const workers = [ - new Worker("onweb", "beef31beer146", [ - { type: "familiar", name: "Mosquito" }, - ]), - new Worker("assistant2", "a$$b0T!2", [ - { type: "familiar", name: "Mosquito" }, - ]), - new Worker("Zorax the Questionable", "aenimus!", [ - { type: "skill", name: "Double-Fisted Skull Smashing" }, - { type: "familiar", name: "Ghost of Crimbo Commerce" }, - { type: "familiar", name: "Mosquito" }, - ]), -]; +const workers = parseWorkers(process.env); const itemFeatures = await compile("./features/items.feature");