Skip to content

Commit 8dbedc9

Browse files
committed
agent starter
1 parent bddd9c4 commit 8dbedc9

File tree

16 files changed

+83
-45
lines changed

16 files changed

+83
-45
lines changed

.changeset/config.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"changelog": [
44
"@changesets/changelog-git",
55
{
6-
"repo": "ephemeraHQ/message-kit"
6+
"repo": "ephemeraHQ/xmtp-agents"
77
}
88
],
99
"commit": false,
@@ -12,5 +12,5 @@
1212
"access": "public",
1313
"baseBranch": "main",
1414
"updateInternalDependencies": "patch",
15-
"ignore": ["base-links", "docs", "@xmtp/tsconfig"]
15+
"ignore": ["@xmtp/tsconfig"]
1616
}

.github/CODEOWNERS

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Global rule for message-kit package
2-
packages/message-kit/* @ephemeraHQ/engineering
1+
# Global rule for xmtp-agents package
2+
packages/xmtp-agents/* @ephemeraHQ/engineering
33

44
# No specific code owners for other files, meaning no approval required

.github/ISSUE_TEMPLATE/bug_report.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ body:
88
value: |
99
Thank you for taking the time to report a bug. Community contributions like yours are key to the development and adoption of XMTP. Review the following guidelines for reporting a bug:
1010
- Include 1 bug per issue. Creating 1 issue per bug will make it easier to assign and track progress on bugs.
11-
- Check [existing issues](https://github.com/ephemeraHQ/message-kit/issues) to see if your issue has already been reported.
12-
- Ensure that the bug is not security-related and can safely be disclosed publicly on GitHub. For information about how to report a security issue, see [Security policy](https://github.com/ephemeraHQ/message-kit/security/policy).
13-
- Follow the [XMTP code of conduct](https://github.com/ephemeraHQ/message-kit/blob/main/CODE_OF_CONDUCT.md).
11+
- Check [existing issues](https://github.com/ephemeraHQ/xmtp-agents/issues) to see if your issue has already been reported.
12+
- Ensure that the bug is not security-related and can safely be disclosed publicly on GitHub. For information about how to report a security issue, see [Security policy](https://github.com/ephemeraHQ/xmtp-agents/security/policy).
13+
- Follow the [XMTP code of conduct](https://github.com/ephemeraHQ/xmtp-agents/blob/main/CODE_OF_CONDUCT.md).
1414
- type: textarea
1515
id: bug-description
1616
attributes:

.github/ISSUE_TEMPLATE/feature_request.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ body:
88
value: |
99
Thank you for taking the time to request a feature. Community contributions like yours are key to the development and adoption of XMTP. Review the following guidelines for requesting a feature:
1010
- Include 1 feature request per issue. Creating 1 issue per request will make it easier to explore and assign a priority to a request.
11-
- Check [existing issues](https://github.com/ephemeraHQ/message-kit/issues) to see if the feature has already been requested.
12-
- Ensure that the feature is not security-related and can safely be disclosed publicly on GitHub. For information about how to report a security issue, see [Security policy](https://github.com/ephemeraHQ/message-kit/security/policy).
13-
- Follow the [XMTP code of conduct](https://github.com/ephemeraHQ/message-kit/blob/main/CODE_OF_CONDUCT.md).
11+
- Check [existing issues](https://github.com/ephemeraHQ/xmtp-agents/issues) to see if the feature has already been requested.
12+
- Ensure that the feature is not security-related and can safely be disclosed publicly on GitHub. For information about how to report a security issue, see [Security policy](https://github.com/ephemeraHQ/xmtp-agents/security/policy).
13+
- Follow the [XMTP code of conduct](https://github.com/ephemeraHQ/xmtp-agents/blob/main/CODE_OF_CONDUCT.md).
1414
- type: textarea
1515
id: problem-description
1616
attributes:

.github/ISSUE_TEMPLATE/skill_request.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ body:
88
value: |
99
Thank you for taking the time to request a skill. Community contributions like yours are key to the development and adoption of the skills library. Review the following guidelines for requesting a skill:
1010
- Include 1 skill request per issue. Creating 1 issue per request will make it easier to explore and assign a priority to a request.
11-
- Check [existing issues](https://github.com/ephemeraHQ/message-kit/issues) to see if the skill has already been requested.
12-
- Ensure that the skill is not security-related and can safely be disclosed publicly on GitHub. For information about how to report a security issue, see [Security policy](https://github.com/ephemeraHQ/message-kit/security/policy).
13-
- Follow the [XMTP code of conduct](https://github.com/ephemeraHQ/message-kit/blob/main/CODE_OF_CONDUCT.md).
11+
- Check [existing issues](https://github.com/ephemeraHQ/xmtp-agents/issues) to see if the skill has already been requested.
12+
- Ensure that the skill is not security-related and can safely be disclosed publicly on GitHub. For information about how to report a security issue, see [Security policy](https://github.com/ephemeraHQ/xmtp-agents/security/policy).
13+
- Follow the [XMTP code of conduct](https://github.com/ephemeraHQ/xmtp-agents/blob/main/CODE_OF_CONDUCT.md).
1414
- type: textarea
1515
id: problem-description
1616
attributes:

.github/workflows/build.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
- name: Install dependencies
4444
run: yarn
4545
- name: Build
46-
run: yarn build:message-kit
46+
run: yarn build:xmtp-agents
4747
- name: Test client
4848
run: yarn test:client
4949
continue-on-error: true

.gitignore

+10-12
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@ node_modules/
33
.DS_Store
44

55
# Template specific ignores
6-
templates/**/data/
7-
templates/**/.data/
8-
templates/**/.turbo/
9-
templates/**/dist/
10-
templates/**/.env
6+
recipes/**/data/
7+
recipes/**/.data/
8+
recipes/**/.turbo/
9+
recipes/**/dist/
10+
recipes/**/.env
1111

