Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugins externalized (WIP) #838

Open
wants to merge 313 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
313 commits
Select commit Hold shift + click to select a range
7758c54
Add web search plugin
avaer Dec 30, 2024
6e8ef27
Remove .npmignore
avaer Dec 30, 2024
3023f54
Add web search plugin hacks
avaer Dec 30, 2024
9fe3031
Web search plugin integration
avaer Dec 30, 2024
6d46680
Update lock
avaer Dec 30, 2024
5223ade
Add image generation plugin
avaer Dec 30, 2024
35b6b66
Remove .npmignore
avaer Dec 30, 2024
81e871b
Update main file path to src/index.ts in package.json
avaer Dec 30, 2024
4e16f79
Add image generation plugin to upstreet agent
avaer Dec 30, 2024
3f26570
Update lock
avaer Dec 30, 2024
50835bf
Add story plugin
avaer Dec 30, 2024
f0de695
Add plugin-story to react-agents plugins list
avaer Dec 30, 2024
db13425
Hack story plugin
avaer Dec 30, 2024
76374ce
Update lock
avaer Dec 30, 2024
2a97963
Add nft generation plugin
avaer Dec 30, 2024
2849e1e
Remove.npmignore
avaer Dec 30, 2024
aa0de27
Hack nft generation plugin
avaer Dec 30, 2024
b5cb56a
Add plugin for NFT generation in Upstreet Agent
avaer Dec 30, 2024
515bef3
Update lock
avaer Dec 30, 2024
73ea6c5
Add evm plugin
avaer Dec 30, 2024
beaaa96
Add plugin-evm to list of plugins in package.json
avaer Dec 30, 2024
c0fbd16
Add evm plugin hacks
avaer Dec 30, 2024
5dae9b7
Update lock
avaer Dec 30, 2024
e9ec2a6
Add gitbook plugin source
avaer Dec 30, 2024
05ca8c8
Hook in gitbook plugin
avaer Dec 30, 2024
ac3ca0d
Add gitbook plugin hacks
avaer Dec 30, 2024
97e3fb8
More gitbook plugin hacks
avaer Dec 30, 2024
710fbf1
Add plugin-gitbook to upstreet-agent dependencies
avaer Dec 30, 2024
28f2b30
Update lock
avaer Dec 30, 2024
a965ccf
Add near plugin source
avaer Dec 30, 2024
c312109
Remove npmignore
avaer Dec 30, 2024
1df87fc
Add near plugin hacks
avaer Dec 30, 2024
2b4c2a7
Add plugin-near to the list of plugins
avaer Dec 30, 2024
2abd52b
Update lock
avaer Dec 30, 2024
b3d37cc
Add avalanche plugin source
avaer Dec 30, 2024
2ea046f
Add avalanche plugin to upstreet agent
avaer Dec 30, 2024
609941a
Plugin hacks
avaer Dec 30, 2024
def0ea1
Update lock
avaer Dec 30, 2024
46ba29a
Add multiversx
avaer Dec 30, 2024
8a47ca8
Remove npmignore
avaer Dec 30, 2024
5ff0313
Hack multiversx plugin
avaer Dec 30, 2024
8f8489c
Add plugin-multiversx to the list of plugins
avaer Dec 30, 2024
0bccb2e
Update lock
avaer Dec 30, 2024
bac0bf1
Add video generation plugin
avaer Dec 30, 2024
eda3e0c
Remove npmignore
avaer Dec 30, 2024
558c7eb
Hack video generation plugin
avaer Dec 30, 2024
78de9fc
Add video generation plugin support
avaer Dec 30, 2024
3717273
Update lock
avaer Dec 30, 2024
15905c1
Add zksnyc plugin
avaer Dec 30, 2024
f150b56
Add zksync-era plugin to upstreet-agent package
avaer Dec 30, 2024
b4ddf85
Hack zksync plugin
avaer Dec 30, 2024
68dfcf6
Update lock
avaer Dec 30, 2024
0e2028e
Add 0g plugin
avaer Dec 30, 2024
67b4386
Hack 0g plugin
avaer Dec 30, 2024
bdb39ee
Integrate 0g plugin
avaer Dec 30, 2024
4bf7a6c
Update lock
avaer Dec 30, 2024
cc7e4c1
Add intiface plugin
avaer Dec 30, 2024
97d59ab
Remove .npmignore
avaer Dec 30, 2024
95b5b59
Hack intiface plugin
avaer Dec 30, 2024
7969c40
Integration intiface plugin
avaer Dec 30, 2024
cb250f6
Hack intiface plugin
avaer Dec 30, 2024
e4188d6
Update lock
avaer Dec 30, 2024
023a94f
Add icp plugin
avaer Dec 30, 2024
7987766
Hack icp plugin
avaer Dec 30, 2024
421217a
Add plugin-icp to the list of plugins
avaer Dec 30, 2024
0ba0ead
Update lock
avaer Dec 30, 2024
d223632
Add echochambers plugin
avaer Dec 30, 2024
30cfcc9
Add plugin-echochambers to upstreet-agent plugins
avaer Dec 30, 2024
6a1fb64
Hack echochambers plugin
avaer Dec 30, 2024
c365eea
Update lock
avaer Dec 30, 2024
d84d001
Add starknet plugin
avaer Dec 30, 2024
38fe2cb
Remove .npmignore
avaer Dec 30, 2024
de465b8
Add '@elizaos/plugin-starknet' to the list of plugins
avaer Dec 30, 2024
587010d
Hack starknet plugin
avaer Dec 30, 2024
da12f5f
Update lock
avaer Dec 30, 2024
e65b608
Add conflux plugin
avaer Dec 30, 2024
1dde3ff
Add conflux plugin to upstreet-agent package
avaer Dec 30, 2024
f30dc1a
Hack conflux plugin
avaer Dec 30, 2024
68835ea
Update lock
avaer Dec 30, 2024
04cc5a0
Add aptos plugin
avaer Dec 30, 2024
2d644b8
Remove npmignore
avaer Dec 30, 2024
3ff76d8
Hack aptos plugin
avaer Dec 30, 2024
f22bc11
Add plugin-aptos to plugins list
avaer Dec 30, 2024
20a0637
Update lock
avaer Dec 30, 2024
80e6def
Add bootstrap plugin source
avaer Dec 30, 2024
0f3ac92
Remove .npmignore
avaer Dec 30, 2024
a157e61
Add Bootstrap plugin to the list of available plugins
avaer Dec 30, 2024
d160dd0
Hack boostrap plugin
avaer Dec 30, 2024
72887ba
Update lock
avaer Dec 30, 2024
4005547
Logging cleanup
avaer Dec 30, 2024
a4b94cd
Add ton plugin
avaer Dec 30, 2024
a896a19
Hack ton plugin
avaer Dec 30, 2024
4292609
Add ton plugin
avaer Dec 30, 2024
7ca56cf
Update lock
avaer Dec 30, 2024
77ff38b
Add cronoszkevm plugin
avaer Dec 30, 2024
826178d
Hack cronoszkevm plugin
avaer Dec 30, 2024
a558c06
Integrate cronosZkEVMPlugin
avaer Dec 30, 2024
a4f9d51
Update lock
avaer Dec 30, 2024
82b5d3c
Add abstract plugin
avaer Dec 30, 2024
0b0c5e9
Hack abstract plugin
avaer Dec 30, 2024
1178193
Add plugin-abstract to the list of plugins
avaer Dec 30, 2024
73cfe02
Update lock
avaer Dec 30, 2024
547e5b6
Add fuel plugin
avaer Dec 30, 2024
be27696
Remove npmignore
avaer Dec 30, 2024
3f6fb3e
Hack fuel plugin
avaer Dec 30, 2024
64c1e92
Integrate fuel plugin
avaer Dec 30, 2024
f0191d8
Update lock
avaer Dec 30, 2024
7715388
Add ferePro plugin
avaer Dec 30, 2024
83a878d
Remove npmignore
avaer Dec 30, 2024
3fc1446
Hack ferePro plugin
avaer Dec 30, 2024
606c5f9
Add ferePro plugin
avaer Dec 30, 2024
b1e56c5
Update lock
avaer Dec 30, 2024
d703f23
Move whatsapp plugin to plugins
avaer Dec 30, 2024
9902434
Remove whataspp plugin from clients
avaer Dec 30, 2024
a10e4ed
Plugins cleanup
avaer Dec 30, 2024
05526b4
Update plugin install
avaer Dec 30, 2024
046869e
Update lock
avaer Dec 30, 2024
f58dd31
Add discord client
avaer Dec 30, 2024
0062d79
Remove npmignore
avaer Dec 30, 2024
106aa53
Add github source
avaer Dec 30, 2024
b5a1081
Remove .npmignore
avaer Dec 30, 2024
eb1f1f4
Add twitter client
avaer Dec 30, 2024
25af084
Remove npmignore
avaer Dec 30, 2024
97ee037
Add client installs
avaer Dec 30, 2024
dd652b5
Update lock
avaer Dec 30, 2024
beb0f7e
Add components types
avaer Dec 30, 2024
6784438
Major clients integration stub update
avaer Dec 30, 2024
77aa2df
Major plugins integration update
avaer Dec 30, 2024
c1d4eac
Hook in initial runtime
avaer Dec 30, 2024
da08825
Hack clients
avaer Dec 30, 2024
803e0cf
Add slack client
avaer Dec 31, 2024
872e1c7
Install slack client
avaer Dec 31, 2024
a0f0755
Hook in slack client
avaer Dec 31, 2024
5f17d9e
Hack slack client
avaer Dec 31, 2024
7ddae5c
Update lock
avaer Dec 31, 2024
74d28b9
Add telegram client
avaer Dec 31, 2024
b2db1c6
Add telegram client
avaer Dec 31, 2024
acb7fad
Update lock
avaer Dec 31, 2024
b242106
Hack telegram client
avaer Dec 31, 2024
0fa02a3
Update lock
avaer Dec 31, 2024
9bb4b37
Install farcaster client
avaer Dec 31, 2024
2d419c8
Hook in farcaster client
avaer Dec 31, 2024
48c01c6
Hack farcaaster client
avaer Dec 31, 2024
e896f83
Update lock
avaer Dec 31, 2024
8ef4633
Add lens client
avaer Dec 31, 2024
5f5538a
Integrate lens client
avaer Dec 31, 2024
43204a9
Hack lens client
avaer Dec 31, 2024
f133712
Update lock
avaer Dec 31, 2024
dac4c20
Update @discordjs/opus to npm in discord-client
avaer Dec 31, 2024
3d827f4
Update lock
avaer Dec 31, 2024
1f944c5
Fixing chat build
avaer Dec 31, 2024
c38d2df
Revert "Update @discordjs/opus to npm in discord-client"
avaer Dec 31, 2024
1a89db8
Add cdc asset handling
avaer Dec 31, 2024
f2a7351
Add missing transpile package in chat config
avaer Dec 31, 2024
5cc054e
Fix package name
avaer Dec 31, 2024
25aa569
Remove discord client
avaer Dec 31, 2024
5735940
Update lock
avaer Dec 31, 2024
91b8994
Fix node: imports in chat
avaer Dec 31, 2024
fa871ba
Fix chat imports
avaer Dec 31, 2024
70a06cf
Add additional imports
avaer Dec 31, 2024
ef8698c
Add additional proxy packages
avaer Dec 31, 2024
43a42ae
Update lock
avaer Dec 31, 2024
c863c62
Small cleanup
avaer Dec 31, 2024
9380093
Add wrangler rules
avaer Dec 31, 2024
7f36210
Update wrangler compatibility flags
avaer Dec 31, 2024
c2be1a4
Fix electron runtime
avaer Dec 31, 2024
832b297
Remove old wrangler version
avaer Jan 1, 2025
d2979ef
Update wrangler version
avaer Jan 1, 2025
85dc36e
Remove conflicting fastembed module install
avaer Jan 1, 2025
2859191
Add init.ts
avaer Jan 1, 2025
ab1bfe8
Import init.ts
avaer Jan 1, 2025
cd88859
Copy in init.ts in agent install
avaer Jan 1, 2025
c8f7abd
Pass stack trace limit to wrangler
avaer Jan 1, 2025
37f55ba
Bugfix lens agent
avaer Jan 1, 2025
ab12e93
Fix wallet import
avaer Jan 1, 2025
e1acfa6
Remove dead AGENT_JSON var
avaer Jan 1, 2025
0d3ff74
Update lock
avaer Jan 1, 2025
71cf9ac
Add missing imports
avaer Jan 1, 2025
852f7a9
Hook in more core imports
avaer Jan 1, 2025
8c1309d
Hack import.meta.url
avaer Jan 1, 2025
f6e30ed
Fix import.meta.url hack
avaer Jan 1, 2025
6058596
Port amqplib -> rhea in solana plugin
avaer Jan 1, 2025
6577c26
Update lock
avaer Jan 1, 2025
60a0ef7
Add missing embedding.ts
avaer Jan 1, 2025
f17eeda
Merge branch 'dev' into plugins
avaer Jan 1, 2025
940cd4f
Comment out local embedding support
avaer Jan 1, 2025
c5002fb
Remove .gitignore
avaer Jan 1, 2025
b1b7948
Remove old plugins from install
avaer Jan 2, 2025
055b9fe
Add json-schema-to-zod-object dep
avaer Jan 2, 2025
4059753
Clean up old modules in install process
avaer Jan 2, 2025
faec77b
Major plugins architecture update
avaer Jan 3, 2025
4309cbb
Update lock
avaer Jan 3, 2025
6d29ae1
Clean up next config
avaer Jan 3, 2025
980fab6
Rm externalized client- modules
avaer Jan 3, 2025
5511b2d
Rm externalized plugins
avaer Jan 3, 2025
1802286
Update json-schema-to-zod-object
avaer Jan 3, 2025
11b20cd
Add env var
avaer Jan 3, 2025
63573f9
Update plugins api
avaer Jan 3, 2025
59945f1
Add test to usdk package.json
avaer Jan 3, 2025
2f871dc
Add usdk workspace + test to root
avaer Jan 3, 2025
fadf956
Add usdk jest config
avaer Jan 3, 2025
e5a8b25
Add usdk test
avaer Jan 3, 2025
b5e8983
Remove commented-out code in Plugins component
avaer Jan 3, 2025
c6c92aa
Add jest types
avaer Jan 4, 2025
025eb97
Update lock
avaer Jan 4, 2025
f155fb8
Remove dead tasks
avaer Jan 4, 2025
9938242
Fix jest config
avaer Jan 4, 2025
6a3b69b
Add new test command
avaer Jan 4, 2025
e351f87
Update upstreet-agent package.json jest deps
avaer Jan 4, 2025
89bc494
Bump json-schema-to-zod-object version
avaer Jan 4, 2025
6b89f4d
Update test to load react-agents
avaer Jan 4, 2025
f284e8c
Update lock
avaer Jan 4, 2025
3061551
Update json-schema-to-zod-object
avaer Jan 4, 2025
23bb5b7
Update jest config
avaer Jan 4, 2025
650ecbc
Small types update
avaer Jan 4, 2025
4119089
File renaming
avaer Jan 4, 2025
2380787
More file renames
avaer Jan 4, 2025
28944e7
Rename types file
avaer Jan 4, 2025
2676f38
Rename eliza types
avaer Jan 4, 2025
05a4659
Fix types
avaer Jan 4, 2025
45c924f
Update lock
avaer Jan 4, 2025
4257dab
Install react
avaer Jan 4, 2025
322a7ca
Update supabase loader
avaer Jan 4, 2025
7ee5fe8
Update wallet loading
avaer Jan 4, 2025
947998e
Remove old basic test
avaer Jan 4, 2025
392480a
Update lock
avaer Jan 4, 2025
8296bf4
Add missing test
avaer Jan 4, 2025
d8779d7
Run jest tests in github actions workflow
avaer Jan 4, 2025
22424ae
Fix module name
avaer Jan 4, 2025
15d6972
Update tests
avaer Jan 4, 2025
3aa31e6
Update test
avaer Jan 4, 2025
9ae4ec9
Remove old agents dir
avaer Jan 4, 2025
a32b632
Update test timeout
avaer Jan 4, 2025
937bf9d
Tests cleanup
avaer Jan 4, 2025
ecf562c
Update plugins limit
avaer Jan 4, 2025
798b16a
Update test timeout
avaer Jan 4, 2025
e8ebfea
Return agents from root render
avaer Jan 4, 2025
311c67b
Update agents api
avaer Jan 4, 2025
a592237
Update test
avaer Jan 4, 2025
b047418
Add async unmount
avaer Jan 4, 2025
8c1954a
Fix skip + limit
avaer Jan 4, 2025
e587cae
Add core ping component
avaer Jan 4, 2025
f1278af
Move ping manager to be a default component
avaer Jan 4, 2025
e8b8f85
Update ping.tsx
avaer Jan 4, 2025
782bebc
Unlock all plugins
avaer Jan 4, 2025
8100e90
Bump json-schema-to-zod-object version
avaer Jan 5, 2025
36e01ad
Add missing react types
avaer Jan 5, 2025
bd26013
Update lock
avaer Jan 5, 2025
d19b581
Update json-schema-to-zod-object version
avaer Jan 5, 2025
bce19a0
Small cleanup
avaer Jan 5, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/usdk-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ on:
jobs:
test-usdk:
runs-on: ubuntu-22.04
env:
FAL_API_KEY: ${{ secrets.FAL_API_KEY }}

