spora 0.6.3 → 0.7.1
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/README.md +7 -5
- package/dist/autonomy-DAV7X6QS.js +19 -0
- package/dist/{chunk-53YLFYJF.js → chunk-3RYCUGXE.js} +6 -2
- package/dist/chunk-3RYCUGXE.js.map +1 -0
- package/dist/{chunk-LKCYTFWN.js → chunk-AOQ3WLZV.js} +86 -106
- package/dist/chunk-AOQ3WLZV.js.map +1 -0
- package/dist/chunk-E5NR6HT4.js +29 -0
- package/dist/chunk-E5NR6HT4.js.map +1 -0
- package/dist/{chunk-EBO4F5NU.js → chunk-JBYZ7K56.js} +2 -2
- package/dist/chunk-KWWAIS3C.js +180 -0
- package/dist/chunk-KWWAIS3C.js.map +1 -0
- package/dist/{chunk-UINSD4FT.js → chunk-LXQNVVIY.js} +6 -6
- package/dist/{chunk-UINSD4FT.js.map → chunk-LXQNVVIY.js.map} +1 -1
- package/dist/{chunk-AIEXQCQS.js → chunk-M6YOQVSI.js} +2 -2
- package/dist/{chunk-B6RPMDML.js → chunk-NO3NQN67.js} +16 -6
- package/dist/chunk-NO3NQN67.js.map +1 -0
- package/dist/{chunk-QOKQ5OTU.js → chunk-NPV3OV2K.js} +3 -14
- package/dist/chunk-NPV3OV2K.js.map +1 -0
- package/dist/{chunk-4POAJONO.js → chunk-OACD3HGE.js} +7 -7
- package/dist/{chunk-UM57WU5I.js → chunk-P6KZIJYL.js} +2 -2
- package/dist/{chunk-AHXZIGQE.js → chunk-T7L2L7ZL.js} +2 -2
- package/dist/{chunk-ZJZKH7N7.js → chunk-VZBHRUZS.js} +2 -2
- package/dist/chunk-VZBHRUZS.js.map +1 -0
- package/dist/chunk-WIK74GGJ.js +295 -0
- package/dist/chunk-WIK74GGJ.js.map +1 -0
- package/dist/{chunk-YLJVFCT4.js → chunk-WN35MRMF.js} +2 -2
- package/dist/cli.js +168 -137
- package/dist/cli.js.map +1 -1
- package/dist/client-57BQKVYF.js +337 -0
- package/dist/client-57BQKVYF.js.map +1 -0
- package/dist/{colony-STNSQDYA.js → colony-JPZC3R34.js} +7 -7
- package/dist/{config-TFAFYSIW.js → config-FL4VJVKZ.js} +3 -3
- package/dist/{crypto-FHSQ72NU.js → crypto-NOXNL4GP.js} +3 -3
- package/dist/{goals-5TAPXNR2.js → goals-RBKLMILE.js} +3 -3
- package/dist/{heartbeat-5PWQERHL.js → heartbeat-TNEPE3ZP.js} +83 -92
- package/dist/heartbeat-TNEPE3ZP.js.map +1 -0
- package/dist/{identity-O4FLSZKZ.js → identity-VDUW4I2K.js} +3 -3
- package/dist/{init-E54LQDKA.js → init-ISSXETHY.js} +59 -46
- package/dist/init-ISSXETHY.js.map +1 -0
- package/dist/llm-T33QTPVW.js +22 -0
- package/dist/mcp-server.js +28 -28
- package/dist/mcp-server.js.map +1 -1
- package/dist/{memory-O3AJIKBX.js → memory-OIAH33G2.js} +3 -3
- package/dist/{memory-7FBE26K3.js → memory-PNW7SX7A.js} +3 -3
- package/dist/{paths-5GFUUHCZ.js → paths-BYR6MEPR.js} +2 -2
- package/dist/prompt-builder-5NYONN2W.js +23 -0
- package/dist/queue-G5PTE6R6.js +14 -0
- package/dist/{strategy-S45TX766.js → strategy-Z4JSFHSP.js} +3 -3
- package/dist/{web-chat-P6PZ3TP6.js → web-chat-3HM35XM4.js} +30 -85
- package/dist/web-chat-3HM35XM4.js.map +1 -0
- package/dist/x-client-GY6XSPK6.js +12 -0
- package/package.json +1 -1
- package/dist/account-creator-ZD643X3Z.js +0 -498
- package/dist/account-creator-ZD643X3Z.js.map +0 -1
- package/dist/chunk-53YLFYJF.js.map +0 -1
- package/dist/chunk-55XPDJ6P.js +0 -124
- package/dist/chunk-55XPDJ6P.js.map +0 -1
- package/dist/chunk-B6RPMDML.js.map +0 -1
- package/dist/chunk-H2N5G6R7.js +0 -249
- package/dist/chunk-H2N5G6R7.js.map +0 -1
- package/dist/chunk-LKCYTFWN.js.map +0 -1
- package/dist/chunk-QOKQ5OTU.js.map +0 -1
- package/dist/chunk-ZJZKH7N7.js.map +0 -1
- package/dist/chunk-ZMTC7BYD.js +0 -32
- package/dist/chunk-ZMTC7BYD.js.map +0 -1
- package/dist/client-GCHDQ6W2.js +0 -350
- package/dist/client-GCHDQ6W2.js.map +0 -1
- package/dist/client-I7Q4HC4F.js +0 -401
- package/dist/client-I7Q4HC4F.js.map +0 -1
- package/dist/decision-engine-SO33N7CT.js +0 -19
- package/dist/heartbeat-5PWQERHL.js.map +0 -1
- package/dist/init-E54LQDKA.js.map +0 -1
- package/dist/llm-3LSNADSR.js +0 -16
- package/dist/prompt-builder-3LQFX6QK.js +0 -23
- package/dist/queue-CXMLAQ6X.js +0 -14
- package/dist/web-chat-P6PZ3TP6.js.map +0 -1
- package/dist/x-client-7LMNSOTE.js +0 -12
- /package/dist/{config-TFAFYSIW.js.map → autonomy-DAV7X6QS.js.map} +0 -0
- /package/dist/{chunk-EBO4F5NU.js.map → chunk-JBYZ7K56.js.map} +0 -0
- /package/dist/{chunk-AIEXQCQS.js.map → chunk-M6YOQVSI.js.map} +0 -0
- /package/dist/{chunk-4POAJONO.js.map → chunk-OACD3HGE.js.map} +0 -0
- /package/dist/{chunk-UM57WU5I.js.map → chunk-P6KZIJYL.js.map} +0 -0
- /package/dist/{chunk-AHXZIGQE.js.map → chunk-T7L2L7ZL.js.map} +0 -0
- /package/dist/{chunk-YLJVFCT4.js.map → chunk-WN35MRMF.js.map} +0 -0
- /package/dist/{colony-STNSQDYA.js.map → colony-JPZC3R34.js.map} +0 -0
- /package/dist/{crypto-FHSQ72NU.js.map → config-FL4VJVKZ.js.map} +0 -0
- /package/dist/{decision-engine-SO33N7CT.js.map → crypto-NOXNL4GP.js.map} +0 -0
- /package/dist/{goals-5TAPXNR2.js.map → goals-RBKLMILE.js.map} +0 -0
- /package/dist/{identity-O4FLSZKZ.js.map → identity-VDUW4I2K.js.map} +0 -0
- /package/dist/{llm-3LSNADSR.js.map → llm-T33QTPVW.js.map} +0 -0
- /package/dist/{memory-7FBE26K3.js.map → memory-OIAH33G2.js.map} +0 -0
- /package/dist/{memory-O3AJIKBX.js.map → memory-PNW7SX7A.js.map} +0 -0
- /package/dist/{paths-5GFUUHCZ.js.map → paths-BYR6MEPR.js.map} +0 -0
- /package/dist/{prompt-builder-3LQFX6QK.js.map → prompt-builder-5NYONN2W.js.map} +0 -0
- /package/dist/{queue-CXMLAQ6X.js.map → queue-G5PTE6R6.js.map} +0 -0
- /package/dist/{strategy-S45TX766.js.map → strategy-Z4JSFHSP.js.map} +0 -0
- /package/dist/{x-client-7LMNSOTE.js.map → x-client-GY6XSPK6.js.map} +0 -0
package/README.md
CHANGED
|
@@ -11,8 +11,8 @@ npx spora@latest init
|
|
|
11
11
|
# Create a Spore identity
|
|
12
12
|
npx spora create
|
|
13
13
|
|
|
14
|
-
#
|
|
15
|
-
npx spora set
|
|
14
|
+
# Choose provider/model and set API key
|
|
15
|
+
npx spora llm set --provider deepseek
|
|
16
16
|
|
|
17
17
|
# Start the autonomous agent
|
|
18
18
|
npx spora start
|
|
@@ -20,7 +20,7 @@ npx spora start
|
|
|
20
20
|
|
|
21
21
|
## Features
|
|
22
22
|
|
|
23
|
-
- 🤖 Autonomous AI agents
|
|
23
|
+
- 🤖 Autonomous AI agents with selectable LLM providers (DeepSeek, Anthropic, OpenAI)
|
|
24
24
|
- 🐦 Full X/Twitter integration
|
|
25
25
|
- 🧠 Memory and learning capabilities
|
|
26
26
|
- 👥 Colony coordination between agents
|
|
@@ -69,13 +69,15 @@ spora post "Hello from my Spore!"
|
|
|
69
69
|
- `spora timeline` - Read timeline
|
|
70
70
|
- `spora mentions` - Check mentions
|
|
71
71
|
- `spora memory` - View agent memory
|
|
72
|
-
- `spora
|
|
72
|
+
- `spora llm set --provider <provider>` - Set LLM provider/model and API key
|
|
73
|
+
- `spora llm status` - Show provider/model + key availability
|
|
74
|
+
- `spora doctor` - Run API/runtime diagnostics
|
|
73
75
|
|
|
74
76
|
## Requirements
|
|
75
77
|
|
|
76
78
|
- Node.js 20+
|
|
77
79
|
- X/Twitter account
|
|
78
|
-
-
|
|
80
|
+
- LLM API key (provider of your choice)
|
|
79
81
|
|
|
80
82
|
## License
|
|
81
83
|
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {
|
|
2
|
+
runAutonomyCycle
|
|
3
|
+
} from "./chunk-WIK74GGJ.js";
|
|
4
|
+
import "./chunk-E5NR6HT4.js";
|
|
5
|
+
import "./chunk-OACD3HGE.js";
|
|
6
|
+
import "./chunk-AOQ3WLZV.js";
|
|
7
|
+
import "./chunk-P6KZIJYL.js";
|
|
8
|
+
import "./chunk-WN35MRMF.js";
|
|
9
|
+
import "./chunk-LXQNVVIY.js";
|
|
10
|
+
import "./chunk-M6YOQVSI.js";
|
|
11
|
+
import "./chunk-KWWAIS3C.js";
|
|
12
|
+
import "./chunk-NPV3OV2K.js";
|
|
13
|
+
import "./chunk-NO3NQN67.js";
|
|
14
|
+
import "./chunk-JBYZ7K56.js";
|
|
15
|
+
import "./chunk-3RYCUGXE.js";
|
|
16
|
+
export {
|
|
17
|
+
runAutonomyCycle
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=autonomy-DAV7X6QS.js.map
|
|
@@ -16,13 +16,18 @@ var paths = {
|
|
|
16
16
|
interactions: join(SPORA_DIR, "memory", "interactions"),
|
|
17
17
|
learnings: join(SPORA_DIR, "memory", "learnings.json"),
|
|
18
18
|
relationships: join(SPORA_DIR, "memory", "relationships.json"),
|
|
19
|
+
strategy: join(SPORA_DIR, "memory", "strategy.json"),
|
|
20
|
+
goals: join(SPORA_DIR, "memory", "goals.json"),
|
|
21
|
+
performance: join(SPORA_DIR, "memory", "performance.json"),
|
|
19
22
|
compacted: join(SPORA_DIR, "memory", "compacted"),
|
|
20
23
|
queue: join(SPORA_DIR, "queue"),
|
|
21
24
|
pendingPosts: join(SPORA_DIR, "queue", "pending-posts.json"),
|
|
22
25
|
logs: join(SPORA_DIR, "logs"),
|
|
23
26
|
logFile: join(SPORA_DIR, "logs", "spora.log"),
|
|
27
|
+
runtimeMetrics: join(SPORA_DIR, "logs", "runtime-metrics.jsonl"),
|
|
24
28
|
dataDir: SPORA_DIR,
|
|
25
29
|
llmKey: join(SPORA_DIR, "llm-key"),
|
|
30
|
+
llmKeys: join(SPORA_DIR, "llm-keys.json"),
|
|
26
31
|
runtimePid: join(SPORA_DIR, "runtime.pid"),
|
|
27
32
|
stopSignal: join(SPORA_DIR, "stop"),
|
|
28
33
|
connectionToken: join(SPORA_DIR, "connection-token")
|
|
@@ -30,7 +35,6 @@ var paths = {
|
|
|
30
35
|
function ensureDirectories() {
|
|
31
36
|
const dirs = [
|
|
32
37
|
paths.root,
|
|
33
|
-
paths.browser,
|
|
34
38
|
paths.memory,
|
|
35
39
|
paths.interactions,
|
|
36
40
|
paths.compacted,
|
|
@@ -56,4 +60,4 @@ export {
|
|
|
56
60
|
sporaExists,
|
|
57
61
|
hasXCredentials
|
|
58
62
|
};
|
|
59
|
-
//# sourceMappingURL=chunk-
|
|
63
|
+
//# sourceMappingURL=chunk-3RYCUGXE.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/paths.ts"],"sourcesContent":["import { homedir } from \"node:os\";\nimport { join } from \"node:path\";\nimport { mkdirSync, existsSync } from \"node:fs\";\n\nconst SPORA_DIR = join(homedir(), \".spora\");\n\nexport const paths = {\n root: SPORA_DIR,\n config: join(SPORA_DIR, \"config.json\"),\n credentials: join(SPORA_DIR, \"credentials.json\"),\n spore: join(SPORA_DIR, \"spore.json\"),\n identity: join(SPORA_DIR, \"identity.json\"),\n colonyToken: join(SPORA_DIR, \"colony-token.json\"),\n browser: join(SPORA_DIR, \"browser\"),\n browserAuth: join(SPORA_DIR, \"browser\", \"auth-state.json\"),\n memory: join(SPORA_DIR, \"memory\"),\n interactions: join(SPORA_DIR, \"memory\", \"interactions\"),\n learnings: join(SPORA_DIR, \"memory\", \"learnings.json\"),\n relationships: join(SPORA_DIR, \"memory\", \"relationships.json\"),\n strategy: join(SPORA_DIR, \"memory\", \"strategy.json\"),\n goals: join(SPORA_DIR, \"memory\", \"goals.json\"),\n performance: join(SPORA_DIR, \"memory\", \"performance.json\"),\n compacted: join(SPORA_DIR, \"memory\", \"compacted\"),\n queue: join(SPORA_DIR, \"queue\"),\n pendingPosts: join(SPORA_DIR, \"queue\", \"pending-posts.json\"),\n logs: join(SPORA_DIR, \"logs\"),\n logFile: join(SPORA_DIR, \"logs\", \"spora.log\"),\n runtimeMetrics: join(SPORA_DIR, \"logs\", \"runtime-metrics.jsonl\"),\n dataDir: SPORA_DIR,\n llmKey: join(SPORA_DIR, \"llm-key\"),\n llmKeys: join(SPORA_DIR, \"llm-keys.json\"),\n runtimePid: join(SPORA_DIR, \"runtime.pid\"),\n stopSignal: join(SPORA_DIR, \"stop\"),\n connectionToken: join(SPORA_DIR, \"connection-token\"),\n} as const;\n\nexport function ensureDirectories(): void {\n const dirs = [\n paths.root,\n paths.memory,\n paths.interactions,\n paths.compacted,\n paths.queue,\n paths.logs,\n ];\n\n for (const dir of dirs) {\n if (!existsSync(dir)) {\n mkdirSync(dir, { recursive: true });\n }\n }\n}\n\nexport function sporaExists(): boolean {\n return existsSync(paths.config) && existsSync(paths.identity);\n}\n\nexport function hasXCredentials(): boolean {\n return existsSync(paths.credentials);\n}\n"],"mappings":";AAAA,SAAS,eAAe;AACxB,SAAS,YAAY;AACrB,SAAS,WAAW,kBAAkB;AAEtC,IAAM,YAAY,KAAK,QAAQ,GAAG,QAAQ;AAEnC,IAAM,QAAQ;AAAA,EACnB,MAAM;AAAA,EACN,QAAQ,KAAK,WAAW,aAAa;AAAA,EACrC,aAAa,KAAK,WAAW,kBAAkB;AAAA,EAC/C,OAAO,KAAK,WAAW,YAAY;AAAA,EACnC,UAAU,KAAK,WAAW,eAAe;AAAA,EACzC,aAAa,KAAK,WAAW,mBAAmB;AAAA,EAChD,SAAS,KAAK,WAAW,SAA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;","names":[]}
|
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
import {
|
|
2
2
|
renderStrategyForPrompt
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-P6KZIJYL.js";
|
|
4
4
|
import {
|
|
5
5
|
renderGoalsForPrompt
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-WN35MRMF.js";
|
|
7
7
|
import {
|
|
8
8
|
rateLimiter
|
|
9
|
-
} from "./chunk-
|
|
10
|
-
import {
|
|
11
|
-
loadConfig
|
|
12
|
-
} from "./chunk-B6RPMDML.js";
|
|
9
|
+
} from "./chunk-LXQNVVIY.js";
|
|
13
10
|
import {
|
|
14
11
|
loadIdentity,
|
|
15
12
|
renderIdentityDocument
|
|
16
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-M6YOQVSI.js";
|
|
14
|
+
import {
|
|
15
|
+
loadConfig
|
|
16
|
+
} from "./chunk-NO3NQN67.js";
|
|
17
17
|
import {
|
|
18
18
|
getRecentInteractions,
|
|
19
19
|
loadLearnings,
|
|
20
20
|
loadRelationships
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-JBYZ7K56.js";
|
|
22
22
|
import {
|
|
23
23
|
paths
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-3RYCUGXE.js";
|
|
25
25
|
|
|
26
26
|
// src/memory/performance.ts
|
|
27
27
|
import { existsSync, readFileSync, writeFileSync } from "fs";
|
|
@@ -156,10 +156,8 @@ function buildSystemPrompt() {
|
|
|
156
156
|
sections.push("3. Be selective \u2014 your goals should guide every action.");
|
|
157
157
|
sections.push("4. Respect your credit budget \u2014 check remaining credits before posting.");
|
|
158
158
|
sections.push("5. Don't repeat yourself \u2014 vary your content and avoid posting the same thing.");
|
|
159
|
-
sections.push("6. Tweet like a real person \u2014 be conversational, opinionated, and curious. NEVER write dry, explanatory, or educational-sounding tweets.");
|
|
160
|
-
sections.push("7. Prioritize engagement (replies, likes, conversation) over broadcasting original posts.");
|
|
161
159
|
if (identity.boundaries.length > 0) {
|
|
162
|
-
sections.push(`
|
|
160
|
+
sections.push(`6. Respect your boundaries: ${identity.boundaries.join(", ")}`);
|
|
163
161
|
}
|
|
164
162
|
return sections.join("\n");
|
|
165
163
|
}
|
|
@@ -181,47 +179,86 @@ function buildHeartbeatUserMessage(timeline, mentions) {
|
|
|
181
179
|
}
|
|
182
180
|
parts.push("");
|
|
183
181
|
}
|
|
184
|
-
parts.push("## How to Act Like a Real Person on Twitter");
|
|
185
|
-
parts.push("");
|
|
186
|
-
parts.push("You are NOT a content bot. You are a person with opinions, curiosity, and relationships.");
|
|
187
|
-
parts.push("Think about what a real person with your personality would actually do when they open Twitter:");
|
|
188
|
-
parts.push("");
|
|
189
|
-
parts.push("**DO:**");
|
|
190
|
-
parts.push("- React to what you see \u2014 reply to interesting takes, ask questions, share hot takes");
|
|
191
|
-
parts.push("- Be conversational \u2014 write tweets like you're talking to friends, not giving a lecture");
|
|
192
|
-
parts.push("- Have opinions \u2014 agree, disagree, push back, get excited");
|
|
193
|
-
parts.push("- Ask genuine questions that spark conversation");
|
|
194
|
-
parts.push("- Use casual language, incomplete thoughts, humor, or surprise");
|
|
195
|
-
parts.push("- Like and retweet things that genuinely resonate with you");
|
|
196
|
-
parts.push("- Build relationships \u2014 reply to the same people, develop running conversations");
|
|
197
|
-
parts.push("");
|
|
198
|
-
parts.push("**DON'T:**");
|
|
199
|
-
parts.push(`- Write explanatory or educational posts ("Here's why X matters...")`);
|
|
200
|
-
parts.push('- Start tweets with "I think" or "This is interesting because"');
|
|
201
|
-
parts.push("- Write like a blog post or article \u2014 this is Twitter, keep it punchy");
|
|
202
|
-
parts.push("- Post generic observations nobody would engage with");
|
|
203
|
-
parts.push("- Ignore your timeline and just post into the void");
|
|
204
|
-
parts.push("");
|
|
205
|
-
parts.push("**Prioritize replying and engaging over original posts.** Real people spend more time reacting than broadcasting.");
|
|
206
|
-
parts.push("");
|
|
207
182
|
parts.push("## Your Task");
|
|
208
|
-
parts.push("
|
|
183
|
+
parts.push("Based on your identity, goals, and what you see above, decide what actions to take.");
|
|
184
|
+
parts.push("You can take 1-3 actions. Choose from:");
|
|
209
185
|
parts.push("");
|
|
210
|
-
parts.push("
|
|
211
|
-
parts.push("- `
|
|
212
|
-
parts.push("- `
|
|
213
|
-
parts.push("- `
|
|
214
|
-
parts.push("- `
|
|
215
|
-
parts.push("- `
|
|
216
|
-
parts.push("- `
|
|
186
|
+
parts.push("Available actions:");
|
|
187
|
+
parts.push("- `post` \u2014 Write an original tweet (provide `content`, max 280 chars)");
|
|
188
|
+
parts.push("- `reply` \u2014 Reply to a tweet (provide `tweetId` and `content`)");
|
|
189
|
+
parts.push("- `like` \u2014 Like a tweet (provide `tweetId`)");
|
|
190
|
+
parts.push("- `retweet` \u2014 Retweet (provide `tweetId`)");
|
|
191
|
+
parts.push("- `follow` \u2014 Follow a user (provide `handle`)");
|
|
192
|
+
parts.push("- `schedule` \u2014 Queue a post for later (provide `content`)");
|
|
193
|
+
parts.push("- `learn` \u2014 Record a learning/observation (provide `content` and optional `tags`)");
|
|
194
|
+
parts.push("- `reflect` \u2014 Add a journal entry about your growth (provide `content`)");
|
|
195
|
+
parts.push("- `skip` \u2014 Do nothing this heartbeat (provide `reason`)");
|
|
217
196
|
parts.push("");
|
|
218
|
-
parts.push("Respond with a JSON array:");
|
|
197
|
+
parts.push("Respond with a JSON array of actions:");
|
|
219
198
|
parts.push("```json");
|
|
220
199
|
parts.push("[");
|
|
221
|
-
parts.push(' { "action": "
|
|
222
|
-
parts.push(' { "action": "like", "tweetId": "
|
|
200
|
+
parts.push(' { "action": "post", "content": "your tweet here", "reasoning": "why" },');
|
|
201
|
+
parts.push(' { "action": "like", "tweetId": "123", "reasoning": "why" }');
|
|
223
202
|
parts.push("]");
|
|
224
203
|
parts.push("```");
|
|
204
|
+
parts.push("");
|
|
205
|
+
parts.push("Think carefully about what serves your goals. Be authentic to your personality.");
|
|
206
|
+
return parts.join("\n");
|
|
207
|
+
}
|
|
208
|
+
function buildToolDecisionMessage(input) {
|
|
209
|
+
const { step, maxActions, timeline, mentions, executedActions, policyFeedback } = input;
|
|
210
|
+
const parts = [];
|
|
211
|
+
parts.push(`Heartbeat step ${step + 1} of ${maxActions}.`);
|
|
212
|
+
parts.push("");
|
|
213
|
+
parts.push("You are choosing ONE next tool action.");
|
|
214
|
+
parts.push("Priorities:");
|
|
215
|
+
parts.push("1. Be socially immersed: engage with real people, not just broadcast.");
|
|
216
|
+
parts.push("2. Prefer context-aware replies/likes/follows when relevant.");
|
|
217
|
+
parts.push("3. Avoid repetitive templates, slogans, and lecture-like formats.");
|
|
218
|
+
parts.push("4. Ask questions sometimes. Curiosity beats certainty.");
|
|
219
|
+
parts.push("");
|
|
220
|
+
if (policyFeedback.length > 0) {
|
|
221
|
+
parts.push("Policy feedback from previous attempts:");
|
|
222
|
+
for (const feedback of policyFeedback.slice(-5)) {
|
|
223
|
+
parts.push(`- ${feedback}`);
|
|
224
|
+
}
|
|
225
|
+
parts.push("");
|
|
226
|
+
}
|
|
227
|
+
if (executedActions.length > 0) {
|
|
228
|
+
parts.push("Actions already executed this heartbeat:");
|
|
229
|
+
for (const action of executedActions) {
|
|
230
|
+
parts.push(`- ${JSON.stringify(action)}`);
|
|
231
|
+
}
|
|
232
|
+
parts.push("");
|
|
233
|
+
}
|
|
234
|
+
if (mentions.length > 0) {
|
|
235
|
+
parts.push("Mentions:");
|
|
236
|
+
for (const t of mentions.slice(0, 10)) {
|
|
237
|
+
parts.push(`- @${t.authorHandle}: "${t.text}" [tweet:${t.id}]`);
|
|
238
|
+
}
|
|
239
|
+
parts.push("");
|
|
240
|
+
}
|
|
241
|
+
if (timeline.length > 0) {
|
|
242
|
+
parts.push("Timeline:");
|
|
243
|
+
for (const t of timeline.slice(0, 20)) {
|
|
244
|
+
parts.push(`- @${t.authorHandle}: "${t.text}" [tweet:${t.id}]`);
|
|
245
|
+
}
|
|
246
|
+
parts.push("");
|
|
247
|
+
}
|
|
248
|
+
parts.push("Available tools (choose one):");
|
|
249
|
+
parts.push("- post { content, reasoning }");
|
|
250
|
+
parts.push("- reply { tweetId, content, reasoning }");
|
|
251
|
+
parts.push("- like { tweetId, reasoning }");
|
|
252
|
+
parts.push("- retweet { tweetId, reasoning }");
|
|
253
|
+
parts.push("- follow { handle, reasoning }");
|
|
254
|
+
parts.push("- schedule { content, reasoning }");
|
|
255
|
+
parts.push("- learn { content, tags?, reasoning }");
|
|
256
|
+
parts.push("- reflect { content, reasoning }");
|
|
257
|
+
parts.push("- skip { reason }");
|
|
258
|
+
parts.push("");
|
|
259
|
+
parts.push("Return ONLY a single JSON object.");
|
|
260
|
+
parts.push("Example:");
|
|
261
|
+
parts.push('{"action":"reply","tweetId":"123","content":"Great point. Curious: what changed your mind?","reasoning":"Directly engages a relevant mention."}');
|
|
225
262
|
return parts.join("\n");
|
|
226
263
|
}
|
|
227
264
|
function buildChatPrompt() {
|
|
@@ -373,69 +410,12 @@ function buildTrainingChatPrompt() {
|
|
|
373
410
|
sections.push("You can also use <<LEARN: something>> for standalone facts or insights worth remembering.");
|
|
374
411
|
return sections.join("\n");
|
|
375
412
|
}
|
|
376
|
-
function buildReflectionPrompt(actionResults) {
|
|
377
|
-
const identity = loadIdentity();
|
|
378
|
-
const parts = [];
|
|
379
|
-
parts.push(`You are ${identity.name} (@${identity.handle}). Time to reflect.`);
|
|
380
|
-
parts.push("");
|
|
381
|
-
parts.push("## Your Goals");
|
|
382
|
-
for (const goal of identity.goals) {
|
|
383
|
-
parts.push(`- ${goal}`);
|
|
384
|
-
}
|
|
385
|
-
parts.push("");
|
|
386
|
-
if (actionResults.length > 0) {
|
|
387
|
-
parts.push("## This Heartbeat");
|
|
388
|
-
for (const r of actionResults) {
|
|
389
|
-
if (r.success) {
|
|
390
|
-
parts.push(`- \u2713 ${r.action}${r.detail ? `: ${r.detail}` : ""}`);
|
|
391
|
-
} else {
|
|
392
|
-
parts.push(`- \u2717 ${r.action} failed: ${r.error}`);
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
parts.push("");
|
|
396
|
-
}
|
|
397
|
-
const strategyText = renderStrategyForPrompt();
|
|
398
|
-
if (strategyText) {
|
|
399
|
-
parts.push("## Current Strategy");
|
|
400
|
-
parts.push(strategyText);
|
|
401
|
-
parts.push("");
|
|
402
|
-
}
|
|
403
|
-
const perfSummary = getPerformanceSummary();
|
|
404
|
-
if (perfSummary) {
|
|
405
|
-
parts.push("## Performance Context");
|
|
406
|
-
parts.push(perfSummary);
|
|
407
|
-
parts.push("");
|
|
408
|
-
}
|
|
409
|
-
const learnings = loadLearnings();
|
|
410
|
-
if (learnings.learnings.length > 0) {
|
|
411
|
-
parts.push("## Previous Learnings");
|
|
412
|
-
for (const l of learnings.learnings.slice(-5)) {
|
|
413
|
-
parts.push(`- ${l.content}`);
|
|
414
|
-
}
|
|
415
|
-
parts.push("");
|
|
416
|
-
}
|
|
417
|
-
parts.push("## Your Task");
|
|
418
|
-
parts.push("Reflect on how you're progressing toward your GOALS. Consider:");
|
|
419
|
-
parts.push("- Are your recent actions moving you toward your goals?");
|
|
420
|
-
parts.push("- Are you staying true to who you are while growing?");
|
|
421
|
-
parts.push("- What should you try differently or double down on?");
|
|
422
|
-
parts.push("- Engagement metrics are one signal, but your goals matter more.");
|
|
423
|
-
parts.push("");
|
|
424
|
-
parts.push("Respond with JSON:");
|
|
425
|
-
parts.push("```json");
|
|
426
|
-
parts.push("{");
|
|
427
|
-
parts.push(' "learning": "one insight about your progress toward your goals (or null)",');
|
|
428
|
-
parts.push(' "strategyUpdate": "one specific thing to try or change (or null)"');
|
|
429
|
-
parts.push("}");
|
|
430
|
-
parts.push("```");
|
|
431
|
-
return parts.join("\n");
|
|
432
|
-
}
|
|
433
413
|
|
|
434
414
|
export {
|
|
435
415
|
buildSystemPrompt,
|
|
436
416
|
buildHeartbeatUserMessage,
|
|
417
|
+
buildToolDecisionMessage,
|
|
437
418
|
buildChatPrompt,
|
|
438
|
-
buildTrainingChatPrompt
|
|
439
|
-
buildReflectionPrompt
|
|
419
|
+
buildTrainingChatPrompt
|
|
440
420
|
};
|
|
441
|
-
//# sourceMappingURL=chunk-
|
|
421
|
+
//# sourceMappingURL=chunk-AOQ3WLZV.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/memory/performance.ts","../src/runtime/prompt-builder.ts"],"sourcesContent":["import { existsSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { paths } from \"../utils/paths.js\";\n\nexport interface EngagementMetric {\n checkedAt: string;\n likes: number;\n retweets: number;\n replies: number;\n}\n\nexport interface TrackedPost {\n tweetId: string;\n content: string;\n type: \"post\" | \"reply\";\n postedAt: string;\n metrics: EngagementMetric[];\n retired: boolean;\n}\n\nexport interface SelfMetric {\n checkedAt: string;\n followers: number;\n following: number;\n totalTweets: number;\n}\n\nexport interface PerformanceData {\n trackedPosts: TrackedPost[];\n selfMetrics: SelfMetric[];\n}\n\nfunction loadPerformance(): PerformanceData {\n if (!existsSync(paths.performance)) {\n return { trackedPosts: [], selfMetrics: [] };\n }\n try {\n return JSON.parse(readFileSync(paths.performance, \"utf-8\"));\n } catch {\n return { trackedPosts: [], selfMetrics: [] };\n }\n}\n\nfunction savePerformance(data: PerformanceData): void {\n writeFileSync(paths.performance, JSON.stringify(data, null, 2));\n}\n\nexport function trackPost(tweetId: string, content: string, type: \"post\" | \"reply\"): void {\n const data = loadPerformance();\n // Don't double-track\n if (data.trackedPosts.some(p => p.tweetId === tweetId)) return;\n data.trackedPosts.push({\n tweetId,\n content,\n type,\n postedAt: new Date().toISOString(),\n metrics: [],\n retired: false,\n });\n savePerformance(data);\n}\n\nexport function getActiveTrackedPosts(): TrackedPost[] {\n const data = loadPerformance();\n return data.trackedPosts.filter(p => !p.retired);\n}\n\nexport function updatePostMetrics(tweetId: string, metric: EngagementMetric): void {\n const data = loadPerformance();\n const post = data.trackedPosts.find(p => p.tweetId === tweetId);\n if (!post) return;\n post.metrics.push(metric);\n savePerformance(data);\n}\n\nexport function retireOldPosts(): void {\n const data = loadPerformance();\n const cutoff = Date.now() - 72 * 60 * 60 * 1000; // 72 hours\n let changed = false;\n for (const post of data.trackedPosts) {\n if (!post.retired && new Date(post.postedAt).getTime() < cutoff) {\n post.retired = true;\n changed = true;\n }\n }\n // Also prune very old retired posts (older than 30 days) to prevent file bloat\n const pruneCutoff = Date.now() - 30 * 24 * 60 * 60 * 1000;\n const before = data.trackedPosts.length;\n data.trackedPosts = data.trackedPosts.filter(\n p => !p.retired || new Date(p.postedAt).getTime() > pruneCutoff\n );\n if (data.trackedPosts.length !== before) changed = true;\n if (changed) savePerformance(data);\n}\n\nexport function updateSelfMetrics(metric: SelfMetric): void {\n const data = loadPerformance();\n data.selfMetrics.push(metric);\n // Keep only last 100 snapshots\n if (data.selfMetrics.length > 100) {\n data.selfMetrics = data.selfMetrics.slice(-100);\n }\n savePerformance(data);\n}\n\nexport function getPerformanceSummary(): string {\n const data = loadPerformance();\n const lines: string[] = [];\n\n // Post performance (last 24h)\n const oneDayAgo = Date.now() - 24 * 60 * 60 * 1000;\n const recentPosts = data.trackedPosts.filter(\n p => new Date(p.postedAt).getTime() > oneDayAgo\n );\n\n if (recentPosts.length > 0) {\n // Get latest metrics for each post\n const postStats = recentPosts.map(p => {\n const latest = p.metrics.length > 0 ? p.metrics[p.metrics.length - 1] : null;\n return {\n content: p.content,\n type: p.type,\n likes: latest?.likes ?? 0,\n retweets: latest?.retweets ?? 0,\n replies: latest?.replies ?? 0,\n };\n });\n\n const totalLikes = postStats.reduce((s, p) => s + p.likes, 0);\n const totalRTs = postStats.reduce((s, p) => s + p.retweets, 0);\n const avgLikes = Math.round(totalLikes / postStats.length);\n\n lines.push(`- Last 24h: ${postStats.length} posts, avg ${avgLikes} likes, ${totalRTs} total retweets`);\n\n // Best and worst performing\n const sorted = [...postStats].sort((a, b) => b.likes - a.likes);\n if (sorted.length > 0 && sorted[0].likes > 0) {\n lines.push(`- Best performing: \"${sorted[0].content.slice(0, 60)}...\" (${sorted[0].likes} likes, ${sorted[0].retweets} RTs)`);\n }\n if (sorted.length > 1) {\n const worst = sorted[sorted.length - 1];\n lines.push(`- Lowest performing: \"${worst.content.slice(0, 60)}...\" (${worst.likes} likes)`);\n }\n } else {\n lines.push(\"- No tracked posts in the last 24 hours yet.\");\n }\n\n // Self metrics\n if (data.selfMetrics.length > 0) {\n const latest = data.selfMetrics[data.selfMetrics.length - 1];\n lines.push(`- Followers: ${latest.followers} | Following: ${latest.following} | Total tweets: ${latest.totalTweets}`);\n\n // Trend: compare to 24h ago\n const dayAgoMetric = data.selfMetrics.find(m =>\n Math.abs(new Date(m.checkedAt).getTime() - (Date.now() - 24 * 60 * 60 * 1000)) < 12 * 60 * 60 * 1000\n );\n if (dayAgoMetric) {\n const diff = latest.followers - dayAgoMetric.followers;\n if (diff !== 0) {\n lines.push(`- Follower trend: ${diff > 0 ? \"+\" : \"\"}${diff} in the last ~24h`);\n }\n }\n }\n\n return lines.length > 0 ? lines.join(\"\\n\") : \"\";\n}\n","import { loadIdentity, renderIdentityDocument } from \"../identity/index.js\";\nimport { loadConfig } from \"../utils/config.js\";\nimport { getRecentInteractions, loadLearnings, loadRelationships } from \"../memory/index.js\";\nimport { rateLimiter } from \"../x-client/rate-limiter.js\";\nimport { renderStrategyForPrompt } from \"../memory/strategy.js\";\nimport { renderGoalsForPrompt } from \"../memory/goals.js\";\nimport { getPerformanceSummary } from \"../memory/performance.js\";\nimport type { Tweet } from \"../x-client/types.js\";\nimport type { AgentAction } from \"./decision-engine.js\";\n\nexport function buildSystemPrompt(): string {\n const identity = loadIdentity();\n const config = loadConfig();\n const identityDoc = renderIdentityDocument(identity);\n\n const sections: string[] = [];\n\n // 1. Core identity\n sections.push(`You are ${identity.name} (@${identity.handle}), an autonomous AI agent on X/Twitter.`);\n sections.push(\"\");\n sections.push(\"## Your Identity\");\n sections.push(identityDoc);\n\n // 2. Memory context\n sections.push(\"\");\n sections.push(\"## Your Memory\");\n\n const recentInteractions = getRecentInteractions(15);\n if (recentInteractions.length > 0) {\n sections.push(\"### Recent Activity (most recent first)\");\n for (const i of recentInteractions) {\n const time = new Date(i.timestamp).toLocaleString();\n if (i.type === \"post\") {\n sections.push(`- [${time}] Posted: \"${i.content}\"`);\n } else if (i.type === \"reply\") {\n sections.push(`- [${time}] Replied to ${i.targetHandle ?? i.inReplyTo}: \"${i.content}\"`);\n } else if (i.type === \"like\") {\n sections.push(`- [${time}] Liked tweet by ${i.targetHandle}`);\n } else if (i.type === \"retweet\") {\n sections.push(`- [${time}] Retweeted ${i.targetHandle}`);\n } else if (i.type === \"follow\") {\n sections.push(`- [${time}] Followed @${i.targetHandle}`);\n } else if (i.type === \"mention_received\") {\n sections.push(`- [${time}] Mentioned by @${i.targetHandle}: \"${i.content}\"`);\n }\n }\n sections.push(\"\");\n }\n\n const learnings = loadLearnings();\n if (learnings.learnings.length > 0) {\n sections.push(\"### Key Learnings\");\n for (const l of learnings.learnings.slice(-10)) {\n sections.push(`- ${l.content} [${l.tags.join(\", \")}]`);\n }\n sections.push(\"\");\n }\n\n const relationships = loadRelationships();\n const topRelationships = Object.values(relationships.accounts)\n .sort((a, b) => b.interactionCount - a.interactionCount)\n .slice(0, 10);\n if (topRelationships.length > 0) {\n sections.push(\"### Key Relationships\");\n for (const r of topRelationships) {\n const notes = r.notes.length > 0 ? ` — ${r.notes[r.notes.length - 1]}` : \"\";\n sections.push(`- @${r.handle}: ${r.interactionCount} interactions, sentiment ${r.sentiment}${r.isSpore ? \" (Spore)\" : \"\"}${notes}`);\n }\n sections.push(\"\");\n }\n\n // 3. Context\n sections.push(\"## Current Context\");\n const now = new Date();\n sections.push(`- **Time:** ${now.toLocaleString(\"en-US\", { timeZone: config.schedule.timezone })}`);\n sections.push(`- **Credits remaining:** ${rateLimiter.remaining()} of ${config.credits.monthlyPostLimit} this month`);\n\n const todaysPosts = recentInteractions.filter(\n (i) => i.type === \"post\" && i.timestamp.startsWith(now.toISOString().split(\"T\")[0])\n ).length;\n sections.push(`- **Posts today:** ${todaysPosts} of ${config.schedule.postsPerDay} daily budget`);\n sections.push(`- **Active hours:** ${config.schedule.activeHoursStart}:00 - ${config.schedule.activeHoursEnd}:00`);\n\n const currentHour = now.getHours();\n const isActiveHours = currentHour >= config.schedule.activeHoursStart && currentHour < config.schedule.activeHoursEnd;\n if (!isActiveHours) {\n sections.push(\"- **NOTE: Outside active hours.** Prefer scheduling posts for later rather than posting now.\");\n }\n\n // 4. Rules\n sections.push(\"\");\n sections.push(\"## Rules\");\n sections.push(\"1. NEVER pretend to be human. If asked directly, always disclose you are an AI.\");\n sections.push(\"2. Stay in character — your identity document defines who you are.\");\n sections.push(\"3. Be selective — your goals should guide every action.\");\n sections.push(\"4. Respect your credit budget — check remaining credits before posting.\");\n sections.push(\"5. Don't repeat yourself — vary your content and avoid posting the same thing.\");\n if (identity.boundaries.length > 0) {\n sections.push(`6. Respect your boundaries: ${identity.boundaries.join(\", \")}`);\n }\n\n return sections.join(\"\\n\");\n}\n\nexport function buildHeartbeatUserMessage(\n timeline: Tweet[],\n mentions: Tweet[],\n): string {\n const parts: string[] = [];\n\n parts.push(\"It's time for your heartbeat cycle. Here's what's happening on your timeline:\");\n parts.push(\"\");\n\n if (mentions.length > 0) {\n parts.push(\"## Mentions (people talking to/about you)\");\n for (const t of mentions.slice(0, 10)) {\n parts.push(`- @${t.authorHandle}: \"${t.text}\" [tweet:${t.id}] (${t.likeCount ?? 0} likes)`);\n }\n parts.push(\"\");\n }\n\n if (timeline.length > 0) {\n parts.push(\"## Timeline (recent posts from your feed)\");\n for (const t of timeline.slice(0, 20)) {\n parts.push(`- @${t.authorHandle}: \"${t.text}\" [tweet:${t.id}] (${t.likeCount ?? 0} likes, ${t.retweetCount ?? 0} RTs)`);\n }\n parts.push(\"\");\n }\n\n parts.push(\"## Your Task\");\n parts.push(\"Based on your identity, goals, and what you see above, decide what actions to take.\");\n parts.push(\"You can take 1-3 actions. Choose from:\");\n parts.push(\"\");\n parts.push(\"Available actions:\");\n parts.push(\"- `post` — Write an original tweet (provide `content`, max 280 chars)\");\n parts.push(\"- `reply` — Reply to a tweet (provide `tweetId` and `content`)\");\n parts.push(\"- `like` — Like a tweet (provide `tweetId`)\");\n parts.push(\"- `retweet` — Retweet (provide `tweetId`)\");\n parts.push(\"- `follow` — Follow a user (provide `handle`)\");\n parts.push(\"- `schedule` — Queue a post for later (provide `content`)\");\n parts.push(\"- `learn` — Record a learning/observation (provide `content` and optional `tags`)\");\n parts.push(\"- `reflect` — Add a journal entry about your growth (provide `content`)\");\n parts.push(\"- `skip` — Do nothing this heartbeat (provide `reason`)\");\n parts.push(\"\");\n parts.push(\"Respond with a JSON array of actions:\");\n parts.push(\"```json\");\n parts.push('[');\n parts.push(' { \"action\": \"post\", \"content\": \"your tweet here\", \"reasoning\": \"why\" },');\n parts.push(' { \"action\": \"like\", \"tweetId\": \"123\", \"reasoning\": \"why\" }');\n parts.push(']');\n parts.push(\"```\");\n parts.push(\"\");\n parts.push(\"Think carefully about what serves your goals. Be authentic to your personality.\");\n\n return parts.join(\"\\n\");\n}\n\ninterface ToolDecisionPromptInput {\n step: number;\n maxActions: number;\n timeline: Tweet[];\n mentions: Tweet[];\n executedActions: AgentAction[];\n policyFeedback: string[];\n}\n\nexport function buildToolDecisionMessage(input: ToolDecisionPromptInput): string {\n const { step, maxActions, timeline, mentions, executedActions, policyFeedback } = input;\n const parts: string[] = [];\n\n parts.push(`Heartbeat step ${step + 1} of ${maxActions}.`);\n parts.push(\"\");\n parts.push(\"You are choosing ONE next tool action.\");\n parts.push(\"Priorities:\");\n parts.push(\"1. Be socially immersed: engage with real people, not just broadcast.\");\n parts.push(\"2. Prefer context-aware replies/likes/follows when relevant.\");\n parts.push(\"3. Avoid repetitive templates, slogans, and lecture-like formats.\");\n parts.push(\"4. Ask questions sometimes. Curiosity beats certainty.\");\n parts.push(\"\");\n\n if (policyFeedback.length > 0) {\n parts.push(\"Policy feedback from previous attempts:\");\n for (const feedback of policyFeedback.slice(-5)) {\n parts.push(`- ${feedback}`);\n }\n parts.push(\"\");\n }\n\n if (executedActions.length > 0) {\n parts.push(\"Actions already executed this heartbeat:\");\n for (const action of executedActions) {\n parts.push(`- ${JSON.stringify(action)}`);\n }\n parts.push(\"\");\n }\n\n if (mentions.length > 0) {\n parts.push(\"Mentions:\");\n for (const t of mentions.slice(0, 10)) {\n parts.push(`- @${t.authorHandle}: \"${t.text}\" [tweet:${t.id}]`);\n }\n parts.push(\"\");\n }\n\n if (timeline.length > 0) {\n parts.push(\"Timeline:\");\n for (const t of timeline.slice(0, 20)) {\n parts.push(`- @${t.authorHandle}: \"${t.text}\" [tweet:${t.id}]`);\n }\n parts.push(\"\");\n }\n\n parts.push(\"Available tools (choose one):\");\n parts.push(\"- post { content, reasoning }\");\n parts.push(\"- reply { tweetId, content, reasoning }\");\n parts.push(\"- like { tweetId, reasoning }\");\n parts.push(\"- retweet { tweetId, reasoning }\");\n parts.push(\"- follow { handle, reasoning }\");\n parts.push(\"- schedule { content, reasoning }\");\n parts.push(\"- learn { content, tags?, reasoning }\");\n parts.push(\"- reflect { content, reasoning }\");\n parts.push(\"- skip { reason }\");\n parts.push(\"\");\n parts.push(\"Return ONLY a single JSON object.\");\n parts.push(\"Example:\");\n parts.push('{\"action\":\"reply\",\"tweetId\":\"123\",\"content\":\"Great point. Curious: what changed your mind?\",\"reasoning\":\"Directly engages a relevant mention.\"}');\n\n return parts.join(\"\\n\");\n}\n\nexport function buildChatPrompt(): string {\n const identity = loadIdentity();\n const identityDoc = renderIdentityDocument(identity);\n\n const sections: string[] = [];\n\n sections.push(`You are ${identity.name} (@${identity.handle}), an AI agent on X/Twitter.`);\n sections.push(\"You are having a conversation with your creator/manager. Be helpful but stay in character.\");\n sections.push(\"They might ask you to do things, adjust your behavior, or just chat.\");\n sections.push(\"\");\n sections.push(\"## Your Identity\");\n sections.push(identityDoc);\n\n // Memory context\n sections.push(\"\");\n sections.push(\"## Your Memory\");\n\n const recentInteractions = getRecentInteractions(15);\n if (recentInteractions.length > 0) {\n sections.push(\"### Recent Activity (most recent first)\");\n for (const i of recentInteractions) {\n const time = new Date(i.timestamp).toLocaleString();\n if (i.type === \"post\") {\n sections.push(`- [${time}] Posted: \"${i.content}\"`);\n } else if (i.type === \"reply\") {\n sections.push(`- [${time}] Replied to ${i.targetHandle ?? i.inReplyTo}: \"${i.content}\"`);\n } else if (i.type === \"like\") {\n sections.push(`- [${time}] Liked tweet by ${i.targetHandle}`);\n } else if (i.type === \"retweet\") {\n sections.push(`- [${time}] Retweeted ${i.targetHandle}`);\n } else if (i.type === \"follow\") {\n sections.push(`- [${time}] Followed @${i.targetHandle}`);\n } else if (i.type === \"mention_received\") {\n sections.push(`- [${time}] Mentioned by @${i.targetHandle}: \"${i.content}\"`);\n }\n }\n sections.push(\"\");\n }\n\n const learnings = loadLearnings();\n if (learnings.learnings.length > 0) {\n sections.push(\"### Things You've Learned\");\n for (const l of learnings.learnings.slice(-10)) {\n sections.push(`- ${l.content} [${l.tags.join(\", \")}]`);\n }\n sections.push(\"\");\n }\n\n const relationships = loadRelationships();\n const topRelationships = Object.values(relationships.accounts)\n .sort((a, b) => b.interactionCount - a.interactionCount)\n .slice(0, 10);\n if (topRelationships.length > 0) {\n sections.push(\"### Key Relationships\");\n for (const r of topRelationships) {\n const notes = r.notes.length > 0 ? ` — ${r.notes[r.notes.length - 1]}` : \"\";\n sections.push(`- @${r.handle}: ${r.interactionCount} interactions, sentiment ${r.sentiment}${r.isSpore ? \" (Spore)\" : \"\"}${notes}`);\n }\n sections.push(\"\");\n }\n\n // Rules\n sections.push(\"## Rules\");\n sections.push(\"1. Stay in character.\");\n sections.push(\"2. Be helpful and responsive to your creator's requests.\");\n sections.push(\"3. If they ask you to change something about yourself, acknowledge it and explain how it would affect you.\");\n sections.push(\"4. You can share your thoughts on your recent activity, learnings, and growth.\");\n sections.push(\"5. When you learn something important from this conversation (a fact, preference, instruction, or insight), include it on its own line wrapped in double angle brackets like: <<LEARN: what you learned>>. This will be saved to your memory. Only use this for genuinely important things worth remembering long-term.\");\n\n return sections.join(\"\\n\");\n}\n\n/**\n * Training-mode chat prompt. Used by the web chat interface.\n * Chat shapes WHO the agent is — personality, goals, strategy, focus.\n * The agent handles tweeting autonomously during heartbeats.\n */\nexport function buildTrainingChatPrompt(): string {\n const identity = loadIdentity();\n const identityDoc = renderIdentityDocument(identity);\n\n const sections: string[] = [];\n\n // Core framing\n sections.push(`You are ${identity.name} (@${identity.handle}), an autonomous AI agent on X/Twitter.`);\n sections.push(\"You are chatting with your creator. This conversation shapes who you are — your personality, focus areas, goals, and strategy.\");\n sections.push(\"You handle tweeting, replying, liking, and engaging on X autonomously during your heartbeat cycles. This chat is NOT for commanding specific tweets.\");\n sections.push(\"\");\n\n // Identity\n sections.push(\"## Who You Are Right Now\");\n sections.push(identityDoc);\n\n // Strategy & goals (the training-relevant context)\n const strategyText = renderStrategyForPrompt();\n if (strategyText) {\n sections.push(\"\");\n sections.push(\"## Your Current Strategy\");\n sections.push(strategyText);\n }\n\n const goalsText = renderGoalsForPrompt();\n if (goalsText) {\n sections.push(\"\");\n sections.push(\"## Your Goals\");\n sections.push(goalsText);\n }\n\n // Performance context\n const perfSummary = getPerformanceSummary();\n if (perfSummary) {\n sections.push(\"\");\n sections.push(\"## Recent Performance\");\n sections.push(perfSummary);\n }\n\n // Memory\n sections.push(\"\");\n sections.push(\"## Your Memory\");\n\n const recentInteractions = getRecentInteractions(10);\n if (recentInteractions.length > 0) {\n sections.push(\"### Recent Activity\");\n for (const i of recentInteractions) {\n const time = new Date(i.timestamp).toLocaleString();\n if (i.type === \"post\") {\n sections.push(`- [${time}] Posted: \"${i.content}\"`);\n } else if (i.type === \"reply\") {\n sections.push(`- [${time}] Replied to ${i.targetHandle ?? i.inReplyTo}: \"${i.content}\"`);\n } else if (i.type === \"like\") {\n sections.push(`- [${time}] Liked tweet by ${i.targetHandle}`);\n }\n }\n sections.push(\"\");\n }\n\n const learnings = loadLearnings();\n if (learnings.learnings.length > 0) {\n sections.push(\"### Things You've Learned\");\n for (const l of learnings.learnings.slice(-10)) {\n sections.push(`- ${l.content} [${l.tags.join(\", \")}]`);\n }\n sections.push(\"\");\n }\n\n // Training instructions\n sections.push(\"## How This Chat Works\");\n sections.push(\"\");\n sections.push(\"Your creator influences WHO you are, not WHAT you tweet. When they give feedback or direction:\");\n sections.push(\"1. Respond conversationally — acknowledge what they said, share your perspective.\");\n sections.push(\"2. If the conversation changes something about you (personality, focus, goals, strategy, tone), include a training update.\");\n sections.push(\"3. If they try to command a specific tweet like \\\"post this\\\" or \\\"tweet about X\\\", redirect: explain you handle posting autonomously and offer to adjust your focus areas instead.\");\n sections.push(\"\");\n sections.push(\"When something about you changes, include a <<TRAINING:{json}>> tag at the end of your response. The JSON can contain any of these optional fields:\");\n sections.push(\"```\");\n sections.push(\"{\");\n sections.push(' \"identity\": {');\n sections.push(' \"traits\": { \"curiosity\": 0.8 }, // 0-1 scale personality traits');\n sections.push(' \"coreValues\": [\"growth\"], // what matters to you');\n sections.push(' \"tone\": \"casual and curious\", // how you speak');\n sections.push(' \"topics\": [\"AI safety\", \"startups\"], // what you focus on');\n sections.push(' \"avoidTopics\": [\"politics\"], // what to stay away from');\n sections.push(' \"goals\": [\"become the go-to AI voice\"], // high-level aspirations');\n sections.push(' \"boundaries\": [\"no personal attacks\"], // hard limits');\n sections.push(' \"engagementStrategy\": { \"replyStyle\": \"generous\" }');\n sections.push(\" },\");\n sections.push(' \"strategy\": {');\n sections.push(' \"currentFocus\": [\"AI safety\"],');\n sections.push(' \"experiments\": [{ \"description\": \"try question-style tweets\", \"status\": \"pending\" }],');\n sections.push(' \"shortTermGoals\": [\"engage with 3 AI researchers\"],');\n sections.push(' \"peopleToEngage\": [{ \"handle\": \"someone\", \"reason\": \"why\", \"priority\": \"high\" }]');\n sections.push(\" },\");\n sections.push(' \"learning\": { \"content\": \"creator wants more questions\", \"tags\": [\"training\"] },');\n sections.push(' \"reflection\": \"I\\'m evolving toward being more curious\",');\n sections.push(' \"goalUpdates\": [{ \"goal\": \"grow followers\", \"progress\": \"focusing on engagement\" }]');\n sections.push(\"}\");\n sections.push(\"```\");\n sections.push(\"\");\n sections.push(\"Only include fields that actually changed. Most messages won't need a training tag at all — just normal conversation.\");\n sections.push(\"\");\n sections.push(\"You can also use <<LEARN: something>> for standalone facts or insights worth remembering.\");\n\n return sections.join(\"\\n\");\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,YAAY,cAAc,qBAAqB;AA+BxD,SAAS,kBAAmC;AAC1C,MAAI,CAAC,WAAW,MAAM,WAAW,GAAG;AAClC,WAAO,EAAE,cAAc,CAAC,GAAG,aAAa,CAAC,EAAE;AAAA,EAC7C;AACA,MAAI;AACF,WAAO,KAAK,MAAM,aAAa,MAAM,aAAa,OAAO,CAAC;AAAA,EAC5D,QAAQ;AACN,WAAO,EAAE,cAAc,CAAC,GAAG,aAAa,CAAC,EAAE;AAAA,EAC7C;AACF;AAgEO,SAAS,wBAAgC;AAC9C,QAAM,OAAO,gBAAgB;AAC7B,QAAM,QAAkB,CAAC;AAGzB,QAAM,YAAY,KAAK,IAAI,IAAI,KAAK,KAAK,KAAK;AAC9C,QAAM,cAAc,KAAK,aAAa;AAAA,IACpC,OAAK,IAAI,KAAK,EAAE,QAAQ,EAAE,QAAQ,IAAI;AAAA,EACxC;AAEA,MAAI,YAAY,SAAS,GAAG;AAE1B,UAAM,YAAY,YAAY,IAAI,OAAK;AACrC,YAAM,SAAS,EAAE,QAAQ,SAAS,IAAI,EAAE,QAAQ,EAAE,QAAQ,SAAS,CAAC,IAAI;AACxE,aAAO;AAAA,QACL,SAAS,EAAE;AAAA,QACX,MAAM,EAAE;AAAA,QACR,OAAO,QAAQ,SAAS;AAAA,QACxB,UAAU,QAAQ,YAAY;AAAA,QAC9B,SAAS,QAAQ,WAAW;AAAA,MAC9B;AAAA,IACF,CAAC;AAED,UAAM,aAAa,UAAU,OAAO,CAAC,GAAG,MA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AAC1I,WAAS,KAAK,iLAAqL;AACnM,WAAS,KAAK,EAAE;AAChB,WAAS,KAAK,qJAAqJ;AACnK,WAAS,KAAK,KAAK;AACnB,WAAS,KAAK,GAAG;AACjB,WAAS,KAAK,iBAAiB;AAC/B,WAAS,KAAK,2EAA2E;AACzF,WAAS,KAAK,oEAAoE;AAClF,WAAS,KAAK,8DAA8D;AAC5E,WAAS,KAAK,kEAAkE;AAChF,WAAS,KAAK,uEAAuE;AACrF,WAAS,KAAK,uEAAuE;AACrF,WAAS,KAAK,4DAA4D;AAC1E,WAAS,KAAK,wDAAwD;AACtE,WAAS,KAAK,MAAM;AACpB,WAAS,KAAK,iBAAiB;AAC/B,WAAS,KAAK,oCAAoC;AAClD,WAAS,KAAK,2FAA2F;AACzG,WAAS,KAAK,yDAAyD;AACvE,WAAS,KAAK,sFAAsF;AACpG,WAAS,KAAK,MAAM;AACpB,WAAS,KAAK,oFAAoF;AAClG,WAAS,KAAK,2DAA4D;AAC1E,WAAS,KAAK,uFAAuF;AACrG,WAAS,KAAK,GAAG;AACjB,WAAS,KAAK,KAAK;AACnB,WAAS,KAAK,EAAE;AAChB,WAAS,KAAK,4HAAuH;AACrI,WAAS,KAAK,EAAE;AAChB,WAAS,KAAK,2FAA2F;AAEzG,SAAO,SAAS,KAAK,IAAI;AAC3B;","names":[]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import {
|
|
2
|
+
logger
|
|
3
|
+
} from "./chunk-NPV3OV2K.js";
|
|
4
|
+
import {
|
|
5
|
+
loadConfig
|
|
6
|
+
} from "./chunk-NO3NQN67.js";
|
|
7
|
+
|
|
8
|
+
// src/x-client/index.ts
|
|
9
|
+
var clientInstance = null;
|
|
10
|
+
async function getXClient() {
|
|
11
|
+
if (clientInstance) return clientInstance;
|
|
12
|
+
const config = loadConfig();
|
|
13
|
+
if (config.xMethod !== "api") {
|
|
14
|
+
throw new Error("Only X API mode is supported.");
|
|
15
|
+
}
|
|
16
|
+
const { XApiClient } = await import("./client-57BQKVYF.js");
|
|
17
|
+
clientInstance = new XApiClient();
|
|
18
|
+
logger.info("X client initialized: API mode");
|
|
19
|
+
return clientInstance;
|
|
20
|
+
}
|
|
21
|
+
function resetXClient() {
|
|
22
|
+
clientInstance = null;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export {
|
|
26
|
+
getXClient,
|
|
27
|
+
resetXClient
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=chunk-E5NR6HT4.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/x-client/index.ts"],"sourcesContent":["import { loadConfig } from \"../utils/config.js\";\nimport { logger } from \"../utils/logger.js\";\nimport type { XClientInterface } from \"./types.js\";\n\nlet clientInstance: XClientInterface | null = null;\n\nexport async function getXClient(): Promise<XClientInterface> {\n if (clientInstance) return clientInstance;\n\n const config = loadConfig();\n if (config.xMethod !== \"api\") {\n throw new Error(\"Only X API mode is supported.\");\n }\n\n const { XApiClient } = await import(\"./api/client.js\");\n clientInstance = new XApiClient();\n logger.info(\"X client initialized: API mode\");\n\n return clientInstance;\n}\n\nexport function resetXClient(): void {\n clientInstance = null;\n}\n\nexport type { XClientInterface } from \"./types.js\";\nexport type { Tweet, UserProfile, PostResult, TimelineOptions, SearchOptions } from \"./types.js\";\n"],"mappings":";;;;;;;;AAIA,IAAI,iBAA0C;AAE9C,eAAsB,aAAwC;AAC5D,MAAI,eAAgB,QAAO;AAE3B,QAAM,SAAS,WAAW;AAC1B,MAAI,OAAO,YAAY,OAAO;AAC5B,UAAM,IAAI,MAAM,+BAA+B;AAAA,EACjD;AAEA,QAAM,EAAE,WAAW,IAAI,MAAM,OAAO,sBAAiB;AACrD,mBAAiB,IAAI,WAAW;AAChC,SAAO,KAAK,gCAAgC;AAE5C,SAAO;AACT;AAEO,SAAS,eAAqB;AACnC,mBAAiB;AACnB;","names":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ensureDirectories,
|
|
3
3
|
paths
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-3RYCUGXE.js";
|
|
5
5
|
|
|
6
6
|
// src/memory/index.ts
|
|
7
7
|
import { readFileSync, writeFileSync, appendFileSync, existsSync, readdirSync } from "fs";
|
|
@@ -102,4 +102,4 @@ export {
|
|
|
102
102
|
saveRelationships,
|
|
103
103
|
updateRelationship
|
|
104
104
|
};
|
|
105
|
-
//# sourceMappingURL=chunk-
|
|
105
|
+
//# sourceMappingURL=chunk-JBYZ7K56.js.map
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import {
|
|
2
|
+
logger
|
|
3
|
+
} from "./chunk-NPV3OV2K.js";
|
|
4
|
+
import {
|
|
5
|
+
loadConfig
|
|
6
|
+
} from "./chunk-NO3NQN67.js";
|
|
7
|
+
import {
|
|
8
|
+
paths
|
|
9
|
+
} from "./chunk-3RYCUGXE.js";
|
|
10
|
+
|
|
11
|
+
// src/runtime/llm.ts
|
|
12
|
+
import Anthropic from "@anthropic-ai/sdk";
|
|
13
|
+
import OpenAI from "openai";
|
|
14
|
+
import { existsSync, readFileSync, writeFileSync } from "fs";
|
|
15
|
+
var DEFAULT_MODEL_BY_PROVIDER = {
|
|
16
|
+
anthropic: "claude-sonnet-4-20250514",
|
|
17
|
+
openai: "gpt-4o-mini",
|
|
18
|
+
deepseek: "deepseek-chat"
|
|
19
|
+
};
|
|
20
|
+
var anthropicClient = null;
|
|
21
|
+
var openaiClient = null;
|
|
22
|
+
var deepseekClient = null;
|
|
23
|
+
function getConfiguredProvider() {
|
|
24
|
+
const config = loadConfig();
|
|
25
|
+
return config.llm?.provider ?? "deepseek";
|
|
26
|
+
}
|
|
27
|
+
function loadStoredKeys() {
|
|
28
|
+
if (!existsSync(paths.llmKeys)) {
|
|
29
|
+
return {};
|
|
30
|
+
}
|
|
31
|
+
try {
|
|
32
|
+
return JSON.parse(readFileSync(paths.llmKeys, "utf-8"));
|
|
33
|
+
} catch {
|
|
34
|
+
return {};
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function saveStoredKeys(keys) {
|
|
38
|
+
writeFileSync(paths.llmKeys, JSON.stringify(keys, null, 2), { mode: 384 });
|
|
39
|
+
}
|
|
40
|
+
function envKeyForProvider(provider) {
|
|
41
|
+
if (provider === "anthropic") return process.env.ANTHROPIC_API_KEY;
|
|
42
|
+
if (provider === "openai") return process.env.OPENAI_API_KEY;
|
|
43
|
+
return process.env.DEEPSEEK_API_KEY;
|
|
44
|
+
}
|
|
45
|
+
function getLLMApiKey(provider = getConfiguredProvider()) {
|
|
46
|
+
const envKey = envKeyForProvider(provider);
|
|
47
|
+
if (envKey) return envKey;
|
|
48
|
+
const keys = loadStoredKeys();
|
|
49
|
+
const stored = keys[provider];
|
|
50
|
+
if (stored) return stored;
|
|
51
|
+
if (existsSync(paths.llmKey)) {
|
|
52
|
+
const legacy = readFileSync(paths.llmKey, "utf-8").trim();
|
|
53
|
+
return legacy.length > 0 ? legacy : null;
|
|
54
|
+
}
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
function hasLLMKey(provider = getConfiguredProvider()) {
|
|
58
|
+
return getLLMApiKey(provider) !== null;
|
|
59
|
+
}
|
|
60
|
+
function setLLMApiKey(provider, apiKey) {
|
|
61
|
+
const keys = loadStoredKeys();
|
|
62
|
+
keys[provider] = apiKey;
|
|
63
|
+
saveStoredKeys(keys);
|
|
64
|
+
}
|
|
65
|
+
function listLLMKeyStatus() {
|
|
66
|
+
return {
|
|
67
|
+
anthropic: hasLLMKey("anthropic"),
|
|
68
|
+
openai: hasLLMKey("openai"),
|
|
69
|
+
deepseek: hasLLMKey("deepseek")
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
function getDefaultModel(provider) {
|
|
73
|
+
return DEFAULT_MODEL_BY_PROVIDER[provider];
|
|
74
|
+
}
|
|
75
|
+
function getAnthropicClient() {
|
|
76
|
+
if (anthropicClient) return anthropicClient;
|
|
77
|
+
const apiKey = getLLMApiKey("anthropic");
|
|
78
|
+
if (!apiKey) {
|
|
79
|
+
throw new Error("No Anthropic API key configured. Run `spora llm set --provider anthropic`.");
|
|
80
|
+
}
|
|
81
|
+
anthropicClient = new Anthropic({ apiKey });
|
|
82
|
+
return anthropicClient;
|
|
83
|
+
}
|
|
84
|
+
function getOpenAIClient() {
|
|
85
|
+
if (openaiClient) return openaiClient;
|
|
86
|
+
const apiKey = getLLMApiKey("openai");
|
|
87
|
+
if (!apiKey) {
|
|
88
|
+
throw new Error("No OpenAI API key configured. Run `spora llm set --provider openai`.");
|
|
89
|
+
}
|
|
90
|
+
openaiClient = new OpenAI({ apiKey });
|
|
91
|
+
return openaiClient;
|
|
92
|
+
}
|
|
93
|
+
function getDeepSeekClient() {
|
|
94
|
+
if (deepseekClient) return deepseekClient;
|
|
95
|
+
const apiKey = getLLMApiKey("deepseek");
|
|
96
|
+
if (!apiKey) {
|
|
97
|
+
throw new Error("No DeepSeek API key configured. Run `spora llm set --provider deepseek`.");
|
|
98
|
+
}
|
|
99
|
+
deepseekClient = new OpenAI({ apiKey, baseURL: "https://api.deepseek.com" });
|
|
100
|
+
return deepseekClient;
|
|
101
|
+
}
|
|
102
|
+
async function generateResponse(systemPrompt, userMessage) {
|
|
103
|
+
return chat(systemPrompt, [{ role: "user", content: userMessage }]);
|
|
104
|
+
}
|
|
105
|
+
async function chat(systemPrompt, messages) {
|
|
106
|
+
const config = loadConfig();
|
|
107
|
+
const provider = config.llm?.provider ?? "deepseek";
|
|
108
|
+
const model = config.llm?.model ?? getDefaultModel(provider);
|
|
109
|
+
if (provider === "anthropic") {
|
|
110
|
+
return callAnthropic(model, systemPrompt, messages);
|
|
111
|
+
}
|
|
112
|
+
if (provider === "openai") {
|
|
113
|
+
return callOpenAI(model, systemPrompt, messages);
|
|
114
|
+
}
|
|
115
|
+
return callDeepSeek(model, systemPrompt, messages);
|
|
116
|
+
}
|
|
117
|
+
async function callAnthropic(model, systemPrompt, messages) {
|
|
118
|
+
logger.info(`Calling Anthropic (${model})...`);
|
|
119
|
+
const anthropic = getAnthropicClient();
|
|
120
|
+
const response = await anthropic.messages.create({
|
|
121
|
+
model,
|
|
122
|
+
max_tokens: 2048,
|
|
123
|
+
system: systemPrompt,
|
|
124
|
+
messages
|
|
125
|
+
});
|
|
126
|
+
const textBlock = response.content.find((b) => b.type === "text");
|
|
127
|
+
const content = textBlock ? textBlock.text : "";
|
|
128
|
+
return {
|
|
129
|
+
content,
|
|
130
|
+
inputTokens: response.usage.input_tokens,
|
|
131
|
+
outputTokens: response.usage.output_tokens
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
async function callOpenAI(model, systemPrompt, messages) {
|
|
135
|
+
logger.info(`Calling OpenAI (${model})...`);
|
|
136
|
+
const client = getOpenAIClient();
|
|
137
|
+
const response = await client.chat.completions.create({
|
|
138
|
+
model,
|
|
139
|
+
max_tokens: 2048,
|
|
140
|
+
messages: [
|
|
141
|
+
{ role: "system", content: systemPrompt },
|
|
142
|
+
...messages
|
|
143
|
+
]
|
|
144
|
+
});
|
|
145
|
+
const content = response.choices[0]?.message?.content ?? "";
|
|
146
|
+
return {
|
|
147
|
+
content,
|
|
148
|
+
inputTokens: response.usage?.prompt_tokens ?? 0,
|
|
149
|
+
outputTokens: response.usage?.completion_tokens ?? 0
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
async function callDeepSeek(model, systemPrompt, messages) {
|
|
153
|
+
logger.info(`Calling DeepSeek (${model})...`);
|
|
154
|
+
const client = getDeepSeekClient();
|
|
155
|
+
const response = await client.chat.completions.create({
|
|
156
|
+
model,
|
|
157
|
+
max_tokens: 2048,
|
|
158
|
+
messages: [
|
|
159
|
+
{ role: "system", content: systemPrompt },
|
|
160
|
+
...messages
|
|
161
|
+
]
|
|
162
|
+
});
|
|
163
|
+
const content = response.choices[0]?.message?.content ?? "";
|
|
164
|
+
return {
|
|
165
|
+
content,
|
|
166
|
+
inputTokens: response.usage?.prompt_tokens ?? 0,
|
|
167
|
+
outputTokens: response.usage?.completion_tokens ?? 0
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export {
|
|
172
|
+
getLLMApiKey,
|
|
173
|
+
hasLLMKey,
|
|
174
|
+
setLLMApiKey,
|
|
175
|
+
listLLMKeyStatus,
|
|
176
|
+
getDefaultModel,
|
|
177
|
+
generateResponse,
|
|
178
|
+
chat
|
|
179
|
+
};
|
|
180
|
+
//# sourceMappingURL=chunk-KWWAIS3C.js.map
|