Skip to content

Commit 423fe44

Browse files
authored
Merge branch 'develop' into interactionimage
2 parents 9f743cd + 87d8eca commit 423fe44

File tree

11 files changed

+629
-434
lines changed

11 files changed

+629
-434
lines changed

.github/workflows/integrationTests.yaml

+6-9
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ on:
33
push:
44
branches:
55
- "*"
6-
pull_request_target:
6+
pull_request:
77
branches:
88
- "*"
99

@@ -33,12 +33,9 @@ jobs:
3333
- name: Build packages
3434
run: pnpm build
3535

36-
- name: Check for API key
37-
run: |
38-
if [ -z "$OPENAI_API_KEY" ]; then
39-
echo "Error: OPENAI_API_KEY is not set."
40-
exit 1
41-
fi
42-
4336
- name: Run integration tests
44-
run: pnpm run integrationTests
37+
env:
38+
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
39+
COINBASE_COMMERCE_KEY: ${{ secrets.COINBASE_COMMERCE_KEY }}
40+
run: |
41+
pnpm run integrationTests

packages/client-twitter/src/post.ts

+2-41
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
stringToUuid,
99
TemplateType,
1010
UUID,
11+
truncateToCompleteSentence,
1112
} from "@elizaos/core";
1213
import { elizaLogger } from "@elizaos/core";
1314
import { ClientBase } from "./base.ts";
@@ -77,40 +78,6 @@ Tweet:
7778
# Respond with qualifying action tags only. Default to NO action unless extremely confident of relevance.` +
7879
postActionResponseFooter;
7980

