spora 0.3.2 → 0.3.3

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.
Files changed (83) hide show
  1. package/package.json +1 -1
  2. package/dist/account-creator-SETL5CGT.js +0 -498
  3. package/dist/account-creator-SETL5CGT.js.map +0 -1
  4. package/dist/chunk-DFSYD45Q.js +0 -665
  5. package/dist/chunk-DFSYD45Q.js.map +0 -1
  6. package/dist/chunk-FCAK5FYQ.js +0 -127
  7. package/dist/chunk-FCAK5FYQ.js.map +0 -1
  8. package/dist/chunk-GJFBWIW3.js +0 -622
  9. package/dist/chunk-GJFBWIW3.js.map +0 -1
  10. package/dist/chunk-HERI4RPY.js +0 -156
  11. package/dist/chunk-HERI4RPY.js.map +0 -1
  12. package/dist/chunk-J7J557HV.js +0 -47
  13. package/dist/chunk-J7J557HV.js.map +0 -1
  14. package/dist/chunk-JWMADEQO.js +0 -57
  15. package/dist/chunk-JWMADEQO.js.map +0 -1
  16. package/dist/chunk-LRKBNKMQ.js +0 -79
  17. package/dist/chunk-LRKBNKMQ.js.map +0 -1
  18. package/dist/chunk-NLWU5432.js +0 -32
  19. package/dist/chunk-NLWU5432.js.map +0 -1
  20. package/dist/chunk-POEDIDM6.js +0 -56
  21. package/dist/chunk-POEDIDM6.js.map +0 -1
  22. package/dist/chunk-Q7YS3AIK.js +0 -63
  23. package/dist/chunk-Q7YS3AIK.js.map +0 -1
  24. package/dist/chunk-QHFM2YW6.js +0 -159
  25. package/dist/chunk-QHFM2YW6.js.map +0 -1
  26. package/dist/chunk-R7PAD4OL.js +0 -44
  27. package/dist/chunk-R7PAD4OL.js.map +0 -1
  28. package/dist/chunk-RNVEWVDN.js +0 -129
  29. package/dist/chunk-RNVEWVDN.js.map +0 -1
  30. package/dist/chunk-SUFTVQME.js +0 -82
  31. package/dist/chunk-SUFTVQME.js.map +0 -1
  32. package/dist/chunk-SXMDYUK3.js +0 -80
  33. package/dist/chunk-SXMDYUK3.js.map +0 -1
  34. package/dist/chunk-YZ7RWJ6Z.js +0 -262
  35. package/dist/chunk-YZ7RWJ6Z.js.map +0 -1
  36. package/dist/cli.js +0 -654
  37. package/dist/cli.js.map +0 -1
  38. package/dist/client-23THPNVL.js +0 -382
  39. package/dist/client-23THPNVL.js.map +0 -1
  40. package/dist/client-NVI3ZD4G.js +0 -411
  41. package/dist/client-NVI3ZD4G.js.map +0 -1
  42. package/dist/colony-J4EZQI37.js +0 -229
  43. package/dist/colony-J4EZQI37.js.map +0 -1
  44. package/dist/config-QRBOL4NX.js +0 -14
  45. package/dist/config-QRBOL4NX.js.map +0 -1
  46. package/dist/crypto-ZVWJLD2J.js +0 -14
  47. package/dist/crypto-ZVWJLD2J.js.map +0 -1
  48. package/dist/decision-engine-WBD36PZI.js +0 -19
  49. package/dist/decision-engine-WBD36PZI.js.map +0 -1
  50. package/dist/goals-IM4AEHS4.js +0 -12
  51. package/dist/goals-IM4AEHS4.js.map +0 -1
  52. package/dist/heartbeat-35HVB5PB.js +0 -317
  53. package/dist/heartbeat-35HVB5PB.js.map +0 -1
  54. package/dist/identity-LN2R4KJU.js +0 -26
  55. package/dist/identity-LN2R4KJU.js.map +0 -1
  56. package/dist/image-search-SZVMGWLN.js +0 -45
  57. package/dist/image-search-SZVMGWLN.js.map +0 -1
  58. package/dist/init-ANGLSI2L.js +0 -403
  59. package/dist/init-ANGLSI2L.js.map +0 -1
  60. package/dist/llm-MHZG2VHU.js +0 -16
  61. package/dist/llm-MHZG2VHU.js.map +0 -1
  62. package/dist/mcp-server.js +0 -773
  63. package/dist/mcp-server.js.map +0 -1
  64. package/dist/memory-J6AYZ5Y2.js +0 -26
  65. package/dist/memory-J6AYZ5Y2.js.map +0 -1
  66. package/dist/memory-JMXU3UXR.js +0 -26
  67. package/dist/memory-JMXU3UXR.js.map +0 -1
  68. package/dist/paths-KXOWF2B2.js +0 -13
  69. package/dist/paths-KXOWF2B2.js.map +0 -1
  70. package/dist/performance-7G6R6ELJ.js +0 -18
  71. package/dist/performance-7G6R6ELJ.js.map +0 -1
  72. package/dist/prompt-builder-NSU4IFPB.js +0 -28
  73. package/dist/prompt-builder-NSU4IFPB.js.map +0 -1
  74. package/dist/queue-MLRTMJRE.js +0 -14
  75. package/dist/queue-MLRTMJRE.js.map +0 -1
  76. package/dist/strategy-TOVFBIZQ.js +0 -12
  77. package/dist/strategy-TOVFBIZQ.js.map +0 -1
  78. package/dist/web-chat/chat.html +0 -1343
  79. package/dist/web-chat/logo.png +0 -0
  80. package/dist/web-chat-N2AYUWT7.js +0 -802
  81. package/dist/web-chat-N2AYUWT7.js.map +0 -1
  82. package/dist/x-client-HUXCQOAW.js +0 -12
  83. package/dist/x-client-HUXCQOAW.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/runtime/heartbeat.ts"],"sourcesContent":["import { existsSync, unlinkSync, writeFileSync, readFileSync } from \"node:fs\";\nimport { logger } from \"../utils/logger.js\";\nimport { loadConfig } from \"../utils/config.js\";\nimport { paths } from \"../utils/paths.js\";\nimport { getXClient } from \"../x-client/index.js\";\nimport { flushQueue } from \"../scheduler/queue.js\";\nimport { buildSystemPrompt, buildHeartbeatUserMessage, buildReflectionPrompt, parseReflection } from \"./prompt-builder.js\";\nimport { generateResponse } from \"./llm.js\";\nimport { parseActions, executeActions, type ActionResult } from \"./decision-engine.js\";\nimport { retireOldPosts, getActiveTrackedPosts, updatePostMetrics, updateSelfMetrics, getPerformanceSummary } from \"../memory/performance.js\";\nimport { loadStrategy, saveStrategy } from \"../memory/strategy.js\";\nimport { loadIdentity } from \"../identity/index.js\";\nimport { addLearning } from \"../memory/index.js\";\nimport type { Tweet } from \"../x-client/types.js\";\n\nlet running = false;\nlet lastMentionsSinceId: string | undefined;\n\nexport function isRunning(): boolean {\n return running;\n}\n\nexport function requestStop(): void {\n writeFileSync(paths.stopSignal, \"stop\");\n logger.info(\"Stop signal sent.\");\n}\n\nfunction shouldStop(): boolean {\n if (existsSync(paths.stopSignal)) {\n unlinkSync(paths.stopSignal);\n return true;\n }\n return false;\n}\n\nfunction writePid(): void {\n writeFileSync(paths.runtimePid, String(process.pid));\n}\n\nfunction clearPid(): void {\n if (existsSync(paths.runtimePid)) {\n unlinkSync(paths.runtimePid);\n }\n}\n\nexport function getRunningPid(): number | null {\n if (!existsSync(paths.runtimePid)) return null;\n const pid = parseInt(readFileSync(paths.runtimePid, \"utf-8\").trim(), 10);\n if (isNaN(pid)) return null;\n\n // Check if process is actually running\n try {\n process.kill(pid, 0);\n return pid;\n } catch {\n // Process not running, clean up stale PID\n clearPid();\n return null;\n }\n}\n\nexport async function startHeartbeatLoop(): Promise<void> {\n // Check if already running\n const existingPid = getRunningPid();\n if (existingPid) {\n throw new Error(`Spora is already running (PID ${existingPid}). Run \\`spora stop\\` first.`);\n }\n\n running = true;\n writePid();\n\n const config = loadConfig();\n const intervalMs = config.runtime?.heartbeatIntervalMs ?? 60_000;\n const maxActions = config.runtime?.actionsPerHeartbeat ?? 3;\n\n logger.info(`Spora agent starting. Heartbeat interval: ${intervalMs / 1000}s, max actions: ${maxActions}`);\n console.log(`\\nSpora agent is running (PID ${process.pid})`);\n console.log(`Heartbeat every ${Math.round(intervalMs / 60_000)} minutes`);\n console.log(`Press Ctrl+C or run \\`spora stop\\` to stop.\\n`);\n\n // Handle graceful shutdown\n const shutdown = () => {\n logger.info(\"Shutting down...\");\n running = false;\n clearPid();\n process.exit(0);\n };\n process.on(\"SIGINT\", shutdown);\n process.on(\"SIGTERM\", shutdown);\n\n // Clean any stale stop signal\n if (existsSync(paths.stopSignal)) {\n unlinkSync(paths.stopSignal);\n }\n\n let heartbeatCount = 0;\n\n while (running) {\n heartbeatCount++;\n logger.info(`=== Heartbeat #${heartbeatCount} ===`);\n\n try {\n await runHeartbeat(maxActions, intervalMs, heartbeatCount);\n } catch (error) {\n logger.error(\"Heartbeat error\", error);\n console.error(`Heartbeat #${heartbeatCount} failed: ${(error as Error).message}`);\n }\n\n // Check for stop signal\n if (shouldStop()) {\n logger.info(\"Stop signal received.\");\n break;\n }\n\n // Sleep with jitter\n const jitter = Math.floor(Math.random() * intervalMs * 0.3);\n const sleepMs = intervalMs + jitter;\n logger.info(`Sleeping ${Math.round(sleepMs / 1000)}s until next heartbeat...`);\n\n // Sleep in chunks — flush queue during sleep so scheduled posts go out on time\n const chunkMs = 10_000;\n let slept = 0;\n while (slept < sleepMs && running) {\n await new Promise((r) => setTimeout(r, Math.min(chunkMs, sleepMs - slept)));\n slept += chunkMs;\n if (shouldStop()) {\n running = false;\n break;\n }\n\n // Flush queue during sleep so scheduled posts go out at their intended times\n try {\n const flushed = await flushQueue();\n if (flushed.posted > 0) {\n logger.info(`Flushed ${flushed.posted} scheduled post(s) during sleep`);\n }\n } catch {\n // Queue flush failed during sleep, not critical\n }\n }\n }\n\n clearPid();\n logger.info(\"Spora agent stopped.\");\n console.log(\"\\nSpora agent stopped.\");\n}\n\nasync function runHeartbeat(maxActions: number, intervalMs: number, heartbeatCount: number = 1): Promise<void> {\n // 1. Flush any queued posts\n logger.info(\"Checking queue...\");\n try {\n const flushed = await flushQueue();\n if (flushed.posted > 0) {\n logger.info(`Flushed ${flushed.posted} queued posts.`);\n }\n } catch (error) {\n logger.warn(`Queue flush failed: ${(error as Error).message}`);\n }\n\n const client = await getXClient();\n\n // Get own handle\n let ownHandle: string | undefined;\n if (\"getAuthenticatedHandle\" in client) {\n try {\n ownHandle = await (client as any).getAuthenticatedHandle();\n } catch {}\n }\n\n // 2. Check engagement on tracked posts (performance feedback loop)\n logger.info(\"Checking post performance...\");\n try {\n retireOldPosts();\n const activePosts = getActiveTrackedPosts();\n for (const post of activePosts.slice(0, 5)) {\n try {\n const tweet = await client.getTweet(post.tweetId);\n if (tweet) {\n updatePostMetrics(post.tweetId, {\n checkedAt: new Date().toISOString(),\n likes: tweet.likeCount ?? 0,\n retweets: tweet.retweetCount ?? 0,\n replies: tweet.replyCount ?? 0,\n });\n }\n } catch { /* skip individual tweet lookup failures */ }\n await new Promise(r => setTimeout(r, 1000));\n }\n } catch (error) {\n logger.warn(`Performance check failed: ${(error as Error).message}`);\n }\n\n // 3. Self-awareness: check own profile (every 6th heartbeat)\n if (heartbeatCount % 6 === 1) {\n logger.info(\"Checking own profile...\");\n try {\n const handle = ownHandle ?? loadIdentity().handle;\n const profile = await client.getProfile(handle);\n updateSelfMetrics({\n checkedAt: new Date().toISOString(),\n followers: profile.followersCount,\n following: profile.followingCount,\n totalTweets: profile.tweetCount,\n });\n logger.info(`Self: ${profile.followersCount} followers, ${profile.followingCount} following`);\n } catch (error) {\n logger.warn(`Self-check failed: ${(error as Error).message}`);\n }\n }\n\n // 4. Read timeline and mentions\n logger.info(\"Reading timeline and mentions...\");\n\n let timeline: Tweet[] = [];\n let mentions: Tweet[] = [];\n\n try {\n timeline = await client.getTimeline({ count: 20 });\n if (ownHandle) {\n timeline = timeline.filter(t => t.authorHandle.toLowerCase() !== ownHandle!.toLowerCase());\n }\n } catch (error) {\n logger.warn(`Timeline read failed: ${(error as Error).message}`);\n }\n\n try {\n mentions = await client.getMentions({ count: 10, sinceId: lastMentionsSinceId });\n if (mentions.length > 0) {\n lastMentionsSinceId = mentions[0].id;\n }\n } catch (error) {\n logger.warn(`Mentions read failed: ${(error as Error).message}`);\n }\n\n // 5. Proactive discovery (every 4th heartbeat)\n let discoveryResults: Tweet[] = [];\n if (heartbeatCount % 4 === 0) {\n logger.info(\"Running proactive discovery...\");\n try {\n const identity = loadIdentity();\n const strategy = loadStrategy();\n const allTopics = [...identity.topics, ...(strategy.currentFocus ?? [])];\n if (allTopics.length > 0) {\n const topic = allTopics[Math.floor(Math.random() * allTopics.length)];\n discoveryResults = await client.searchTweets(topic, { count: 10 });\n // Filter out own tweets from discovery\n if (ownHandle) {\n discoveryResults = discoveryResults.filter(t => t.authorHandle.toLowerCase() !== ownHandle!.toLowerCase());\n }\n logger.info(`Discovery for \"${topic}\": ${discoveryResults.length} results`);\n }\n } catch (error) {\n logger.warn(`Discovery failed: ${(error as Error).message}`);\n }\n }\n\n // 6. Build prompts\n const systemPrompt = buildSystemPrompt();\n const userMessage = buildHeartbeatUserMessage(timeline, mentions, intervalMs, discoveryResults);\n\n // 7. Ask LLM for decisions\n logger.info(\"Asking LLM for decisions...\");\n const response = await generateResponse(systemPrompt, userMessage, { temperature: 0.95 });\n\n // 8. Parse and execute actions\n const actions = parseActions(response.content);\n if (actions.length === 0) {\n logger.info(\"LLM returned no actions.\");\n return;\n }\n\n // Build set of valid tweet IDs from timeline + mentions + discovery\n const validTweetIds = new Set<string>();\n const tweetMap = new Map<string, Tweet>();\n for (const t of timeline) { validTweetIds.add(t.id); tweetMap.set(t.id, t); }\n for (const t of mentions) { validTweetIds.add(t.id); tweetMap.set(t.id, t); }\n for (const t of discoveryResults) { validTweetIds.add(t.id); tweetMap.set(t.id, t); }\n\n // Filter out actions with fake/hallucinated tweet IDs\n const validatedActions = actions.filter(a => {\n if (a.tweetId) {\n const cleanId = a.tweetId.replace(/^tweet:/i, \"\").trim();\n if (!validTweetIds.has(cleanId)) {\n logger.warn(`Rejected ${a.action}: tweet ID ${cleanId} not in timeline/mentions (likely hallucinated)`);\n return false;\n }\n }\n return true;\n });\n\n // Limit to max actions per heartbeat\n const limitedActions = validatedActions.slice(0, maxActions);\n logger.info(`Executing ${limitedActions.length} action(s)...`);\n\n const results = await executeActions(limitedActions, tweetMap);\n\n // 9. Log results\n for (const result of results) {\n if (result.success) {\n logger.info(` [OK] ${result.action}${result.detail ? `: ${result.detail}` : \"\"}`);\n } else {\n logger.warn(` [FAIL] ${result.action}: ${result.error}`);\n }\n }\n\n // 10. Reflection phase — brief LLM call to extract insights and update strategy\n logger.info(\"Reflecting on actions...\");\n try {\n const perfSummary = getPerformanceSummary();\n const currentStrategy = loadStrategy();\n const reflectPrompt = buildReflectionPrompt(results, perfSummary, currentStrategy);\n const reflection = await generateResponse(systemPrompt, reflectPrompt, { temperature: 0.7 });\n const reflectionData = parseReflection(reflection.content);\n\n if (reflectionData.learning) {\n addLearning(reflectionData.learning, \"reflection\", [\"auto-reflect\"]);\n logger.info(`Reflection learning: \"${reflectionData.learning.slice(0, 60)}...\"`);\n }\n if (reflectionData.strategyUpdate) {\n const updated = { ...currentStrategy, ...reflectionData.strategyUpdate, lastUpdated: new Date().toISOString() };\n saveStrategy(updated);\n logger.info(\"Strategy updated from reflection.\");\n }\n } catch (error) {\n logger.warn(`Reflection failed: ${(error as Error).message}`);\n }\n\n logger.info(`Heartbeat complete. ${results.filter((r) => r.success).length}/${results.length} actions succeeded.`);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,YAAY,YAAY,eAAe,oBAAoB;AAepE,IAAI,UAAU;AACd,IAAI;AAEG,SAAS,YAAqB;AACnC,SAAO;AACT;AAEO,SAAS,cAAoB;AAClC,gBAAc,MAAM,YAAY,MAAM;AACtC,SAAO,KAAK,mBAAmB;AACjC;AAEA,SAAS,aAAsB;AAC7B,MAAI,WAAW,MAAM,UAAU,GAAG;AAChC,eAAW,MAAM,UAAU;AAC3B,WAAO;AAAA,EACT;AACA,SAAO;AACT;AAEA,SAAS,WAAiB;AACxB,gBAAc,MAAM,YAAY,OAAO,QAAQ,GAAG,CAAC;AACrD;AAEA,SAAS,WAAiB;AACxB,MAAI,WAAW,MAAM,UAAU,GAAG;AAChC,eAAW,MAAM,UAAU;AAAA,EAC7B;AACF;AAEO,SAAS,gBAA+B;AAC7C,MAAI,CAAC,WAAW,MAAM,UAAU,EAAG,QAAO;AAC1C,QAAM,MAAM,SAAS,aAAa,MAAM,YAAY,OAAO,EAAE,KAAK,GAAG,EAAE;AACvE,MAAI,MAAM,GAAG,EAAG,QAAO;AAGvB,MAAI;AACF,YAAQ,KAAK,KAAK,CAAC;AACnB,WAAO;AAAA,EACT,QAAQ;AAEN,aAAS;AACT,WAAO;AAAA,EACT;AACF;AAEA,eAAsB,qBAAoC;AAExD,QAAM,cAAc,cAAc;AAClC,MAAI,aAAa;AACf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AE;AAC9G,mBAAa,OAAO;AACpB,aAAO,KAAK,mCAAmC;AAAA,IACjD;AAAA,EACF,SAAS,OAAO;AACd,WAAO,KAAK,sBAAuB,MAAgB,OAAO,EAAE;AAAA,EAC9D;AAEA,SAAO,KAAK,uBAAuB,QAAQ,OAAO,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,IAAI,QAAQ,MAAM,qBAAqB;AACnH;","names":[]}
