@elizaos/cli 1.2.11-beta.8 → 1.2.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-TX2IPIRH.js → chunk-2ALAPQLV.js} +22 -15
- package/dist/{chunk-BLRB6AXA.js → chunk-OXCJTWT3.js} +3 -1
- package/dist/{chunk-XIKLSITV.js → chunk-WEAYAAIM.js} +2 -2
- package/dist/commands/agent/actions/index.js +1 -1
- package/dist/commands/agent/index.js +1 -1
- package/dist/commands/create/actions/index.js +2 -2
- package/dist/commands/create/index.js +3 -3
- package/dist/index.js +10 -10
- package/dist/{registry-6SICSJM2.js → registry-N626N4VG.js} +1 -1
- package/dist/templates/plugin-quick-starter/package.json +1 -1
- package/dist/templates/plugin-starter/package.json +1 -1
- package/dist/templates/project-starter/package.json +4 -4
- package/dist/templates/project-tee-starter/package.json +3 -3
- package/dist/{utils-HHN2DEEB.js → utils-H66532NB.js} +1 -1
- package/package.json +5 -5
- package/templates/plugin-quick-starter/package.json +2 -2
- package/templates/plugin-starter/package.json +2 -2
- package/templates/project-starter/package.json +5 -5
- package/templates/project-tee-starter/package.json +4 -4
- package/dist/templates/plugin-quick-starter/dist/index.js +0 -195
- package/dist/templates/plugin-quick-starter/dist/index.js.map +0 -1
- package/templates/plugin-quick-starter/dist/index.d.ts +0 -13
- package/templates/plugin-quick-starter/dist/index.js +0 -195
- package/templates/plugin-quick-starter/dist/index.js.map +0 -1
|
@@ -2761,7 +2761,7 @@ async function getGitHubCredentials() {
|
|
|
2761
2761
|
}
|
|
2762
2762
|
logger10.warn("Invalid GitHub token found in environment variables");
|
|
2763
2763
|
}
|
|
2764
|
-
const { getGitHubToken: getGitHubToken2 } = await import("./registry-
|
|
2764
|
+
const { getGitHubToken: getGitHubToken2 } = await import("./registry-N626N4VG.js");
|
|
2765
2765
|
const token = await getGitHubToken2() || void 0;
|
|
2766
2766
|
if (token) {
|
|
2767
2767
|
const isValid2 = await validateGitHubToken(token);
|
|
@@ -4276,6 +4276,7 @@ function isTestOrCiEnvironment() {
|
|
|
4276
4276
|
process.env.ELIZA_TEST_MODE === "1",
|
|
4277
4277
|
process.env.ELIZA_CLI_TEST_MODE === "true",
|
|
4278
4278
|
process.env.ELIZA_SKIP_LOCAL_CLI_DELEGATION === "true",
|
|
4279
|
+
process.env.ELIZA_DISABLE_LOCAL_CLI_DELEGATION === "true",
|
|
4279
4280
|
process.env.BUN_TEST === "true",
|
|
4280
4281
|
process.env.VITEST === "true",
|
|
4281
4282
|
process.env.JEST_WORKER_ID !== void 0,
|
|
@@ -4321,6 +4322,14 @@ async function tryDelegateToLocalCli() {
|
|
|
4321
4322
|
logger19.debug("No local CLI found, using global installation");
|
|
4322
4323
|
return false;
|
|
4323
4324
|
}
|
|
4325
|
+
if (process.env._ELIZA_CLI_DELEGATION_DEPTH) {
|
|
4326
|
+
const depth = parseInt(process.env._ELIZA_CLI_DELEGATION_DEPTH, 10);
|
|
4327
|
+
if (depth > 0) {
|
|
4328
|
+
logger19.debug("Delegation depth exceeded, preventing infinite loop");
|
|
4329
|
+
return false;
|
|
4330
|
+
}
|
|
4331
|
+
}
|
|
4332
|
+
process.env._ELIZA_CLI_DELEGATION_DEPTH = "1";
|
|
4324
4333
|
await delegateToLocalCli(localCliPath);
|
|
4325
4334
|
return true;
|
|
4326
4335
|
} catch (error) {
|
|
@@ -4349,7 +4358,8 @@ import path19 from "path";
|
|
|
4349
4358
|
import { existsSync as existsSync16 } from "fs";
|
|
4350
4359
|
var ModuleLoader = class {
|
|
4351
4360
|
require;
|
|
4352
|
-
|
|
4361
|
+
asyncCache = /* @__PURE__ */ new Map();
|
|
4362
|
+
syncCache = /* @__PURE__ */ new Map();
|
|
4353
4363
|
projectPath;
|
|
4354
4364
|
constructor(projectPath) {
|
|
4355
4365
|
this.projectPath = projectPath || this.detectProjectPath();
|
|
@@ -4377,9 +4387,9 @@ var ModuleLoader = class {
|
|
|
4377
4387
|
* @throws Error if the module cannot be found in the project
|
|
4378
4388
|
*/
|
|
4379
4389
|
async load(moduleName) {
|
|
4380
|
-
if (this.
|
|
4390
|
+
if (this.asyncCache.has(moduleName)) {
|
|
4381
4391
|
logger20.debug(`Using cached module: ${moduleName}`);
|
|
4382
|
-
return this.
|
|
4392
|
+
return this.asyncCache.get(moduleName);
|
|
4383
4393
|
}
|
|
4384
4394
|
try {
|
|
4385
4395
|
const localModulePath = path19.join(this.projectPath, "node_modules", moduleName);
|
|
@@ -4395,10 +4405,8 @@ var ModuleLoader = class {
|
|
|
4395
4405
|
logger20.warn(`Expected local module but resolved to global: ${modulePath}`);
|
|
4396
4406
|
}
|
|
4397
4407
|
const module = await import(pathToFileURL(modulePath).href);
|
|
4398
|
-
this.
|
|
4399
|
-
logger20.
|
|
4400
|
-
`Loaded ${moduleName} from ${isLocalModule ? "local" : "global"} installation`
|
|
4401
|
-
);
|
|
4408
|
+
this.asyncCache.set(moduleName, module);
|
|
4409
|
+
logger20.info(`Loaded ${moduleName} from ${isLocalModule ? "local" : "global"} installation`);
|
|
4402
4410
|
return module;
|
|
4403
4411
|
} catch (error) {
|
|
4404
4412
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
@@ -4421,9 +4429,9 @@ Original error: ${errorMessage}`
|
|
|
4421
4429
|
* @throws Error if the module cannot be found in the project
|
|
4422
4430
|
*/
|
|
4423
4431
|
loadSync(moduleName) {
|
|
4424
|
-
if (this.
|
|
4432
|
+
if (this.syncCache.has(moduleName)) {
|
|
4425
4433
|
logger20.debug(`Using cached module: ${moduleName}`);
|
|
4426
|
-
return this.
|
|
4434
|
+
return this.syncCache.get(moduleName);
|
|
4427
4435
|
}
|
|
4428
4436
|
try {
|
|
4429
4437
|
const localModulePath = path19.join(this.projectPath, "node_modules", moduleName);
|
|
@@ -4439,10 +4447,8 @@ Original error: ${errorMessage}`
|
|
|
4439
4447
|
logger20.warn(`Expected local module but resolved to global: ${modulePath}`);
|
|
4440
4448
|
}
|
|
4441
4449
|
const module = this.require(modulePath);
|
|
4442
|
-
this.
|
|
4443
|
-
logger20.
|
|
4444
|
-
`Loaded ${moduleName} from ${isLocalModule ? "local" : "global"} installation`
|
|
4445
|
-
);
|
|
4450
|
+
this.syncCache.set(moduleName, module);
|
|
4451
|
+
logger20.info(`Loaded ${moduleName} from ${isLocalModule ? "local" : "global"} installation`);
|
|
4446
4452
|
return module;
|
|
4447
4453
|
} catch (error) {
|
|
4448
4454
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
@@ -4482,7 +4488,8 @@ Original error: ${errorMessage}`
|
|
|
4482
4488
|
* Clear the module cache. Useful for testing or hot reloading scenarios.
|
|
4483
4489
|
*/
|
|
4484
4490
|
clearCache() {
|
|
4485
|
-
this.
|
|
4491
|
+
this.asyncCache.clear();
|
|
4492
|
+
this.syncCache.clear();
|
|
4486
4493
|
}
|
|
4487
4494
|
/**
|
|
4488
4495
|
* Get the resolved path for a module without loading it.
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
promptAndStorePostgresUrl,
|
|
16
16
|
runTasks,
|
|
17
17
|
setupPgLite
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-2ALAPQLV.js";
|
|
19
19
|
|
|
20
20
|
// src/characters/eliza.ts
|
|
21
21
|
var baseCharacter = {
|
|
@@ -856,6 +856,7 @@ To use this agent:`);
|
|
|
856
856
|
console.info(` elizaos agent start --path ${agentFilePath}`);
|
|
857
857
|
}
|
|
858
858
|
async function createTEEProject(projectName, targetDir, database, aiModel, embeddingModel, isNonInteractive = false) {
|
|
859
|
+
delete process.env.PGLITE_DATA_DIR;
|
|
859
860
|
const teeTargetDir = join(targetDir, projectName);
|
|
860
861
|
const dirResult = await validateTargetDirectory(teeTargetDir);
|
|
861
862
|
if (!dirResult.isValid) {
|
|
@@ -901,6 +902,7 @@ Next steps:`);
|
|
|
901
902
|
});
|
|
902
903
|
}
|
|
903
904
|
async function createProject(projectName, targetDir, database, aiModel, embeddingModel, isNonInteractive = false) {
|
|
905
|
+
delete process.env.PGLITE_DATA_DIR;
|
|
904
906
|
const projectTargetDir = projectName === "." ? targetDir : join(targetDir, projectName);
|
|
905
907
|
const dirResult = await validateTargetDirectory(projectTargetDir);
|
|
906
908
|
if (!dirResult.isValid) {
|
|
@@ -9,11 +9,11 @@ import {
|
|
|
9
9
|
selectEmbeddingModel,
|
|
10
10
|
validateCreateOptions,
|
|
11
11
|
validateProjectName
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-OXCJTWT3.js";
|
|
13
13
|
import {
|
|
14
14
|
displayBanner,
|
|
15
15
|
handleError
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-2ALAPQLV.js";
|
|
17
17
|
|
|
18
18
|
// src/commands/create/index.ts
|
|
19
19
|
import { Command } from "commander";
|
|
@@ -8,8 +8,8 @@ import {
|
|
|
8
8
|
setupAIModelConfig,
|
|
9
9
|
setupEmbeddingModelConfig,
|
|
10
10
|
setupProjectEnvironment
|
|
11
|
-
} from "../../../chunk-
|
|
12
|
-
import "../../../chunk-
|
|
11
|
+
} from "../../../chunk-OXCJTWT3.js";
|
|
12
|
+
import "../../../chunk-2ALAPQLV.js";
|
|
13
13
|
import "../../../chunk-FDEDLANP.js";
|
|
14
14
|
import "../../../chunk-4O6EZU37.js";
|
|
15
15
|
import "../../../chunk-D3Q2UZLZ.js";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
create
|
|
3
|
-
} from "../../chunk-
|
|
4
|
-
import "../../chunk-
|
|
5
|
-
import "../../chunk-
|
|
3
|
+
} from "../../chunk-WEAYAAIM.js";
|
|
4
|
+
import "../../chunk-OXCJTWT3.js";
|
|
5
|
+
import "../../chunk-2ALAPQLV.js";
|
|
6
6
|
import "../../chunk-FDEDLANP.js";
|
|
7
7
|
import "../../chunk-4O6EZU37.js";
|
|
8
8
|
import "../../chunk-D3Q2UZLZ.js";
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
import {
|
|
3
3
|
create
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-WEAYAAIM.js";
|
|
5
5
|
import {
|
|
6
6
|
getElizaCharacter
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-OXCJTWT3.js";
|
|
8
8
|
import {
|
|
9
9
|
TestRunner,
|
|
10
10
|
UserEnvironment,
|
|
@@ -43,7 +43,7 @@ import {
|
|
|
43
43
|
testPublishToNpm,
|
|
44
44
|
tryDelegateToLocalCli,
|
|
45
45
|
validateDataDir
|
|
46
|
-
} from "./chunk-
|
|
46
|
+
} from "./chunk-2ALAPQLV.js";
|
|
47
47
|
import {
|
|
48
48
|
configureEmojis,
|
|
49
49
|
emoji,
|
|
@@ -289,24 +289,24 @@ function setupEnvironment() {
|
|
|
289
289
|
async function startServerProcess(args = []) {
|
|
290
290
|
await stopServerProcess();
|
|
291
291
|
console.info("Starting server...");
|
|
292
|
-
const nodeExecutable =
|
|
292
|
+
const nodeExecutable = process.execPath;
|
|
293
293
|
const localCliPath = await getLocalCliPath();
|
|
294
294
|
let scriptPath;
|
|
295
295
|
if (localCliPath) {
|
|
296
296
|
console.info("Using local @elizaos/cli installation");
|
|
297
297
|
scriptPath = localCliPath;
|
|
298
298
|
} else {
|
|
299
|
-
scriptPath =
|
|
299
|
+
scriptPath = process.argv[1];
|
|
300
300
|
}
|
|
301
301
|
const env2 = setupEnvironment();
|
|
302
|
-
const
|
|
302
|
+
const childProcess = Bun.spawn([nodeExecutable, scriptPath, "start", ...args], {
|
|
303
303
|
stdio: ["inherit", "inherit", "inherit"],
|
|
304
304
|
env: env2,
|
|
305
|
-
cwd:
|
|
305
|
+
cwd: process.cwd()
|
|
306
306
|
});
|
|
307
|
-
serverState.process =
|
|
307
|
+
serverState.process = childProcess;
|
|
308
308
|
serverState.isRunning = true;
|
|
309
|
-
|
|
309
|
+
childProcess.exited.then((exitCode) => {
|
|
310
310
|
if (exitCode !== 0) {
|
|
311
311
|
console.warn(`Server process exited with code ${exitCode}`);
|
|
312
312
|
} else {
|
|
@@ -4981,7 +4981,7 @@ async function installPluginDependencies(projectInfo) {
|
|
|
4981
4981
|
};
|
|
4982
4982
|
await fs11.promises.writeFile(packageJsonPath, JSON.stringify(packageJsonContent, null, 2));
|
|
4983
4983
|
}
|
|
4984
|
-
const { installPlugin: installPlugin2 } = await import("./utils-
|
|
4984
|
+
const { installPlugin: installPlugin2 } = await import("./utils-H66532NB.js");
|
|
4985
4985
|
for (const dependency of project.pluginModule.dependencies) {
|
|
4986
4986
|
await installPlugin2(dependency, pluginsDir);
|
|
4987
4987
|
const dependencyPath = path25.join(pluginsDir, "node_modules", dependency);
|
|
@@ -28,10 +28,10 @@
|
|
|
28
28
|
"dist"
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@elizaos/cli": "1.2.
|
|
32
|
-
"@elizaos/core": "1.2.
|
|
33
|
-
"@elizaos/plugin-bootstrap": "1.2.
|
|
34
|
-
"@elizaos/plugin-sql": "1.2.
|
|
31
|
+
"@elizaos/cli": "1.2.12",
|
|
32
|
+
"@elizaos/core": "1.2.12",
|
|
33
|
+
"@elizaos/plugin-bootstrap": "1.2.12",
|
|
34
|
+
"@elizaos/plugin-sql": "1.2.12",
|
|
35
35
|
"@tanstack/react-query": "^5.29.0",
|
|
36
36
|
"clsx": "^2.1.1",
|
|
37
37
|
"react": "^18.3.1",
|
|
@@ -33,10 +33,10 @@
|
|
|
33
33
|
"GUIDE.md"
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@elizaos/cli": "1.2.
|
|
37
|
-
"@elizaos/core": "1.2.
|
|
36
|
+
"@elizaos/cli": "1.2.12",
|
|
37
|
+
"@elizaos/core": "1.2.12",
|
|
38
38
|
"@elizaos/plugin-redpill": "1.0.3",
|
|
39
|
-
"@elizaos/plugin-sql": "1.2.
|
|
39
|
+
"@elizaos/plugin-sql": "1.2.12",
|
|
40
40
|
"@phala/dstack-sdk": "0.1.11",
|
|
41
41
|
"@solana/web3.js": "1.98.2",
|
|
42
42
|
"viem": "2.30.1",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elizaos/cli",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.12",
|
|
4
4
|
"description": "elizaOS CLI - Manage your AI agents and plugins",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
@@ -69,14 +69,14 @@
|
|
|
69
69
|
"typescript": "5.8.3",
|
|
70
70
|
"vite": "^6.3.5"
|
|
71
71
|
},
|
|
72
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "991b811b95d08df421efc4f516d0cfb52c4a83b3",
|
|
73
73
|
"dependencies": {
|
|
74
74
|
"@anthropic-ai/claude-code": "^1.0.35",
|
|
75
75
|
"@anthropic-ai/sdk": "^0.54.0",
|
|
76
76
|
"@clack/prompts": "^0.11.0",
|
|
77
|
-
"@elizaos/core": "1.2.
|
|
78
|
-
"@elizaos/plugin-sql": "1.2.
|
|
79
|
-
"@elizaos/server": "1.2.
|
|
77
|
+
"@elizaos/core": "1.2.12",
|
|
78
|
+
"@elizaos/plugin-sql": "1.2.12",
|
|
79
|
+
"@elizaos/server": "1.2.12",
|
|
80
80
|
"bun": "^1.2.17",
|
|
81
81
|
"chalk": "^5.3.0",
|
|
82
82
|
"chokidar": "^4.0.3",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"tsup.config.ts"
|
|
41
41
|
],
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@elizaos/core": "1.2.
|
|
43
|
+
"@elizaos/core": "1.2.12",
|
|
44
44
|
"zod": "^3.24.4"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
@@ -73,4 +73,4 @@
|
|
|
73
73
|
}
|
|
74
74
|
},
|
|
75
75
|
"gitHead": "d5bd5c43bfebeb7ac02f9e029f924cb6cd5c2ec7"
|
|
76
|
-
}
|
|
76
|
+
}
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"tsup.config.ts"
|
|
41
41
|
],
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@elizaos/core": "1.2.
|
|
43
|
+
"@elizaos/core": "1.2.12",
|
|
44
44
|
"@tanstack/react-query": "^5.80.7",
|
|
45
45
|
"clsx": "^2.1.1",
|
|
46
46
|
"tailwind-merge": "^3.3.1",
|
|
@@ -88,4 +88,4 @@
|
|
|
88
88
|
}
|
|
89
89
|
},
|
|
90
90
|
"gitHead": "d5bd5c43bfebeb7ac02f9e029f924cb6cd5c2ec7"
|
|
91
|
-
}
|
|
91
|
+
}
|
|
@@ -28,10 +28,10 @@
|
|
|
28
28
|
"dist"
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@elizaos/cli": "1.2.
|
|
32
|
-
"@elizaos/core": "1.2.
|
|
33
|
-
"@elizaos/plugin-bootstrap": "1.2.
|
|
34
|
-
"@elizaos/plugin-sql": "1.2.
|
|
31
|
+
"@elizaos/cli": "1.2.12",
|
|
32
|
+
"@elizaos/core": "1.2.12",
|
|
33
|
+
"@elizaos/plugin-bootstrap": "1.2.12",
|
|
34
|
+
"@elizaos/plugin-sql": "1.2.12",
|
|
35
35
|
"@tanstack/react-query": "^5.29.0",
|
|
36
36
|
"clsx": "^2.1.1",
|
|
37
37
|
"react": "^18.3.1",
|
|
@@ -76,4 +76,4 @@
|
|
|
76
76
|
"access": "public"
|
|
77
77
|
},
|
|
78
78
|
"gitHead": "b165ad83e5f7a21bc1edbd83374ca087e3cd6b33"
|
|
79
|
-
}
|
|
79
|
+
}
|
|
@@ -33,10 +33,10 @@
|
|
|
33
33
|
"GUIDE.md"
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@elizaos/cli": "1.2.
|
|
37
|
-
"@elizaos/core": "1.2.
|
|
36
|
+
"@elizaos/cli": "1.2.12",
|
|
37
|
+
"@elizaos/core": "1.2.12",
|
|
38
38
|
"@elizaos/plugin-redpill": "1.0.3",
|
|
39
|
-
"@elizaos/plugin-sql": "1.2.
|
|
39
|
+
"@elizaos/plugin-sql": "1.2.12",
|
|
40
40
|
"@phala/dstack-sdk": "0.1.11",
|
|
41
41
|
"@solana/web3.js": "1.98.2",
|
|
42
42
|
"viem": "2.30.1",
|
|
@@ -71,4 +71,4 @@
|
|
|
71
71
|
"description": "Mr. TEE: Project starter for elizaOS with TEE capabilities"
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
|
-
}
|
|
74
|
+
}
|
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
// src/plugin.ts
|
|
2
|
-
import {
|
|
3
|
-
ModelType,
|
|
4
|
-
Service,
|
|
5
|
-
logger,
|
|
6
|
-
EventType
|
|
7
|
-
} from "@elizaos/core";
|
|
8
|
-
import { z } from "zod";
|
|
9
|
-
var configSchema = z.object({
|
|
10
|
-
EXAMPLE_PLUGIN_VARIABLE: z.string().min(1, "Example plugin variable is not provided").optional().transform((val) => {
|
|
11
|
-
if (!val) {
|
|
12
|
-
logger.warn("Example plugin variable is not provided (this is expected)");
|
|
13
|
-
}
|
|
14
|
-
return val;
|
|
15
|
-
})
|
|
16
|
-
});
|
|
17
|
-
var helloWorldAction = {
|
|
18
|
-
name: "HELLO_WORLD",
|
|
19
|
-
similes: ["GREET", "SAY_HELLO"],
|
|
20
|
-
description: "Responds with a simple hello world message",
|
|
21
|
-
validate: async (_runtime, _message, _state) => {
|
|
22
|
-
return true;
|
|
23
|
-
},
|
|
24
|
-
handler: async (_runtime, message, _state, _options = {}, callback, _responses) => {
|
|
25
|
-
try {
|
|
26
|
-
logger.info("Handling HELLO_WORLD action");
|
|
27
|
-
const responseContent = {
|
|
28
|
-
text: "hello world!",
|
|
29
|
-
actions: ["HELLO_WORLD"],
|
|
30
|
-
source: message.content.source
|
|
31
|
-
};
|
|
32
|
-
if (callback) {
|
|
33
|
-
await callback(responseContent);
|
|
34
|
-
}
|
|
35
|
-
return {
|
|
36
|
-
text: "hello world!",
|
|
37
|
-
success: true,
|
|
38
|
-
data: {
|
|
39
|
-
actions: ["HELLO_WORLD"],
|
|
40
|
-
source: message.content.source
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
} catch (error) {
|
|
44
|
-
logger.error("Error in HELLO_WORLD action:", error);
|
|
45
|
-
return {
|
|
46
|
-
success: false,
|
|
47
|
-
error: error instanceof Error ? error : new Error(String(error))
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
examples: [
|
|
52
|
-
[
|
|
53
|
-
{
|
|
54
|
-
name: "{{name1}}",
|
|
55
|
-
content: {
|
|
56
|
-
text: "Can you say hello?"
|
|
57
|
-
}
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
name: "{{name2}}",
|
|
61
|
-
content: {
|
|
62
|
-
text: "hello world!",
|
|
63
|
-
actions: ["HELLO_WORLD"]
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
]
|
|
67
|
-
]
|
|
68
|
-
};
|
|
69
|
-
var helloWorldProvider = {
|
|
70
|
-
name: "HELLO_WORLD_PROVIDER",
|
|
71
|
-
description: "A simple example provider",
|
|
72
|
-
get: async (_runtime, _message, _state) => {
|
|
73
|
-
return {
|
|
74
|
-
text: "I am a provider",
|
|
75
|
-
values: {},
|
|
76
|
-
data: {}
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
var StarterService = class _StarterService extends Service {
|
|
81
|
-
static serviceType = "starter";
|
|
82
|
-
capabilityDescription = "This is a starter service which is attached to the agent through the starter plugin.";
|
|
83
|
-
constructor(runtime) {
|
|
84
|
-
super(runtime);
|
|
85
|
-
}
|
|
86
|
-
static async start(runtime) {
|
|
87
|
-
logger.info("Starting starter service");
|
|
88
|
-
const service = new _StarterService(runtime);
|
|
89
|
-
return service;
|
|
90
|
-
}
|
|
91
|
-
static async stop(runtime) {
|
|
92
|
-
logger.info("Stopping starter service");
|
|
93
|
-
const service = runtime.getService(_StarterService.serviceType);
|
|
94
|
-
if (!service) {
|
|
95
|
-
throw new Error("Starter service not found");
|
|
96
|
-
}
|
|
97
|
-
if ("stop" in service && typeof service.stop === "function") {
|
|
98
|
-
await service.stop();
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
async stop() {
|
|
102
|
-
logger.info("Starter service stopped");
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
var starterPlugin = {
|
|
106
|
-
name: "plugin-quick-starter",
|
|
107
|
-
description: "Quick backend-only plugin template for elizaOS",
|
|
108
|
-
config: {
|
|
109
|
-
EXAMPLE_PLUGIN_VARIABLE: process.env.EXAMPLE_PLUGIN_VARIABLE
|
|
110
|
-
},
|
|
111
|
-
async init(config) {
|
|
112
|
-
logger.info("Initializing plugin-quick-starter");
|
|
113
|
-
try {
|
|
114
|
-
const validatedConfig = await configSchema.parseAsync(config);
|
|
115
|
-
for (const [key, value] of Object.entries(validatedConfig)) {
|
|
116
|
-
if (value) process.env[key] = value;
|
|
117
|
-
}
|
|
118
|
-
} catch (error) {
|
|
119
|
-
if (error instanceof z.ZodError) {
|
|
120
|
-
throw new Error(
|
|
121
|
-
`Invalid plugin configuration: ${error.errors.map((e) => e.message).join(", ")}`
|
|
122
|
-
);
|
|
123
|
-
}
|
|
124
|
-
throw error;
|
|
125
|
-
}
|
|
126
|
-
},
|
|
127
|
-
models: {
|
|
128
|
-
[ModelType.TEXT_SMALL]: async (_runtime, { prompt, stopSequences = [] }) => {
|
|
129
|
-
return "Never gonna give you up, never gonna let you down, never gonna run around and desert you...";
|
|
130
|
-
},
|
|
131
|
-
[ModelType.TEXT_LARGE]: async (_runtime, {
|
|
132
|
-
prompt,
|
|
133
|
-
stopSequences = [],
|
|
134
|
-
maxTokens = 8192,
|
|
135
|
-
temperature = 0.7,
|
|
136
|
-
frequencyPenalty = 0.7,
|
|
137
|
-
presencePenalty = 0.7
|
|
138
|
-
}) => {
|
|
139
|
-
return "Never gonna make you cry, never gonna say goodbye, never gonna tell a lie and hurt you...";
|
|
140
|
-
}
|
|
141
|
-
},
|
|
142
|
-
routes: [
|
|
143
|
-
{
|
|
144
|
-
name: "api-status",
|
|
145
|
-
path: "/api/status",
|
|
146
|
-
type: "GET",
|
|
147
|
-
handler: async (_req, res) => {
|
|
148
|
-
res.json({
|
|
149
|
-
status: "ok",
|
|
150
|
-
plugin: "quick-starter",
|
|
151
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
],
|
|
156
|
-
events: {
|
|
157
|
-
[EventType.MESSAGE_RECEIVED]: [
|
|
158
|
-
async (params) => {
|
|
159
|
-
logger.debug("MESSAGE_RECEIVED event received");
|
|
160
|
-
logger.debug("Message:", params.message);
|
|
161
|
-
}
|
|
162
|
-
],
|
|
163
|
-
[EventType.VOICE_MESSAGE_RECEIVED]: [
|
|
164
|
-
async (params) => {
|
|
165
|
-
logger.debug("VOICE_MESSAGE_RECEIVED event received");
|
|
166
|
-
logger.debug("Message:", params.message);
|
|
167
|
-
}
|
|
168
|
-
],
|
|
169
|
-
[EventType.WORLD_CONNECTED]: [
|
|
170
|
-
async (params) => {
|
|
171
|
-
logger.debug("WORLD_CONNECTED event received");
|
|
172
|
-
logger.debug("World:", params.world);
|
|
173
|
-
}
|
|
174
|
-
],
|
|
175
|
-
[EventType.WORLD_JOINED]: [
|
|
176
|
-
async (params) => {
|
|
177
|
-
logger.debug("WORLD_JOINED event received");
|
|
178
|
-
logger.debug("World:", params.world);
|
|
179
|
-
}
|
|
180
|
-
]
|
|
181
|
-
},
|
|
182
|
-
services: [StarterService],
|
|
183
|
-
actions: [helloWorldAction],
|
|
184
|
-
providers: [helloWorldProvider]
|
|
185
|
-
// dependencies: ['@elizaos/plugin-knowledge'], <--- plugin dependecies go here (if requires another plugin)
|
|
186
|
-
};
|
|
187
|
-
|
|
188
|
-
// src/index.ts
|
|
189
|
-
var index_default = starterPlugin;
|
|
190
|
-
export {
|
|
191
|
-
StarterService,
|
|
192
|
-
index_default as default,
|
|
193
|
-
starterPlugin
|
|
194
|
-
};
|
|
195
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/plugin.ts","../src/index.ts"],"sourcesContent":["import type { Plugin } from '@elizaos/core';\nimport {\n type Action,\n type ActionResult,\n type Content,\n type GenerateTextParams,\n type HandlerCallback,\n type IAgentRuntime,\n type Memory,\n ModelType,\n type Provider,\n type ProviderResult,\n Service,\n type State,\n logger,\n type MessagePayload,\n type WorldPayload,\n EventType,\n} from '@elizaos/core';\nimport { z } from 'zod';\n\n/**\n * Defines the configuration schema for a plugin, including the validation rules for the plugin name.\n *\n * @type {import('zod').ZodObject<{ EXAMPLE_PLUGIN_VARIABLE: import('zod').ZodString }>}\n */\nconst configSchema = z.object({\n EXAMPLE_PLUGIN_VARIABLE: z\n .string()\n .min(1, 'Example plugin variable is not provided')\n .optional()\n .transform((val) => {\n if (!val) {\n logger.warn('Example plugin variable is not provided (this is expected)');\n }\n return val;\n }),\n});\n\n/**\n * Example HelloWorld action\n * This demonstrates the simplest possible action structure\n */\n/**\n * Action representing a hello world message.\n * @typedef {Object} Action\n * @property {string} name - The name of the action.\n * @property {string[]} similes - An array of related actions.\n * @property {string} description - A brief description of the action.\n * @property {Function} validate - Asynchronous function to validate the action.\n * @property {Function} handler - Asynchronous function to handle the action and generate a response.\n * @property {Object[]} examples - An array of example inputs and expected outputs for the action.\n */\nconst helloWorldAction: Action = {\n name: 'HELLO_WORLD',\n similes: ['GREET', 'SAY_HELLO'],\n description: 'Responds with a simple hello world message',\n\n validate: async (\n _runtime: IAgentRuntime,\n _message: Memory,\n _state: State | undefined\n ): Promise<boolean> => {\n // Always valid\n return true;\n },\n\n handler: async (\n _runtime: IAgentRuntime,\n message: Memory,\n _state: State | undefined,\n _options: Record<string, unknown> = {},\n callback?: HandlerCallback,\n _responses?: Memory[]\n ): Promise<ActionResult> => {\n try {\n logger.info('Handling HELLO_WORLD action');\n\n // Simple response content for callback\n const responseContent: Content = {\n text: 'hello world!',\n actions: ['HELLO_WORLD'],\n source: message.content.source,\n };\n\n // Call back with the hello world message if callback is provided\n if (callback) {\n await callback(responseContent);\n }\n\n // Return ActionResult\n return {\n text: 'hello world!',\n success: true,\n data: {\n actions: ['HELLO_WORLD'],\n source: message.content.source,\n },\n };\n } catch (error) {\n logger.error('Error in HELLO_WORLD action:', error);\n return {\n success: false,\n error: error instanceof Error ? error : new Error(String(error)),\n };\n }\n },\n\n examples: [\n [\n {\n name: '{{name1}}',\n content: {\n text: 'Can you say hello?',\n },\n },\n {\n name: '{{name2}}',\n content: {\n text: 'hello world!',\n actions: ['HELLO_WORLD'],\n },\n },\n ],\n ],\n};\n\n/**\n * Example Hello World Provider\n * This demonstrates the simplest possible provider implementation\n */\nconst helloWorldProvider: Provider = {\n name: 'HELLO_WORLD_PROVIDER',\n description: 'A simple example provider',\n\n get: async (\n _runtime: IAgentRuntime,\n _message: Memory,\n _state: State | undefined\n ): Promise<ProviderResult> => {\n return {\n text: 'I am a provider',\n values: {},\n data: {},\n };\n },\n};\n\nexport class StarterService extends Service {\n static override serviceType = 'starter';\n\n override capabilityDescription =\n 'This is a starter service which is attached to the agent through the starter plugin.';\n\n constructor(runtime: IAgentRuntime) {\n super(runtime);\n }\n\n static override async start(runtime: IAgentRuntime): Promise<Service> {\n logger.info('Starting starter service');\n const service = new StarterService(runtime);\n return service;\n }\n\n static override async stop(runtime: IAgentRuntime): Promise<void> {\n logger.info('Stopping starter service');\n const service = runtime.getService(StarterService.serviceType);\n if (!service) {\n throw new Error('Starter service not found');\n }\n if ('stop' in service && typeof service.stop === 'function') {\n await service.stop();\n }\n }\n\n override async stop(): Promise<void> {\n logger.info('Starter service stopped');\n }\n}\n\nexport const starterPlugin: Plugin = {\n name: 'plugin-quick-starter',\n description: 'Quick backend-only plugin template for elizaOS',\n config: {\n EXAMPLE_PLUGIN_VARIABLE: process.env.EXAMPLE_PLUGIN_VARIABLE,\n },\n async init(config: Record<string, string>) {\n logger.info('Initializing plugin-quick-starter');\n try {\n const validatedConfig = await configSchema.parseAsync(config);\n\n // Set all environment variables at once\n for (const [key, value] of Object.entries(validatedConfig)) {\n if (value) process.env[key] = value;\n }\n } catch (error) {\n if (error instanceof z.ZodError) {\n throw new Error(\n `Invalid plugin configuration: ${error.errors.map((e) => e.message).join(', ')}`\n );\n }\n throw error;\n }\n },\n models: {\n [ModelType.TEXT_SMALL]: async (\n _runtime,\n { prompt, stopSequences = [] }: GenerateTextParams\n ) => {\n return 'Never gonna give you up, never gonna let you down, never gonna run around and desert you...';\n },\n [ModelType.TEXT_LARGE]: async (\n _runtime,\n {\n prompt,\n stopSequences = [],\n maxTokens = 8192,\n temperature = 0.7,\n frequencyPenalty = 0.7,\n presencePenalty = 0.7,\n }: GenerateTextParams\n ) => {\n return 'Never gonna make you cry, never gonna say goodbye, never gonna tell a lie and hurt you...';\n },\n },\n routes: [\n {\n name: 'api-status',\n path: '/api/status',\n type: 'GET',\n handler: async (_req: any, res: any) => {\n res.json({\n status: 'ok',\n plugin: 'quick-starter',\n timestamp: new Date().toISOString(),\n });\n },\n },\n ],\n events: {\n [EventType.MESSAGE_RECEIVED]: [\n async (params: MessagePayload) => {\n logger.debug('MESSAGE_RECEIVED event received');\n logger.debug('Message:', params.message);\n },\n ],\n [EventType.VOICE_MESSAGE_RECEIVED]: [\n async (params: MessagePayload) => {\n logger.debug('VOICE_MESSAGE_RECEIVED event received');\n logger.debug('Message:', params.message);\n },\n ],\n [EventType.WORLD_CONNECTED]: [\n async (params: WorldPayload) => {\n logger.debug('WORLD_CONNECTED event received');\n logger.debug('World:', params.world);\n },\n ],\n [EventType.WORLD_JOINED]: [\n async (params: WorldPayload) => {\n logger.debug('WORLD_JOINED event received');\n logger.debug('World:', params.world);\n },\n ],\n },\n services: [StarterService],\n actions: [helloWorldAction],\n providers: [helloWorldProvider],\n // dependencies: ['@elizaos/plugin-knowledge'], <--- plugin dependecies go here (if requires another plugin)\n};\n\nexport default starterPlugin;\n","import { starterPlugin } from './plugin.ts';\n\nexport { starterPlugin, StarterService } from './plugin.ts';\nexport default starterPlugin;\n"],"mappings":";AACA;AAAA,EAQE;AAAA,EAGA;AAAA,EAEA;AAAA,EAGA;AAAA,OACK;AACP,SAAS,SAAS;AAOlB,IAAM,eAAe,EAAE,OAAO;AAAA,EAC5B,yBAAyB,EACtB,OAAO,EACP,IAAI,GAAG,yCAAyC,EAChD,SAAS,EACT,UAAU,CAAC,QAAQ;AAClB,QAAI,CAAC,KAAK;AACR,aAAO,KAAK,4DAA4D;AAAA,IAC1E;AACA,WAAO;AAAA,EACT,CAAC;AACL,CAAC;AAgBD,IAAM,mBAA2B;AAAA,EAC/B,MAAM;AAAA,EACN,SAAS,CAAC,SAAS,WAAW;AAAA,EAC9B,aAAa;AAAA,EAEb,UAAU,OACR,UACA,UACA,WACqB;AAErB,WAAO;AAAA,EACT;AAAA,EAEA,SAAS,OACP,UACA,SACA,QACA,WAAoC,CAAC,GACrC,UACA,eAC0B;AAC1B,QAAI;AACF,aAAO,KAAK,6BAA6B;AAGzC,YAAM,kBAA2B;AAAA,QAC/B,MAAM;AAAA,QACN,SAAS,CAAC,aAAa;AAAA,QACvB,QAAQ,QAAQ,QAAQ;AAAA,MAC1B;AAGA,UAAI,UAAU;AACZ,cAAM,SAAS,eAAe;AAAA,MAChC;AAGA,aAAO;AAAA,QACL,MAAM;AAAA,QACN,SAAS;AAAA,QACT,MAAM;AAAA,UACJ,SAAS,CAAC,aAAa;AAAA,UACvB,QAAQ,QAAQ,QAAQ;AAAA,QAC1B;AAAA,MACF;AAAA,IACF,SAAS,OAAO;AACd,aAAO,MAAM,gCAAgC,KAAK;AAClD,aAAO;AAAA,QACL,SAAS;AAAA,QACT,OAAO,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,KAAK,CAAC;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AO,WAA2B;AAChC,eAAO,MAAM,uCAAuC;AACpD,eAAO,MAAM,YAAY,OAAO,OAAO;AAAA,MACzC;AAAA,IACF;AAAA,IACA,CAAC,UAAU,eAAe,GAAG;AAAA,MAC3B,OAAO,WAAyB;AAC9B,eAAO,MAAM,gCAAgC;AAC7C,eAAO,MAAM,UAAU,OAAO,KAAK;AAAA,MACrC;AAAA,IACF;AAAA,IACA,CAAC,UAAU,YAAY,GAAG;AAAA,MACxB,OAAO,WAAyB;AAC9B,eAAO,MAAM,6BAA6B;AAC1C,eAAO,MAAM,UAAU,OAAO,KAAK;AAAA,MACrC;AAAA,IACF;AAAA,EACF;AAAA,EACA,UAAU,CAAC,cAAc;AAAA,EACzB,SAAS,CAAC,gBAAgB;AAAA,EAC1B,WAAW,CAAC,kBAAkB;AAAA;AAEhC;;;AC1QA,IAAO,gBAAQ;","names":[]}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Plugin, Service, IAgentRuntime } from '@elizaos/core';
|
|
2
|
-
|
|
3
|
-
declare class StarterService extends Service {
|
|
4
|
-
static serviceType: string;
|
|
5
|
-
capabilityDescription: string;
|
|
6
|
-
constructor(runtime: IAgentRuntime);
|
|
7
|
-
static start(runtime: IAgentRuntime): Promise<Service>;
|
|
8
|
-
static stop(runtime: IAgentRuntime): Promise<void>;
|
|
9
|
-
stop(): Promise<void>;
|
|
10
|
-
}
|
|
11
|
-
declare const starterPlugin: Plugin;
|
|
12
|
-
|
|
13
|
-
export { StarterService, starterPlugin as default, starterPlugin };
|
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
// src/plugin.ts
|
|
2
|
-
import {
|
|
3
|
-
ModelType,
|
|
4
|
-
Service,
|
|
5
|
-
logger,
|
|
6
|
-
EventType
|
|
7
|
-
} from "@elizaos/core";
|
|
8
|
-
import { z } from "zod";
|
|
9
|
-
var configSchema = z.object({
|
|
10
|
-
EXAMPLE_PLUGIN_VARIABLE: z.string().min(1, "Example plugin variable is not provided").optional().transform((val) => {
|
|
11
|
-
if (!val) {
|
|
12
|
-
logger.warn("Example plugin variable is not provided (this is expected)");
|
|
13
|
-
}
|
|
14
|
-
return val;
|
|
15
|
-
})
|
|
16
|
-
});
|
|
17
|
-
var helloWorldAction = {
|
|
18
|
-
name: "HELLO_WORLD",
|
|
19
|
-
similes: ["GREET", "SAY_HELLO"],
|
|
20
|
-
description: "Responds with a simple hello world message",
|
|
21
|
-
validate: async (_runtime, _message, _state) => {
|
|
22
|
-
return true;
|
|
23
|
-
},
|
|
24
|
-
handler: async (_runtime, message, _state, _options = {}, callback, _responses) => {
|
|
25
|
-
try {
|
|
26
|
-
logger.info("Handling HELLO_WORLD action");
|
|
27
|
-
const responseContent = {
|
|
28
|
-
text: "hello world!",
|
|
29
|
-
actions: ["HELLO_WORLD"],
|
|
30
|
-
source: message.content.source
|
|
31
|
-
};
|
|
32
|
-
if (callback) {
|
|
33
|
-
await callback(responseContent);
|
|
34
|
-
}
|
|
35
|
-
return {
|
|
36
|
-
text: "hello world!",
|
|
37
|
-
success: true,
|
|
38
|
-
data: {
|
|
39
|
-
actions: ["HELLO_WORLD"],
|
|
40
|
-
source: message.content.source
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
} catch (error) {
|
|
44
|
-
logger.error("Error in HELLO_WORLD action:", error);
|
|
45
|
-
return {
|
|
46
|
-
success: false,
|
|
47
|
-
error: error instanceof Error ? error : new Error(String(error))
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
examples: [
|
|
52
|
-
[
|
|
53
|
-
{
|
|
54
|
-
name: "{{name1}}",
|
|
55
|
-
content: {
|
|
56
|
-
text: "Can you say hello?"
|
|
57
|
-
}
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
name: "{{name2}}",
|
|
61
|
-
content: {
|
|
62
|
-
text: "hello world!",
|
|
63
|
-
actions: ["HELLO_WORLD"]
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
]
|
|
67
|
-
]
|
|
68
|
-
};
|
|
69
|
-
var helloWorldProvider = {
|
|
70
|
-
name: "HELLO_WORLD_PROVIDER",
|
|
71
|
-
description: "A simple example provider",
|
|
72
|
-
get: async (_runtime, _message, _state) => {
|
|
73
|
-
return {
|
|
74
|
-
text: "I am a provider",
|
|
75
|
-
values: {},
|
|
76
|
-
data: {}
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
var StarterService = class _StarterService extends Service {
|
|
81
|
-
static serviceType = "starter";
|
|
82
|
-
capabilityDescription = "This is a starter service which is attached to the agent through the starter plugin.";
|
|
83
|
-
constructor(runtime) {
|
|
84
|
-
super(runtime);
|
|
85
|
-
}
|
|
86
|
-
static async start(runtime) {
|
|
87
|
-
logger.info("Starting starter service");
|
|
88
|
-
const service = new _StarterService(runtime);
|
|
89
|
-
return service;
|
|
90
|
-
}
|
|
91
|
-
static async stop(runtime) {
|
|
92
|
-
logger.info("Stopping starter service");
|
|
93
|
-
const service = runtime.getService(_StarterService.serviceType);
|
|
94
|
-
if (!service) {
|
|
95
|
-
throw new Error("Starter service not found");
|
|
96
|
-
}
|
|
97
|
-
if ("stop" in service && typeof service.stop === "function") {
|
|
98
|
-
await service.stop();
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
async stop() {
|
|
102
|
-
logger.info("Starter service stopped");
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
var starterPlugin = {
|
|
106
|
-
name: "plugin-quick-starter",
|
|
107
|
-
description: "Quick backend-only plugin template for elizaOS",
|
|
108
|
-
config: {
|
|
109
|
-
EXAMPLE_PLUGIN_VARIABLE: process.env.EXAMPLE_PLUGIN_VARIABLE
|
|
110
|
-
},
|
|
111
|
-
async init(config) {
|
|
112
|
-
logger.info("Initializing plugin-quick-starter");
|
|
113
|
-
try {
|
|
114
|
-
const validatedConfig = await configSchema.parseAsync(config);
|
|
115
|
-
for (const [key, value] of Object.entries(validatedConfig)) {
|
|
116
|
-
if (value) process.env[key] = value;
|
|
117
|
-
}
|
|
118
|
-
} catch (error) {
|
|
119
|
-
if (error instanceof z.ZodError) {
|
|
120
|
-
throw new Error(
|
|
121
|
-
`Invalid plugin configuration: ${error.errors.map((e) => e.message).join(", ")}`
|
|
122
|
-
);
|
|
123
|
-
}
|
|
124
|
-
throw error;
|
|
125
|
-
}
|
|
126
|
-
},
|
|
127
|
-
models: {
|
|
128
|
-
[ModelType.TEXT_SMALL]: async (_runtime, { prompt, stopSequences = [] }) => {
|
|
129
|
-
return "Never gonna give you up, never gonna let you down, never gonna run around and desert you...";
|
|
130
|
-
},
|
|
131
|
-
[ModelType.TEXT_LARGE]: async (_runtime, {
|
|
132
|
-
prompt,
|
|
133
|
-
stopSequences = [],
|
|
134
|
-
maxTokens = 8192,
|
|
135
|
-
temperature = 0.7,
|
|
136
|
-
frequencyPenalty = 0.7,
|
|
137
|
-
presencePenalty = 0.7
|
|
138
|
-
}) => {
|
|
139
|
-
return "Never gonna make you cry, never gonna say goodbye, never gonna tell a lie and hurt you...";
|
|
140
|
-
}
|
|
141
|
-
},
|
|
142
|
-
routes: [
|
|
143
|
-
{
|
|
144
|
-
name: "api-status",
|
|
145
|
-
path: "/api/status",
|
|
146
|
-
type: "GET",
|
|
147
|
-
handler: async (_req, res) => {
|
|
148
|
-
res.json({
|
|
149
|
-
status: "ok",
|
|
150
|
-
plugin: "quick-starter",
|
|
151
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
],
|
|
156
|
-
events: {
|
|
157
|
-
[EventType.MESSAGE_RECEIVED]: [
|
|
158
|
-
async (params) => {
|
|
159
|
-
logger.debug("MESSAGE_RECEIVED event received");
|
|
160
|
-
logger.debug("Message:", params.message);
|
|
161
|
-
}
|
|
162
|
-
],
|
|
163
|
-
[EventType.VOICE_MESSAGE_RECEIVED]: [
|
|
164
|
-
async (params) => {
|
|
165
|
-
logger.debug("VOICE_MESSAGE_RECEIVED event received");
|
|
166
|
-
logger.debug("Message:", params.message);
|
|
167
|
-
}
|
|
168
|
-
],
|
|
169
|
-
[EventType.WORLD_CONNECTED]: [
|
|
170
|
-
async (params) => {
|
|
171
|
-
logger.debug("WORLD_CONNECTED event received");
|
|
172
|
-
logger.debug("World:", params.world);
|
|
173
|
-
}
|
|
174
|
-
],
|
|
175
|
-
[EventType.WORLD_JOINED]: [
|
|
176
|
-
async (params) => {
|
|
177
|
-
logger.debug("WORLD_JOINED event received");
|
|
178
|
-
logger.debug("World:", params.world);
|
|
179
|
-
}
|
|
180
|
-
]
|
|
181
|
-
},
|
|
182
|
-
services: [StarterService],
|
|
183
|
-
actions: [helloWorldAction],
|
|
184
|
-
providers: [helloWorldProvider]
|
|
185
|
-
// dependencies: ['@elizaos/plugin-knowledge'], <--- plugin dependecies go here (if requires another plugin)
|
|
186
|
-
};
|
|
187
|
-
|
|
188
|
-
// src/index.ts
|
|
189
|
-
var index_default = starterPlugin;
|
|
190
|
-
export {
|
|
191
|
-
StarterService,
|
|
192
|
-
index_default as default,
|
|
193
|
-
starterPlugin
|
|
194
|
-
};
|
|
195
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/plugin.ts","../src/index.ts"],"sourcesContent":["import type { Plugin } from '@elizaos/core';\nimport {\n type Action,\n type ActionResult,\n type Content,\n type GenerateTextParams,\n type HandlerCallback,\n type IAgentRuntime,\n type Memory,\n ModelType,\n type Provider,\n type ProviderResult,\n Service,\n type State,\n logger,\n type MessagePayload,\n type WorldPayload,\n EventType,\n} from '@elizaos/core';\nimport { z } from 'zod';\n\n/**\n * Defines the configuration schema for a plugin, including the validation rules for the plugin name.\n *\n * @type {import('zod').ZodObject<{ EXAMPLE_PLUGIN_VARIABLE: import('zod').ZodString }>}\n */\nconst configSchema = z.object({\n EXAMPLE_PLUGIN_VARIABLE: z\n .string()\n .min(1, 'Example plugin variable is not provided')\n .optional()\n .transform((val) => {\n if (!val) {\n logger.warn('Example plugin variable is not provided (this is expected)');\n }\n return val;\n }),\n});\n\n/**\n * Example HelloWorld action\n * This demonstrates the simplest possible action structure\n */\n/**\n * Action representing a hello world message.\n * @typedef {Object} Action\n * @property {string} name - The name of the action.\n * @property {string[]} similes - An array of related actions.\n * @property {string} description - A brief description of the action.\n * @property {Function} validate - Asynchronous function to validate the action.\n * @property {Function} handler - Asynchronous function to handle the action and generate a response.\n * @property {Object[]} examples - An array of example inputs and expected outputs for the action.\n */\nconst helloWorldAction: Action = {\n name: 'HELLO_WORLD',\n similes: ['GREET', 'SAY_HELLO'],\n description: 'Responds with a simple hello world message',\n\n validate: async (\n _runtime: IAgentRuntime,\n _message: Memory,\n _state: State | undefined\n ): Promise<boolean> => {\n // Always valid\n return true;\n },\n\n handler: async (\n _runtime: IAgentRuntime,\n message: Memory,\n _state: State | undefined,\n _options: Record<string, unknown> = {},\n callback?: HandlerCallback,\n _responses?: Memory[]\n ): Promise<ActionResult> => {\n try {\n logger.info('Handling HELLO_WORLD action');\n\n // Simple response content for callback\n const responseContent: Content = {\n text: 'hello world!',\n actions: ['HELLO_WORLD'],\n source: message.content.source,\n };\n\n // Call back with the hello world message if callback is provided\n if (callback) {\n await callback(responseContent);\n }\n\n // Return ActionResult\n return {\n text: 'hello world!',\n success: true,\n data: {\n actions: ['HELLO_WORLD'],\n source: message.content.source,\n },\n };\n } catch (error) {\n logger.error('Error in HELLO_WORLD action:', error);\n return {\n success: false,\n error: error instanceof Error ? error : new Error(String(error)),\n };\n }\n },\n\n examples: [\n [\n {\n name: '{{name1}}',\n content: {\n text: 'Can you say hello?',\n },\n },\n {\n name: '{{name2}}',\n content: {\n text: 'hello world!',\n actions: ['HELLO_WORLD'],\n },\n },\n ],\n ],\n};\n\n/**\n * Example Hello World Provider\n * This demonstrates the simplest possible provider implementation\n */\nconst helloWorldProvider: Provider = {\n name: 'HELLO_WORLD_PROVIDER',\n description: 'A simple example provider',\n\n get: async (\n _runtime: IAgentRuntime,\n _message: Memory,\n _state: State | undefined\n ): Promise<ProviderResult> => {\n return {\n text: 'I am a provider',\n values: {},\n data: {},\n };\n },\n};\n\nexport class StarterService extends Service {\n static override serviceType = 'starter';\n\n override capabilityDescription =\n 'This is a starter service which is attached to the agent through the starter plugin.';\n\n constructor(runtime: IAgentRuntime) {\n super(runtime);\n }\n\n static override async start(runtime: IAgentRuntime): Promise<Service> {\n logger.info('Starting starter service');\n const service = new StarterService(runtime);\n return service;\n }\n\n static override async stop(runtime: IAgentRuntime): Promise<void> {\n logger.info('Stopping starter service');\n const service = runtime.getService(StarterService.serviceType);\n if (!service) {\n throw new Error('Starter service not found');\n }\n if ('stop' in service && typeof service.stop === 'function') {\n await service.stop();\n }\n }\n\n override async stop(): Promise<void> {\n logger.info('Starter service stopped');\n }\n}\n\nexport const starterPlugin: Plugin = {\n name: 'plugin-quick-starter',\n description: 'Quick backend-only plugin template for elizaOS',\n config: {\n EXAMPLE_PLUGIN_VARIABLE: process.env.EXAMPLE_PLUGIN_VARIABLE,\n },\n async init(config: Record<string, string>) {\n logger.info('Initializing plugin-quick-starter');\n try {\n const validatedConfig = await configSchema.parseAsync(config);\n\n // Set all environment variables at once\n for (const [key, value] of Object.entries(validatedConfig)) {\n if (value) process.env[key] = value;\n }\n } catch (error) {\n if (error instanceof z.ZodError) {\n throw new Error(\n `Invalid plugin configuration: ${error.errors.map((e) => e.message).join(', ')}`\n );\n }\n throw error;\n }\n },\n models: {\n [ModelType.TEXT_SMALL]: async (\n _runtime,\n { prompt, stopSequences = [] }: GenerateTextParams\n ) => {\n return 'Never gonna give you up, never gonna let you down, never gonna run around and desert you...';\n },\n [ModelType.TEXT_LARGE]: async (\n _runtime,\n {\n prompt,\n stopSequences = [],\n maxTokens = 8192,\n temperature = 0.7,\n frequencyPenalty = 0.7,\n presencePenalty = 0.7,\n }: GenerateTextParams\n ) => {\n return 'Never gonna make you cry, never gonna say goodbye, never gonna tell a lie and hurt you...';\n },\n },\n routes: [\n {\n name: 'api-status',\n path: '/api/status',\n type: 'GET',\n handler: async (_req: any, res: any) => {\n res.json({\n status: 'ok',\n plugin: 'quick-starter',\n timestamp: new Date().toISOString(),\n });\n },\n },\n ],\n events: {\n [EventType.MESSAGE_RECEIVED]: [\n async (params: MessagePayload) => {\n logger.debug('MESSAGE_RECEIVED event received');\n logger.debug('Message:', params.message);\n },\n ],\n [EventType.VOICE_MESSAGE_RECEIVED]: [\n async (params: MessagePayload) => {\n logger.debug('VOICE_MESSAGE_RECEIVED event received');\n logger.debug('Message:', params.message);\n },\n ],\n [EventType.WORLD_CONNECTED]: [\n async (params: WorldPayload) => {\n logger.debug('WORLD_CONNECTED event received');\n logger.debug('World:', params.world);\n },\n ],\n [EventType.WORLD_JOINED]: [\n async (params: WorldPayload) => {\n logger.debug('WORLD_JOINED event received');\n logger.debug('World:', params.world);\n },\n ],\n },\n services: [StarterService],\n actions: [helloWorldAction],\n providers: [helloWorldProvider],\n // dependencies: ['@elizaos/plugin-knowledge'], <--- plugin dependecies go here (if requires another plugin)\n};\n\nexport default starterPlugin;\n","import { starterPlugin } from './plugin.ts';\n\nexport { starterPlugin, StarterService } from './plugin.ts';\nexport default starterPlugin;\n"],"mappings":";AACA;AAAA,EAQE;AAAA,EAGA;AAAA,EAEA;AAAA,EAGA;AAAA,OACK;AACP,SAAS,SAAS;AAOlB,IAAM,eAAe,EAAE,OAAO;AAAA,EAC5B,yBAAyB,EACtB,OAAO,EACP,IAAI,GAAG,yCAAyC,EAChD,SAAS,EACT,UAAU,CAAC,QAAQ;AAClB,QAAI,CAAC,KAAK;AACR,aAAO,KAAK,4DAA4D;AAAA,IAC1E;AACA,WAAO;AAAA,EACT,CAAC;AACL,CAAC;AAgBD,IAAM,mBAA2B;AAAA,EAC/B,MAAM;AAAA,EACN,SAAS,CAAC,SAAS,WAAW;AAAA,EAC9B,aAAa;AAAA,EAEb,UAAU,OACR,UACA,UACA,WACqB;AAErB,WAAO;AAAA,EACT;AAAA,EAEA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