Skip to content

Commit

Permalink
Merge pull request #3098 from AIFlowML/fix-plugin-autonome-clean
Browse files Browse the repository at this point in the history
fix: plugin-autonome-v1
  • Loading branch information
tcm390 authored Jan 31, 2025
2 parents 8fa1da8 + 761d070 commit 7b864f4
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 18 deletions.
42 changes: 42 additions & 0 deletions packages/plugin-autonome/biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"$schema": "https://biomejs.dev/schemas/1.5.3/schema.json",
"organizeImports": {
"enabled": false
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"correctness": {
"noUnusedVariables": "error"
},
"suspicious": {
"noExplicitAny": "error"
},
"style": {
"useConst": "error",
"useImportType": "off"
}
}
},
"formatter": {
"enabled": true,
"indentStyle": "space",
"indentWidth": 4,
"lineWidth": 100
},
"javascript": {
"formatter": {
"quoteStyle": "single",

"trailingCommas": "es5"
}
},
"files": {
"ignore": [
"dist/**/*",
"extra/**/*",
"node_modules/**/*"
]
}
}
9 changes: 6 additions & 3 deletions packages/plugin-autonome/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,17 @@
"axios": "^1.7.9"
},
"devDependencies": {
"vitest": "^2.1.8"
"@biomejs/biome": "1.9.4"
},
"scripts": {
"build": "tsup --format esm --dts",
"dev": "tsup --format esm --dts --watch",
"test": "vitest run",
"test:watch": "vitest watch",
"test:coverage": "vitest run --coverage"

"lint": "biome lint .",
"lint:fix": "biome check --apply .",
"format": "biome format .",
"format:fix": "biome format --write ."
},
"peerDependencies": {
"form-data": "4.0.1",
Expand Down
35 changes: 20 additions & 15 deletions packages/plugin-autonome/src/actions/launchAgent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,17 @@ export interface LaunchAgentContent extends Content {
config: string;
}

function isLaunchAgentContent(content: any): content is LaunchAgentContent {
// Rafactoring
function isLaunchAgentContent(content: unknown): content is LaunchAgentContent {
elizaLogger.log("Content for launchAgent", content);
return typeof content.name === "string" && typeof content.config === "string";
return (
typeof content === "object" &&
content !== null &&
"name" in content &&
"config" in content &&
typeof (content as LaunchAgentContent).name === "string" &&
typeof (content as LaunchAgentContent).config === "string"
);
}

const launchTemplate = `Respond with a JSON markdown block containing only the extracted values. Use null for any values that cannot be determined.
Expand Down Expand Up @@ -54,16 +62,18 @@ export default {
callback?: HandlerCallback
): Promise<boolean> => {
elizaLogger.log("Starting LAUNCH_AGENT handler...");
// Initialize or update state
if (!state) {
state = (await runtime.composeState(message)) as State;

// Initialize or update state also in lanuchContext
let currentState = state;
if (!currentState) {
currentState = (await runtime.composeState(message)) as State;
} else {
state = await runtime.updateRecentMessageState(state);
currentState = await runtime.updateRecentMessageState(currentState);
}

// Compose launch context
const launchContext = composeContext({
state,
state: currentState,
template: launchTemplate,
});

Expand Down Expand Up @@ -113,25 +123,20 @@ export default {

try {
const resp = await sendPostRequest();
if (resp && resp.data && resp.data.app && resp.data.app.id) {
if (resp?.data?.app?.id) {
elizaLogger.log(
"Launching successful, please find your agent on"
);
elizaLogger.log(
"https://dev.autonome.fun/autonome/" +
resp.data.app.id +
"/details"
`https://dev.autonome.fun/autonome/${resp.data.app.id}/details`
);
}
if (callback) {
callback({
text: `Successfully launch agent ${content.name}`,
content: {
success: true,
appId:
"https://dev.autonome.fun/autonome/" +
resp.data.app.id +
"/details",
appId: `https://dev.autonome.fun/autonome/${resp.data.app.id}/details`,
},
});
}
Expand Down
1 change: 1 addition & 0 deletions packages/plugin-autonome/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { Plugin } from "@elizaos/core";
import launchAgent from "./actions/launchAgent";

// Action setup
export const autonomePlugin: Plugin = {
name: "autonome",
description: "Autonome Plugin for Eliza",
Expand Down

0 comments on commit 7b864f4

Please sign in to comment.