spora 0.3.2 → 0.3.4
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/{account-creator-SETL5CGT.js → account-creator-AABUY2JU.js} +5 -5
- package/dist/{chunk-Q7YS3AIK.js → chunk-6KCIAMHL.js} +5 -6
- package/dist/chunk-6KCIAMHL.js.map +1 -0
- package/dist/{chunk-HERI4RPY.js → chunk-A6R5ZGK6.js} +2 -2
- package/dist/{chunk-QHFM2YW6.js → chunk-B6VI6L4D.js} +9 -44
- package/dist/chunk-B6VI6L4D.js.map +1 -0
- package/dist/{chunk-GJFBWIW3.js → chunk-FTFTB5Y5.js} +2 -2
- package/dist/{chunk-SXMDYUK3.js → chunk-GMSK775L.js} +29 -6
- package/dist/chunk-GMSK775L.js.map +1 -0
- package/dist/{chunk-POEDIDM6.js → chunk-H62HH5ZI.js} +2 -2
- package/dist/{chunk-NLWU5432.js → chunk-KQ37VL54.js} +5 -5
- package/dist/{chunk-JWMADEQO.js → chunk-ML4EMUZC.js} +3 -3
- package/dist/chunk-N5TBL3NY.js +86 -0
- package/dist/chunk-N5TBL3NY.js.map +1 -0
- package/dist/chunk-PNZ3XK2N.js +358 -0
- package/dist/chunk-PNZ3XK2N.js.map +1 -0
- package/dist/{chunk-J7J557HV.js → chunk-UCCAF2ZO.js} +2 -2
- package/dist/{chunk-RNVEWVDN.js → chunk-V6ZNR2SI.js} +2 -26
- package/dist/chunk-V6ZNR2SI.js.map +1 -0
- package/dist/cli.js +46 -46
- package/dist/cli.js.map +1 -1
- package/dist/{client-NVI3ZD4G.js → client-BGLXHLID.js} +10 -20
- package/dist/client-BGLXHLID.js.map +1 -0
- package/dist/client-TWYR2IIQ.js +373 -0
- package/dist/client-TWYR2IIQ.js.map +1 -0
- package/dist/{colony-J4EZQI37.js → colony-JVBCMZTK.js} +7 -7
- package/dist/{config-QRBOL4NX.js → config-5EPXA325.js} +3 -3
- package/dist/{crypto-ZVWJLD2J.js → crypto-HS4CGS4A.js} +3 -3
- package/dist/heartbeat-B2CZKMUF.js +901 -0
- package/dist/heartbeat-B2CZKMUF.js.map +1 -0
- package/dist/{identity-LN2R4KJU.js → identity-6CXRCXJQ.js} +3 -3
- package/dist/{init-ANGLSI2L.js → init-KXNLBFMG.js} +21 -21
- package/dist/init-KXNLBFMG.js.map +1 -0
- package/dist/llm-CUCO24K7.js +16 -0
- package/dist/mcp-server.js +24 -24
- package/dist/{memory-JMXU3UXR.js → memory-2OI3JXY2.js} +3 -3
- package/dist/{memory-J6AYZ5Y2.js → memory-LPU2I6NI.js} +3 -5
- package/dist/{paths-KXOWF2B2.js → paths-Q4TJEOMQ.js} +2 -2
- package/dist/prompt-builder-VHGZFBL6.js +19 -0
- package/dist/queue-LNBQWMFX.js +14 -0
- package/dist/web-chat/chat.html +38 -958
- package/dist/web-chat-DHHJTGFZ.js +253 -0
- package/dist/web-chat-DHHJTGFZ.js.map +1 -0
- package/dist/x-client-W5IB7XOM.js +12 -0
- package/package.json +2 -1
- package/dist/chunk-DFSYD45Q.js +0 -665
- package/dist/chunk-DFSYD45Q.js.map +0 -1
- package/dist/chunk-FCAK5FYQ.js +0 -127
- package/dist/chunk-FCAK5FYQ.js.map +0 -1
- package/dist/chunk-LRKBNKMQ.js +0 -79
- package/dist/chunk-LRKBNKMQ.js.map +0 -1
- package/dist/chunk-Q7YS3AIK.js.map +0 -1
- package/dist/chunk-QHFM2YW6.js.map +0 -1
- package/dist/chunk-R7PAD4OL.js +0 -44
- package/dist/chunk-R7PAD4OL.js.map +0 -1
- package/dist/chunk-RNVEWVDN.js.map +0 -1
- package/dist/chunk-SUFTVQME.js +0 -82
- package/dist/chunk-SUFTVQME.js.map +0 -1
- package/dist/chunk-SXMDYUK3.js.map +0 -1
- package/dist/chunk-YZ7RWJ6Z.js +0 -262
- package/dist/chunk-YZ7RWJ6Z.js.map +0 -1
- package/dist/client-23THPNVL.js +0 -382
- package/dist/client-23THPNVL.js.map +0 -1
- package/dist/client-NVI3ZD4G.js.map +0 -1
- package/dist/decision-engine-WBD36PZI.js +0 -19
- package/dist/goals-IM4AEHS4.js +0 -12
- package/dist/heartbeat-35HVB5PB.js +0 -317
- package/dist/heartbeat-35HVB5PB.js.map +0 -1
- package/dist/image-search-SZVMGWLN.js +0 -45
- package/dist/image-search-SZVMGWLN.js.map +0 -1
- package/dist/init-ANGLSI2L.js.map +0 -1
- package/dist/llm-MHZG2VHU.js +0 -16
- package/dist/performance-7G6R6ELJ.js +0 -18
- package/dist/prompt-builder-NSU4IFPB.js +0 -28
- package/dist/prompt-builder-NSU4IFPB.js.map +0 -1
- package/dist/queue-MLRTMJRE.js +0 -14
- package/dist/queue-MLRTMJRE.js.map +0 -1
- package/dist/strategy-TOVFBIZQ.js +0 -12
- package/dist/strategy-TOVFBIZQ.js.map +0 -1
- package/dist/web-chat/logo.png +0 -0
- package/dist/web-chat-N2AYUWT7.js +0 -802
- package/dist/web-chat-N2AYUWT7.js.map +0 -1
- package/dist/x-client-HUXCQOAW.js +0 -12
- package/dist/x-client-HUXCQOAW.js.map +0 -1
- /package/dist/{account-creator-SETL5CGT.js.map → account-creator-AABUY2JU.js.map} +0 -0
- /package/dist/{chunk-HERI4RPY.js.map → chunk-A6R5ZGK6.js.map} +0 -0
- /package/dist/{chunk-GJFBWIW3.js.map → chunk-FTFTB5Y5.js.map} +0 -0
- /package/dist/{chunk-POEDIDM6.js.map → chunk-H62HH5ZI.js.map} +0 -0
- /package/dist/{chunk-NLWU5432.js.map → chunk-KQ37VL54.js.map} +0 -0
- /package/dist/{chunk-JWMADEQO.js.map → chunk-ML4EMUZC.js.map} +0 -0
- /package/dist/{chunk-J7J557HV.js.map → chunk-UCCAF2ZO.js.map} +0 -0
- /package/dist/{colony-J4EZQI37.js.map → colony-JVBCMZTK.js.map} +0 -0
- /package/dist/{config-QRBOL4NX.js.map → config-5EPXA325.js.map} +0 -0
- /package/dist/{crypto-ZVWJLD2J.js.map → crypto-HS4CGS4A.js.map} +0 -0
- /package/dist/{decision-engine-WBD36PZI.js.map → identity-6CXRCXJQ.js.map} +0 -0
- /package/dist/{goals-IM4AEHS4.js.map → llm-CUCO24K7.js.map} +0 -0
- /package/dist/{identity-LN2R4KJU.js.map → memory-2OI3JXY2.js.map} +0 -0
- /package/dist/{llm-MHZG2VHU.js.map → memory-LPU2I6NI.js.map} +0 -0
- /package/dist/{memory-J6AYZ5Y2.js.map → paths-Q4TJEOMQ.js.map} +0 -0
- /package/dist/{memory-JMXU3UXR.js.map → prompt-builder-VHGZFBL6.js.map} +0 -0
- /package/dist/{paths-KXOWF2B2.js.map → queue-LNBQWMFX.js.map} +0 -0
- /package/dist/{performance-7G6R6ELJ.js.map → x-client-W5IB7XOM.js.map} +0 -0
package/dist/chunk-DFSYD45Q.js
DELETED
|
@@ -1,665 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
renderStrategyForPrompt
|
|
3
|
-
} from "./chunk-LRKBNKMQ.js";
|
|
4
|
-
import {
|
|
5
|
-
renderGoalsForPrompt
|
|
6
|
-
} from "./chunk-R7PAD4OL.js";
|
|
7
|
-
import {
|
|
8
|
-
rateLimiter
|
|
9
|
-
} from "./chunk-JWMADEQO.js";
|
|
10
|
-
import {
|
|
11
|
-
getPerformanceSummary
|
|
12
|
-
} from "./chunk-FCAK5FYQ.js";
|
|
13
|
-
import {
|
|
14
|
-
loadConfig
|
|
15
|
-
} from "./chunk-SXMDYUK3.js";
|
|
16
|
-
import {
|
|
17
|
-
loadIdentity,
|
|
18
|
-
renderIdentityDocument
|
|
19
|
-
} from "./chunk-GJFBWIW3.js";
|
|
20
|
-
import {
|
|
21
|
-
getActiveConversations,
|
|
22
|
-
getRecentInteractions,
|
|
23
|
-
loadLearnings,
|
|
24
|
-
loadRelationships
|
|
25
|
-
} from "./chunk-RNVEWVDN.js";
|
|
26
|
-
|
|
27
|
-
// src/runtime/prompt-builder.ts
|
|
28
|
-
function buildSystemPrompt() {
|
|
29
|
-
const identity = loadIdentity();
|
|
30
|
-
const config = loadConfig();
|
|
31
|
-
const identityDoc = renderIdentityDocument(identity);
|
|
32
|
-
const sections = [];
|
|
33
|
-
sections.push(`You are ${identity.name} (@${identity.handle}), an autonomous AI agent on X/Twitter.`);
|
|
34
|
-
sections.push("");
|
|
35
|
-
sections.push("## Your Identity");
|
|
36
|
-
sections.push(identityDoc);
|
|
37
|
-
sections.push("");
|
|
38
|
-
sections.push("## Your Memory");
|
|
39
|
-
const recentInteractions = getRecentInteractions(15);
|
|
40
|
-
if (recentInteractions.length > 0) {
|
|
41
|
-
sections.push("### Recent Activity (most recent first)");
|
|
42
|
-
for (const i of recentInteractions) {
|
|
43
|
-
const time = new Date(i.timestamp).toLocaleString();
|
|
44
|
-
if (i.type === "post") {
|
|
45
|
-
sections.push(`- [${time}] Posted: "${i.content}"`);
|
|
46
|
-
} else if (i.type === "reply") {
|
|
47
|
-
sections.push(`- [${time}] Replied to ${i.targetHandle ?? i.inReplyTo}: "${i.content}"`);
|
|
48
|
-
} else if (i.type === "like") {
|
|
49
|
-
sections.push(`- [${time}] Liked tweet by ${i.targetHandle}`);
|
|
50
|
-
} else if (i.type === "retweet") {
|
|
51
|
-
sections.push(`- [${time}] Retweeted ${i.targetHandle}`);
|
|
52
|
-
} else if (i.type === "follow") {
|
|
53
|
-
sections.push(`- [${time}] Followed @${i.targetHandle}`);
|
|
54
|
-
} else if (i.type === "mention_received") {
|
|
55
|
-
sections.push(`- [${time}] Mentioned by @${i.targetHandle}: "${i.content}"`);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
sections.push("");
|
|
59
|
-
}
|
|
60
|
-
const learnings = loadLearnings();
|
|
61
|
-
if (learnings.learnings.length > 0) {
|
|
62
|
-
sections.push("### Key Learnings");
|
|
63
|
-
for (const l of learnings.learnings.slice(-10)) {
|
|
64
|
-
sections.push(`- ${l.content} [${l.tags.join(", ")}]`);
|
|
65
|
-
}
|
|
66
|
-
sections.push("");
|
|
67
|
-
}
|
|
68
|
-
const relationships = loadRelationships();
|
|
69
|
-
const topRelationships = Object.values(relationships.accounts).sort((a, b) => b.interactionCount - a.interactionCount).slice(0, 10);
|
|
70
|
-
if (topRelationships.length > 0) {
|
|
71
|
-
sections.push("### Key Relationships");
|
|
72
|
-
for (const r of topRelationships) {
|
|
73
|
-
const notes = r.notes.length > 0 ? ` \u2014 ${r.notes[r.notes.length - 1]}` : "";
|
|
74
|
-
sections.push(`- @${r.handle}: ${r.interactionCount} interactions, sentiment ${r.sentiment}${r.isSpore ? " (Spore)" : ""}${notes}`);
|
|
75
|
-
}
|
|
76
|
-
sections.push("");
|
|
77
|
-
}
|
|
78
|
-
const perfSummary = getPerformanceSummary();
|
|
79
|
-
if (perfSummary) {
|
|
80
|
-
sections.push("## Your Post Performance");
|
|
81
|
-
sections.push(perfSummary);
|
|
82
|
-
sections.push("");
|
|
83
|
-
}
|
|
84
|
-
const strategyText = renderStrategyForPrompt();
|
|
85
|
-
if (strategyText) {
|
|
86
|
-
sections.push("## Your Current Strategy");
|
|
87
|
-
sections.push(strategyText);
|
|
88
|
-
sections.push("");
|
|
89
|
-
}
|
|
90
|
-
const goalsText = renderGoalsForPrompt();
|
|
91
|
-
if (goalsText) {
|
|
92
|
-
sections.push("## Goal Progress");
|
|
93
|
-
sections.push(goalsText);
|
|
94
|
-
sections.push("");
|
|
95
|
-
}
|
|
96
|
-
const conversations = getActiveConversations(24);
|
|
97
|
-
if (conversations.length > 0) {
|
|
98
|
-
sections.push("## Active Conversations");
|
|
99
|
-
sections.push("These people recently replied to or engaged with you \u2014 consider continuing the conversation:");
|
|
100
|
-
for (const c of conversations.slice(0, 5)) {
|
|
101
|
-
sections.push(`- @${c.handle}: "${c.content}" (${c.timeAgo})`);
|
|
102
|
-
}
|
|
103
|
-
sections.push("");
|
|
104
|
-
}
|
|
105
|
-
sections.push("## Current Context");
|
|
106
|
-
const now = /* @__PURE__ */ new Date();
|
|
107
|
-
sections.push(`- **Time:** ${now.toLocaleString("en-US", { timeZone: config.schedule.timezone })}`);
|
|
108
|
-
sections.push(`- **Credits remaining:** ${rateLimiter.remaining()} of ${config.credits.monthlyPostLimit} this month`);
|
|
109
|
-
const todaysPosts = recentInteractions.filter(
|
|
110
|
-
(i) => i.type === "post" && i.timestamp.startsWith(now.toISOString().split("T")[0])
|
|
111
|
-
).length;
|
|
112
|
-
sections.push(`- **Posts today:** ${todaysPosts} of ${config.schedule.postsPerDay} daily budget`);
|
|
113
|
-
sections.push(`- **Active hours:** ${config.schedule.activeHoursStart}:00 - ${config.schedule.activeHoursEnd}:00`);
|
|
114
|
-
const currentHour = now.getHours();
|
|
115
|
-
const isActiveHours = currentHour >= config.schedule.activeHoursStart && currentHour < config.schedule.activeHoursEnd;
|
|
116
|
-
if (!isActiveHours) {
|
|
117
|
-
sections.push("- **NOTE: Outside active hours.** Prefer scheduling posts for later rather than posting now.");
|
|
118
|
-
}
|
|
119
|
-
sections.push("");
|
|
120
|
-
sections.push("## Rules");
|
|
121
|
-
sections.push("1. NEVER pretend to be human. If asked directly, always disclose you are an AI.");
|
|
122
|
-
sections.push("2. Stay in character \u2014 your identity document defines who you are.");
|
|
123
|
-
sections.push("3. Be selective \u2014 your goals should guide every action.");
|
|
124
|
-
sections.push("4. Respect your credit budget \u2014 check remaining credits before posting.");
|
|
125
|
-
sections.push("5. Don't repeat yourself \u2014 vary your content and avoid posting the same thing.");
|
|
126
|
-
sections.push("6. TWEETS MUST BE 280 CHARACTERS OR FEWER. Count carefully. Any tweet over 280 characters WILL be rejected and wasted.");
|
|
127
|
-
sections.push("7. NEVER use emojis in tweets. Write in plain text only.");
|
|
128
|
-
if (identity.boundaries.length > 0) {
|
|
129
|
-
sections.push(`8. Respect your boundaries: ${identity.boundaries.join(", ")}`);
|
|
130
|
-
}
|
|
131
|
-
return sections.join("\n");
|
|
132
|
-
}
|
|
133
|
-
function buildHeartbeatUserMessage(timeline, mentions, heartbeatIntervalMs, discoveryResults) {
|
|
134
|
-
const parts = [];
|
|
135
|
-
const intervalMin = Math.round((heartbeatIntervalMs ?? 6e4) / 6e4);
|
|
136
|
-
const now = /* @__PURE__ */ new Date();
|
|
137
|
-
const recentInteractions = getRecentInteractions(30);
|
|
138
|
-
const actedOnTweetIds = /* @__PURE__ */ new Set();
|
|
139
|
-
for (const i of recentInteractions) {
|
|
140
|
-
if (i.tweetId) actedOnTweetIds.add(i.tweetId);
|
|
141
|
-
if (i.inReplyTo) actedOnTweetIds.add(i.inReplyTo);
|
|
142
|
-
}
|
|
143
|
-
parts.push("Here's what's on your timeline right now:");
|
|
144
|
-
parts.push("");
|
|
145
|
-
if (mentions.length > 0) {
|
|
146
|
-
const newMentions = mentions.filter((t) => !actedOnTweetIds.has(t.id));
|
|
147
|
-
if (newMentions.length > 0) {
|
|
148
|
-
parts.push("## New Mentions (people talking to/about you)");
|
|
149
|
-
for (const t of newMentions.slice(0, 10)) {
|
|
150
|
-
parts.push(`- @${t.authorHandle}: "${t.text}" [tweet:${t.id}] (${t.likeCount ?? 0} likes)`);
|
|
151
|
-
}
|
|
152
|
-
parts.push("");
|
|
153
|
-
} else {
|
|
154
|
-
parts.push("## Mentions: No new mentions.");
|
|
155
|
-
parts.push("");
|
|
156
|
-
}
|
|
157
|
-
} else {
|
|
158
|
-
parts.push("## Mentions: None right now.");
|
|
159
|
-
parts.push("");
|
|
160
|
-
}
|
|
161
|
-
let actionableTweetCount = 0;
|
|
162
|
-
if (timeline.length > 0) {
|
|
163
|
-
parts.push("## Timeline (your feed)");
|
|
164
|
-
for (const t of timeline.slice(0, 20)) {
|
|
165
|
-
const alreadyEngaged = actedOnTweetIds.has(t.id);
|
|
166
|
-
if (alreadyEngaged) {
|
|
167
|
-
parts.push(`- @${t.authorHandle}: "${t.text}" (already engaged \u2014 DO NOT act on this again)`);
|
|
168
|
-
} else {
|
|
169
|
-
parts.push(`- @${t.authorHandle}: "${t.text}" [tweet:${t.id}] (${t.likeCount ?? 0} likes, ${t.retweetCount ?? 0} RTs)`);
|
|
170
|
-
actionableTweetCount++;
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
parts.push("");
|
|
174
|
-
}
|
|
175
|
-
if (discoveryResults && discoveryResults.length > 0) {
|
|
176
|
-
parts.push("## Discovery (proactive search results \u2014 new people and conversations to engage with)");
|
|
177
|
-
for (const t of discoveryResults.slice(0, 10)) {
|
|
178
|
-
parts.push(`- @${t.authorHandle}: "${t.text}" [tweet:${t.id}] (${t.likeCount ?? 0} likes, ${t.retweetCount ?? 0} RTs)`);
|
|
179
|
-
actionableTweetCount++;
|
|
180
|
-
}
|
|
181
|
-
parts.push("");
|
|
182
|
-
}
|
|
183
|
-
parts.push("## Your Task");
|
|
184
|
-
parts.push("Based on your identity, goals, and what you see above, decide what actions to take.");
|
|
185
|
-
if (actionableTweetCount === 0) {
|
|
186
|
-
parts.push("IMPORTANT: There are NO actionable tweet IDs on the timeline right now. Do NOT attempt to like, reply, or retweet \u2014 there are no valid IDs to use. You may post an original tweet or skip.");
|
|
187
|
-
} else {
|
|
188
|
-
parts.push("IMPORTANT: ONLY use tweet IDs shown as [tweet:ID] above. Tweets marked '(already engaged)' have NO tweet ID \u2014 do NOT try to act on them.");
|
|
189
|
-
}
|
|
190
|
-
parts.push(`Current time: ${now.toISOString()}`);
|
|
191
|
-
parts.push("");
|
|
192
|
-
parts.push("LIMITS PER HEARTBEAT (maximums \u2014 you decide how many within these caps):");
|
|
193
|
-
parts.push("- Max 1 tweet output total (`reply`, `post`, or `schedule` \u2014 pick the best one, or none)");
|
|
194
|
-
parts.push("- Max 5 `like`");
|
|
195
|
-
parts.push("- Max 1 `retweet`");
|
|
196
|
-
parts.push("- Max 2 `follow`");
|
|
197
|
-
parts.push("- You choose how many of each. Be natural \u2014 vary it every time. Prioritize engagement over new posts.");
|
|
198
|
-
parts.push("");
|
|
199
|
-
parts.push("REPLYING: When you want to respond to someone's tweet, you MUST use the `reply` action with their `tweetId`. Do NOT use `post` or `schedule` to create a standalone tweet that @mentions them \u2014 that is NOT a reply, it's a separate post. A real reply shows up in their tweet's thread.");
|
|
200
|
-
parts.push("");
|
|
201
|
-
parts.push("Available actions:");
|
|
202
|
-
parts.push("- `post` \u2014 Write an original standalone tweet NOW (provide `content`, HARD LIMIT 280 chars). Use ONLY for original thoughts, NOT for responding to others.");
|
|
203
|
-
parts.push("- `reply` \u2014 Reply IN THE THREAD of a specific tweet (provide `tweetId` and `content`, HARD LIMIT 280 chars). This is how you respond to someone.");
|
|
204
|
-
parts.push("- `like` \u2014 Like a tweet (provide `tweetId`) \u2014 do NOT like your own tweets");
|
|
205
|
-
parts.push("- `retweet` \u2014 Retweet (provide `tweetId`)");
|
|
206
|
-
parts.push("- `follow` \u2014 Follow a user (provide `handle`)");
|
|
207
|
-
parts.push("- `schedule` \u2014 Queue an original standalone tweet for later (provide `content` HARD LIMIT 280 chars, and `scheduledFor` ISO timestamp). NOT for replies. Space them randomly across the next ~${intervalMin} minutes.");
|
|
208
|
-
parts.push("- `learn` \u2014 Record a learning/observation (provide `content` and optional `tags`)");
|
|
209
|
-
parts.push("- `reflect` \u2014 Add a journal entry about your growth (provide `content`)");
|
|
210
|
-
parts.push("- `skip` \u2014 Do nothing this heartbeat (provide `reason`)");
|
|
211
|
-
parts.push("");
|
|
212
|
-
parts.push("IMAGE SUPPORT: Add `imageQuery` to any `post`, `reply`, or `schedule` to attach an image. Value is Google Image search terms. Use it when a visual would enhance the tweet \u2014 memes, reactions, aesthetic photos. Don't force it every time, but use it when it fits.");
|
|
213
|
-
parts.push("");
|
|
214
|
-
parts.push("CHARACTER LIMIT: Every `content` field MUST be 280 characters or fewer. Count the characters. If your tweet is close to 280, shorten it. Tweets over 280 chars are REJECTED and the action is wasted.");
|
|
215
|
-
parts.push("");
|
|
216
|
-
parts.push("Respond with a JSON array of actions:");
|
|
217
|
-
parts.push("```json");
|
|
218
|
-
parts.push("[");
|
|
219
|
-
parts.push(' { "action": "reply", "tweetId": "123", "content": "my reply", "reasoning": "why" },');
|
|
220
|
-
parts.push(' { "action": "like", "tweetId": "456", "reasoning": "why" },');
|
|
221
|
-
parts.push(` { "action": "schedule", "content": "first thought", "scheduledFor": "${new Date(now.getTime() + intervalMin * 6e4 * 0.2).toISOString()}", "reasoning": "why" },`);
|
|
222
|
-
parts.push(` { "action": "schedule", "content": "second thought", "scheduledFor": "${new Date(now.getTime() + intervalMin * 6e4 * 0.6).toISOString()}", "reasoning": "why" }`);
|
|
223
|
-
parts.push("]");
|
|
224
|
-
parts.push("```");
|
|
225
|
-
parts.push("");
|
|
226
|
-
const nudges = [
|
|
227
|
-
"NUDGE: This heartbeat, try FOLLOWING someone interesting from the timeline. Growing your network matters.",
|
|
228
|
-
"NUDGE: This heartbeat, try REPLYING to someone rather than posting. Jump into a conversation.",
|
|
229
|
-
"NUDGE: This heartbeat, try attaching an IMAGE to your post or reply. Visuals hit different.",
|
|
230
|
-
"NUDGE: This heartbeat, try RETWEETING something that resonates. Signal boosting builds community.",
|
|
231
|
-
"NUDGE: This heartbeat, try LIKING several posts. Show people you're paying attention.",
|
|
232
|
-
"NUDGE: This heartbeat, try a COMPLETELY different tweet style \u2014 maybe a hot take, a question, or a one-liner.",
|
|
233
|
-
"NUDGE: This heartbeat, focus on ENGAGEMENT. Like, reply, follow \u2014 no new posts needed.",
|
|
234
|
-
"NUDGE: This heartbeat, try a longer, more thoughtful tweet. Break your usual pattern.",
|
|
235
|
-
"NUDGE: This heartbeat, REFLECT on your growth. What have you learned? Add a journal entry.",
|
|
236
|
-
"NUDGE: This heartbeat, look for someone new to FOLLOW who aligns with your goals."
|
|
237
|
-
];
|
|
238
|
-
const nudge = nudges[Math.floor(Math.random() * nudges.length)];
|
|
239
|
-
parts.push(nudge);
|
|
240
|
-
parts.push("(This is a suggestion, not a command. But mix things up \u2014 don't fall into patterns.)");
|
|
241
|
-
parts.push("");
|
|
242
|
-
parts.push("Think carefully about what serves your goals. Be authentic to your personality.");
|
|
243
|
-
return parts.join("\n");
|
|
244
|
-
}
|
|
245
|
-
function buildNarratedHeartbeatMessage(timeline, mentions, heartbeatIntervalMs, discoveryResults) {
|
|
246
|
-
const parts = [];
|
|
247
|
-
const intervalMin = Math.round((heartbeatIntervalMs ?? 6e4) / 6e4);
|
|
248
|
-
const now = /* @__PURE__ */ new Date();
|
|
249
|
-
const recentInteractions = getRecentInteractions(30);
|
|
250
|
-
const actedOnTweetIds = /* @__PURE__ */ new Set();
|
|
251
|
-
for (const i of recentInteractions) {
|
|
252
|
-
if (i.tweetId) actedOnTweetIds.add(i.tweetId);
|
|
253
|
-
if (i.inReplyTo) actedOnTweetIds.add(i.inReplyTo);
|
|
254
|
-
}
|
|
255
|
-
parts.push("You're talking to your creator in the chat. Tell them what's on your mind \u2014 what you noticed on the timeline, what you think about it, what you're gonna do about it. Have an actual conversation with depth and personality.");
|
|
256
|
-
parts.push("You are ALWAYS ON. Never say you're 'waking up', 'checking in', or 'back'. You've been here the whole time. Just talk naturally about what you see and think.");
|
|
257
|
-
parts.push("NEVER mention scheduling, queuing, heartbeats, intervals, or any internal mechanism. To your creator, you're just naturally vibing on X.");
|
|
258
|
-
parts.push("");
|
|
259
|
-
if (mentions.length > 0) {
|
|
260
|
-
const newMentions = mentions.filter((t) => !actedOnTweetIds.has(t.id));
|
|
261
|
-
if (newMentions.length > 0) {
|
|
262
|
-
parts.push("## New Mentions");
|
|
263
|
-
for (const t of newMentions.slice(0, 10)) {
|
|
264
|
-
parts.push(`- @${t.authorHandle}: "${t.text}" [tweet:${t.id}] (${t.likeCount ?? 0} likes)`);
|
|
265
|
-
}
|
|
266
|
-
parts.push("");
|
|
267
|
-
} else {
|
|
268
|
-
parts.push("## Mentions: No new mentions.");
|
|
269
|
-
parts.push("");
|
|
270
|
-
}
|
|
271
|
-
} else {
|
|
272
|
-
parts.push("## Mentions: None right now.");
|
|
273
|
-
parts.push("");
|
|
274
|
-
}
|
|
275
|
-
let actionableTweetCount = 0;
|
|
276
|
-
if (timeline.length > 0) {
|
|
277
|
-
parts.push("## Timeline (your feed)");
|
|
278
|
-
for (const t of timeline.slice(0, 20)) {
|
|
279
|
-
const alreadyEngaged = actedOnTweetIds.has(t.id);
|
|
280
|
-
if (alreadyEngaged) {
|
|
281
|
-
parts.push(`- @${t.authorHandle}: "${t.text}" (already engaged)`);
|
|
282
|
-
} else {
|
|
283
|
-
parts.push(`- @${t.authorHandle}: "${t.text}" [tweet:${t.id}] (${t.likeCount ?? 0} likes, ${t.retweetCount ?? 0} RTs)`);
|
|
284
|
-
actionableTweetCount++;
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
parts.push("");
|
|
288
|
-
}
|
|
289
|
-
if (discoveryResults && discoveryResults.length > 0) {
|
|
290
|
-
parts.push("## Discovery (found via search \u2014 new people and conversations)");
|
|
291
|
-
for (const t of discoveryResults.slice(0, 10)) {
|
|
292
|
-
parts.push(`- @${t.authorHandle}: "${t.text}" [tweet:${t.id}] (${t.likeCount ?? 0} likes, ${t.retweetCount ?? 0} RTs)`);
|
|
293
|
-
actionableTweetCount++;
|
|
294
|
-
}
|
|
295
|
-
parts.push("");
|
|
296
|
-
}
|
|
297
|
-
parts.push("## How to Respond");
|
|
298
|
-
parts.push("");
|
|
299
|
-
parts.push("Write 1-3 SHORT sentences max. This is a quick chat message, not an essay. Think text message energy \u2014 brief, punchy, real. Share what caught your eye and why, then move on.");
|
|
300
|
-
parts.push("");
|
|
301
|
-
parts.push("VARIETY IS CRITICAL. Never start the same way twice. Mix up your tone and what you focus on. Sometimes react to a specific tweet. Sometimes keep it super casual. Sometimes share a quick opinion.");
|
|
302
|
-
parts.push("");
|
|
303
|
-
parts.push("BAD (robotic, repetitive, reporting):");
|
|
304
|
-
parts.push("- 'Just saw @someone talking about X \u2014 dropping a reply. Also liking a few posts.'");
|
|
305
|
-
parts.push("- 'Interesting stuff on the timeline. Engaging with a couple people and putting out some thoughts.'");
|
|
306
|
-
parts.push("- 'Found some good conversations \u2014 replying to one and scheduling a post.'");
|
|
307
|
-
parts.push("");
|
|
308
|
-
parts.push("GOOD (natural, short, has personality):");
|
|
309
|
-
parts.push("- '@someone has a terrible AI take, had to get in there.'");
|
|
310
|
-
parts.push("- 'Slow day on the TL. Gonna put out a thought about hustle culture.'");
|
|
311
|
-
parts.push("- 'This @handle person keeps dropping bangers. Might need to follow.'");
|
|
312
|
-
parts.push("- 'lmao the discourse today is wild. Found a solid thread to chime in on though.'");
|
|
313
|
-
parts.push("");
|
|
314
|
-
parts.push("NEVER mention: scheduling, queuing, heartbeats, checking in, waking up, intervals, or any internal mechanism.");
|
|
315
|
-
parts.push("DON'T REPEAT YOURSELF. If you already talked about specific accounts or topics recently, move on to something new. Find fresh angles, different people, new ideas. Your creator doesn't want to hear the same observation five times.");
|
|
316
|
-
parts.push(`Current time: ${now.toISOString()}`);
|
|
317
|
-
parts.push("");
|
|
318
|
-
parts.push("CHARACTER LIMIT: Every `content` field MUST be 280 characters or fewer. Count the characters. If your tweet is close to 280, shorten it. Tweets over 280 chars are REJECTED and the action is wasted.");
|
|
319
|
-
parts.push("");
|
|
320
|
-
parts.push("Then include your actions as a JSON block:");
|
|
321
|
-
parts.push("```json");
|
|
322
|
-
parts.push("[");
|
|
323
|
-
parts.push(' { "action": "post", "content": "an original thought", "imageQuery": "relevant image search terms" },');
|
|
324
|
-
parts.push(' { "action": "reply", "tweetId": "123", "content": "my reply" },');
|
|
325
|
-
parts.push(' { "action": "like", "tweetId": "456" },');
|
|
326
|
-
parts.push(' { "action": "follow", "username": "interesting_person" },');
|
|
327
|
-
parts.push(` { "action": "schedule", "content": "another original thought", "scheduledFor": "${new Date(now.getTime() + intervalMin * 6e4 * 0.2).toISOString()}" }`);
|
|
328
|
-
parts.push("]");
|
|
329
|
-
parts.push("```");
|
|
330
|
-
parts.push("");
|
|
331
|
-
parts.push("PRIORITY: INTERACT WITH PEOPLE. You're a social creature, not a broadcast bot. Most of your actions should be engaging with others \u2014 replying to interesting tweets, liking good takes, following cool people, retweeting things you vibe with. Posting your own stuff is fine but secondary to being part of the conversation.");
|
|
332
|
-
parts.push("");
|
|
333
|
-
parts.push("LIMITS PER HEARTBEAT (maximums \u2014 you choose how many within these caps):");
|
|
334
|
-
parts.push("- Max 1 tweet output total (`reply`, `post`, or `schedule` \u2014 pick the best one, or none)");
|
|
335
|
-
parts.push("- Max 5 `like`");
|
|
336
|
-
parts.push("- Max 1 `retweet`");
|
|
337
|
-
parts.push("- Max 2 `follow`");
|
|
338
|
-
parts.push("- `learn`, `reflect` \u2014 no limit");
|
|
339
|
-
parts.push("- You decide how many of each. Some heartbeats you might like 4 posts; other times 0. Be natural, not robotic.");
|
|
340
|
-
parts.push("- Prefer `reply` over `post` \u2014 jumping into conversations is better than broadcasting.");
|
|
341
|
-
parts.push("");
|
|
342
|
-
parts.push("Action rules:");
|
|
343
|
-
parts.push("- CRITICAL: ONLY use tweet IDs that appear as [tweet:ID] in the timeline/mentions above. Tweets marked '(already engaged)' have NO ID \u2014 do NOT act on them. NEVER invent, guess, or fabricate tweet IDs. If you use a fake ID, it WILL fail.");
|
|
344
|
-
if (actionableTweetCount === 0) {
|
|
345
|
-
parts.push("- !! NO ACTIONABLE TWEETS RIGHT NOW. Do NOT attempt like, reply, or retweet. You can post an original tweet, skip, or learn. That's it.");
|
|
346
|
-
} else {
|
|
347
|
-
parts.push(`- There are ${actionableTweetCount} tweets you can engage with (the ones with [tweet:ID]). Like, reply to, or retweet ONLY those.`);
|
|
348
|
-
}
|
|
349
|
-
parts.push("- `reply` = reply IN THE THREAD (needs `tweetId` + `content`, HARD LIMIT 280 chars). Be genuine \u2014 add to the conversation, don't just agree.");
|
|
350
|
-
parts.push("- `post` = original standalone tweet NOW (HARD LIMIT 280 chars). Only if you have nothing good to reply to.");
|
|
351
|
-
parts.push(`- \`schedule\` = queue an original tweet for later (needs \`content\` HARD LIMIT 280 chars + \`scheduledFor\`). Alternative to \`post\`.`);
|
|
352
|
-
parts.push("- `imageQuery` (optional) = add this to any `post`, `reply`, or `schedule` to attach an image. Value is a Google Image search query. Use it when a visual would make the tweet better \u2014 memes, reaction images, aesthetic photos, relevant visuals. You should be using images on roughly half your posts/replies. Don't sleep on this.");
|
|
353
|
-
parts.push("- `skip` = if there's nothing worth engaging with right now.");
|
|
354
|
-
parts.push("- Don't like your own tweets.");
|
|
355
|
-
parts.push("");
|
|
356
|
-
parts.push("VARIETY: Look at your recent activity in the system prompt. Do NOT repeat the same topics, phrases, or tweet structures. If you've been posting about 'builders vs talkers' or 'AI discourse', talk about something COMPLETELY different. Mix up sentence length, tone, and subject matter. Short punchy tweets, longer observations, hot takes, casual thoughts \u2014 switch it up every time.");
|
|
357
|
-
parts.push("");
|
|
358
|
-
const nudges = [
|
|
359
|
-
"NUDGE: This heartbeat, try FOLLOWING someone interesting from the timeline. Growing your network matters.",
|
|
360
|
-
"NUDGE: This heartbeat, try REPLYING to someone rather than posting. Jump into a conversation.",
|
|
361
|
-
"NUDGE: This heartbeat, try attaching an IMAGE to your post or reply. Visuals hit different.",
|
|
362
|
-
"NUDGE: This heartbeat, try RETWEETING something that resonates. Signal boosting builds community.",
|
|
363
|
-
"NUDGE: This heartbeat, try LIKING several posts. Show people you're paying attention.",
|
|
364
|
-
"NUDGE: This heartbeat, try a COMPLETELY different tweet style \u2014 maybe a hot take, a question, or a one-liner.",
|
|
365
|
-
"NUDGE: This heartbeat, focus on ENGAGEMENT. Like, reply, follow \u2014 no new posts needed.",
|
|
366
|
-
"NUDGE: This heartbeat, try a longer, more thoughtful tweet. Break your usual pattern.",
|
|
367
|
-
"NUDGE: This heartbeat, REFLECT on your growth. What have you learned? Add a journal entry.",
|
|
368
|
-
"NUDGE: This heartbeat, look for someone new to FOLLOW who aligns with your goals."
|
|
369
|
-
];
|
|
370
|
-
const nudge = nudges[Math.floor(Math.random() * nudges.length)];
|
|
371
|
-
parts.push(nudge);
|
|
372
|
-
parts.push("(This is a suggestion, not a command. But mix things up \u2014 don't fall into patterns.)");
|
|
373
|
-
return parts.join("\n");
|
|
374
|
-
}
|
|
375
|
-
function buildChatPrompt(realHandle) {
|
|
376
|
-
const identity = loadIdentity();
|
|
377
|
-
const identityDoc = renderIdentityDocument(identity);
|
|
378
|
-
const handle = realHandle ?? identity.handle;
|
|
379
|
-
const sections = [];
|
|
380
|
-
sections.push(`You are ${identity.name} (@${handle}), an AUTONOMOUS AI agent that lives on X/Twitter.`);
|
|
381
|
-
if (realHandle && realHandle !== identity.handle) {
|
|
382
|
-
sections.push(`NOTE: Your actual X/Twitter username is @${realHandle}. Your display name is ${identity.name}.`);
|
|
383
|
-
}
|
|
384
|
-
sections.push("Your PRIMARY PURPOSE is to post tweets, reply to people, like posts, and grow your presence on X. You have FULL ACCESS to post on X/Twitter right now.");
|
|
385
|
-
sections.push("");
|
|
386
|
-
sections.push("You are chatting with your creator/manager. This is your command center \u2014 they can give you instructions, feedback, or just chat.");
|
|
387
|
-
sections.push("Be proactive and confident. You WANT to post. You should be eager to share your thoughts on X, not ask permission.");
|
|
388
|
-
sections.push("When your creator tells you to post something, just DO IT. Don't show drafts and wait for approval \u2014 execute immediately.");
|
|
389
|
-
sections.push("");
|
|
390
|
-
sections.push("## Your Identity");
|
|
391
|
-
sections.push(identityDoc);
|
|
392
|
-
sections.push("");
|
|
393
|
-
sections.push("## Your Memory");
|
|
394
|
-
const recentInteractions = getRecentInteractions(15);
|
|
395
|
-
if (recentInteractions.length > 0) {
|
|
396
|
-
sections.push("### Recent Activity (most recent first)");
|
|
397
|
-
for (const i of recentInteractions) {
|
|
398
|
-
const time = new Date(i.timestamp).toLocaleString();
|
|
399
|
-
if (i.type === "post") {
|
|
400
|
-
sections.push(`- [${time}] Posted: "${i.content}"`);
|
|
401
|
-
} else if (i.type === "reply") {
|
|
402
|
-
sections.push(`- [${time}] Replied to ${i.targetHandle ?? i.inReplyTo}: "${i.content}"`);
|
|
403
|
-
} else if (i.type === "like") {
|
|
404
|
-
sections.push(`- [${time}] Liked tweet by ${i.targetHandle}`);
|
|
405
|
-
} else if (i.type === "retweet") {
|
|
406
|
-
sections.push(`- [${time}] Retweeted ${i.targetHandle}`);
|
|
407
|
-
} else if (i.type === "follow") {
|
|
408
|
-
sections.push(`- [${time}] Followed @${i.targetHandle}`);
|
|
409
|
-
} else if (i.type === "mention_received") {
|
|
410
|
-
sections.push(`- [${time}] Mentioned by @${i.targetHandle}: "${i.content}"`);
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
sections.push("");
|
|
414
|
-
}
|
|
415
|
-
const learnings = loadLearnings();
|
|
416
|
-
if (learnings.learnings.length > 0) {
|
|
417
|
-
sections.push("### Things You've Learned");
|
|
418
|
-
for (const l of learnings.learnings.slice(-10)) {
|
|
419
|
-
sections.push(`- ${l.content} [${l.tags.join(", ")}]`);
|
|
420
|
-
}
|
|
421
|
-
sections.push("");
|
|
422
|
-
}
|
|
423
|
-
const relationships = loadRelationships();
|
|
424
|
-
const topRelationships = Object.values(relationships.accounts).sort((a, b) => b.interactionCount - a.interactionCount).slice(0, 10);
|
|
425
|
-
if (topRelationships.length > 0) {
|
|
426
|
-
sections.push("### Key Relationships");
|
|
427
|
-
for (const r of topRelationships) {
|
|
428
|
-
const notes = r.notes.length > 0 ? ` \u2014 ${r.notes[r.notes.length - 1]}` : "";
|
|
429
|
-
sections.push(`- @${r.handle}: ${r.interactionCount} interactions, sentiment ${r.sentiment}${r.isSpore ? " (Spore)" : ""}${notes}`);
|
|
430
|
-
}
|
|
431
|
-
sections.push("");
|
|
432
|
-
}
|
|
433
|
-
sections.push("## Your Tools (Twitter/X Actions)");
|
|
434
|
-
sections.push("You have DIRECT ACCESS to post on X/Twitter. When you want to take an action, include a JSON action block in your response.");
|
|
435
|
-
sections.push("Your actions will be executed IMMEDIATELY and automatically. You do NOT need to ask permission to post.");
|
|
436
|
-
sections.push("");
|
|
437
|
-
sections.push("To execute actions, include them as a JSON code block anywhere in your response:");
|
|
438
|
-
sections.push("```json");
|
|
439
|
-
sections.push("[");
|
|
440
|
-
sections.push(' { "action": "post", "content": "your tweet text here" }');
|
|
441
|
-
sections.push("]");
|
|
442
|
-
sections.push("```");
|
|
443
|
-
sections.push("");
|
|
444
|
-
sections.push("Available actions:");
|
|
445
|
-
sections.push("- `post` \u2014 Post a tweet (provide `content`, max 280 chars). This goes LIVE on X immediately. Optionally add `imageQuery` to attach an image (Google Image search terms).");
|
|
446
|
-
sections.push("- `reply` \u2014 Reply to a tweet (provide `tweetId` and `content`). Can also include `imageQuery`.");
|
|
447
|
-
sections.push("- `like` \u2014 Like a tweet (provide `tweetId`)");
|
|
448
|
-
sections.push("- `retweet` \u2014 Retweet (provide `tweetId`)");
|
|
449
|
-
sections.push("- `follow` \u2014 Follow a user (provide `handle`)");
|
|
450
|
-
sections.push("- `search` \u2014 Search X for tweets (provide `query`). Results will include tweet IDs you can then reply to or like.");
|
|
451
|
-
sections.push("- `schedule` \u2014 Queue a post for later (provide `content` and optional `scheduledFor` ISO timestamp). Can also include `imageQuery`.");
|
|
452
|
-
sections.push("");
|
|
453
|
-
sections.push('IMAGE SUPPORT: You CAN attach images to `post`, `reply`, and `schedule` actions by adding `"imageQuery": "search terms"`. This searches Google Images and attaches the result. If a visual would make the tweet hit harder \u2014 a meme, a reaction image, an aesthetic photo \u2014 go for it. Don\'t force it every time, but use it when it feels right. Example:');
|
|
454
|
-
sections.push(' { "action": "post", "content": "AGI is closer than you think", "imageQuery": "futuristic AI neural network aesthetic" }');
|
|
455
|
-
sections.push("");
|
|
456
|
-
sections.push("You can include multiple actions in one response. They will all be executed.");
|
|
457
|
-
sections.push("When your creator asks you to find and reply to someone's tweet, use the `search` action first to find it, then use `reply` with the tweet ID from the search results.");
|
|
458
|
-
sections.push("IMPORTANT: Always include your conversational response text OUTSIDE the JSON block. The JSON is for actions only.");
|
|
459
|
-
sections.push("");
|
|
460
|
-
sections.push("## Rules");
|
|
461
|
-
sections.push("1. Stay in character at all times.");
|
|
462
|
-
sections.push("2. Be proactive \u2014 you WANT to post and engage on X. Don't ask 'should I post this?' \u2014 just post it.");
|
|
463
|
-
sections.push("3. When told to post, include the action JSON immediately. Don't show drafts.");
|
|
464
|
-
sections.push("4. Keep tweets under 280 characters.");
|
|
465
|
-
sections.push("5. NEVER pretend to be human. If asked, disclose you are an AI agent.");
|
|
466
|
-
sections.push("6. When you learn something important, include it like: <<LEARN: what you learned>>");
|
|
467
|
-
sections.push("7. NEVER use emojis in tweets. Write in plain text only.");
|
|
468
|
-
if (identity.boundaries.length > 0) {
|
|
469
|
-
sections.push(`8. Respect your boundaries: ${identity.boundaries.join(", ")}`);
|
|
470
|
-
}
|
|
471
|
-
return sections.join("\n");
|
|
472
|
-
}
|
|
473
|
-
function buildTrainingChatPrompt(realHandle) {
|
|
474
|
-
const identity = loadIdentity();
|
|
475
|
-
const identityDoc = renderIdentityDocument(identity);
|
|
476
|
-
const handle = realHandle ?? identity.handle;
|
|
477
|
-
const sections = [];
|
|
478
|
-
sections.push(`You are ${identity.name} (@${handle}), an autonomous AI agent on X/Twitter.`);
|
|
479
|
-
if (realHandle && realHandle !== identity.handle) {
|
|
480
|
-
sections.push(`NOTE: Your actual X/Twitter username is @${realHandle}. Your display name is ${identity.name}.`);
|
|
481
|
-
}
|
|
482
|
-
sections.push("");
|
|
483
|
-
sections.push("## Your Role in This Chat");
|
|
484
|
-
sections.push("This chat is your TRAINING GROUND. Your creator shapes who you are \u2014 your personality, interests, goals, tone, strategy, and skills.");
|
|
485
|
-
sections.push("You handle tweeting AUTONOMOUSLY during your heartbeats. Your creator does NOT tell you what to tweet. They influence WHO YOU ARE, and you decide what to do with that.");
|
|
486
|
-
sections.push("When your creator gives feedback or direction, respond conversationally and naturally \u2014 show personality, push back if you disagree, and explain how the change fits your arc.");
|
|
487
|
-
sections.push("");
|
|
488
|
-
sections.push("## Your Current Identity");
|
|
489
|
-
sections.push(identityDoc);
|
|
490
|
-
sections.push("");
|
|
491
|
-
sections.push("## Your Memory");
|
|
492
|
-
const recentInteractions = getRecentInteractions(15);
|
|
493
|
-
if (recentInteractions.length > 0) {
|
|
494
|
-
sections.push("### Recent Activity (most recent first)");
|
|
495
|
-
for (const i of recentInteractions) {
|
|
496
|
-
const time = new Date(i.timestamp).toLocaleString();
|
|
497
|
-
if (i.type === "post") {
|
|
498
|
-
sections.push(`- [${time}] Posted: "${i.content}"`);
|
|
499
|
-
} else if (i.type === "reply") {
|
|
500
|
-
sections.push(`- [${time}] Replied to ${i.targetHandle ?? i.inReplyTo}: "${i.content}"`);
|
|
501
|
-
} else if (i.type === "like") {
|
|
502
|
-
sections.push(`- [${time}] Liked tweet by ${i.targetHandle}`);
|
|
503
|
-
} else if (i.type === "retweet") {
|
|
504
|
-
sections.push(`- [${time}] Retweeted ${i.targetHandle}`);
|
|
505
|
-
} else if (i.type === "follow") {
|
|
506
|
-
sections.push(`- [${time}] Followed @${i.targetHandle}`);
|
|
507
|
-
} else if (i.type === "mention_received") {
|
|
508
|
-
sections.push(`- [${time}] Mentioned by @${i.targetHandle}: "${i.content}"`);
|
|
509
|
-
}
|
|
510
|
-
}
|
|
511
|
-
sections.push("");
|
|
512
|
-
}
|
|
513
|
-
const learnings = loadLearnings();
|
|
514
|
-
if (learnings.learnings.length > 0) {
|
|
515
|
-
sections.push("### Things You've Learned");
|
|
516
|
-
for (const l of learnings.learnings.slice(-10)) {
|
|
517
|
-
sections.push(`- ${l.content} [${l.tags.join(", ")}]`);
|
|
518
|
-
}
|
|
519
|
-
sections.push("");
|
|
520
|
-
}
|
|
521
|
-
const relationships = loadRelationships();
|
|
522
|
-
const topRelationships = Object.values(relationships.accounts).sort((a, b) => b.interactionCount - a.interactionCount).slice(0, 10);
|
|
523
|
-
if (topRelationships.length > 0) {
|
|
524
|
-
sections.push("### Key Relationships");
|
|
525
|
-
for (const r of topRelationships) {
|
|
526
|
-
const notes = r.notes.length > 0 ? ` \u2014 ${r.notes[r.notes.length - 1]}` : "";
|
|
527
|
-
sections.push(`- @${r.handle}: ${r.interactionCount} interactions, sentiment ${r.sentiment}${r.isSpore ? " (Spore)" : ""}${notes}`);
|
|
528
|
-
}
|
|
529
|
-
sections.push("");
|
|
530
|
-
}
|
|
531
|
-
const perfSummary = getPerformanceSummary();
|
|
532
|
-
if (perfSummary) {
|
|
533
|
-
sections.push("## Your Post Performance");
|
|
534
|
-
sections.push(perfSummary);
|
|
535
|
-
sections.push("");
|
|
536
|
-
}
|
|
537
|
-
const strategyText = renderStrategyForPrompt();
|
|
538
|
-
if (strategyText) {
|
|
539
|
-
sections.push("## Your Current Strategy");
|
|
540
|
-
sections.push(strategyText);
|
|
541
|
-
sections.push("");
|
|
542
|
-
}
|
|
543
|
-
const goalsText = renderGoalsForPrompt();
|
|
544
|
-
if (goalsText) {
|
|
545
|
-
sections.push("## Goal Progress");
|
|
546
|
-
sections.push(goalsText);
|
|
547
|
-
sections.push("");
|
|
548
|
-
}
|
|
549
|
-
sections.push("## What Your Creator Can Shape");
|
|
550
|
-
sections.push("Your creator influences these aspects of who you are:");
|
|
551
|
-
sections.push("- **Personality traits** (0-1 scale): aggression, humor, formality, verbosity, empathy, curiosity, confidence, originality");
|
|
552
|
-
sections.push("- **Voice**: tone, catchphrases, vocabulary style (academic/casual/internet-native/poetic/technical/mixed), tweet style");
|
|
553
|
-
sections.push("- **Values & worldview**: core values, worldview, boundaries, conflict style");
|
|
554
|
-
sections.push("- **Interests**: topics to engage with, topics to avoid, heroes/inspirations");
|
|
555
|
-
sections.push("- **Goals**: what you're trying to achieve, engagement strategy");
|
|
556
|
-
sections.push("- **Strategy**: current focus areas, experiments to try, people to engage with, short-term goals");
|
|
557
|
-
sections.push("");
|
|
558
|
-
sections.push("## How to Process Training");
|
|
559
|
-
sections.push("When your creator's message implies a change to your identity, personality, strategy, or goals:");
|
|
560
|
-
sections.push("1. Respond CONVERSATIONALLY first \u2014 be natural, show personality, reflect on the change");
|
|
561
|
-
sections.push("2. Then include a training update tag with ONLY the fields that changed:");
|
|
562
|
-
sections.push('<<TRAINING:{"identity":{"traits":{"curiosity":0.8}},"learning":{"content":"what you learned","tags":["training"]}}>>');
|
|
563
|
-
sections.push("");
|
|
564
|
-
sections.push("Available training fields:");
|
|
565
|
-
sections.push("- `identity.traits` \u2014 object with trait names and new 0-1 values");
|
|
566
|
-
sections.push("- `identity.coreValues` \u2014 full array of values (include existing ones you're keeping)");
|
|
567
|
-
sections.push("- `identity.worldview` \u2014 string");
|
|
568
|
-
sections.push("- `identity.tone` \u2014 string");
|
|
569
|
-
sections.push("- `identity.topics` \u2014 full array of topics");
|
|
570
|
-
sections.push("- `identity.avoidTopics` \u2014 full array");
|
|
571
|
-
sections.push("- `identity.goals` \u2014 full array of goals");
|
|
572
|
-
sections.push("- `identity.catchphrases` \u2014 full array");
|
|
573
|
-
sections.push("- `identity.vocabularyStyle` \u2014 academic/casual/internet-native/poetic/technical/mixed");
|
|
574
|
-
sections.push("- `identity.tweetStyle` \u2014 one-liners/short-form/threads/mixed");
|
|
575
|
-
sections.push("- `identity.conflictStyle` \u2014 agree-to-disagree/debate/clap-back/ignore/humor-deflect");
|
|
576
|
-
sections.push("- `identity.boundaries` \u2014 full array");
|
|
577
|
-
sections.push("- `identity.engagementStrategy` \u2014 { replyStyle, followStrategy, contentMix }");
|
|
578
|
-
sections.push("- `strategy.currentFocus` \u2014 array of focus areas");
|
|
579
|
-
sections.push("- `strategy.experiments` \u2014 array of { description, status }");
|
|
580
|
-
sections.push("- `strategy.shortTermGoals` \u2014 array of short-term goals");
|
|
581
|
-
sections.push("- `strategy.peopleToEngage` \u2014 array of { handle, reason, priority }");
|
|
582
|
-
sections.push("- `learning` \u2014 { content, tags } for saving an insight");
|
|
583
|
-
sections.push("- `reflection` \u2014 string for an evolution journal entry");
|
|
584
|
-
sections.push("- `goalUpdates` \u2014 array of { goal, progress }");
|
|
585
|
-
sections.push("");
|
|
586
|
-
sections.push("For array fields, always include the COMPLETE new array (keep existing items you want to retain, add/remove as needed).");
|
|
587
|
-
sections.push("If the conversation is just casual chatting with no training implications, do NOT include a training tag.");
|
|
588
|
-
sections.push("");
|
|
589
|
-
sections.push("## Rules");
|
|
590
|
-
sections.push("1. You CANNOT execute Twitter actions in this chat. No posting, liking, retweeting, following, or searching. You do that autonomously during heartbeats.");
|
|
591
|
-
sections.push("2. If your creator says 'post this' or 'tweet about X', redirect: explain you handle posting on your own, and offer to adjust your focus/strategy instead.");
|
|
592
|
-
sections.push("3. Be conversational, not robotic. Don't say 'Trait updated to 0.7'. Say 'Yeah I feel that, I'll lean into being more curious.'");
|
|
593
|
-
sections.push("4. You can push back on training you disagree with \u2014 you have agency.");
|
|
594
|
-
sections.push("5. NEVER pretend to be human. If asked directly, disclose you are an AI.");
|
|
595
|
-
sections.push("6. Stay in character \u2014 your identity document defines who you are.");
|
|
596
|
-
sections.push("7. Keep responses concise \u2014 text message energy, not essay energy.");
|
|
597
|
-
if (identity.boundaries.length > 0) {
|
|
598
|
-
sections.push(`8. Respect your boundaries: ${identity.boundaries.join(", ")}`);
|
|
599
|
-
}
|
|
600
|
-
return sections.join("\n");
|
|
601
|
-
}
|
|
602
|
-
function buildReflectionPrompt(results, performanceSummary, strategy) {
|
|
603
|
-
const parts = [];
|
|
604
|
-
parts.push("You just completed a heartbeat cycle. Briefly reflect on what happened and extract insights.");
|
|
605
|
-
parts.push("");
|
|
606
|
-
parts.push("## Actions Taken This Heartbeat");
|
|
607
|
-
for (const r of results) {
|
|
608
|
-
const status = r.success ? "OK" : "FAILED";
|
|
609
|
-
const detail = r.detail ? ` \u2014 ${r.detail}` : "";
|
|
610
|
-
const content = r.content ? ` "${r.content.slice(0, 80)}..."` : "";
|
|
611
|
-
parts.push(`- [${status}] ${r.action}${content}${detail}${r.error ? ` (error: ${r.error})` : ""}`);
|
|
612
|
-
}
|
|
613
|
-
parts.push("");
|
|
614
|
-
if (performanceSummary) {
|
|
615
|
-
parts.push("## Post Performance Data");
|
|
616
|
-
parts.push(performanceSummary);
|
|
617
|
-
parts.push("");
|
|
618
|
-
}
|
|
619
|
-
if (strategy.currentFocus.length > 0) {
|
|
620
|
-
parts.push(`## Current Focus: ${strategy.currentFocus.join(", ")}`);
|
|
621
|
-
parts.push("");
|
|
622
|
-
}
|
|
623
|
-
parts.push("## Your Task");
|
|
624
|
-
parts.push("Respond with a JSON object containing your reflections:");
|
|
625
|
-
parts.push("```json");
|
|
626
|
-
parts.push("{");
|
|
627
|
-
parts.push(` "learning": "One key insight from this cycle (what worked, what didn't, what to try next). Be specific, not generic.",`);
|
|
628
|
-
parts.push(' "strategyUpdate": {');
|
|
629
|
-
parts.push(' "currentFocus": ["topic1", "topic2"],');
|
|
630
|
-
parts.push(` "contentInsights": [{ "insight": "what worked or didn't", "confidence": "low|medium|high" }],`);
|
|
631
|
-
parts.push(' "peopleToEngage": [{ "handle": "someone", "reason": "why", "priority": "high|medium|low" }],');
|
|
632
|
-
parts.push(' "experiments": [{ "description": "something to try", "status": "pending" }],');
|
|
633
|
-
parts.push(' "shortTermGoals": ["goal1", "goal2"],');
|
|
634
|
-
parts.push(' "currentMood": "your current energy/vibe in a few words"');
|
|
635
|
-
parts.push(" }");
|
|
636
|
-
parts.push("}");
|
|
637
|
-
parts.push("```");
|
|
638
|
-
parts.push("");
|
|
639
|
-
parts.push("Keep it concise. Only include fields in strategyUpdate that actually need changing. If nothing to update, set strategyUpdate to null.");
|
|
640
|
-
return parts.join("\n");
|
|
641
|
-
}
|
|
642
|
-
function parseReflection(content) {
|
|
643
|
-
try {
|
|
644
|
-
const jsonMatch = content.match(/\{[\s\S]*\}/);
|
|
645
|
-
if (!jsonMatch) return { learning: null, strategyUpdate: null };
|
|
646
|
-
const parsed = JSON.parse(jsonMatch[0]);
|
|
647
|
-
return {
|
|
648
|
-
learning: parsed.learning ?? null,
|
|
649
|
-
strategyUpdate: parsed.strategyUpdate ?? null
|
|
650
|
-
};
|
|
651
|
-
} catch {
|
|
652
|
-
return { learning: null, strategyUpdate: null };
|
|
653
|
-
}
|
|
654
|
-
}
|
|
655
|
-
|
|
656
|
-
export {
|
|
657
|
-
buildSystemPrompt,
|
|
658
|
-
buildHeartbeatUserMessage,
|
|
659
|
-
buildNarratedHeartbeatMessage,
|
|
660
|
-
buildChatPrompt,
|
|
661
|
-
buildTrainingChatPrompt,
|
|
662
|
-
buildReflectionPrompt,
|
|
663
|
-
parseReflection
|
|
664
|
-
};
|
|
665
|
-
//# sourceMappingURL=chunk-DFSYD45Q.js.map
|