1212
# Specific template paths
13-
templates/*/data/
14-
templates/*/.data/
15-
templates/*/.turbo/
16-
templates/*/dist/
17-
templates/*/.env
13+
recipes/*/data/
14+
recipes/*/.data/
15+
recipes/*/.turbo/
16+
recipes/*/dist/
17+
recipes/*/.env
1818

1919
# testing
2020
coverage
@@ -75,5 +75,3 @@ next-env.d.ts
7575

7676
# remix
7777
.data
78-
79-
packages/create-message-kit/templates/**/*

CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ yarn dev
2121
Make it work in the playground:
2222

2323
```tsx
24-
message-kit/
24+
xmtp-agents/
2525
└── packages/
2626
└── agent-starter
2727
└── resolver

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
</div>
55

66
![Release](https://img.shields.io/website/http/huggingface.co/docs/smolagents/index.html.svg?down_color=red&down_message=offline&up_message=online)
7-
[![MIT License](https://img.shields.io/github/license/ephemerahq/message-kit)](https://github.com/ephemerahq/message-kit/blob/main/LICENSE)
7+
[![MIT License](https://img.shields.io/github/license/ephemerahq/xmtp-agents)](https://github.com/ephemerahq/xmtp-agents/blob/main/LICENSE)
88
[![Number of GitHub stars](https://img.shields.io/github/stars/ephemerahq/message-kit?logo=github)](https://github.com/ephemerahq/message-kit)
99

1010
<img src="media/logo.png" alt="Logo" width="60" />
1111

1212
# xmtp-agents
1313

14-
This library offers a convenient TypeScript wrapper for the [XMTP SDK for Node](https://github.com/xmtp/xmtp-js/tree/main/sdks/node-sdk), simplifying agent delopment.
14+
This library offers a convenient TypeScript wrapper for the [@xmtp/node-sdk](https://github.com/xmtp/xmtp-js/tree/main/sdks/node-sdk), simplifying agent delopment.
1515

1616
</div>
1717

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
"build": "yarn build:agent-starter && yarn build:recipes",
1313
"build:agent-starter": "turbo run build --filter=./packages/agent-starter --force",
1414
"build:recipes": "turbo run build --filter='./recipes/*'",
15-
"changeset": "yarn copy && changeset add --type patch",
15+
"changeset": " changeset add --type patch",
1616
"clean": "turbo run clean && rm -rf node_modules && yarn cache clean",
1717
"format": "turbo run format",
18-
"publish": "yarn install && yarn build && yarn copy && node scripts/publish.js",
18+
"publish": "yarn install && yarn build && node scripts/publish.js",
1919
"recipes": "node scripts/recipes.js",
2020
"test": "FORCE_COLOR=1 turbo run test --force --concurrency=1",
2121
"test:client": "cd packages/agent-starter/tests && yarn test:client",

packages/agent-starter/rollup.config.js

-4
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,11 @@ const external = [
99
"@xmtp/content-type-reply",
1010
"@xmtp/content-type-remote-attachment",
1111
"@xmtp/content-type-read-receipt",
12-
"jsdom",
1312
"@xmtp/node-sdk",
14-
"@xmtp/message-kit",
15-
"@redis/client",
1613
"@xmtp/proto",
1714
"@xmtp/node-bindings",
1815
"cross-fetch",
1916
"node-fetch",
20-
"dns",
2117
"path",
2218
"crypto",
2319
"viem",

packages/agent-starter/src/lib/xmtp.ts

+5-6
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ export class XMTP {
100100
);
101101

102102
this.client = client;
103-
104103
this.inboxId = client.inboxId;
105104
this.address = client.accountAddress;
106105
Promise.all([streamMessages(this.onMessage, client, this)]);
@@ -223,17 +222,17 @@ export class XMTP {
223222
agentMessage.receivers = [agentMessage.originalMessage?.sender.inboxId];
224223
}
225224
for (let receiver of agentMessage.receivers) {
226-
let resolvedAddress = isAddress(receiver)
225+
let inboxId = !isAddress(receiver)
227226
? receiver
228227
: await this.client?.getInboxIdByAddress(receiver);
229-
if (!resolvedAddress) {
228+
if (!inboxId) {
230229
throw new Error("Invalid receiver address");
231230
}
232231
let conversation = await this.client?.conversations
233232
.list()
234233
.find(
235234
(conv: Conversation) =>
236-
conv.dmPeerInboxId?.toLowerCase() === resolvedAddress.toLowerCase(),
235+
conv.dmPeerInboxId?.toLowerCase() === inboxId.toLowerCase(),
237236
);
238237
return conversation?.send(message, contentType);
239238
}
@@ -354,7 +353,7 @@ function setupPrivateKey(customKey?: string): {
354353
isRandom = true;
355354

356355
if (fs) {
357-
const envContent = `\nKEY=${key.substring(2)}\n`;
356+
const envContent = `\nKEY=${key.substring(2)}`;
358357
if (fs.existsSync(envFilePath)) {
359358
fs.appendFileSync(envFilePath, envContent);
360359
} else {
@@ -393,7 +392,7 @@ async function setupTestEncryptionKey(): Promise<Uint8Array> {
393392
const testEncryptionKey = toHex(getRandomValues(new Uint8Array(32)));
394393

395394
// Prepare the env content
396-
const envContent = `\nTEST_ENCRYPTION_KEY=${testEncryptionKey}\n`;
395+
const envContent = `\nTEST_ENCRYPTION_KEY=${testEncryptionKey}`;
397396

398397
if (fs) {
399398
if (fs.existsSync(envFilePath)) {

recipes/gated-group/src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ async function main() {
3333
});
3434

3535
console.log(
36-
`XMTP agent initialized on ${agent?.address}\nSend a message on https://xmtp.chat`,
36+
`XMTP agent initialized on ${agent?.address}\nSend a message on https://xmtp.chat or https://converse.xyz/dm/${agent?.address}`,
3737
);
3838
}
3939