strategy:
matrix:
node-version: [22]
Expand All @@ -28,3 +31,5 @@ jobs:
run: cd packages/usdk && pnpm install --no-optional --no-frozen-lockfile
- name: Run USDK command
run: cd packages/usdk && ./usdk.js --version
- name: Run Jest tests
run: cd packages/usdk && pnpm test
37 changes: 29 additions & 8 deletions apps/chat/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

const path = require('path');
const webpack = require('webpack');
const { builtinModules } = require('module');

module.exports = {
// experimental: {
Expand All @@ -14,6 +15,7 @@ module.exports = {
'react-agents-client',
'ecctrl',
'ucom',
'@elizaos/core',
],
async redirects() {
return [
Expand Down Expand Up @@ -88,28 +90,42 @@ module.exports = {
use: [options.defaultLoaders.babel],
}); */

config.plugins.push(
new webpack.NormalModuleReplacementPlugin(/^node:(.*)$/, (resource) => {
resource.request = resource.request.replace(/^node:/, '');
})
);

// fix react resolution in sdk subpackage
const usdkPath = path.resolve(__dirname, '../../packages/usdk');
const upstreetAgentPath = path.resolve(__dirname, '../../packages/usdk/packages/upstreet-agent');
const reactAgentsPath = path.resolve(__dirname, '../../packages/usdk/packages/upstreet-agent/packages/react-agents');
const reactAgentsClientPath = path.resolve(__dirname, '../../packages/usdk/packages/upstreet-agent/packages/react-agents-client');
const reactAgentsBrowserPath = path.resolve(__dirname, '../../packages/usdk/packages/upstreet-agent/packages/react-agents-browser');
const replacePlugin = (scopePath, moduleRegexp) => {
const replacePlugin = (scopePath, moduleRegexp, importPath) => {
return new webpack.NormalModuleReplacementPlugin(moduleRegexp, (resource) => {
if (resource.context.includes(scopePath)) {
if (
(typeof scopePath == 'string' && resource.context.includes(scopePath)) ||
(scopePath instanceof RegExp && scopePath.test(resource.context))
) {
if (builtinModules.includes(resource.request)) {
resource.request = path.join(importPath, 'node_modules', resource.request);
}
const p = require.resolve(resource.request, {
paths: [scopePath],
paths: [importPath],
});
resource.request = p;
}
});
};
const modulesRegex = /^react|^fs$|^child_process$/;
config.plugins.push(
replacePlugin(reactAgentsPath, /^react/),
replacePlugin(reactAgentsClientPath, /^react/),
replacePlugin(reactAgentsBrowserPath, /^react/),
replacePlugin(upstreetAgentPath, /^react/),
replacePlugin(usdkPath, /^react/),
replacePlugin(reactAgentsPath, modulesRegex, upstreetAgentPath),
replacePlugin(reactAgentsClientPath, modulesRegex, upstreetAgentPath),
replacePlugin(reactAgentsBrowserPath, modulesRegex, upstreetAgentPath),
replacePlugin(upstreetAgentPath, modulesRegex, upstreetAgentPath),
replacePlugin(usdkPath, modulesRegex, upstreetAgentPath),
replacePlugin(/\/path-scurry\/|\/0g-ts-sdk\//, modulesRegex, upstreetAgentPath),
);

// config.experiments = {
Expand All @@ -123,6 +139,11 @@ module.exports = {
type: 'asset/resource',
});

config.module.rules.push({
test: /\.cdc$/,
type: 'asset/source'
});

return config;
},
async headers() {
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
"private": true,
"type": "module",
"scripts": {
"test": "npm run usdk test",
"clean": "find . -type d -name node_modules -exec rm -rf {} +",
"chat": "npm run -w @upstreet/chat --",
"docs": "npm run -w @upstreet/docs --"
"docs": "npm run -w @upstreet/docs --",
"usdk": "npm run -w usdk --"
},
"workspaces": [
"apps/*",
Expand Down
10 changes: 10 additions & 0 deletions packages/usdk/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/** @type {import('ts-jest').JestConfigWithTsJest} **/
export default {
preset: "ts-jest/presets/default-esm",
testEnvironment: "node",
transformIgnorePatterns: [],
testMatch: [
'**/test/?(*.)+(spec|test).[jt]s?(x)',
],
extensionsToTreatAsEsm: [".ts", ".tsx"],
};
10 changes: 7 additions & 3 deletions packages/usdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"type": "module",
"main": "module.mjs",
"scripts": {
"preinstall": "[[ $npm_config_global == 'true' ]] || exit 0; cd packages/upstreet-agent && pnpm install --ignore-workspace --no-frozen-lockfile"
"preinstall": "[[ $npm_config_global == 'true' ]] || exit 0; cd packages/upstreet-agent && pnpm install --ignore-workspace --no-frozen-lockfile",
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js --testTimeout 600000"
},
"keywords": [
"ai",
Expand Down Expand Up @@ -60,6 +61,7 @@
"@supabase/supabase-js": "^2.47.1",
"@tsndr/cloudflare-worker-jwt": "2.5.3",
"@types/estree": "^1.0.5",
"@types/react": "19.0.0",
"@wasm-audio-decoders/common": "file:./packages/upstreet-agent/packages/codecs/packages/mpg123-decoder/packages/wasm-audio-decoders-common",
"alea": "^1.0.1",
"ansi-escape-sequences": "^6.2.2",
Expand Down Expand Up @@ -103,6 +105,7 @@
"png-chunks-extract": "^1.0.0",
"pnpm": "^9.12.3",
"pretty-bytes": "^6.1.1",
"react": "file:./packages/upstreet-agent/packages/react",
"react-agents": "file:./packages/upstreet-agent/packages/react-agents",
"queue-manager": "file:./packages/upstreet-agent/packages/queue-manager",
"react-agents-electron": "file:./packages/upstreet-agent/packages/react-agents-electron",
Expand Down Expand Up @@ -130,7 +133,6 @@
"web-worker": "1.2.0",
"webp-wasm": "^1.0.6",
"winston": "^3.16.0",
"wrangler": "^3.95.0",
"ws": "^8.17.0",
"yjs": "^13.6.18",
"zjs": "file:./packages/upstreet-agent/packages/react-agents-client/packages/multiplayer/packages/zjs",
Expand All @@ -150,7 +152,9 @@
"whatwg-url": "14.0.0"
},
"devDependencies": {
"@types/jest": "^29.5.14",
"@types/node": "^18.0.0",
"jest": "^29.0.0"
"jest": "^29.0.0",
"ts-jest": "^29.2.5"
}
}
4 changes: 2 additions & 2 deletions packages/usdk/packages/upstreet-agent/durable-object.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import './init.ts';
import './main.jsx';
import React from 'react';
import dotenv from 'dotenv';
import { createRoot, Root } from 'react-agents/root.ts';
Expand All @@ -6,8 +8,6 @@ import App from './agent.tsx';
import agentJsonSource from './agent.json';
import envTxt from './.env.txt';

Error.stackTraceLimit = 300;

const alarmTimeout = 10 * 1000;

const parseAgentJson = (agentJsonSource) => {
Expand Down
7 changes: 7 additions & 0 deletions packages/usdk/packages/upstreet-agent/init.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Error.stackTraceLimit = 300;
globalThis.__filename = 'node.js';
globalThis.__dirname = '/';
(globalThis.process as any).version = '20.0.0';
if (typeof import.meta.url === 'undefined') {
import.meta.url = `file://localhost/${globalThis.__filename}`;
}
3 changes: 1 addition & 2 deletions packages/usdk/packages/upstreet-agent/main.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import './init.ts';
export { DurableObject } from './durable-object.tsx';
import { headers } from 'react-agents/constants.mjs';
import agentJsonSource from './agent.json';

Error.stackTraceLimit = 300;

const parseAgentJson = (agentJsonSource) => {
try {
if (typeof agentJsonSource === 'string') {
Expand Down
7 changes: 7 additions & 0 deletions packages/usdk/packages/upstreet-agent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,27 @@
"dependencies": {
"@aws-sdk/util-format-url": "^3.577.0",
"@electric-sql/pglite": "^0.2.15",
"@elizaos/core": "file:./packages/elizaos-core-proxy",
"@iarna/toml": "^2.2.5",
"@supabase/postgrest-js": "^1.17.7",
"@supabase/supabase-js": "^2.47.1",
"@tsndr/cloudflare-worker-jwt": "2.5.3",
"@types/jest": "^29.5.13",
"@types/react": "19.0.0",
"browser-util-inspect": "^0.2.0",
"child_process": "file:./packages/fs-proxy",
"codecs": "file:./packages/codecs",
"debouncer": "file:./packages/debouncer",
"dedent": "^1.5.3",
"dotenv": "^16.4.5",
"ethers": "^6.12.0",
"format-util": "^1.0.5",
"fs": "file:./packages/fs-proxy",
"javascript-time-ago": "^2.5.11",
"jest": "^29.0.0",
"jimp": "^1.6.0",
"json-schema-to-zod-object": "^2.6.7",
"memfs": "^4.15.1",
"memoize-one": "^6.0.0",
"minimatch": "^9.0.4",
"openai": "^4.56.0",
Expand All @@ -31,6 +37,7 @@
"react-agents-node": "file:./packages/react-agents-node",
"react-reconciler": "file:./packages/react-reconciler",
"stripe": "^16.10.0",
"tls": "file:./packages/tls-proxy",
"together-ai": "^0.6.0-alpha.4",
"ts-jest": "^29.2.5",
"twitter-api-sdk": "^1.2.1",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export const spawn = () => {
throw new Error('not implemented');
};
const childProcess = {
spawn,
};
export default childProcess;
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "child_process",
"main": "child-process.mjs"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
import handlebars from "handlebars";
import { type State } from "./types.ts";
import { names, uniqueNamesGenerator } from "unique-names-generator";

/**
* Composes a context string by replacing placeholders in a template with corresponding values from the state.
*
* This function takes a template string with placeholders in the format `{{placeholder}}` and a state object.
* It replaces each placeholder with the value from the state object that matches the placeholder's name.
* If a matching key is not found in the state object for a given placeholder, the placeholder is replaced with an empty string.
*
* By default, this function uses a simple string replacement approach. However, when `templatingEngine` is set to `'handlebars'`, it uses Handlebars templating engine instead, compiling the template into a reusable function and evaluating it with the provided state object.
*
* @param {Object} params - The parameters for composing the context.
* @param {State} params.state - The state object containing values to replace the placeholders in the template.
* @param {string} params.template - The template string containing placeholders to be replaced with state values.
* @param {"handlebars" | undefined} [params.templatingEngine] - The templating engine to use for compiling and evaluating the template (optional, default: `undefined`).
* @returns {string} The composed context string with placeholders replaced by corresponding state values.
*
* @example
* // Given a state object and a template
* const state = { userName: "Alice", userAge: 30 };
* const template = "Hello, {{userName}}! You are {{userAge}} years old";
*
* // Composing the context with simple string replacement will result in:
* // "Hello, Alice! You are 30 years old."
* const contextSimple = composeContext({ state, template });
*/
export const composeContext = ({
state,
template,
templatingEngine,
}: {
state: State;
template: string;
templatingEngine?: "handlebars";
}) => {
if (templatingEngine === "handlebars") {
const templateFunction = handlebars.compile(template);
return templateFunction(state);
}

// @ts-expect-error match isn't working as expected
const out = template.replace(/{{\w+}}/g, (match) => {
const key = match.replace(/{{|}}/g, "");
return state[key] ?? "";
});
return out;
};

/**
* Adds a header to a body of text.
*
* This function takes a header string and a body string and returns a new string with the header prepended to the body.
* If the body string is empty, the header is returned as is.
*
* @param {string} header - The header to add to the body.
* @param {string} body - The body to which to add the header.
* @returns {string} The body with the header prepended.
*
* @example
* // Given a header and a body
* const header = "Header";
* const body = "Body";
*
* // Adding the header to the body will result in:
* // "Header\nBody"
* const text = addHeader(header, body);
*/
export const addHeader = (header: string, body: string) => {
return body.length > 0 ? `${header ? header + "\n" : header}${body}\n` : "";
};

/**
* Generates a string with random user names populated in a template.
*
* This function generates a specified number of random user names and populates placeholders
* in the provided template with these names. Placeholders in the template should follow the format `{{userX}}`
* where `X` is the position of the user (e.g., `{{user1}}`, `{{user2}}`).
*
* @param {string} params.template - The template string containing placeholders for random user names.
* @param {number} params.length - The number of random user names to generate.
* @returns {string} The template string with placeholders replaced by random user names.
*
* @example
* // Given a template and a length
* const template = "Hello, {{user1}}! Meet {{user2}} and {{user3}}.";
* const length = 3;
*
* // Composing the random user string will result in:
* // "Hello, John! Meet Alice and Bob."
* const result = composeRandomUser({ template, length });
*/
export const composeRandomUser = (template: string, length: number) => {
const exampleNames = Array.from({ length }, () =>
uniqueNamesGenerator({ dictionaries: [names] })
);
let result = template;
for (let i = 0; i < exampleNames.length; i++) {
result = result.replaceAll(`{{user${i + 1}}}`, exampleNames[i]);
}

return result;
};
Loading
Loading