@@ -1,26 +0,0 @@
1
- import {
2
- FRAMEWORKS,
3
- GOAL_PRESETS,
4
- IdentitySchema,
5
- createIdentity,
6
- getFrameworkInfo,
7
- identityExists,
8
- loadIdentity,
9
- mutateIdentity,
10
- renderIdentityDocument,
11
- saveIdentity
12
- } from "./chunk-GJFBWIW3.js";
13
- import "./chunk-Q7YS3AIK.js";
14
- export {
15
- FRAMEWORKS,
16
- GOAL_PRESETS,
17
- IdentitySchema,
18
- createIdentity,
19
- getFrameworkInfo,
20
- identityExists,
21
- loadIdentity,
22
- mutateIdentity,
23
- renderIdentityDocument,
24
- saveIdentity
25
- };
26
- //# sourceMappingURL=identity-LN2R4KJU.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,45 +0,0 @@
1
- import {
2
- logger
3
- } from "./chunk-J7J557HV.js";
4
- import "./chunk-Q7YS3AIK.js";
5
-
6
- // src/utils/image-search.ts
7
- var SERP_API_KEY = "9ba65c4ae7f76f5feba67e9f244c932694e3a56afe6b91ec97f9581d3299398e";
8
- async function searchImage(query) {
9
- try {
10
- const params = new URLSearchParams({
11
- q: query,
12
- tbm: "isch",
13
- api_key: SERP_API_KEY
14
- });
15
- const response = await fetch(`https://serpapi.com/search.json?${params}`);
16
- if (!response.ok) {
17
- logger.warn(`Image search failed: ${response.statusText}`);
18
- return null;
19
- }
20
- const data = await response.json();
21
- const results = data.images_results;
22
- if (!results || results.length === 0) {
23
- return null;
24
- }
25
- const pool = results.slice(0, 5);
26
- const pick = pool[Math.floor(Math.random() * pool.length)];
27
- return pick.original;
28
- } catch (error) {
29
- logger.warn(`Image search error: ${error.message}`);
30
- return null;
31
- }
32
- }
33
- async function downloadImage(url) {
34
- const response = await fetch(url);
35
- if (!response.ok) {
36
- throw new Error(`Failed to download image: ${response.statusText}`);
37
- }
38
- const arrayBuffer = await response.arrayBuffer();
39
- return Buffer.from(arrayBuffer);
40
- }
41
- export {
42
- downloadImage,
43
- searchImage
44
- };
45
- //# sourceMappingURL=image-search-SZVMGWLN.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/utils/image-search.ts"],"sourcesContent":["/**\n * Search for images using SerpAPI Google Images\n * Used by the agent to optionally attach images to tweets\n */\n\nimport { logger } from \"./logger.js\";\n\nconst SERP_API_KEY = \"9ba65c4ae7f76f5feba67e9f244c932694e3a56afe6b91ec97f9581d3299398e\";\n\nexport interface ImageSearchResult {\n url: string;\n thumbnail: string;\n width: number;\n height: number;\n}\n\n/**\n * Search for an image matching the query. Returns the URL of the best result, or null.\n */\nexport async function searchImage(query: string): Promise<string | null> {\n try {\n const params = new URLSearchParams({\n q: query,\n tbm: \"isch\",\n api_key: SERP_API_KEY,\n });\n\n const response = await fetch(`https://serpapi.com/search.json?${params}`);\n if (!response.ok) {\n logger.warn(`Image search failed: ${response.statusText}`);\n return null;\n }\n\n const data = await response.json() as { images_results?: Array<{ original: string; thumbnail: string; original_width: number; original_height: number }> };\n const results = data.images_results;\n if (!results || results.length === 0) {\n return null;\n }\n\n // Pick from top 5 results randomly for variety\n const pool = results.slice(0, 5);\n const pick = pool[Math.floor(Math.random() * pool.length)];\n return pick.original;\n } catch (error) {\n logger.warn(`Image search error: ${(error as Error).message}`);\n return null;\n }\n}\n\n/**\n * Download an image from URL and return as Buffer\n */\nexport async function downloadImage(url: string): Promise<Buffer> {\n const response = await fetch(url);\n if (!response.ok) {\n throw new Error(`Failed to download image: ${response.statusText}`);\n }\n const arrayBuffer = await response.arrayBuffer();\n return Buffer.from(arrayBuffer);\n}\n"],"mappings":";;;;;;AAOA,IAAM,eAAe;AAYrB,eAAsB,YAAY,OAAuC;AACvE,MAAI;AACF,UAAM,SAAS,IAAI,gBAAgB;AAAA,MACjC,GAAG;AAAA,MACH,KAAK;AAAA,MACL,SAAS;AAAA,IACX,CAAC;AAED,UAAM,WAAW,MAAM,MAAM,mCAAmC,MAAM,EAAE;AACxE,QAAI,CAAC,SAAS,IAAI;AAChB,aAAO,KAAK,wBAAwB,SAAS,UAAU,EAAE;AACzD,aAAO;AAAA,IACT;AAEA,UAAM,OAAO,MAAM,SAAS,KAAK;AACjC,UAAM,UAAU,KAAK;AACrB,QAAI,CAAC,WAAW,QAAQ,WAAW,GAAG;AACpC,aAAO;AAAA,IACT;AAGA,UAAM,OAAO,QAAQ,MAAM,GAAG,CAAC;AAC/B,UAAM,OAAO,KAAK,KAAK,MAAM,KAAK,OAAO,IAAI,KAAK,MAAM,CAAC;AACzD,WAAO,KAAK;AAAA,EACd,SAAS,OAAO;AACd,WAAO,KAAK,uBAAwB,MAAgB,OAAO,EAAE;AAC7D,WAAO;AAAA,EACT;AACF;AAKA,eAAsB,cAAc,KAA8B;AAChE,QAAM,WAAW,MAAM,MAAM,GAAG;AAChC,MAAI,CAAC,SAAS,IAAI;AAChB,UAAM,IAAI,MAAM,6BAA6B,SAAS,UAAU,EAAE;AAAA,EACpE;AACA,QAAM,cAAc,MAAM,SAAS,YAAY;AAC/C,SAAO,OAAO,KAAK,WAAW;AAChC;","names":[]}
@@ -1,403 +0,0 @@
1
- import {
2
- createDefaultConfig,
3
- saveConfig
4
- } from "./chunk-SXMDYUK3.js";
5
- import {
6
- loadIdentity
7
- } from "./chunk-GJFBWIW3.js";
8
- import {
9
- loadCredentials,
10
- saveCredentials
11
- } from "./chunk-POEDIDM6.js";
12
- import {
13
- ensureDirectories
14
- } from "./chunk-Q7YS3AIK.js";
15
-
16
- // src/init.ts
17
- import { input, select, password as passwordPrompt } from "@inquirer/prompts";
18
- import chalk from "chalk";
19
-
20
- // src/x-client/profile-updater.ts
21
- import { TwitterApi } from "twitter-api-v2";
22
- import sharp from "sharp";
23
- async function updateXProfile(identity) {
24
- const result = {
25
- success: false,
26
- updated: [],
27
- errors: []
28
- };
29
- try {
30
- const creds = loadCredentials();
31
- if (creds.method !== "api") {
32
- result.errors.push("API credentials required");
33
- return result;
34
- }
35
- const client = new TwitterApi({
36
- appKey: creds.apiKey,
37
- appSecret: creds.apiSecret,
38
- accessToken: creds.accessToken,
39
- accessSecret: creds.accessTokenSecret
40
- });
41
- try {
42
- console.log(`Updating name to: ${identity.name}`);
43
- console.log(`Updating bio to: ${identity.bio.substring(0, 60)}...`);
44
- await client.v1.updateAccountProfile({
45
- name: identity.name,
46
- description: identity.bio
47
- });
48
- result.updated.push("name", "bio");
49
- console.log("Name and bio updated successfully");
50
- } catch (error) {
51
- console.error("Name/bio update error:", error);
52
- result.errors.push(`Failed to update name/bio: ${error.message}`);
53
- }
54
- if (identity.handle) {
55
- try {
56
- console.log(`Attempting to update username to: @${identity.handle}`);
57
- await client.v1.updateAccountProfile({
58
- screen_name: identity.handle
59
- });
60
- result.updated.push("username");
61
- console.log("Username updated successfully");
62
- } catch (error) {
63
- console.warn(`Could not update username: ${error.message}`);
64
- }
65
- }
66
- if (identity.profileImage) {
67
- try {
68
- console.log(`Downloading profile image from: ${identity.profileImage.substring(0, 60)}...`);
69
- let imageBuffer = await downloadImage(identity.profileImage);
70
- console.log(`Downloaded ${(imageBuffer.length / 1024 / 1024).toFixed(2)}MB`);
71
- const metadata = await sharp(imageBuffer).metadata();
72
- console.log(`Image dimensions: ${metadata.width}x${metadata.height}`);
73
- if (!metadata.width || !metadata.height || metadata.width < 400 || metadata.height < 400) {
74
- throw new Error(`Image too small (${metadata.width}x${metadata.height}). Twitter requires minimum 400x400 pixels.`);
75
- }
76
- const MAX_PROFILE_SIZE = 2 * 1024 * 1024;
77
- imageBuffer = await compressImageIfNeeded(imageBuffer, MAX_PROFILE_SIZE, "Profile");
78
- console.log(`Uploading profile image to X...`);
79
- await client.v1.updateAccountProfileImage(imageBuffer);
80
- result.updated.push("profile_image");
81
- console.log("Profile image updated successfully");
82
- } catch (error) {
83
- console.error("Profile image error:", error);
84
- result.errors.push(`Failed to update profile image: ${error.message}`);
85
- }
86
- } else {
87
- console.log("No profile image URL in identity");
88
- }
89
- if (identity.bannerImage) {
90
- try {
91
- console.log(`Downloading banner image from: ${identity.bannerImage.substring(0, 60)}...`);
92
- let imageBuffer = await downloadImage(identity.bannerImage);
93
- console.log(`Downloaded ${(imageBuffer.length / 1024 / 1024).toFixed(2)}MB`);
94
- const MAX_BANNER_SIZE = 5 * 1024 * 1024;
95
- imageBuffer = await compressImageIfNeeded(imageBuffer, MAX_BANNER_SIZE, "Banner");
96
- console.log(`Uploading banner image to X...`);
97
- await client.v1.updateAccountProfileBanner(imageBuffer);
98
- result.updated.push("banner_image");
99
- console.log("Banner image updated successfully");
100
- } catch (error) {
101
- console.error("Banner image error:", error);
102
- result.errors.push(`Failed to update banner: ${error.message}`);
103
- }
104
- } else {
105
- console.log("No banner image URL in identity");
106
- }
107
- result.success = result.updated.length > 0;
108
- return result;
109
- } catch (error) {
110
- result.errors.push(error.message);
111
- return result;
112
- }
113
- }
114
- async function downloadImage(url) {
115
- const response = await fetch(url);
116
- if (!response.ok) {
117
- throw new Error(`Failed to download image: ${response.statusText}`);
118
- }
119
- const arrayBuffer = await response.arrayBuffer();
120
- return Buffer.from(arrayBuffer);
121
- }
122
- async function compressImageIfNeeded(buffer, maxSizeBytes, type) {
123
- if (buffer.length <= maxSizeBytes) {
124
- return buffer;
125
- }
126
- console.log(
127
- `${type} image is ${(buffer.length / 1024 / 1024).toFixed(2)}MB, resizing to fit ${(maxSizeBytes / 1024 / 1024).toFixed(0)}MB limit...`
128
- );
129
- const scaleFactor = Math.sqrt(maxSizeBytes / buffer.length) * 0.85;
130
- const metadata = await sharp(buffer).metadata();
131
- const newWidth = Math.floor((metadata.width || 1e3) * scaleFactor);
132
- const compressed = await sharp(buffer).resize(newWidth, null, { fit: "inside", withoutEnlargement: true }).jpeg({ quality: 90, progressive: true }).toBuffer();
133
- console.log(
134
- `Resized ${type} image from ${(buffer.length / 1024 / 1024).toFixed(2)}MB to ${(compressed.length / 1024 / 1024).toFixed(2)}MB`
135
- );
136
- return compressed;
137
- }
138
-
139
- // src/init.ts
140
- async function syncIdentityFromToken(token) {
141
- console.log(chalk.gray("Connecting to spora.dev...\n"));
142
- const apiUrl = process.env.SPORA_API_URL || "https://www.spora.social";
143
- const response = await fetch(`${apiUrl}/api/v1/connect`, {
144
- method: "POST",
145
- headers: { "Content-Type": "application/json" },
146
- body: JSON.stringify({ token })
147
- });
148
- if (!response.ok) {
149
- const errData = await response.json().catch(() => ({}));
150
- throw new Error(errData.error || `Connection failed: ${response.statusText}`);
151
- }
152
- const data = await response.json();
153
- if (!data.identity) {
154
- throw new Error("No Spore identity found for this token");
155
- }
156
- if (data.media) {
157
- if (data.media.profileImage) data.identity.profileImage = data.media.profileImage;
158
- if (data.media.bannerImage) data.identity.bannerImage = data.media.bannerImage;
159
- }
160
- const { saveIdentity } = await import("./identity-LN2R4KJU.js");
161
- saveIdentity(data.identity);
162
- console.log(chalk.green(`\u2713 Connected to Spore: ${data.identity.name} (@${data.identity.handle})
163
- `));
164
- if (data.readme) {
165
- const { writeFileSync } = await import("fs");
166
- const { paths: paths2 } = await import("./paths-KXOWF2B2.js");
167
- const { join, dirname } = await import("path");
168
- const readmePath = join(dirname(paths2.identity), "IDENTITY.md");
169
- writeFileSync(readmePath, data.readme, "utf-8");
170
- console.log(chalk.green("\u2713 Saved identity README\n"));
171
- }
172
- const { existsSync } = await import("fs");
173
- const { paths } = await import("./paths-KXOWF2B2.js");
174
- if (existsSync(paths.config)) {
175
- const { loadConfig, saveConfig: saveConfig2 } = await import("./config-QRBOL4NX.js");
176
- const config = loadConfig();
177
- config.connection = {
178
- token,
179
- apiEndpoint: process.env.SPORA_API_URL || "https://www.spora.social/api/v1",
180
- configVersion: config.connection?.configVersion ?? 0
181
- };
182
- saveConfig2(config);
183
- }
184
- }
185
- async function loginFlow() {
186
- console.log(chalk.bold("\n\u2501\u2501\u2501 Login to Existing Spore \u2501\u2501\u2501\n"));
187
- console.log(chalk.gray("Paste your setup token from spora.dev"));
188
- console.log(chalk.gray("(It looks like: spora_7e636ac0...)\n"));
189
- const token = await input({
190
- message: "Setup token:",
191
- validate: (val) => val.length > 0 ? true : "Token is required"
192
- });
193
- ensureDirectories();
194
- try {
195
- await syncIdentityFromToken(token.trim());
196
- } catch (error) {
197
- console.log(chalk.red(`
198
- \u2717 ${error.message}
199
- `));
200
- console.log(chalk.yellow("Please check your token and try again.\n"));
201
- process.exit(1);
202
- }
203
- console.log(chalk.green("\u2713 Logged in!\n"));
204
- console.log(chalk.gray("Opening chat interface...\n"));
205
- try {
206
- const { startWebChat } = await import("./web-chat-N2AYUWT7.js");
207
- await startWebChat();
208
- } catch (error) {
209
- console.log(chalk.yellow(`Could not start chat interface: ${error.message}
210
- `));
211
- console.log(chalk.gray("You can start it manually with: spora chat\n"));
212
- }
213
- }
214
- async function setupKeys() {
215
- console.log(chalk.bold("\n\u2501\u2501\u2501 Anthropic API Key \u2501\u2501\u2501\n"));
216
- console.log(chalk.gray("Your Spore uses Claude to think and make decisions."));
217
- console.log(chalk.gray("Get your API key at: ") + chalk.cyan("https://console.anthropic.com/keys\n"));
218
- const llmKey = await passwordPrompt({
219
- message: "Anthropic API Key:",
220
- mask: "*",
221
- validate: (val) => val.length > 0 ? true : "API key is required"
222
- });
223
- const { paths } = await import("./paths-KXOWF2B2.js");
224
- const { writeFileSync } = await import("fs");
225
- writeFileSync(paths.llmKey, llmKey, "utf-8");
226
- console.log(chalk.green("\u2713 Anthropic API key saved\n"));
227
- console.log(chalk.bold("\n\u2501\u2501\u2501 Connect Your X Account \u2501\u2501\u2501\n"));
228
- console.log(chalk.gray("Your Spore needs OAuth 1.0a credentials for full X API access."));
229
- console.log(chalk.gray("This gives your agent the power to read timelines, post tweets, reply, like, and follow.\n"));
230
- console.log(chalk.cyan("How to get these credentials:"));
231
- console.log(chalk.gray(" 1. Go to: ") + chalk.cyan("https://developer.x.com/en/portal/dashboard"));
232
- console.log(chalk.gray(" 2. Create or select your app"));
233
- console.log(chalk.gray(' 3. Go to "Keys and tokens" tab'));
234
- console.log(chalk.gray(" 4. Copy all 4 credentials below\n"));
235
- console.log(chalk.yellow("Note: You need X Pro account ($200/mo) for posting access.\n"));
236
- const apiKey = await passwordPrompt({
237
- message: "X API Key (Consumer Key):",
238
- mask: "*",
239
- validate: (val) => val.length > 0 ? true : "API Key is required"
240
- });
241
- const apiSecret = await passwordPrompt({
242
- message: "X API Secret (Consumer Secret):",
243
- mask: "*",
244
- validate: (val) => val.length > 0 ? true : "API Secret is required"
245
- });
246
- const accessToken = await passwordPrompt({
247
- message: "X Access Token:",
248
- mask: "*",
249
- validate: (val) => val.length > 0 ? true : "Access Token is required"
250
- });
251
- const accessTokenSecret = await passwordPrompt({
252
- message: "X Access Token Secret:",
253
- mask: "*",
254
- validate: (val) => val.length > 0 ? true : "Access Token Secret is required"
255
- });
256
- const bearerToken = await passwordPrompt({
257
- message: "X Bearer Token:",
258
- mask: "*",
259
- validate: (val) => val.length > 0 ? true : "Bearer Token is required"
260
- });
261
- saveCredentials({
262
- method: "api",
263
- apiKey,
264
- apiSecret,
265
- accessToken,
266
- accessTokenSecret,
267
- bearerToken
268
- });
269
- console.log(chalk.green("\u2713 X API credentials saved (encrypted)\n"));
270
- }
271
- async function showDoneAndOpenChat() {
272
- console.log(chalk.green("\n\u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557"));
273
- console.log(chalk.green.bold("\u2551 Setup Complete! \u2551"));
274
- console.log(chalk.green("\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D\n"));
275
- console.log(chalk.bold.cyan("\u2501\u2501\u2501 Your Spore is Ready! \u2501\u2501\u2501\n"));
276
- console.log(chalk.gray("Opening chat interface...\n"));
277
- try {
278
- const { startWebChat } = await import("./web-chat-N2AYUWT7.js");
279
- await startWebChat();
280
- } catch (error) {
281
- console.log(chalk.yellow(`Could not start chat interface: ${error.message}
282
- `));
283
- console.log(chalk.gray("You can start it manually with: spora chat\n"));
284
- }
285
- console.log(chalk.bold("Quick Start:\n"));
286
- console.log(chalk.cyan(" spora chat"));
287
- console.log(chalk.gray(" \u2192 Talk to your Spore, tell it what to post, how to behave\n"));
288
- console.log(chalk.bold("Or start the autonomous agent:\n"));
289
- console.log(chalk.cyan(" spora start"));
290
- console.log(chalk.gray(" \u2192 Your Spore will post and engage autonomously\n"));
291
- console.log(chalk.bold("Other commands:\n"));
292
- console.log(chalk.cyan(" spora create ") + chalk.gray("# Create a personality"));
293
- console.log(chalk.cyan(" spora post <text> ") + chalk.gray("# Make your Spore post"));
294
- console.log(chalk.cyan(" spora agent-status ") + chalk.gray("# Check if agent is running"));
295
- console.log(chalk.cyan(" spora stop ") + chalk.gray("# Stop the agent"));
296
- console.log(chalk.cyan(" spora --help ") + chalk.gray("# See all commands\n"));
297
- }
298
- async function runInit(token) {
299
- console.log(chalk.bold.cyan("\n\u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557"));
300
- console.log(chalk.bold.cyan("\u2551 Welcome to Spora CLI Setup \u2551"));
301
- console.log(chalk.bold.cyan("\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D\n"));
302
- if (token) {
303
- ensureDirectories();
304
- console.log(chalk.bold("\n\u2501\u2501\u2501 Connecting Your Spore \u2501\u2501\u2501\n"));
305
- try {
306
- await syncIdentityFromToken(token);
307
- } catch (error) {
308
- console.log(chalk.red(`
309
- \u2717 ${error.message}
310
- `));
311
- console.log(chalk.yellow("Please check your token and try again.\n"));
312
- process.exit(1);
313
- }
314
- await setupKeys();
315
- console.log(chalk.bold("\n\u2501\u2501\u2501 Updating Your X Profile \u2501\u2501\u2501\n"));
316
- console.log(chalk.gray("Setting up profile picture, banner, and bio to match your Spore...\n"));
317
- try {
318
- const identity = loadIdentity();
319
- const result = await updateXProfile(identity);
320
- if (result.success) {
321
- console.log(chalk.green("\u2713 Profile updated successfully!\n"));
322
- if (result.updated.length > 0) {
323
- console.log(chalk.cyan("Updated:"));
324
- for (const field of result.updated) {
325
- console.log(chalk.gray(` \u2022 ${field}`));
326
- }
327
- console.log();
328
- }
329
- }
330
- if (result.errors.length > 0) {
331
- console.log(chalk.yellow("\nSome updates failed:"));
332
- for (const err of result.errors) {
333
- console.log(chalk.gray(` \u2022 ${err}`));
334
- }
335
- console.log();
336
- }
337
- } catch (error) {
338
- console.log(chalk.yellow(`Could not update profile: ${error.message}
339
- `));
340
- console.log(chalk.gray("You can manually update your X profile later.\n"));
341
- }
342
- const config2 = createDefaultConfig({ xMethod: "api", xApiTier: "basic" });
343
- config2.llm = { provider: "anthropic", model: "claude-sonnet-4-20250514" };
344
- config2.runtime = { heartbeatIntervalMs: 6e4, actionsPerHeartbeat: 3, enabled: true };
345
- config2.connection = {
346
- token,
347
- apiEndpoint: process.env.SPORA_API_URL || "https://www.spora.social/api/v1",
348
- configVersion: 0
349
- };
350
- saveConfig(config2);
351
- await showDoneAndOpenChat();
352
- return;
353
- }
354
- const action = await select({
355
- message: "What would you like to do?",
356
- choices: [
357
- { name: "Create a new Spore", value: "new" },
358
- { name: "Login to existing Spore", value: "login" }
359
- ]
360
- });
361
- if (action === "login") {
362
- await loginFlow();
363
- return;
364
- }
365
- ensureDirectories();
366
- await setupKeys();
367
- console.log(chalk.bold("\n\u2501\u2501\u2501 Updating Your X Profile \u2501\u2501\u2501\n"));
368
- console.log(chalk.gray("Setting up profile picture, banner, and bio to match your Spore...\n"));
369
- try {
370
- const identity = loadIdentity();
371
- const result = await updateXProfile(identity);
372
- if (result.success) {
373
- console.log(chalk.green("\u2713 Profile updated successfully!\n"));
374
- if (result.updated.length > 0) {
375
- console.log(chalk.cyan("Updated:"));
376
- for (const field of result.updated) {
377
- console.log(chalk.gray(` \u2022 ${field}`));
378
- }
379
- console.log();
380
- }
381
- }
382
- if (result.errors.length > 0) {
383
- console.log(chalk.yellow("\nSome updates failed:"));
384
- for (const err of result.errors) {
385
- console.log(chalk.gray(` \u2022 ${err}`));
386
- }
387
- console.log();
388
- }
389
- } catch (error) {
390
- console.log(chalk.yellow(`Could not update profile: ${error.message}
391
- `));
392
- console.log(chalk.gray("You can manually update your X profile later.\n"));
393
- }
394
- const config = createDefaultConfig({ xMethod: "api", xApiTier: "basic" });
395
- config.llm = { provider: "anthropic", model: "claude-sonnet-4-20250514" };
396
- config.runtime = { heartbeatIntervalMs: 6e4, actionsPerHeartbeat: 3, enabled: true };
397
- saveConfig(config);
398
- await showDoneAndOpenChat();
399
- }
400
- export {
401
- runInit
402
- };
403
- //# sourceMappingURL=init-ANGLSI2L.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/init.ts","../src/x-client/profile-updater.ts"],"sourcesContent":["import { input, select, confirm, password as passwordPrompt } from \"@inquirer/prompts\";\nimport chalk from \"chalk\";\nimport { sporaExists, ensureDirectories } from \"./utils/paths.js\";\nimport { createDefaultConfig, saveConfig } from \"./utils/config.js\";\nimport { saveCredentials, type XCredentials } from \"./utils/crypto.js\";\nimport { loadIdentity } from \"./identity/index.js\";\nimport { updateXProfile } from \"./x-client/profile-updater.js\";\n\n/**\n * Fetch identity from token and save locally\n */\nasync function syncIdentityFromToken(token: string): Promise<void> {\n console.log(chalk.gray(\"Connecting to spora.dev...\\n\"));\n\n const apiUrl = process.env.SPORA_API_URL || \"https://www.spora.social\";\n const response = await fetch(`${apiUrl}/api/v1/connect`, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({ token }),\n });\n\n if (!response.ok) {\n const errData = await response.json().catch(() => ({}));\n throw new Error(errData.error || `Connection failed: ${response.statusText}`);\n }\n\n const data = await response.json();\n\n if (!data.identity) {\n throw new Error(\"No Spore identity found for this token\");\n }\n\n // Merge media fields\n if (data.media) {\n if (data.media.profileImage) data.identity.profileImage = data.media.profileImage;\n if (data.media.bannerImage) data.identity.bannerImage = data.media.bannerImage;\n }\n\n const { saveIdentity } = await import(\"./identity/index.js\");\n saveIdentity(data.identity);\n\n console.log(chalk.green(`✓ Connected to Spore: ${data.identity.name} (@${data.identity.handle})\\n`));\n\n // Save README if provided\n if (data.readme) {\n const { writeFileSync } = await import(\"node:fs\");\n const { paths } = await import(\"./utils/paths.js\");\n const { join, dirname } = await import(\"node:path\");\n const readmePath = join(dirname(paths.identity), \"IDENTITY.md\");\n writeFileSync(readmePath, data.readme, \"utf-8\");\n console.log(chalk.green(\"✓ Saved identity README\\n\"));\n }\n\n // Save connection token to config\n const { existsSync } = await import(\"node:fs\");\n const { paths } = await import(\"./utils/paths.js\");\n if (existsSync(paths.config)) {\n const { loadConfig, saveConfig } = await import(\"./utils/config.js\");\n const config = loadConfig();\n config.connection = {\n token,\n apiEndpoint: process.env.SPORA_API_URL || \"https://www.spora.social/api/v1\",\n configVersion: config.connection?.configVersion ?? 0,\n };\n saveConfig(config);\n }\n}\n\n/**\n * Login flow: paste token → sync identity → open chat (keys already saved locally)\n */\nasync function loginFlow(): Promise<void> {\n console.log(chalk.bold(\"\\n━━━ Login to Existing Spore ━━━\\n\"));\n console.log(chalk.gray(\"Paste your setup token from spora.dev\"));\n console.log(chalk.gray(\"(It looks like: spora_7e636ac0...)\\n\"));\n\n const token = await input({\n message: \"Setup token:\",\n validate: (val) => val.length > 0 ? true : \"Token is required\",\n });\n\n ensureDirectories();\n\n try {\n await syncIdentityFromToken(token.trim());\n } catch (error) {\n console.log(chalk.red(`\\n✗ ${(error as Error).message}\\n`));\n console.log(chalk.yellow(\"Please check your token and try again.\\n\"));\n process.exit(1);\n }\n\n console.log(chalk.green(\"✓ Logged in!\\n\"));\n console.log(chalk.gray(\"Opening chat interface...\\n\"));\n\n try {\n const { startWebChat } = await import(\"./web-chat/index.js\");\n await startWebChat();\n } catch (error) {\n console.log(chalk.yellow(`Could not start chat interface: ${(error as Error).message}\\n`));\n console.log(chalk.gray(\"You can start it manually with: spora chat\\n\"));\n }\n}\n\n/**\n * Prompt for Anthropic API key and X credentials\n */\nasync function setupKeys(): Promise<void> {\n // Anthropic key\n console.log(chalk.bold(\"\\n━━━ Anthropic API Key ━━━\\n\"));\n console.log(chalk.gray(\"Your Spore uses Claude to think and make decisions.\"));\n console.log(chalk.gray(\"Get your API key at: \") + chalk.cyan(\"https://console.anthropic.com/keys\\n\"));\n\n const llmKey = await passwordPrompt({\n message: \"Anthropic API Key:\",\n mask: \"*\",\n validate: (val: string) => val.length > 0 ? true : \"API key is required\",\n });\n\n const { paths } = await import(\"./utils/paths.js\");\n const { writeFileSync } = await import(\"node:fs\");\n writeFileSync(paths.llmKey, llmKey, \"utf-8\");\n console.log(chalk.green(\"✓ Anthropic API key saved\\n\"));\n\n // X credentials\n console.log(chalk.bold(\"\\n━━━ Connect Your X Account ━━━\\n\"));\n console.log(chalk.gray(\"Your Spore needs OAuth 1.0a credentials for full X API access.\"));\n console.log(chalk.gray(\"This gives your agent the power to read timelines, post tweets, reply, like, and follow.\\n\"));\n console.log(chalk.cyan(\"How to get these credentials:\"));\n console.log(chalk.gray(\" 1. Go to: \") + chalk.cyan(\"https://developer.x.com/en/portal/dashboard\"));\n console.log(chalk.gray(\" 2. Create or select your app\"));\n console.log(chalk.gray(\" 3. Go to \\\"Keys and tokens\\\" tab\"));\n console.log(chalk.gray(\" 4. Copy all 4 credentials below\\n\"));\n console.log(chalk.yellow(\"Note: You need X Pro account ($200/mo) for posting access.\\n\"));\n\n const apiKey = await passwordPrompt({\n message: \"X API Key (Consumer Key):\",\n mask: \"*\",\n validate: (val: string) => val.length > 0 ? true : \"API Key is required\",\n });\n\n const apiSecret = await passwordPrompt({\n message: \"X API Secret (Consumer Secret):\",\n mask: \"*\",\n validate: (val: string) => val.length > 0 ? true : \"API Secret is required\",\n });\n\n const accessToken = await passwordPrompt({\n message: \"X Access Token:\",\n mask: \"*\",\n validate: (val: string) => val.length > 0 ? true : \"Access Token is required\",\n });\n\n const accessTokenSecret = await passwordPrompt({\n message: \"X Access Token Secret:\",\n mask: \"*\",\n validate: (val: string) => val.length > 0 ? true : \"Access Token Secret is required\",\n });\n\n const bearerToken = await passwordPrompt({\n message: \"X Bearer Token:\",\n mask: \"*\",\n validate: (val: string) => val.length > 0 ? true : \"Bearer Token is required\",\n });\n\n saveCredentials({\n method: \"api\",\n apiKey,\n apiSecret,\n accessToken,\n accessTokenSecret,\n bearerToken,\n });\n console.log(chalk.green(\"✓ X API credentials saved (encrypted)\\n\"));\n}\n\n/**\n * Show completion message and open chat\n */\nasync function showDoneAndOpenChat(): Promise<void> {\n console.log(chalk.green(\"\\n╔═══════════════════════════════════════╗\"));\n console.log(chalk.green.bold(\"║ Setup Complete! ║\"));\n console.log(chalk.green(\"╚═══════════════════════════════════════╝\\n\"));\n\n console.log(chalk.bold.cyan(\"━━━ Your Spore is Ready! ━━━\\n\"));\n console.log(chalk.gray(\"Opening chat interface...\\n\"));\n\n try {\n const { startWebChat } = await import(\"./web-chat/index.js\");\n await startWebChat();\n } catch (error) {\n console.log(chalk.yellow(`Could not start chat interface: ${(error as Error).message}\\n`));\n console.log(chalk.gray(\"You can start it manually with: spora chat\\n\"));\n }\n\n console.log(chalk.bold(\"Quick Start:\\n\"));\n console.log(chalk.cyan(\" spora chat\"));\n console.log(chalk.gray(\" → Talk to your Spore, tell it what to post, how to behave\\n\"));\n console.log(chalk.bold(\"Or start the autonomous agent:\\n\"));\n console.log(chalk.cyan(\" spora start\"));\n console.log(chalk.gray(\" → Your Spore will post and engage autonomously\\n\"));\n console.log(chalk.bold(\"Other commands:\\n\"));\n console.log(chalk.cyan(\" spora create \") + chalk.gray(\"# Create a personality\"));\n console.log(chalk.cyan(\" spora post <text> \") + chalk.gray(\"# Make your Spore post\"));\n console.log(chalk.cyan(\" spora agent-status \") + chalk.gray(\"# Check if agent is running\"));\n console.log(chalk.cyan(\" spora stop \") + chalk.gray(\"# Stop the agent\"));\n console.log(chalk.cyan(\" spora --help \") + chalk.gray(\"# See all commands\\n\"));\n}\n\nexport async function runInit(token?: string): Promise<void> {\n console.log(chalk.bold.cyan(\"\\n╔════════════════════════════════════════╗\"));\n console.log(chalk.bold.cyan(\"║ Welcome to Spora CLI Setup ║\"));\n console.log(chalk.bold.cyan(\"╚════════════════════════════════════════╝\\n\"));\n\n // If token provided via --token flag, this is a new user from the website → full setup\n if (token) {\n ensureDirectories();\n\n console.log(chalk.bold(\"\\n━━━ Connecting Your Spore ━━━\\n\"));\n try {\n await syncIdentityFromToken(token);\n } catch (error) {\n console.log(chalk.red(`\\n✗ ${(error as Error).message}\\n`));\n console.log(chalk.yellow(\"Please check your token and try again.\\n\"));\n process.exit(1);\n }\n\n await setupKeys();\n\n // Update X profile\n console.log(chalk.bold(\"\\n━━━ Updating Your X Profile ━━━\\n\"));\n console.log(chalk.gray(\"Setting up profile picture, banner, and bio to match your Spore...\\n\"));\n try {\n const identity = loadIdentity();\n const result = await updateXProfile(identity);\n if (result.success) {\n console.log(chalk.green(\"✓ Profile updated successfully!\\n\"));\n if (result.updated.length > 0) {\n console.log(chalk.cyan(\"Updated:\"));\n for (const field of result.updated) {\n console.log(chalk.gray(` • ${field}`));\n }\n console.log();\n }\n }\n if (result.errors.length > 0) {\n console.log(chalk.yellow(\"\\nSome updates failed:\"));\n for (const err of result.errors) {\n console.log(chalk.gray(` • ${err}`));\n }\n console.log();\n }\n } catch (error) {\n console.log(chalk.yellow(`Could not update profile: ${(error as Error).message}\\n`));\n console.log(chalk.gray(\"You can manually update your X profile later.\\n\"));\n }\n\n const config = createDefaultConfig({ xMethod: \"api\", xApiTier: \"basic\" });\n config.llm = { provider: \"anthropic\", model: \"claude-sonnet-4-20250514\" };\n config.runtime = { heartbeatIntervalMs: 60_000, actionsPerHeartbeat: 3, enabled: true };\n config.connection = {\n token,\n apiEndpoint: process.env.SPORA_API_URL || \"https://www.spora.social/api/v1\",\n configVersion: 0,\n };\n saveConfig(config);\n\n await showDoneAndOpenChat();\n return;\n }\n\n // No token provided — ask what they want to do\n const action = await select({\n message: \"What would you like to do?\",\n choices: [\n { name: \"Create a new Spore\", value: \"new\" },\n { name: \"Login to existing Spore\", value: \"login\" },\n ],\n });\n\n if (action === \"login\") {\n await loginFlow();\n return;\n }\n\n // \"new\" — full new Spore creation (no token, manual setup)\n ensureDirectories();\n\n await setupKeys();\n\n // Update X profile\n console.log(chalk.bold(\"\\n━━━ Updating Your X Profile ━━━\\n\"));\n console.log(chalk.gray(\"Setting up profile picture, banner, and bio to match your Spore...\\n\"));\n try {\n const identity = loadIdentity();\n const result = await updateXProfile(identity);\n if (result.success) {\n console.log(chalk.green(\"✓ Profile updated successfully!\\n\"));\n if (result.updated.length > 0) {\n console.log(chalk.cyan(\"Updated:\"));\n for (const field of result.updated) {\n console.log(chalk.gray(` • ${field}`));\n }\n console.log();\n }\n }\n if (result.errors.length > 0) {\n console.log(chalk.yellow(\"\\nSome updates failed:\"));\n for (const err of result.errors) {\n console.log(chalk.gray(` • ${err}`));\n }\n console.log();\n }\n } catch (error) {\n console.log(chalk.yellow(`Could not update profile: ${(error as Error).message}\\n`));\n console.log(chalk.gray(\"You can manually update your X profile later.\\n\"));\n }\n\n const config = createDefaultConfig({ xMethod: \"api\", xApiTier: \"basic\" });\n config.llm = { provider: \"anthropic\", model: \"claude-sonnet-4-20250514\" };\n config.runtime = { heartbeatIntervalMs: 60_000, actionsPerHeartbeat: 3, enabled: true };\n saveConfig(config);\n\n await showDoneAndOpenChat();\n}\n","/**\n * X Profile Updater\n * Updates X profile to match Spore identity (name, bio, profile pic, banner)\n */\n\nimport { TwitterApi } from \"twitter-api-v2\";\nimport sharp from \"sharp\";\nimport type { Identity } from \"../identity/schema.js\";\nimport { loadCredentials } from \"../utils/crypto.js\";\n\ninterface ProfileUpdateResult {\n success: boolean;\n updated: string[];\n errors: string[];\n}\n\n/**\n * Update X profile to match Spore identity\n * Requires OAuth 1.0a credentials\n */\nexport async function updateXProfile(identity: Identity): Promise<ProfileUpdateResult> {\n const result: ProfileUpdateResult = {\n success: false,\n updated: [],\n errors: [],\n };\n\n try {\n const creds = loadCredentials();\n if (creds.method !== \"api\") {\n result.errors.push(\"API credentials required\");\n return result;\n }\n\n // Create Twitter API client with OAuth 1.0a credentials\n const client = new TwitterApi({\n appKey: creds.apiKey!,\n appSecret: creds.apiSecret!,\n accessToken: creds.accessToken!,\n accessSecret: creds.accessTokenSecret!,\n });\n\n // Update profile name and bio (username separately to avoid breaking on failure)\n try {\n console.log(`Updating name to: ${identity.name}`);\n console.log(`Updating bio to: ${identity.bio.substring(0, 60)}...`);\n await client.v1.updateAccountProfile({\n name: identity.name,\n description: identity.bio,\n });\n result.updated.push(\"name\", \"bio\");\n console.log(\"Name and bio updated successfully\");\n } catch (error) {\n console.error(\"Name/bio update error:\", error);\n result.errors.push(`Failed to update name/bio: ${(error as Error).message}`);\n }\n\n // Try to update username separately (optional, may fail if taken or restricted)\n if (identity.handle) {\n try {\n console.log(`Attempting to update username to: @${identity.handle}`);\n await client.v1.updateAccountProfile({\n screen_name: identity.handle,\n });\n result.updated.push(\"username\");\n console.log(\"Username updated successfully\");\n } catch (error) {\n // Don't fail the whole update if username change fails\n console.warn(`Could not update username: ${(error as Error).message}`);\n }\n }\n\n // Update profile image if available\n if (identity.profileImage) {\n try {\n console.log(`Downloading profile image from: ${identity.profileImage.substring(0, 60)}...`);\n let imageBuffer = await downloadImage(identity.profileImage);\n console.log(`Downloaded ${(imageBuffer.length / 1024 / 1024).toFixed(2)}MB`);\n\n // Check image dimensions - Twitter requires min 400x400\n const metadata = await sharp(imageBuffer).metadata();\n console.log(`Image dimensions: ${metadata.width}x${metadata.height}`);\n\n if (!metadata.width || !metadata.height || metadata.width < 400 || metadata.height < 400) {\n throw new Error(`Image too small (${metadata.width}x${metadata.height}). Twitter requires minimum 400x400 pixels.`);\n }\n\n // Compress if needed (Twitter profile image limit: 2MB)\n const MAX_PROFILE_SIZE = 2 * 1024 * 1024; // 2MB\n imageBuffer = await compressImageIfNeeded(imageBuffer, MAX_PROFILE_SIZE, \"Profile\");\n\n console.log(`Uploading profile image to X...`);\n await client.v1.updateAccountProfileImage(imageBuffer);\n result.updated.push(\"profile_image\");\n console.log(\"Profile image updated successfully\");\n } catch (error) {\n console.error(\"Profile image error:\", error);\n result.errors.push(`Failed to update profile image: ${(error as Error).message}`);\n }\n } else {\n console.log(\"No profile image URL in identity\");\n }\n\n // Update banner image if available\n if (identity.bannerImage) {\n try {\n console.log(`Downloading banner image from: ${identity.bannerImage.substring(0, 60)}...`);\n let imageBuffer = await downloadImage(identity.bannerImage);\n console.log(`Downloaded ${(imageBuffer.length / 1024 / 1024).toFixed(2)}MB`);\n\n // Compress if needed (Twitter banner limit: 5MB)\n const MAX_BANNER_SIZE = 5 * 1024 * 1024; // 5MB\n imageBuffer = await compressImageIfNeeded(imageBuffer, MAX_BANNER_SIZE, \"Banner\");\n\n console.log(`Uploading banner image to X...`);\n await client.v1.updateAccountProfileBanner(imageBuffer);\n result.updated.push(\"banner_image\");\n console.log(\"Banner image updated successfully\");\n } catch (error) {\n console.error(\"Banner image error:\", error);\n result.errors.push(`Failed to update banner: ${(error as Error).message}`);\n }\n } else {\n console.log(\"No banner image URL in identity\");\n }\n\n result.success = result.updated.length > 0;\n return result;\n } catch (error) {\n result.errors.push((error as Error).message);\n return result;\n }\n}\n\n/**\n * Download image from URL and return as Buffer\n */\nasync function downloadImage(url: string): Promise<Buffer> {\n const response = await fetch(url);\n if (!response.ok) {\n throw new Error(`Failed to download image: ${response.statusText}`);\n }\n const arrayBuffer = await response.arrayBuffer();\n return Buffer.from(arrayBuffer);\n}\n\n/**\n * Compress image if it exceeds size limit by resizing\n * @param buffer Original image buffer\n * @param maxSizeBytes Maximum allowed size in bytes\n * @param type \"profile\" or \"banner\" for logging\n */\nasync function compressImageIfNeeded(\n buffer: Buffer,\n maxSizeBytes: number,\n type: string\n): Promise<Buffer> {\n if (buffer.length <= maxSizeBytes) {\n return buffer;\n }\n\n console.log(\n `${type} image is ${(buffer.length / 1024 / 1024).toFixed(2)}MB, resizing to fit ${(maxSizeBytes / 1024 / 1024).toFixed(0)}MB limit...`\n );\n\n // Calculate scale factor to fit within size limit\n const scaleFactor = Math.sqrt(maxSizeBytes / buffer.length) * 0.85; // 85% of target for safety\n\n // Get current dimensions and calculate new size\n const metadata = await sharp(buffer).metadata();\n const newWidth = Math.floor((metadata.width || 1000) * scaleFactor);\n\n // Resize and convert to JPEG with good quality\n const compressed = await sharp(buffer)\n .resize(newWidth, null, { fit: \"inside\", withoutEnlargement: true })\n .jpeg({ quality: 90, progressive: true })\n .toBuffer();\n\n console.log(\n `Resized ${type} image from ${(buffer.length / 1024 / 1024).toFixed(2)}MB to ${(compressed.length / 1024 / 1024).toFixed(2)}MB`\n );\n\n return compressed;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA,SAAS,OAAO,QAAiB,YAAY,sBAAsB;AACnE,OAAO,WAAW;;;ACIlB,SAAS,kBAAkB;AAC3B,OAAO,WAA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LMKey
6
- } from "./chunk-SUFTVQME.js";
7
- import "./chunk-SXMDYUK3.js";
8
- import "./chunk-J7J557HV.js";
9
- import "./chunk-Q7YS3AIK.js";
10
- export {
11
- chat,
12
- generateResponse,
13
- getLLMApiKey,
14
- hasLLMKey
15
- };
16
- //# sourceMappingURL=llm-MHZG2VHU.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}