Skip to content

Commit

Permalink
Merge pull request elizaOS#955 from odilitime/rename-intiface
Browse files Browse the repository at this point in the history
chore: rename intiface plugin
  • Loading branch information
shakkernerd authored Dec 10, 2024
2 parents e8dab54 + d8368d4 commit cbb5680
Show file tree
Hide file tree
Showing 17 changed files with 38 additions and 38 deletions.
2 changes: 1 addition & 1 deletion agent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"@ai16z/plugin-0g": "workspace:*",
"@ai16z/plugin-aptos": "workspace:*",
"@ai16z/plugin-bootstrap": "workspace:*",
"@ai16z/plugin-buttplug": "workspace:*",
"@ai16z/plugin-intiface": "workspace:*",
"@ai16z/plugin-coinbase": "workspace:*",
"@ai16z/plugin-conflux": "workspace:*",
"@ai16z/plugin-evm": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion agent/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
import { zgPlugin } from "@ai16z/plugin-0g";
import createGoatPlugin from "@ai16z/plugin-goat";
import { bootstrapPlugin } from "@ai16z/plugin-bootstrap";
// import { buttplugPlugin } from "@ai16z/plugin-buttplug";
// import { intifacePlugin } from "@ai16z/plugin-intiface";
import {
coinbaseCommercePlugin,
coinbaseMassPaymentsPlugin,
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ export type Character = {
/** Optional configuration */
settings?: {
secrets?: { [key: string]: string };
buttplug?: boolean;
intiface?: boolean;
voice?: {
model?: string; // For VITS
url?: string; // Legacy VITS support
Expand Down Expand Up @@ -1155,7 +1155,7 @@ export enum ServiceType {
BROWSER = "browser",
SPEECH_GENERATION = "speech_generation",
PDF = "pdf",
BUTTPLUG = "buttplug",
INTIFACE = "intiface",
AWS_S3 = "aws_s3",
}

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@ai16z/plugin-buttplug",
"name": "@ai16z/plugin-intiface",
"version": "0.1.5-alpha.5",
"main": "dist/index.js",
"type": "module",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { IAgentRuntime } from "@ai16z/eliza";
import { z } from "zod";

export const buttplugEnvSchema = z
export const intifaceEnvSchema = z
.object({
INTIFACE_URL: z.string().default("ws://localhost:12345"),
INTIFACE_NAME: z.string().default("Eliza Buttplug Client"),
INTIFACE_NAME: z.string().default("Eliza Intiface Client"),
DEVICE_NAME: z.string().default("Lovense Nora"),
})
.refine(
Expand All @@ -20,11 +20,11 @@ export const buttplugEnvSchema = z
}
);

export type ButtplugConfig = z.infer<typeof buttplugEnvSchema>;
export type IntifaceConfig = z.infer<typeof intifaceEnvSchema>;

export async function validateButtplugConfig(
export async function validateIntifaceConfig(
runtime: IAgentRuntime
): Promise<ButtplugConfig> {
): Promise<IntifaceConfig> {
try {
const config = {
INTIFACE_URL:
Expand All @@ -36,14 +36,14 @@ export async function validateButtplugConfig(
runtime.getSetting("DEVICE_NAME") || process.env.DEVICE_NAME,
};

return buttplugEnvSchema.parse(config);
return intifaceEnvSchema.parse(config);
} catch (error) {
if (error instanceof z.ZodError) {
const errorMessages = error.errors
.map((err) => `${err.path.join(".")}: ${err.message}`)
.join("\n");
throw new Error(
`Buttplug configuration validation failed:\n${errorMessages}`
`Intiface configuration validation failed:\n${errorMessages}`
);
}
throw error;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ButtplugClient, ButtplugNodeWebsocketClientConnector } from "buttplug";
import { validateButtplugConfig, type ButtplugConfig } from "./environment";
import { validateIntifaceConfig, type IntifaceConfig } from "./environment";
import type {
Action,
HandlerCallback,
Expand All @@ -15,22 +15,22 @@ import {
shutdownIntifaceEngine,
} from "./utils";

export interface IButtplugService extends Service {
export interface IIntifaceService extends Service {
vibrate(strength: number, duration: number): Promise<void>;
rotate?(strength: number, duration: number): Promise<void>;
getBatteryLevel?(): Promise<number>;
isConnected(): boolean;
getDevices(): any[];
}

export class ButtplugService extends Service implements IButtplugService {
static serviceType: ServiceType = ServiceType.BUTTPLUG;
export class IntifaceService extends Service implements IIntifaceService {
static serviceType: ServiceType = ServiceType.INTIFACE;
private client: ButtplugClient;
private connected = false;
private devices: Map<string, any> = new Map();
private vibrateQueue: VibrateEvent[] = [];
private isProcessingQueue = false;
private config: ButtplugConfig | null = null;
private config: IntifaceConfig | null = null;
private maxVibrationIntensity = 1;
private rampUpAndDown = false;
private rampSteps = 20;
Expand Down Expand Up @@ -62,16 +62,16 @@ export class ButtplugService extends Service implements IButtplugService {
}
await shutdownIntifaceEngine();
} catch (error) {
console.error("[ButtplugService] Cleanup error:", error);
console.error("[IntifaceService] Cleanup error:", error);
}
}

getInstance(): IButtplugService {
getInstance(): IIntifaceService {
return this;
}

async initialize(runtime: IAgentRuntime): Promise<void> {
this.config = await validateButtplugConfig(runtime);
this.config = await validateIntifaceConfig(runtime);
this.preferredDeviceName = this.config.DEVICE_NAME;
this.client = new ButtplugClient(this.config.INTIFACE_NAME);

Expand Down Expand Up @@ -118,7 +118,7 @@ export class ButtplugService extends Service implements IButtplugService {
await new Promise((r) => setTimeout(r, 2000));
} else {
console.error(
"Failed to connect to Buttplug server after all retries:",
"Failed to connect to Intiface server after all retries:",
error
);
throw error;
Expand All @@ -144,7 +144,7 @@ export class ButtplugService extends Service implements IButtplugService {

private async ensureDeviceAvailable() {
if (!this.connected) {
throw new Error("Not connected to Buttplug server");
throw new Error("Not connected to Intiface server");
}

if (this.devices.size === 0) {
Expand Down Expand Up @@ -325,7 +325,7 @@ const vibrateAction: Action = {
description: "Control vibration intensity of connected devices",
validate: async (runtime: IAgentRuntime, _message: Memory) => {
try {
await validateButtplugConfig(runtime);
await validateIntifaceConfig(runtime);
return true;
} catch {
return false;
Expand All @@ -338,11 +338,11 @@ const vibrateAction: Action = {
options: any,
callback: HandlerCallback
) => {
const service = runtime.getService<IButtplugService>(
ServiceType.BUTTPLUG
const service = runtime.getService<IIntifaceService>(
ServiceType.INTIFACE
);
if (!service) {
throw new Error("Buttplug service not available");
throw new Error("Intiface service not available");
}

// Extract intensity and duration from message
Expand Down Expand Up @@ -435,7 +435,7 @@ const rotateAction: Action = {
description: "Control rotation intensity of connected devices",
validate: async (runtime: IAgentRuntime, _message: Memory) => {
try {
await validateButtplugConfig(runtime);
await validateIntifaceConfig(runtime);
return true;
} catch {
return false;
Expand All @@ -448,8 +448,8 @@ const rotateAction: Action = {
options: any,
callback: HandlerCallback
) => {
const service = runtime.getService<IButtplugService>(
ServiceType.BUTTPLUG
const service = runtime.getService<IIntifaceService>(
ServiceType.INTIFACE
);
if (!service || !service.rotate) {
throw new Error("Rotation not supported");
Expand Down Expand Up @@ -493,7 +493,7 @@ const batteryAction: Action = {
description: "Check battery level of connected devices",
validate: async (runtime: IAgentRuntime, _message: Memory) => {
try {
await validateButtplugConfig(runtime);
await validateIntifaceConfig(runtime);
return true;
} catch {
return false;
Expand All @@ -506,8 +506,8 @@ const batteryAction: Action = {
options: any,
callback: HandlerCallback
) => {
const service = runtime.getService<IButtplugService>(
ServiceType.BUTTPLUG
const service = runtime.getService<IIntifaceService>(
ServiceType.INTIFACE
);
if (!service || !service.getBatteryLevel) {
throw new Error("Battery level check not supported");
Expand Down Expand Up @@ -573,13 +573,13 @@ interface VibrateEvent {
deviceId?: number;
}

export const buttplugPlugin: Plugin = {
name: "buttplug",
export const intifacePlugin: Plugin = {
name: "intiface",
description: "Controls intimate hardware devices",
actions: [vibrateAction, rotateAction, batteryAction],
evaluators: [],
providers: [],
services: [new ButtplugService()],
services: [new IntifaceService()],
};

export default buttplugPlugin;
export default intifacePlugin;
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export async function isPortAvailable(port: number): Promise<boolean> {
export async function startIntifaceEngine(): Promise<void> {
const configPath = path.join(
__dirname,
"../src/buttplug-user-device-config.json"
"../src/intiface-user-device-config.json"
);
try {
const child = spawn(
Expand All @@ -34,7 +34,7 @@ export async function startIntifaceEngine(): Promise<void> {
"12345",
"--use-bluetooth-le",
"--server-name",
"Eliza Buttplugin Server",
"Eliza Intiface Server",
"--use-device-websocket-server",
"--user-device-config-file",
configPath,
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit cbb5680

Please sign in to comment.