80-
/**
81-
* Truncate text to fit within the Twitter character limit, ensuring it ends at a complete sentence.
82-
*/
83-
function truncateToCompleteSentence(
84-
text: string,
85-
maxTweetLength: number
86-
): string {
87-
if (text.length <= maxTweetLength) {
88-
return text;
89-
}
90-
91-
// Attempt to truncate at the last period within the limit
92-
const lastPeriodIndex = text.lastIndexOf(".", maxTweetLength - 1);
93-
if (lastPeriodIndex !== -1) {
94-
const truncatedAtPeriod = text.slice(0, lastPeriodIndex + 1).trim();
95-
if (truncatedAtPeriod.length > 0) {
96-
return truncatedAtPeriod;
97-
}
98-
}
99-
100-
// If no period, truncate to the nearest whitespace within the limit
101-
const lastSpaceIndex = text.lastIndexOf(" ", maxTweetLength - 1);
102-
if (lastSpaceIndex !== -1) {
103-
const truncatedAtSpace = text.slice(0, lastSpaceIndex).trim();
104-
if (truncatedAtSpace.length > 0) {
105-
return truncatedAtSpace + "...";
106-
}
107-
}
108-
109-
// Fallback: Hard truncate and add ellipsis
110-
const hardTruncated = text.slice(0, maxTweetLength - 3).trim();
111-
return hardTruncated + "...";
112-
}
113-
11481
interface PendingTweet {
11582
cleanedContent: string;
11683
roomId: UUID;
@@ -399,7 +366,6 @@ export class TwitterPostClient {
399366

400367
async handleNoteTweet(
401368
client: ClientBase,
402-
runtime: IAgentRuntime,
403369
content: string,
404370
tweetId?: string
405371
) {
@@ -465,11 +431,7 @@ export class TwitterPostClient {
465431
let result;
466432

467433
if (cleanedContent.length > DEFAULT_MAX_TWEET_LENGTH) {
468-
result = await this.handleNoteTweet(
469-
client,
470-
runtime,
471-
cleanedContent
472-
);
434+
result = await this.handleNoteTweet(client, cleanedContent);
473435
} else {
474436
result = await this.sendStandardTweet(client, cleanedContent);
475437
}
@@ -1204,7 +1166,6 @@ export class TwitterPostClient {
12041166
if (replyText.length > DEFAULT_MAX_TWEET_LENGTH) {
12051167
result = await this.handleNoteTweet(
12061168
this.client,
1207-
this.runtime,
12081169
replyText,
12091170
tweet.id
12101171
);

packages/core/src/parsing.ts

+34
Original file line numberDiff line numberDiff line change
@@ -205,3 +205,37 @@ export const parseActionResponseFromText = (
205205

206206
return { actions };
207207
};
208+
209+
/**
210+
* Truncate text to fit within the character limit, ensuring it ends at a complete sentence.
211+
*/
212+
export function truncateToCompleteSentence(
213+
text: string,
214+
maxLength: number
215+
): string {
216+
if (text.length <= maxLength) {
217+
return text;
218+
}
219+
220+
// Attempt to truncate at the last period within the limit
221+
const lastPeriodIndex = text.lastIndexOf(".", maxLength - 1);
222+
if (lastPeriodIndex !== -1) {
223+
const truncatedAtPeriod = text.slice(0, lastPeriodIndex + 1).trim();
224+
if (truncatedAtPeriod.length > 0) {
225+
return truncatedAtPeriod;
226+
}
227+
}
228+
229+
// If no period, truncate to the nearest whitespace within the limit
230+
const lastSpaceIndex = text.lastIndexOf(" ", maxLength - 1);
231+
if (lastSpaceIndex !== -1) {
232+
const truncatedAtSpace = text.slice(0, lastSpaceIndex).trim();
233+
if (truncatedAtSpace.length > 0) {
234+
return truncatedAtSpace + "...";
235+
}
236+
}
237+
238+
// Fallback: Hard truncate and add ellipsis
239+
const hardTruncated = text.slice(0, maxLength - 3).trim();
240+
return hardTruncated + "...";
241+
}

packages/plugin-autonome/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@elizaos/plugin-autonome",
3-
"version": "0.1.7-alpha.1",
3+
"version": "0.1.7",
44
"main": "dist/index.js",
55
"type": "module",
66
"types": "dist/index.d.ts",

packages/plugin-autonome/src/actions/launchAgent.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ export default {
9595
creationMethod: 2,
9696
envList: {},
9797
templateId: "Eliza",
98+
};
9899

99100
const sendPostRequest = async () => {
100101
try {
@@ -169,4 +170,5 @@ export default {
169170
},
170171
],
171172
] as ActionExample[][],
172-
} as Action;
173+
} satisfies Action;
174+

packages/plugin-autonome/tsup.config.ts

-10
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,5 @@ export default defineConfig({
1515
"https",
1616
"http",
1717
"agentkeepalive",
18-
"safe-buffer",
19-
"base-x",
20-
"bs58",
21-
"borsh",
22-
"@solana/buffer-layout",
23-
"stream",
24-
"buffer",
25-
"querystring",
26-
"amqplib",
27-
// Add other modules you want to externalize
2818
],
2919
});

packages/plugin-coinbase/src/plugins/commerce.ts

+11-7
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export async function getAllCharges(apiKey: string) {
8282
// Function to fetch details of a specific charge
8383
export async function getChargeDetails(apiKey: string, chargeId: string) {
8484
elizaLogger.debug("Starting getChargeDetails function");
85-
const getUrl = `${url}${chargeId}`;
85+
const getUrl = `${url}/${chargeId}`;
8686

8787
try {
8888
const response = await fetch(getUrl, {
@@ -204,8 +204,8 @@ export const createCoinbaseChargeAction: Action = {
204204
text: `Charge created successfully: ${chargeResponse.hosted_url}`,
205205
attachments: [
206206
{
207-
id: crypto.randomUUID(),
208-
url: chargeResponse.id,
207+
id: chargeResponse.id,
208+
url: chargeResponse.hosted_url,
209209
title: "Coinbase Commerce Charge",
210210
description: `Charge ID: ${chargeResponse.id}`,
211211
text: `Pay here: ${chargeResponse.hosted_url}`,
@@ -351,6 +351,7 @@ export const getAllChargesAction: Action = {
351351
callback(
352352
{
353353
text: `Successfully fetched all charges. Total charges: ${charges.length}`,
354+
attachments: charges,
354355
},
355356
[]
356357
);
@@ -439,17 +440,20 @@ export const getChargeDetailsAction: Action = {
439440

440441
elizaLogger.info("Fetched charge details:", chargeDetails);
441442

443+
const chargeData = chargeDetails.data;
444+
442445
callback(
443446
{
444447
text: `Successfully fetched charge details for ID: ${charge.id}`,
445448
attachments: [
446449
{
447-
id: crypto.randomUUID(),
448-
url: chargeDetails.hosted_url,
450+
id: chargeData.id,
451+
url: chargeData.hosted_url,
449452
title: `Charge Details for ${charge.id}`,
450-
description: `Details: ${JSON.stringify(chargeDetails, null, 2)}`,
451453
source: "coinbase",
452-
text: "",
454+
description: JSON.stringify(chargeDetails, null, 2),
455+
text: `Pay here: ${chargeData.hosted_url}`,
456+
contentType: "application/json",
453457
},
454458
],
455459
},

0 commit comments

Comments
 (0)