recipes/gm/src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ async function main() {
1515
});
1616

1717
console.log(
18-
`XMTP agent initialized on ${agent?.address}\nSend a message on https://xmtp.chat`,
18+
`XMTP agent initialized on ${agent?.address}\nSend a message on https://xmtp.chat or https://converse.xyz/dm/${agent?.address}`,
1919
);
2020
}
2121

scripts/publish.js

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import { execSync } from "child_process";
2+
import fs from "fs";
3+
import path from "path";
4+
5+
// Function to update the version in package.json
6+
function updatePackageVersion(packagePath, versionType) {
7+
const packageJsonPath = path.join(packagePath, "package.json");
8+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
9+
10+
// Extract current version
11+
const currentVersion = packageJson.version;
12+
console.log(`Current version of ${packageJson.name}: ${currentVersion}`);
13+
14+
// Bump version (simplified logic, you might want to use a library like 'semver' for this)
15+
const versionParts = currentVersion.split(".").map(Number);
16+
let newVersion = currentVersion;
17+
if (versionType === "major") {
18+
versionParts[0] += 1;
19+
versionParts[1] = 0;
20+
versionParts[2] = 0;
21+
newVersion = versionParts.join(".");
22+
} else if (versionType === "minor") {
23+
versionParts[1] += 1;
24+
versionParts[2] = 0;
25+
newVersion = versionParts.join(".");
26+
} else if (versionType === "patch") {
27+
versionParts[2] += 1;
28+
newVersion = versionParts.join(".");
29+
}
30+
31+
packageJson.version = newVersion;
32+
// Write updated version back to package.json
33+
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
34+
console.log(`Updated version of ${packageJson.name} to: ${newVersion}`);
35+
}
36+
37+
// Get the version type from command line arguments
38+
const versionType = process.argv[2];
39+
40+
// Update versions for each package
41+
const packages = ["packages/resolver", "packages/agent-starter"];
42+
43+
packages.forEach((packagePath) => {
44+
updatePackageVersion(packagePath, versionType);
45+
});
46+
47+
execSync(`changeset publish`, { stdio: "inherit" });

yarn.lock

-2
Original file line numberDiff line numberDiff line change
@@ -1366,7 +1366,6 @@ __metadata:
13661366
"@changesets/changelog-git": "npm:^0.2.0"
13671367
"@changesets/cli": "npm:^2.27.5"
13681368
"@rollup/plugin-typescript": "npm:^11.1.6"
1369-
"@types/jsdom": "npm:^21.1.7"
13701369
"@types/node": "npm:^20.14.2"
13711370
"@vitest/coverage-v8": "npm:^2.1.4"
13721371
"@xmtp/content-type-primitives": "npm:^2.0.0"
@@ -1377,7 +1376,6 @@ __metadata:
13771376
"@xmtp/content-type-text": "npm:^2.0.0"
13781377
"@xmtp/node-sdk": "npm:^0.0.38"
13791378
dotenv: "npm:^16.4.5"
1380-
jsdom: "npm:^26.0.0"
13811379
node-fetch: "npm:^3.3.2"
13821380
prettier: "npm:^3.3.1"
13831381
rollup: "npm:^4.18.0"

0 commit comments

Comments
 (0)