Skip to content

Commit

Permalink
Load autospade workers from environment
Browse files Browse the repository at this point in the history
  • Loading branch information
gausie committed Jun 7, 2024
1 parent ce03ed3 commit 6ad903c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
11 changes: 11 additions & 0 deletions packages/autospade/Worker.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
import { Client } from "kol.js";

export function parseWorkers(environment: Record<string, string | undefined>) {
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 }
Expand Down
16 changes: 2 additions & 14 deletions packages/autospade/index.ts
Original file line number Diff line number Diff line change
@@ -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");

Expand Down

0 comments on commit 6ad903c

Please sign in to comment.