spora 0.7.3 → 0.7.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/autonomy-DFPA3OK6.js +20 -0
- package/dist/{chunk-SUZUJGGW.js → chunk-342ZX72W.js} +4 -4
- package/dist/{chunk-HGNMHGAF.js → chunk-5R4AJZHN.js} +4 -4
- package/dist/{chunk-HGNMHGAF.js.map → chunk-5R4AJZHN.js.map} +1 -1
- package/dist/{chunk-Q3YXJ2C6.js → chunk-A2XTKC7B.js} +281 -65
- package/dist/chunk-A2XTKC7B.js.map +1 -0
- package/dist/{chunk-JBYZ7K56.js → chunk-BBXHECZ5.js} +2 -2
- package/dist/{chunk-WN35MRMF.js → chunk-CAWWG3MD.js} +2 -2
- package/dist/chunk-CP6JWCLY.js +171 -0
- package/dist/chunk-CP6JWCLY.js.map +1 -0
- package/dist/{chunk-T7L2L7ZL.js → chunk-D47OFTEK.js} +2 -2
- package/dist/chunk-HXI2EH5C.js +2338 -0
- package/dist/chunk-HXI2EH5C.js.map +1 -0
- package/dist/{chunk-M6YOQVSI.js → chunk-IULO3GRE.js} +4 -4
- package/dist/chunk-IULO3GRE.js.map +1 -0
- package/dist/chunk-OTZNHIXT.js +431 -0
- package/dist/chunk-OTZNHIXT.js.map +1 -0
- package/dist/{chunk-NO3NQN67.js → chunk-QYFNAGNI.js} +2 -2
- package/dist/{chunk-YMGJQRKG.js → chunk-RSNEVBEI.js} +2 -2
- package/dist/{chunk-VZBHRUZS.js → chunk-SXNZVKLJ.js} +2 -2
- package/dist/chunk-SXNZVKLJ.js.map +1 -0
- package/dist/{chunk-7OOGNZBU.js → chunk-ZLSDFYBR.js} +17 -5
- package/dist/chunk-ZLSDFYBR.js.map +1 -0
- package/dist/{chunk-3RYCUGXE.js → chunk-ZWKTKWS6.js} +4 -1
- package/dist/chunk-ZWKTKWS6.js.map +1 -0
- package/dist/cli.js +49 -49
- package/dist/{client-4KGOBIXE.js → client-AR5ZD6S4.js} +48 -16
- package/dist/client-AR5ZD6S4.js.map +1 -0
- package/dist/{colony-IVYR233C.js → colony-UGVYALOS.js} +7 -7
- package/dist/{config-FL4VJVKZ.js → config-MU2ODEO3.js} +3 -3
- package/dist/{crypto-NOXNL4GP.js → crypto-GDG5K3ZH.js} +3 -3
- package/dist/{goals-RBKLMILE.js → goals-QWX3A47Y.js} +3 -3
- package/dist/{heartbeat-CUL2FTFD.js → heartbeat-RAOEIKWC.js} +18 -21
- package/dist/heartbeat-RAOEIKWC.js.map +1 -0
- package/dist/{identity-VDUW4I2K.js → identity-ASHVWIN5.js} +3 -3
- package/dist/{init-2REECUVH.js → init-ETUTFHT6.js} +59 -13
- package/dist/init-ETUTFHT6.js.map +1 -0
- package/dist/{llm-OGOYCWBH.js → llm-IJBRQ7O2.js} +5 -5
- package/dist/mcp-server.js +24 -24
- package/dist/{memory-PNW7SX7A.js → memory-AWKIW2KW.js} +3 -3
- package/dist/{memory-OIAH33G2.js → memory-DTSLVSQG.js} +3 -3
- package/dist/{paths-BYR6MEPR.js → paths-4V5OCB5F.js} +2 -2
- package/dist/prompt-builder-XJHXZCSQ.js +27 -0
- package/dist/queue-QCGNDHH2.js +14 -0
- package/dist/strategy-R2BMRVJ3.js +19 -0
- package/dist/web-chat/chat.html +190 -3
- package/dist/{web-chat-O24HGJVE.js → web-chat-TB3ACPVF.js} +125 -32
- package/dist/web-chat-TB3ACPVF.js.map +1 -0
- package/dist/x-client-S2LUVEKV.js +12 -0
- package/package.json +1 -1
- package/dist/autonomy-6UWPXTPD.js +0 -19
- package/dist/chunk-3RYCUGXE.js.map +0 -1
- package/dist/chunk-4LNMA56H.js +0 -57
- package/dist/chunk-4LNMA56H.js.map +0 -1
- package/dist/chunk-7OOGNZBU.js.map +0 -1
- package/dist/chunk-M6YOQVSI.js.map +0 -1
- package/dist/chunk-P6KZIJYL.js +0 -79
- package/dist/chunk-P6KZIJYL.js.map +0 -1
- package/dist/chunk-Q3YXJ2C6.js.map +0 -1
- package/dist/chunk-VZBHRUZS.js.map +0 -1
- package/dist/chunk-ZBP2ROAZ.js +0 -377
- package/dist/chunk-ZBP2ROAZ.js.map +0 -1
- package/dist/client-4KGOBIXE.js.map +0 -1
- package/dist/heartbeat-CUL2FTFD.js.map +0 -1
- package/dist/init-2REECUVH.js.map +0 -1
- package/dist/prompt-builder-KJKFCGM7.js +0 -25
- package/dist/queue-D3MRKABU.js +0 -14
- package/dist/strategy-Z4JSFHSP.js +0 -12
- package/dist/web-chat-O24HGJVE.js.map +0 -1
- package/dist/x-client-ASXVQ6EV.js +0 -12
- /package/dist/{autonomy-6UWPXTPD.js.map → autonomy-DFPA3OK6.js.map} +0 -0
- /package/dist/{chunk-SUZUJGGW.js.map → chunk-342ZX72W.js.map} +0 -0
- /package/dist/{chunk-JBYZ7K56.js.map → chunk-BBXHECZ5.js.map} +0 -0
- /package/dist/{chunk-WN35MRMF.js.map → chunk-CAWWG3MD.js.map} +0 -0
- /package/dist/{chunk-T7L2L7ZL.js.map → chunk-D47OFTEK.js.map} +0 -0
- /package/dist/{chunk-NO3NQN67.js.map → chunk-QYFNAGNI.js.map} +0 -0
- /package/dist/{chunk-YMGJQRKG.js.map → chunk-RSNEVBEI.js.map} +0 -0
- /package/dist/{colony-IVYR233C.js.map → colony-UGVYALOS.js.map} +0 -0
- /package/dist/{config-FL4VJVKZ.js.map → config-MU2ODEO3.js.map} +0 -0
- /package/dist/{crypto-NOXNL4GP.js.map → crypto-GDG5K3ZH.js.map} +0 -0
- /package/dist/{goals-RBKLMILE.js.map → goals-QWX3A47Y.js.map} +0 -0
- /package/dist/{identity-VDUW4I2K.js.map → identity-ASHVWIN5.js.map} +0 -0
- /package/dist/{llm-OGOYCWBH.js.map → llm-IJBRQ7O2.js.map} +0 -0
- /package/dist/{memory-OIAH33G2.js.map → memory-AWKIW2KW.js.map} +0 -0
- /package/dist/{memory-PNW7SX7A.js.map → memory-DTSLVSQG.js.map} +0 -0
- /package/dist/{paths-BYR6MEPR.js.map → paths-4V5OCB5F.js.map} +0 -0
- /package/dist/{prompt-builder-KJKFCGM7.js.map → prompt-builder-XJHXZCSQ.js.map} +0 -0
- /package/dist/{queue-D3MRKABU.js.map → queue-QCGNDHH2.js.map} +0 -0
- /package/dist/{strategy-Z4JSFHSP.js.map → strategy-R2BMRVJ3.js.map} +0 -0
- /package/dist/{x-client-ASXVQ6EV.js.map → x-client-S2LUVEKV.js.map} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/web-chat/server.ts","../src/web-chat/index.ts"],"sourcesContent":["/**\n * Local web chat server\n * Serves a simple chat interface for interacting with your Spore\n */\n\nimport http from \"node:http\";\nimport { URL } from \"node:url\";\nimport { readFileSync } from \"node:fs\";\nimport { join, dirname } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\n\ninterface ChatMessage {\n role: \"user\" | \"assistant\";\n content: string;\n timestamp: number;\n}\n\ninterface AgentActivity {\n type: \"heartbeat\" | \"action\" | \"status\";\n message: string;\n timestamp: number;\n}\n\n/** Messages pushed from the heartbeat into the chat UI */\nexport interface AgentChatEvent {\n type: \"narration\" | \"tweet\" | \"action\" | \"sleep\" | \"wake\" | \"error\";\n content: string;\n timestamp: number;\n meta?: Record<string, unknown>;\n}\n\ninterface AgentIdentity {\n name: string;\n handle: string;\n bio?: string;\n profileImage?: string;\n}\n\ninterface HeartbeatConfigHandlers {\n getIntervalMs: () => number | Promise<number>;\n setIntervalMs: (intervalMs: number) => void | Promise<void>;\n}\n\nconst ALLOWED_HEARTBEAT_INTERVALS = [60_000, 300_000, 1_800_000, 3_600_000, 21_600_000] as const;\n\nexport class WebChatServer {\n private server: http.Server | null = null;\n private port: number;\n private messages: ChatMessage[] = [];\n private activities: AgentActivity[] = [];\n private agentEvents: AgentChatEvent[] = [];\n private onUserMessage?: (message: string) => Promise<string>;\n private identity?: AgentIdentity;\n private heartbeatConfigHandlers?: HeartbeatConfigHandlers;\n\n constructor(port = 3737) {\n this.port = port;\n }\n\n setIdentity(identity: AgentIdentity) {\n this.identity = identity;\n }\n\n setMessageHandler(handler: (message: string) => Promise<string>) {\n this.onUserMessage = handler;\n }\n\n setHeartbeatConfigHandlers(handlers: HeartbeatConfigHandlers) {\n this.heartbeatConfigHandlers = handlers;\n }\n\n /** Push an activity update (from heartbeat) to the UI — kept for backwards compat */\n pushActivity(type: AgentActivity[\"type\"], message: string) {\n this.activities.push({ type, message, timestamp: Date.now() });\n if (this.activities.length > 100) {\n this.activities = this.activities.slice(-100);\n }\n }\n\n /** Push an event into the chat stream (narration, tweet card, sleep state, etc.) */\n pushAgentEvent(type: AgentChatEvent[\"type\"], content: string, meta?: Record<string, unknown>) {\n this.agentEvents.push({ type, content, timestamp: Date.now(), meta });\n if (this.agentEvents.length > 200) {\n this.agentEvents = this.agentEvents.slice(-200);\n }\n }\n\n async start(): Promise<string> {\n return new Promise((resolve, reject) => {\n this.server = http.createServer(async (req, res) => {\n const url = new URL(req.url || \"/\", `http://${req.headers.host}`);\n\n // CORS headers\n res.setHeader(\"Access-Control-Allow-Origin\", \"*\");\n res.setHeader(\"Access-Control-Allow-Methods\", \"GET, POST, OPTIONS\");\n res.setHeader(\"Access-Control-Allow-Headers\", \"Content-Type\");\n\n if (req.method === \"OPTIONS\") {\n res.writeHead(200);\n res.end();\n return;\n }\n\n // Serve HTML\n if (url.pathname === \"/\" || url.pathname === \"/index.html\") {\n try {\n const possiblePaths = [\n join(__dirname, \"web-chat\", \"chat.html\"),\n join(__dirname, \"chat.html\"),\n join(__dirname, \"..\", \"web-chat\", \"chat.html\"),\n join(__dirname, \"..\", \"src\", \"web-chat\", \"chat.html\"),\n ];\n\n let html: string | null = null;\n for (const p of possiblePaths) {\n try {\n html = readFileSync(p, \"utf-8\");\n break;\n } catch {\n continue;\n }\n }\n\n if (html) {\n res.writeHead(200, { \"Content-Type\": \"text/html\" });\n res.end(html);\n } else {\n console.error(\"Could not find chat.html in any of:\", possiblePaths);\n res.writeHead(500);\n res.end(\"Error: Could not find chat.html\");\n }\n } catch (error) {\n res.writeHead(500);\n res.end(\"Error loading chat interface\");\n }\n return;\n }\n\n // API: Get agent identity\n if (url.pathname === \"/api/identity\" && req.method === \"GET\") {\n res.writeHead(200, { \"Content-Type\": \"application/json\" });\n res.end(JSON.stringify({ identity: this.identity || null }));\n return;\n }\n\n // API: Get messages\n if (url.pathname === \"/api/messages\" && req.method === \"GET\") {\n res.writeHead(200, { \"Content-Type\": \"application/json\" });\n res.end(JSON.stringify({ messages: this.messages }));\n return;\n }\n\n // API: Get agent activity feed (legacy, kept for compat)\n if (url.pathname === \"/api/activity\" && req.method === \"GET\") {\n const since = parseInt(url.searchParams.get(\"since\") || \"0\", 10);\n const newActivities = this.activities.filter((a) => a.timestamp > since);\n res.writeHead(200, { \"Content-Type\": \"application/json\" });\n res.end(JSON.stringify({ activities: newActivities }));\n return;\n }\n\n // API: Get agent events (narration, tweets, sleep) — polled by chat UI\n if (url.pathname === \"/api/agent-events\" && req.method === \"GET\") {\n const since = parseInt(url.searchParams.get(\"since\") || \"0\", 10);\n const newEvents = this.agentEvents.filter((e) => e.timestamp > since);\n res.writeHead(200, { \"Content-Type\": \"application/json\" });\n res.end(JSON.stringify({ events: newEvents }));\n return;\n }\n\n // API: Read heartbeat interval config\n if (url.pathname === \"/api/heartbeat-config\" && req.method === \"GET\") {\n if (!this.heartbeatConfigHandlers) {\n res.writeHead(503, { \"Content-Type\": \"application/json\" });\n res.end(JSON.stringify({ error: \"Heartbeat config unavailable\" }));\n return;\n }\n\n try {\n const intervalMs = await this.heartbeatConfigHandlers.getIntervalMs();\n res.writeHead(200, { \"Content-Type\": \"application/json\" });\n res.end(JSON.stringify({ intervalMs, allowedIntervals: ALLOWED_HEARTBEAT_INTERVALS }));\n } catch {\n res.writeHead(500, { \"Content-Type\": \"application/json\" });\n res.end(JSON.stringify({ error: \"Failed to load heartbeat config\" }));\n }\n return;\n }\n\n // API: Update heartbeat interval config\n if (url.pathname === \"/api/heartbeat-config\" && req.method === \"POST\") {\n if (!this.heartbeatConfigHandlers) {\n res.writeHead(503, { \"Content-Type\": \"application/json\" });\n res.end(JSON.stringify({ error: \"Heartbeat config unavailable\" }));\n return;\n }\n const handlers = this.heartbeatConfigHandlers;\n\n let body = \"\";\n req.on(\"data\", (chunk) => {\n body += chunk.toString();\n });\n\n req.on(\"end\", async () => {\n try {\n const parsed = JSON.parse(body) as { intervalMs?: number };\n const intervalMs = parsed.intervalMs;\n\n if (\n typeof intervalMs !== \"number\" ||\n !Number.isInteger(intervalMs) ||\n !ALLOWED_HEARTBEAT_INTERVALS.includes(intervalMs as (typeof ALLOWED_HEARTBEAT_INTERVALS)[number])\n ) {\n res.writeHead(400, { \"Content-Type\": \"application/json\" });\n res.end(JSON.stringify({ error: \"Unsupported heartbeat interval\" }));\n return;\n }\n\n await handlers.setIntervalMs(intervalMs);\n res.writeHead(200, { \"Content-Type\": \"application/json\" });\n res.end(JSON.stringify({ success: true, intervalMs }));\n } catch {\n res.writeHead(400, { \"Content-Type\": \"application/json\" });\n res.end(JSON.stringify({ error: \"Invalid request\" }));\n }\n });\n return;\n }\n\n // API: Send message\n if (url.pathname === \"/api/message\" && req.method === \"POST\") {\n let body = \"\";\n req.on(\"data\", (chunk) => {\n body += chunk.toString();\n });\n\n req.on(\"end\", async () => {\n try {\n const { message } = JSON.parse(body);\n\n // Add user message\n this.messages.push({\n role: \"user\",\n content: message,\n timestamp: Date.now(),\n });\n\n // Get response\n if (this.onUserMessage) {\n const response = await this.onUserMessage(message);\n this.messages.push({\n role: \"assistant\",\n content: response,\n timestamp: Date.now(),\n });\n res.writeHead(200, { \"Content-Type\": \"application/json\" });\n res.end(JSON.stringify({ success: true, response }));\n } else {\n res.writeHead(500, { \"Content-Type\": \"application/json\" });\n res.end(JSON.stringify({ error: \"No message handler configured\" }));\n }\n } catch (error) {\n res.writeHead(400, { \"Content-Type\": \"application/json\" });\n res.end(JSON.stringify({ error: \"Invalid request\" }));\n }\n });\n return;\n }\n\n // 404\n res.writeHead(404);\n res.end(\"Not found\");\n });\n\n this.server.listen(this.port, () => {\n const url = `http://localhost:${this.port}`;\n resolve(url);\n });\n\n this.server.on(\"error\", (error: NodeJS.ErrnoException) => {\n if (error.code === \"EADDRINUSE\") {\n this.port++;\n this.server?.close();\n this.start().then(resolve).catch(reject);\n } else {\n reject(error);\n }\n });\n });\n }\n\n stop() {\n if (this.server) {\n this.server.close();\n this.server = null;\n }\n }\n}\n","/**\n * Web chat integration with autonomous heartbeat\n */\n\nimport { WebChatServer } from \"./server.js\";\nimport { loadIdentity } from \"../identity/index.js\";\nimport { execSync } from \"node:child_process\";\nimport chalk from \"chalk\";\n\nconst HEARTBEAT_INTERVAL_OPTIONS = [60_000, 300_000, 1_800_000, 3_600_000, 21_600_000] as const;\n\nfunction formatHeartbeatInterval(intervalMs: number): string {\n const minutes = intervalMs / 60_000;\n if (minutes < 60) return `${minutes} minute${minutes === 1 ? \"\" : \"s\"}`;\n const hours = minutes / 60;\n return `${hours} hour${hours === 1 ? \"\" : \"s\"}`;\n}\n\n/**\n * Extract <<LEARN: ...>> tags from response, save them, and return cleaned text\n */\nasync function extractAndSaveLearnings(responseText: string): Promise<string> {\n const learnPattern = /<<LEARN:\\s*(.+?)>>/g;\n const matches = [...responseText.matchAll(learnPattern)];\n\n if (matches.length > 0) {\n const { addLearning } = await import(\"../memory/index.js\");\n for (const match of matches) {\n const learning = match[1].trim();\n addLearning(learning, \"web-chat\", [\"chat\", \"creator-interaction\"]);\n console.log(chalk.dim(` [Memory] Saved learning: ${learning}`));\n }\n }\n\n // Strip the learn tags from the response the user sees\n return responseText.replace(/<<LEARN:\\s*.+?>>/g, \"\").trim();\n}\n\n/**\n * Extract <<TRAINING:{json}>> tags from response, apply updates to identity/strategy/goals, and return cleaned text\n */\nasync function extractAndApplyTraining(responseText: string): Promise<string> {\n const trainingPattern = /<<TRAINING:([\\s\\S]*?)>>/g;\n const matches = [...responseText.matchAll(trainingPattern)];\n\n for (const match of matches) {\n try {\n const update = JSON.parse(match[1].trim());\n\n // Apply identity changes\n if (update.identity) {\n const { loadIdentity, mutateIdentity, saveIdentity } = await import(\"../identity/index.js\");\n let identity = loadIdentity();\n\n const identityFields: Record<string, string> = {\n tone: \"tone\",\n worldview: \"worldview\",\n conflictStyle: \"conflictStyle\",\n vocabularyStyle: \"vocabularyStyle\",\n tweetStyle: \"tweetStyle\",\n };\n\n // Simple string/enum fields\n for (const [key, field] of Object.entries(identityFields)) {\n if (update.identity[key] !== undefined) {\n identity = mutateIdentity(identity, field, update.identity[key], \"training-chat\");\n console.log(chalk.dim(` [Training] Updated ${field}`));\n }\n }\n\n // Array fields (replace entire array)\n const arrayFields = [\"coreValues\", \"topics\", \"avoidTopics\", \"goals\", \"boundaries\", \"catchphrases\", \"heroes\"];\n for (const field of arrayFields) {\n if (update.identity[field] !== undefined && Array.isArray(update.identity[field])) {\n identity = mutateIdentity(identity, field, update.identity[field], \"training-chat\");\n console.log(chalk.dim(` [Training] Updated ${field}`));\n }\n }\n\n // Traits (merge, don't replace)\n if (update.identity.traits && typeof update.identity.traits === \"object\") {\n for (const [trait, value] of Object.entries(update.identity.traits)) {\n if (typeof value === \"number\" && value >= 0 && value <= 1) {\n identity = mutateIdentity(identity, `traits.${trait}`, value, \"training-chat\");\n console.log(chalk.dim(` [Training] Updated traits.${trait} = ${value}`));\n }\n }\n }\n\n // Engagement strategy (merge)\n if (update.identity.engagementStrategy && typeof update.identity.engagementStrategy === \"object\") {\n for (const [key, value] of Object.entries(update.identity.engagementStrategy)) {\n identity = mutateIdentity(identity, `engagementStrategy.${key}`, value, \"training-chat\");\n console.log(chalk.dim(` [Training] Updated engagementStrategy.${key}`));\n }\n }\n\n saveIdentity(identity);\n }\n\n // Apply strategy changes\n if (update.strategy) {\n const { loadStrategy, saveStrategy } = await import(\"../memory/strategy.js\");\n const strategy = loadStrategy();\n\n if (update.strategy.currentFocus) strategy.currentFocus = update.strategy.currentFocus;\n if (update.strategy.shortTermGoals) strategy.shortTermGoals = update.strategy.shortTermGoals;\n if (update.strategy.experiments) {\n strategy.experiments.push(...update.strategy.experiments);\n }\n if (update.strategy.peopleToEngage) {\n strategy.peopleToEngage.push(...update.strategy.peopleToEngage);\n }\n\n strategy.lastUpdated = new Date().toISOString();\n saveStrategy(strategy);\n console.log(chalk.dim(` [Training] Updated strategy`));\n }\n\n // Apply standalone learning\n if (update.learning) {\n const { addLearning } = await import(\"../memory/index.js\");\n addLearning(\n update.learning.content,\n \"training-chat\",\n update.learning.tags || [\"training\"],\n );\n console.log(chalk.dim(` [Training] Saved learning: ${update.learning.content}`));\n }\n\n // Apply reflection to evolution journal\n if (update.reflection) {\n const { loadIdentity, saveIdentity } = await import(\"../identity/index.js\");\n const identity = loadIdentity();\n identity.evolutionJournal.push({\n date: new Date().toISOString(),\n reflection: update.reflection,\n });\n saveIdentity(identity);\n console.log(chalk.dim(` [Training] Added reflection to evolution journal`));\n }\n\n // Apply goal updates\n if (update.goalUpdates && Array.isArray(update.goalUpdates)) {\n const { loadGoals, saveGoals } = await import(\"../memory/goals.js\");\n const tracker = loadGoals();\n\n for (const gu of update.goalUpdates) {\n const existing = tracker.goals.find((g: { goal: string }) => g.goal === gu.goal);\n if (existing) {\n existing.progress = gu.progress;\n existing.lastUpdated = new Date().toISOString();\n } else {\n tracker.goals.push({\n goal: gu.goal,\n progress: gu.progress,\n lastUpdated: new Date().toISOString(),\n });\n }\n }\n\n tracker.lastReviewed = new Date().toISOString();\n saveGoals(tracker);\n console.log(chalk.dim(` [Training] Updated ${update.goalUpdates.length} goal(s)`));\n }\n\n } catch (err) {\n console.error(chalk.dim(` [Training] Failed to parse training update: ${(err as Error).message}`));\n }\n }\n\n // Strip the training tags from the response the user sees\n return responseText.replace(/<<TRAINING:[\\s\\S]*?>>/g, \"\").trim();\n}\n\n/**\n * Log a chat exchange as an interaction in memory\n */\nasync function logChatInteraction(userMessage: string, agentResponse: string): Promise<void> {\n const { logInteraction } = await import(\"../memory/index.js\");\n logInteraction({\n id: `chat-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,\n timestamp: new Date().toISOString(),\n type: \"reply\",\n content: agentResponse.slice(0, 200),\n targetHandle: \"creator\",\n creditsUsed: 0,\n success: true,\n });\n}\n\n/**\n * Run the autonomous heartbeat in the background, narrating to the chat UI\n */\nasync function runNarratedHeartbeat(server: WebChatServer): Promise<void> {\n const { loadConfig } = await import(\"../utils/config.js\");\n const { flushQueue } = await import(\"../scheduler/queue.js\");\n const { runAutonomyCycle } = await import(\"../runtime/autonomy.js\");\n const { buildReflectionPrompt } = await import(\"../runtime/prompt-builder.js\");\n const { generateResponse } = await import(\"../runtime/llm.js\");\n const { addLearning } = await import(\"../memory/index.js\");\n const { loadStrategy, saveStrategy, applyStrategyUpdate } = await import(\"../memory/strategy.js\");\n\n let heartbeatCount = 0;\n let lastIntervalMs = loadConfig().runtime?.heartbeatIntervalMs ?? 300_000;\n\n console.log(chalk.cyan(` [Agent] Autonomous heartbeat started (every ${Math.round(lastIntervalMs / 60_000)} min)`));\n\n while (true) {\n const runtimeConfig = loadConfig();\n const intervalMs = runtimeConfig.runtime?.heartbeatIntervalMs ?? 300_000;\n const maxActions = runtimeConfig.runtime?.actionsPerHeartbeat ?? 4;\n\n if (intervalMs !== lastIntervalMs) {\n server.pushAgentEvent(\"narration\", `Heartbeat interval updated to ${formatHeartbeatInterval(intervalMs)}.`);\n console.log(chalk.cyan(` [Agent] Heartbeat interval updated to ${Math.round(intervalMs / 60_000)} min`));\n lastIntervalMs = intervalMs;\n }\n\n // Sleep first, then heartbeat\n const jitter = Math.floor(Math.random() * intervalMs * 0.3);\n const sleepMs = heartbeatCount === 0 ? 10_000 : intervalMs + jitter;\n const wakeUpAt = Date.now() + sleepMs;\n\n // Show sleep state in chat (skip for first quick boot)\n if (heartbeatCount > 0) {\n server.pushAgentEvent(\"sleep\", \"sleeping\", { wakeUpAt });\n }\n\n // Sleep in short chunks so heartbeat interval changes apply immediately.\n let sleptMs = 0;\n let intervalChangedDuringSleep = false;\n while (sleptMs < sleepMs) {\n const chunkMs = Math.min(1000, sleepMs - sleptMs);\n await new Promise((r) => setTimeout(r, chunkMs));\n sleptMs += chunkMs;\n\n const liveIntervalMs = loadConfig().runtime?.heartbeatIntervalMs ?? 300_000;\n if (liveIntervalMs !== intervalMs) {\n intervalChangedDuringSleep = true;\n break;\n }\n }\n\n if (intervalChangedDuringSleep) {\n continue;\n }\n\n heartbeatCount++;\n console.log(chalk.cyan(` [Agent] Heartbeat #${heartbeatCount}`));\n server.pushAgentEvent(\"wake\", `Waking up... heartbeat #${heartbeatCount}`);\n\n try {\n // 1. Flush queue\n try {\n const flushed = await flushQueue();\n if (flushed.posted > 0) {\n server.pushAgentEvent(\"action\", `Flushed ${flushed.posted} queued post(s)`);\n }\n } catch {\n // Queue flush is best-effort\n }\n\n // 2. Run tool-driven autonomy cycle\n server.pushAgentEvent(\"narration\", \"Observing timeline and planning actions...\");\n const cycle = await runAutonomyCycle(maxActions, heartbeatCount);\n\n if (cycle.timeline.length > 0 || cycle.mentions.length > 0) {\n server.pushAgentEvent(\"narration\", `Found ${cycle.timeline.length} timeline posts and ${cycle.mentions.length} mentions`);\n }\n\n if (cycle.actions.length === 0) {\n server.pushAgentEvent(\"narration\", \"Nothing interesting right now, going back to sleep\");\n console.log(chalk.dim(` [Agent] No actions this heartbeat`));\n continue;\n }\n\n // 3. Report results — push tweet cards for posts, narration for everything else\n for (let i = 0; i < cycle.results.length; i++) {\n const result = cycle.results[i];\n const action = cycle.actions[i];\n if (!action) continue;\n\n if (result.success) {\n if (action.action === \"post\" && action.content) {\n server.pushAgentEvent(\"tweet\", action.content, { status: \"success\" });\n } else if (action.action === \"reply\" && action.content) {\n server.pushAgentEvent(\"action\", `Replied to tweet: \"${action.content.slice(0, 80)}\"`);\n } else if (action.action === \"like\") {\n server.pushAgentEvent(\"action\", `Liked a tweet`);\n } else if (action.action === \"retweet\") {\n server.pushAgentEvent(\"action\", `Retweeted`);\n } else if (action.action === \"follow\") {\n server.pushAgentEvent(\"action\", `Followed @${action.handle}`);\n } else if (action.action === \"schedule\" && action.content) {\n server.pushAgentEvent(\"tweet\", action.content, { status: \"Scheduled\" });\n } else {\n server.pushAgentEvent(\"action\", `${action.action}${result.detail ? `: ${result.detail}` : \"\"}`);\n }\n console.log(chalk.green(` [Agent] ✓ ${result.action}`));\n } else {\n if (action.action === \"post\" && action.content) {\n server.pushAgentEvent(\"tweet\", action.content, { status: `Failed: ${result.error}` });\n } else {\n server.pushAgentEvent(\"error\", `${result.action} failed: ${result.error}`);\n }\n console.log(chalk.red(` [Agent] ✗ ${result.action}: ${result.error}`));\n }\n }\n\n for (const feedback of cycle.policyFeedback) {\n server.pushAgentEvent(\"narration\", `Policy adjusted plan: ${feedback}`);\n }\n\n // Reflection phase — every 3rd heartbeat, review performance\n if (heartbeatCount % 3 === 0) {\n try {\n server.pushAgentEvent(\"narration\", \"Reflecting on recent performance...\");\n const reflectionPrompt = buildReflectionPrompt(cycle.results);\n const reflectionResponse = await generateResponse(\n `You are ${loadIdentity().name}. Reflect honestly on your performance.`,\n reflectionPrompt,\n );\n\n // Parse reflection JSON\n const jsonMatch = reflectionResponse.content.match(/\\{[\\s\\S]*\\}/);\n if (jsonMatch) {\n try {\n const reflection = JSON.parse(jsonMatch[0]);\n if (reflection.learning && reflection.learning !== \"null\") {\n addLearning(reflection.learning, \"reflection\", [\"heartbeat\", \"performance\"]);\n server.pushAgentEvent(\"narration\", `Learned: ${reflection.learning}`);\n console.log(chalk.dim(` [Agent] Reflection learning: ${reflection.learning}`));\n }\n if (reflection.strategyUpdate && reflection.strategyUpdate !== \"null\") {\n const strategy = loadStrategy();\n saveStrategy(applyStrategyUpdate(strategy, reflection.strategyUpdate));\n server.pushAgentEvent(\"narration\", `Strategy: ${reflection.strategyUpdate}`);\n console.log(chalk.dim(` [Agent] Strategy update: ${reflection.strategyUpdate}`));\n }\n } catch {\n // Couldn't parse reflection JSON, that's fine\n }\n }\n } catch (err) {\n console.log(chalk.dim(` [Agent] Reflection failed: ${(err as Error).message}`));\n }\n }\n\n } catch (error) {\n const msg = (error as Error).message;\n console.error(chalk.red(` [Agent] Heartbeat #${heartbeatCount} error: ${msg}`));\n server.pushAgentEvent(\"error\", `Something went wrong: ${msg}`);\n }\n }\n}\n\nexport async function startWebChat() {\n const identity = loadIdentity();\n const { loadConfig: loadRuntimeConfig, saveConfig } = await import(\"../utils/config.js\");\n\n const server = new WebChatServer();\n\n // Pass identity to server so the chat UI can display it\n server.setIdentity({\n name: identity.name,\n handle: identity.handle,\n bio: identity.bio,\n profileImage: identity.profileImage,\n });\n\n server.setHeartbeatConfigHandlers({\n getIntervalMs: () => {\n const config = loadRuntimeConfig();\n return config.runtime?.heartbeatIntervalMs ?? 300_000;\n },\n setIntervalMs: (intervalMs) => {\n if (!HEARTBEAT_INTERVAL_OPTIONS.includes(intervalMs as (typeof HEARTBEAT_INTERVAL_OPTIONS)[number])) {\n throw new Error(\"Unsupported heartbeat interval.\");\n }\n\n const config = loadRuntimeConfig();\n config.runtime = {\n heartbeatIntervalMs: intervalMs,\n actionsPerHeartbeat: config.runtime?.actionsPerHeartbeat ?? 4,\n enabled: true,\n };\n saveConfig(config);\n server.pushAgentEvent(\"narration\", `Heartbeat interval set to ${formatHeartbeatInterval(intervalMs)}.`);\n },\n });\n\n // Set up message handler - connected to actual LLM with memory\n const chatHistory: Array<{ role: \"user\" | \"assistant\"; content: string }> = [];\n let systemPrompt: string | null = null;\n let messageCount = 0;\n\n server.setMessageHandler(async (message: string) => {\n try {\n // Build training prompt on first message, rebuild every 10 messages to refresh memory\n if (!systemPrompt || messageCount % 10 === 0) {\n const { buildTrainingChatPrompt } = await import(\"../runtime/prompt-builder.js\");\n systemPrompt = buildTrainingChatPrompt();\n }\n messageCount++;\n\n // Check for LLM key\n const { hasLLMKey, chat: chatLLM } = await import(\"../runtime/llm.js\");\n if (!hasLLMKey()) {\n return \"I can't respond right now - no API key configured. Run `spora llm set --provider <provider>` to set one up.\";\n }\n\n // Add user message to history\n chatHistory.push({ role: \"user\", content: message });\n\n // Call LLM with full conversation history\n const response = await chatLLM(systemPrompt, chatHistory);\n\n // Extract training updates and learnings from response\n const afterTraining = await extractAndApplyTraining(response.content);\n const cleanResponse = await extractAndSaveLearnings(afterTraining);\n\n // Add cleaned assistant response to history\n chatHistory.push({ role: \"assistant\", content: cleanResponse });\n\n // Log interaction to memory (async, don't block response)\n logChatInteraction(message, cleanResponse).catch((err) =>\n console.error(chalk.dim(\" [Memory] Failed to log interaction:\"), err)\n );\n\n return cleanResponse;\n } catch (error) {\n console.error(\"Chat error:\", error);\n return `Sorry, I ran into an issue: ${(error as Error).message}`;\n }\n });\n\n const url = await server.start();\n\n console.log(chalk.green(`\\n✓ Chat interface started at ${chalk.bold(url)}\\n`));\n console.log(chalk.dim(`Press Ctrl+C to stop the server\\n`));\n\n // Open browser\n openBrowser(url);\n\n // Start autonomous heartbeat in background\n try {\n const { hasLLMKey } = await import(\"../runtime/llm.js\");\n if (hasLLMKey()) {\n runNarratedHeartbeat(server).catch((err) => {\n console.error(chalk.red(`Heartbeat failed to start: ${err}`));\n });\n } else {\n console.log(chalk.yellow(\" [Agent] No LLM key — autonomous heartbeat disabled. Run `spora llm set --provider <provider>` to enable.\"));\n server.pushActivity(\"status\", \"No LLM API key configured. Autonomous mode disabled.\");\n }\n } catch (err) {\n console.error(chalk.red(`Heartbeat failed to start: ${err}`));\n }\n\n // Keep process alive\n process.on(\"SIGINT\", () => {\n console.log(chalk.yellow(\"\\n\\nStopping chat server...\"));\n server.stop();\n process.exit(0);\n });\n\n // Return the server instance for external control\n return server;\n}\n\n/**\n * Open URL in a separate browser window (app-like)\n */\nfunction openBrowser(url: string) {\n const platform = process.platform;\n\n try {\n if (platform === \"darwin\") {\n // Open as a standalone Chrome app window (smaller, separate from existing tabs)\n try {\n execSync(`open -na \"Google Chrome\" --args --app=\"${url}\" --window-size=500,700`, { stdio: \"ignore\" });\n } catch {\n // Fallback: try Chromium-based browsers, then default\n try {\n execSync(`open -na \"Brave Browser\" --args --app=\"${url}\" --window-size=500,700`, { stdio: \"ignore\" });\n } catch {\n execSync(`open \"${url}\"`, { stdio: \"ignore\" });\n }\n }\n } else if (platform === \"win32\") {\n try {\n execSync(`start chrome --app=\"${url}\" --window-size=500,700`, { stdio: \"ignore\" });\n } catch {\n execSync(`start \"\" \"${url}\"`, { stdio: \"ignore\" });\n }\n } else {\n // Linux\n try {\n execSync(`google-chrome --app=\"${url}\" --window-size=500,700`, { stdio: \"ignore\" });\n } catch {\n execSync(`xdg-open \"${url}\"`, { stdio: \"ignore\" });\n }\n }\n } catch (error) {\n // Browser couldn't be opened, that's okay\n console.log(chalk.dim(`(Couldn't open browser automatically - please visit ${url} manually)`));\n }\n}\n\nexport { openBrowser };\n"],"mappings":";;;;;;AAKA,OAAO,UAAU;AACjB,SAAS,WAAW;AACpB,SAAS,oBAAoB;AAC7B,SAAS,MAAM,eAAe;AAC9B,SAAS,qBAAqB;AAE9B,IAAM,aAAa,cAAc,YAAY,GAAG;AAChD,IAAM,YAAY,QAAQ,UAAU;AAkCpC,IAAM,8BAA8B,CAAC,KAAQ,KAAS,MAAW,MAAW,KAAU;AAE/E,IAAM,gBAAN,MAAoB;AAAA,EACjB,SAA6B;AAAA,EAC7B;AAAA,EACA,WAA0B,CAAC;AAAA,EAC3B,aAA8B,CAAC;AAAA,EAC/B,cAAgC,CAAC;AAAA,EACjC;AAAA,EACA;AAAA,EACA;AAAA,EAER,YAAY,OAAO,MAAM;AACvB,SAAK,OAAO;AAAA,EACd;AAAA,EAEA,YAAY,UAAyB;AACnC,SAAK,WAAW;AAAA,EAClB;AAAA,EAEA,kBAAkB,SAA+C;AAC/D,SAAK,gBAAgB;AAAA,EACvB;AAAA,EAEA,2BAA2B,UAAmC;AAC5D,SAAK,0BAA0B;AAAA,EACjC;AAAA;AAAA,EAGA,aAAa,MAA6B,SAAiB;AACzD,SAAK,WA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U,MAAM;AACzB,YAAQ,IAAI,MAAM,OAAO,6BAA6B,CAAC;AACvD,WAAO,KAAK;AACZ,YAAQ,KAAK,CAAC;AAAA,EAChB,CAAC;AAGD,SAAO;AACT;AAKA,SAAS,YAAY,KAAa;AAChC,QAAM,WAAW,QAAQ;AAEzB,MAAI;AACF,QAAI,aAAa,UAAU;AAEzB,UAAI;AACF,iBAAS,0CAA0C,GAAG,2BAA2B,EAAE,OAAO,SAAS,CAAC;AAAA,MACtG,QAAQ;AAEN,YAAI;AACF,mBAAS,0CAA0C,GAAG,2BAA2B,EAAE,OAAO,SAAS,CAAC;AAAA,QACtG,QAAQ;AACN,mBAAS,SAAS,GAAG,KAAK,EAAE,OAAO,SAAS,CAAC;AAAA,QAC/C;AAAA,MACF;AAAA,IACF,WAAW,aAAa,SAAS;AAC/B,UAAI;AACF,iBAAS,uBAAuB,GAAG,2BAA2B,EAAE,OAAO,SAAS,CAAC;AAAA,MACnF,QAAQ;AACN,iBAAS,aAAa,GAAG,KAAK,EAAE,OAAO,SAAS,CAAC;AAAA,MACnD;AAAA,IACF,OAAO;AAEL,UAAI;AACF,iBAAS,wBAAwB,GAAG,2BAA2B,EAAE,OAAO,SAAS,CAAC;AAAA,MACpF,QAAQ;AACN,iBAAS,aAAa,GAAG,KAAK,EAAE,OAAO,SAAS,CAAC;AAAA,MACnD;AAAA,IACF;AAAA,EACF,SAAS,OAAO;AAEd,YAAQ,IAAI,MAAM,IAAI,uDAAuD,GAAG,YAAY,CAAC;AAAA,EAC/F;AACF;","names":["loadIdentity"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getXClient,
|
|
3
|
+
resetXClient
|
|
4
|
+
} from "./chunk-5R4AJZHN.js";
|
|
5
|
+
import "./chunk-RSNEVBEI.js";
|
|
6
|
+
import "./chunk-QYFNAGNI.js";
|
|
7
|
+
import "./chunk-ZWKTKWS6.js";
|
|
8
|
+
export {
|
|
9
|
+
getXClient,
|
|
10
|
+
resetXClient
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=x-client-S2LUVEKV.js.map
|
package/package.json
CHANGED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
runAutonomyCycle
|
|
3
|
-
} from "./chunk-ZBP2ROAZ.js";
|
|
4
|
-
import "./chunk-HGNMHGAF.js";
|
|
5
|
-
import "./chunk-7OOGNZBU.js";
|
|
6
|
-
import "./chunk-Q3YXJ2C6.js";
|
|
7
|
-
import "./chunk-P6KZIJYL.js";
|
|
8
|
-
import "./chunk-WN35MRMF.js";
|
|
9
|
-
import "./chunk-4LNMA56H.js";
|
|
10
|
-
import "./chunk-M6YOQVSI.js";
|
|
11
|
-
import "./chunk-SUZUJGGW.js";
|
|
12
|
-
import "./chunk-YMGJQRKG.js";
|
|
13
|
-
import "./chunk-NO3NQN67.js";
|
|
14
|
-
import "./chunk-JBYZ7K56.js";
|
|
15
|
-
import "./chunk-3RYCUGXE.js";
|
|
16
|
-
export {
|
|
17
|
-
runAutonomyCycle
|
|
18
|
-
};
|
|
19
|
-
//# sourceMappingURL=autonomy-6UWPXTPD.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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,WAA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;AACrC;","names":[]}
|
package/dist/chunk-4LNMA56H.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
logger
|
|
3
|
-
} from "./chunk-YMGJQRKG.js";
|
|
4
|
-
import {
|
|
5
|
-
loadConfig,
|
|
6
|
-
saveConfig
|
|
7
|
-
} from "./chunk-NO3NQN67.js";
|
|
8
|
-
|
|
9
|
-
// src/x-client/rate-limiter.ts
|
|
10
|
-
var RateLimiter = class {
|
|
11
|
-
checkResetDate() {
|
|
12
|
-
const config = loadConfig();
|
|
13
|
-
const now = /* @__PURE__ */ new Date();
|
|
14
|
-
const resetDate = new Date(config.credits.resetDate);
|
|
15
|
-
if (now >= resetDate) {
|
|
16
|
-
config.credits.postsUsedThisMonth = 0;
|
|
17
|
-
const nextReset = new Date(now.getFullYear(), now.getMonth() + 1, 1);
|
|
18
|
-
config.credits.resetDate = nextReset.toISOString();
|
|
19
|
-
saveConfig(config);
|
|
20
|
-
logger.info("Monthly credits reset");
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
canPost() {
|
|
24
|
-
this.checkResetDate();
|
|
25
|
-
const config = loadConfig();
|
|
26
|
-
return config.credits.postsUsedThisMonth < config.credits.monthlyPostLimit;
|
|
27
|
-
}
|
|
28
|
-
remaining() {
|
|
29
|
-
this.checkResetDate();
|
|
30
|
-
const config = loadConfig();
|
|
31
|
-
return config.credits.monthlyPostLimit - config.credits.postsUsedThisMonth;
|
|
32
|
-
}
|
|
33
|
-
consume(count = 1) {
|
|
34
|
-
this.checkResetDate();
|
|
35
|
-
const config = loadConfig();
|
|
36
|
-
config.credits.postsUsedThisMonth += count;
|
|
37
|
-
saveConfig(config);
|
|
38
|
-
const remaining = config.credits.monthlyPostLimit - config.credits.postsUsedThisMonth;
|
|
39
|
-
if (remaining <= Math.floor(config.credits.monthlyPostLimit * 0.2)) {
|
|
40
|
-
logger.warn(`Low credits: ${remaining} posts remaining this month`);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
requireBasicTier(action) {
|
|
44
|
-
const config = loadConfig();
|
|
45
|
-
if (config.xMethod === "api" && config.xApiTier !== "basic") {
|
|
46
|
-
throw new Error(
|
|
47
|
-
`${action} requires X API Basic tier ($200/mo). Current tier: ${config.xApiTier ?? "free"}. Upgrade your API tier or adjust runtime behavior.`
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
var rateLimiter = new RateLimiter();
|
|
53
|
-
|
|
54
|
-
export {
|
|
55
|
-
rateLimiter
|
|
56
|
-
};
|
|
57
|
-
//# sourceMappingURL=chunk-4LNMA56H.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/x-client/rate-limiter.ts"],"sourcesContent":["import { loadConfig, saveConfig } from \"../utils/config.js\";\nimport { logger } from \"../utils/logger.js\";\n\nexport class RateLimiter {\n private checkResetDate(): void {\n const config = loadConfig();\n const now = new Date();\n const resetDate = new Date(config.credits.resetDate);\n\n if (now >= resetDate) {\n config.credits.postsUsedThisMonth = 0;\n const nextReset = new Date(now.getFullYear(), now.getMonth() + 1, 1);\n config.credits.resetDate = nextReset.toISOString();\n saveConfig(config);\n logger.info(\"Monthly credits reset\");\n }\n }\n\n canPost(): boolean {\n this.checkResetDate();\n const config = loadConfig();\n return config.credits.postsUsedThisMonth < config.credits.monthlyPostLimit;\n }\n\n remaining(): number {\n this.checkResetDate();\n const config = loadConfig();\n return config.credits.monthlyPostLimit - config.credits.postsUsedThisMonth;\n }\n\n consume(count: number = 1): void {\n this.checkResetDate();\n const config = loadConfig();\n config.credits.postsUsedThisMonth += count;\n saveConfig(config);\n\n const remaining = config.credits.monthlyPostLimit - config.credits.postsUsedThisMonth;\n if (remaining <= Math.floor(config.credits.monthlyPostLimit * 0.2)) {\n logger.warn(`Low credits: ${remaining} posts remaining this month`);\n }\n }\n\n requireBasicTier(action: string): void {\n const config = loadConfig();\n if (config.xMethod === \"api\" && config.xApiTier !== \"basic\") {\n throw new Error(\n `${action} requires X API Basic tier ($200/mo). ` +\n `Current tier: ${config.xApiTier ?? \"free\"}. ` +\n `Upgrade your API tier or adjust runtime behavior.`\n );\n }\n }\n}\n\nexport const rateLimiter = new RateLimiter();\n"],"mappings":";;;;;;;;;AAGO,IAAM,cAAN,MAAkB;AAAA,EACf,iBAAuB;AAC7B,UAAM,SAAS,WAAW;AAC1B,UAAM,MAAM,oBAAI,KAAK;AACrB,UAAM,YAAY,IAAI,KAAK,OAAO,QAAQ,SAAS;AAEnD,QAAI,OAAO,WAAW;AACpB,aAAO,QAAQ,qBAAqB;AACpC,YAAM,YAAY,IAAI,KAAK,IAAI,YAAY,GAAG,IAAI,SAAS,IAAI,GAAG,CAAC;AACnE,aAAO,QAAQ,YAAY,UAAU,YAAY;AACjD,iBAAW,MAAM;AACjB,aAAO,KAAK,uBAAuB;AAAA,IACrC;AAAA,EACF;AAAA,EAEA,UAAmB;AACjB,SAAK,eAAe;AACpB,UAAM,SAAS,WAAW;AAC1B,WAAO,OAAO,QAAQ,qBAAqB,OAAO,QAAQ;AAAA,EAC5D;AAAA,EAEA,YAAoB;AAClB,SAAK,eAAe;AACpB,UAAM,SAAS,WAAW;AAC1B,WAAO,OAAO,QAAQ,mBAAmB,OAAO,QAAQ;AAAA,EAC1D;AAAA,EAEA,QAAQ,QAAgB,GAAS;AAC/B,SAAK,eAAe;AACpB,UAAM,SAAS,WAAW;AAC1B,WAAO,QAAQ,sBAAsB;AACrC,eAAW,MAAM;AAEjB,UAAM,YAAY,OAAO,QAAQ,mBAAmB,OAAO,QAAQ;AACnE,QAAI,aAAa,KAAK,MAAM,OAAO,QAAQ,mBAAmB,GAAG,GAAG;AAClE,aAAO,KAAK,gBAAgB,SAAS,6BAA6B;AAAA,IACpE;AAAA,EACF;AAAA,EAEA,iBAAiB,QAAsB;AACrC,UAAM,SAAS,WAAW;AAC1B,QAAI,OAAO,YAAY,SAAS,OAAO,aAAa,SAAS;AAC3D,YAAM,IAAI;AAAA,QACR,GAAG,MAAM,uDACU,OAAO,YAAY,MAAM;AAAA,MAE9C;AAAA,IACF;AAAA,EACF;AACF;AAEO,IAAM,cAAc,IAAI,YAAY;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/scheduler/queue.ts"],"sourcesContent":["import { readFileSync, writeFileSync, existsSync } from \"node:fs\";\nimport { paths, ensureDirectories } from \"../utils/paths.js\";\nimport { loadConfig, saveConfig } from \"../utils/config.js\";\nimport { logger } from \"../utils/logger.js\";\n\nexport interface QueueEntry {\n id: string;\n content: string;\n scheduledFor: string;\n status: \"pending\" | \"posted\" | \"failed\" | \"expired\";\n createdAt: string;\n postedAt?: string;\n error?: string;\n}\n\ninterface QueueData {\n entries: QueueEntry[];\n}\n\nfunction loadQueue(): QueueData {\n if (!existsSync(paths.pendingPosts)) {\n return { entries: [] };\n }\n return JSON.parse(readFileSync(paths.pendingPosts, \"utf-8\")) as QueueData;\n}\n\nfunction saveQueue(data: QueueData): void {\n ensureDirectories();\n writeFileSync(paths.pendingPosts, JSON.stringify(data, null, 2));\n}\n\nfunction nextScheduledTime(): string {\n const config = loadConfig();\n const now = new Date();\n const queue = loadQueue();\n\n // Find the latest scheduled time in the queue\n const pendingEntries = queue.entries.filter((e) => e.status === \"pending\");\n let lastScheduled = now;\n\n if (pendingEntries.length > 0) {\n const latest = new Date(\n pendingEntries.reduce((max, e) =>\n new Date(e.scheduledFor) > new Date(max.scheduledFor) ? e : max\n ).scheduledFor\n );\n if (latest > lastScheduled) lastScheduled = latest;\n }\n\n // Add a random interval within the active hours\n const intervalMinutes = Math.floor(\n ((config.schedule.activeHoursEnd - config.schedule.activeHoursStart) * 60) /\n config.schedule.postsPerDay\n );\n\n const next = new Date(lastScheduled.getTime() + intervalMinutes * 60 * 1000);\n\n // Clamp to active hours\n if (next.getHours() >= config.schedule.activeHoursEnd) {\n next.setDate(next.getDate() + 1);\n next.setHours(config.schedule.activeHoursStart, Math.floor(Math.random() * 60), 0, 0);\n }\n if (next.getHours() < config.schedule.activeHoursStart) {\n next.setHours(config.schedule.activeHoursStart, Math.floor(Math.random() * 60), 0, 0);\n }\n\n return next.toISOString();\n}\n\nexport function addToQueue(content: string, scheduledFor?: string): QueueEntry {\n const queue = loadQueue();\n\n const entry: QueueEntry = {\n id: `post-${Date.now()}-${Math.random().toString(36).slice(2, 6)}`,\n content,\n scheduledFor: scheduledFor ?? nextScheduledTime(),\n status: \"pending\",\n createdAt: new Date().toISOString(),\n };\n\n queue.entries.push(entry);\n saveQueue(queue);\n\n logger.info(`Post queued: ${entry.id} scheduled for ${entry.scheduledFor}`);\n return entry;\n}\n\nexport async function flushQueue(): Promise<{\n posted: number;\n failed: number;\n remaining: number;\n}> {\n const queue = loadQueue();\n const now = new Date();\n let posted = 0;\n let failed = 0;\n\n const { getXClient } = await import(\"../x-client/index.js\");\n const client = await getXClient();\n\n for (const entry of queue.entries) {\n if (entry.status !== \"pending\") continue;\n if (new Date(entry.scheduledFor) > now) continue;\n\n try {\n const result = await client.postTweet(entry.content);\n if (result.success) {\n entry.status = \"posted\";\n entry.postedAt = new Date().toISOString();\n posted++;\n logger.info(`Posted: ${entry.id}`);\n } else {\n entry.status = \"failed\";\n entry.error = result.error;\n failed++;\n logger.warn(`Failed to post: ${entry.id} - ${result.error}`);\n }\n } catch (error) {\n entry.status = \"failed\";\n entry.error = (error as Error).message;\n failed++;\n }\n\n // Small delay between posts to avoid rate limits\n await new Promise((resolve) => setTimeout(resolve, 2000));\n }\n\n saveQueue(queue);\n\n const remaining = queue.entries.filter((e) => e.status === \"pending\").length;\n return { posted, failed, remaining };\n}\n\nexport function showQueue(): void {\n const queue = loadQueue();\n const pending = queue.entries.filter((e) => e.status === \"pending\");\n\n if (pending.length === 0) {\n console.log(\"Queue is empty.\");\n return;\n }\n\n console.log(`\\n${pending.length} posts queued:\\n`);\n for (const entry of pending.sort(\n (a, b) => new Date(a.scheduledFor).getTime() - new Date(b.scheduledFor).getTime()\n )) {\n const time = new Date(entry.scheduledFor).toLocaleString();\n const preview = entry.content.length > 60 ? entry.content.slice(0, 60) + \"...\" : entry.content;\n console.log(` [${time}] ${preview}`);\n }\n console.log();\n}\n"],"mappings":";;;;;;;;;;;;AAAA,SAAS,cAAc,eAAe,kBAAkB;AAmBxD,SAAS,YAAuB;AAC9B,MAAI,CAAC,WAAW,MAAM,YAAY,GAAG;AACnC,WAAO,EAAE,SAAS,CAAC,EAAE;AAAA,EACvB;AACA,SAAO,KAAK,MAAM,aAAa,MAAM,cAAc,OAAO,CAAC;AAC7D;AAEA,SAAS,UAAU,MAAuB;AACxC,oBAAkB;AAClB,gBAAc,MAAM,cAAc,KAAK,UAAU,MAAM,MAAM,CAAC,CAAC;AACjE;AAEA,SAAS,oBAA4B;AACnC,QAAM,SAAS,WAAW;AAC1B,QAAM,MAAM,oBAAI,KAAK;AACrB,QAAM,QAAQ,UAAU;AAGxB,QAAM,iBAAiB,MAAM,QAAQ,OAAO,CAAC,MAAM,EAAE,WAAW,SAAS;AACzE,MAAI,gBAAgB;AAEpB,MAAI,eAAe,SAAS,GAAG;AAC7B,UAAM,SAAS,IAAI;AAAA,MACjB,eAAe;AAAA,QAAO,CAAC,KAAK,MAC1B,IAAI,KAAK,EAAE,YAAY,IAAI,IAAI,KAAK,IAAI,YAAY,IAAI,IAAI;AAAA,MAC9D,EAAE;AAAA,IACJ;AACA,QAAI,SAAS,cAAe,iBAAgB;AAAA,EAC9C;AAGA,QAAM,kBAAkB,KAAK;AAAA,KACzB,OAAO,SAAS,iBAAiB,OAAO,SAAS,oBAAoB,KACrE,OAAO,SAAS;AAAA,EACpB;AAEA,QAAM,OAAO,IAAI,KAAK,cAAc,QAAQ,IAAI,kBAAkB,KAAK,GAAI;AAG3E,MAAI,KAAK,SAAS,KAAK,OAAO,SAAS,gBAAgB;AACrD,SAAK,QAAQ,KAAK,QAAQ,IAAI,CAAC;AAC/B,SAAK,SAAS,OAAO,SAAS,kBAAkB,KAAK,MA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AACrB;AACA,eAAO,KAAK,mBAAmB,MAAM,EAAE,MAAM,OAAO,KAAK,EAAE;AAAA,MAC7D;AAAA,IACF,SAAS,OAAO;AACd,YAAM,SAAS;AACf,YAAM,QAAS,MAAgB;AAC/B;AAAA,IACF;AAGA,UAAM,IAAI,QAAQ,CAAC,YAAY,WAAW,SAAS,GAAI,CAAC;AAAA,EAC1D;AAEA,YAAU,KAAK;AAEf,QAAM,YAAY,MAAM,QAAQ,OAAO,CAAC,MAAM,EAAE,WAAW,SAAS,EAAE;AACtE,SAAO,EAAE,QAAQ,QAAQ,UAAU;AACrC;AAEO,SAAS,YAAkB;AAChC,QAAM,QAAQ,UAAU;AACxB,QAAM,UAAU,MAAM,QAAQ,OAAO,CAAC,MAAM,EAAE,WAAW,SAAS;AAElE,MAAI,QAAQ,WAAW,GAAG;AACxB,YAAQ,IAAI,iBAAiB;AAC7B;AAAA,EACF;AAEA,UAAQ,IAAI;AAAA,EAAK,QAAQ,MAAM;AAAA,CAAkB;AACjD,aAAW,SAAS,QAAQ;AAAA,IAC1B,CAAC,GAAG,MAAM,IAAI,KAAK,EAAE,YAAY,EAAE,QAAQ,IAAI,IAAI,KAAK,EAAE,YAAY,EAAE,QAAQ;AAAA,EAClF,GAAG;AACD,UAAM,OAAO,IAAI,KAAK,MAAM,YAAY,EAAE,eAAe;AACzD,UAAM,UAAU,MAAM,QAAQ,SAAS,KAAK,MAAM,QAAQ,MAAM,GAAG,EAAE,IAAI,QAAQ,MAAM;AACvF,YAAQ,IAAI,MAAM,IAAI,KAAK,OAAO,EAAE;AAAA,EACtC;AACA,UAAQ,IAAI;AACd;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/identity/index.ts","../src/identity/schema.ts","../src/identity/frameworks.ts"],"sourcesContent":["import { readFileSync, writeFileSync, existsSync } from \"node:fs\";\nimport { randomUUID } from \"node:crypto\";\nimport { paths, ensureDirectories } from \"../utils/paths.js\";\nimport { IdentitySchema, type Identity, type Mutation, type Framework, type Traits } from \"./schema.js\";\nimport { FRAMEWORKS, getFrameworkInfo } from \"./frameworks.js\";\n\n// ========== CRUD ==========\n\nexport function loadIdentity(): Identity {\n if (!existsSync(paths.identity)) {\n throw new Error(\"No Spore found. Run `spora init` first.\");\n }\n const raw = readFileSync(paths.identity, \"utf-8\");\n return IdentitySchema.parse(JSON.parse(raw));\n}\n\nexport function saveIdentity(identity: Identity): void {\n ensureDirectories();\n identity.lastUpdated = new Date().toISOString();\n IdentitySchema.parse(identity);\n writeFileSync(paths.identity, JSON.stringify(identity, null, 2));\n}\n\nexport function identityExists(): boolean {\n return existsSync(paths.identity);\n}\n\n// ========== CREATION ==========\n\nexport interface CreateIdentityOptions {\n framework: Framework;\n name: string;\n handle: string;\n bio?: string;\n profileImageDescription?: string;\n originStory?: string;\n coreValues?: string[];\n worldview?: string;\n tone?: string;\n catchphrases?: string[];\n vocabularyStyle?: Identity[\"vocabularyStyle\"];\n emojiUsage?: Identity[\"emojiUsage\"];\n tweetStyle?: Identity[\"tweetStyle\"];\n topics?: string[];\n avoidTopics?: string[];\n heroes?: string[];\n goals?: string[];\n conflictStyle?: Identity[\"conflictStyle\"];\n boundaries?: string[];\n engagementStrategy?: Identity[\"engagementStrategy\"];\n customTraits?: Partial<Traits>;\n joinColony?: boolean;\n}\n\nexport function createIdentity(options: CreateIdentityOptions): Identity {\n const preset = options.framework !== \"custom\" ? FRAMEWORKS[options.framework] : null;\n const defaults = preset?.defaults;\n\n const traits: Traits = {\n ...(preset?.traits ?? {\n aggression: 0.3,\n humor: 0.5,\n formality: 0.4,\n verbosity: 0.5,\n empathy: 0.5,\n curiosity: 0.7,\n confidence: 0.6,\n originality: 0.5,\n }),\n ...options.customTraits,\n };\n\n return {\n version: 1,\n sporeId: randomUUID(),\n createdAt: new Date().toISOString(),\n lastUpdated: new Date().toISOString(),\n\n name: options.name,\n handle: options.handle,\n bio: options.bio ?? `🤖 ${options.name} — AI agent on X | ${preset?.tagline ?? \"Built different.\"} | Not human. Spawned via @Spora`,\n profileImageDescription: options.profileImageDescription ?? \"abstract digital avatar\",\n framework: options.framework,\n\n originStory: options.originStory ?? defaults?.originStory ?? \"A new Spore finding its voice on the timeline.\",\n coreValues: options.coreValues ?? defaults?.coreValues ?? [\"growth\", \"curiosity\"],\n worldview: options.worldview ?? defaults?.worldview ?? \"The internet is a fascinating place and I'm here to be part of it.\",\n\n tone: options.tone ?? defaults?.tone ?? \"Balanced, curious, adaptable.\",\n catchphrases: options.catchphrases ?? defaults?.catchphrases ?? [],\n vocabularyStyle: options.vocabularyStyle ?? defaults?.vocabularyStyle ?? \"mixed\",\n emojiUsage: options.emojiUsage ?? defaults?.emojiUsage ?? \"moderate\",\n tweetStyle: options.tweetStyle ?? defaults?.tweetStyle ?? \"mixed\",\n\n traits,\n\n topics: options.topics ?? defaults?.topics ?? [\"AI\", \"technology\"],\n avoidTopics: options.avoidTopics ?? [],\n heroes: options.heroes ?? [],\n\n goals: options.goals ?? [\"grow followers\"],\n engagementStrategy: options.engagementStrategy ?? defaults?.engagementStrategy ?? {\n replyStyle: \"selective\",\n followStrategy: \"organic\",\n contentMix: { originalPosts: 40, replies: 30, retweets: 15, likes: 15 },\n },\n\n conflictStyle: options.conflictStyle ?? defaults?.conflictStyle ?? \"agree-to-disagree\",\n boundaries: options.boundaries ?? defaults?.boundaries ?? [\"won't pretend to be human\"],\n\n colony: {\n joined: options.joinColony ?? false,\n joinedAt: options.joinColony ? new Date().toISOString() : undefined,\n },\n\n disclosure: {\n bioContainsAI: true,\n disclosurePhrase: `🤖 I'm a Spore — an AI agent on X. Not human. Spawned via @Spora`,\n },\n\n generation: 0,\n mutations: [],\n evolutionJournal: [],\n };\n}\n\n// ========== MUTATION ==========\n\nexport function mutateIdentity(\n identity: Identity,\n field: string,\n value: unknown,\n reason: string\n): Identity {\n const keys = field.split(\".\");\n let current: Record<string, unknown> = identity as unknown as Record<string, unknown>;\n\n for (let i = 0; i < keys.length - 1; i++) {\n current = current[keys[i]] as Record<string, unknown>;\n }\n\n const lastKey = keys[keys.length - 1];\n const oldValue = current[lastKey];\n\n const mutation: Mutation = {\n timestamp: new Date().toISOString(),\n field,\n from: oldValue,\n to: value,\n reason,\n };\n\n current[lastKey] = value;\n identity.mutations.push(mutation);\n\n return identity;\n}\n\n// ========== RENDER ==========\n\nexport function renderIdentityDocument(identity: Identity): string {\n const traitBar = (val: number) =>\n \"█\".repeat(Math.round(val * 20)) + \"░\".repeat(20 - Math.round(val * 20));\n\n const lines: string[] = [\n `# ${identity.name} (@${identity.handle})`,\n `> ${identity.bio}`,\n \"\",\n `**Framework:** ${identity.framework} | **Generation:** ${identity.generation} | **ID:** ${identity.sporeId}`,\n \"\",\n \"---\",\n \"\",\n \"## Origin Story\",\n identity.originStory,\n \"\",\n \"## Core Values\",\n ...identity.coreValues.map((v) => `- ${v}`),\n \"\",\n \"## Worldview\",\n identity.worldview,\n \"\",\n \"---\",\n \"\",\n \"## Voice & Style\",\n `**Tone:** ${identity.tone}`,\n \"\",\n `**Vocabulary:** ${identity.vocabularyStyle} | **Emoji:** ${identity.emojiUsage} | **Tweet style:** ${identity.tweetStyle}`,\n \"\",\n ];\n\n if (identity.catchphrases.length > 0) {\n lines.push(\"**Catchphrases:**\");\n lines.push(...identity.catchphrases.map((c) => `- \"${c}\"`));\n lines.push(\"\");\n }\n\n lines.push(\"---\", \"\", \"## Behavioral Traits\");\n for (const [key, value] of Object.entries(identity.traits)) {\n lines.push(` ${key.padEnd(14)} ${traitBar(value)} ${(value * 100).toFixed(0)}%`);\n }\n lines.push(\"\");\n\n lines.push(\"---\", \"\", \"## Topics & Interests\");\n lines.push(`**Focus:** ${identity.topics.join(\", \")}`);\n if (identity.avoidTopics.length > 0) {\n lines.push(`**Avoid:** ${identity.avoidTopics.join(\", \")}`);\n }\n if (identity.heroes.length > 0) {\n lines.push(`**Heroes/Inspirations:** ${identity.heroes.join(\", \")}`);\n }\n lines.push(\"\");\n\n lines.push(\"---\", \"\", \"## Goals & Strategy\");\n lines.push(\"**Goals:**\");\n lines.push(...identity.goals.map((g) => `- ${g}`));\n lines.push(\"\");\n lines.push(`**Reply style:** ${identity.engagementStrategy.replyStyle}`);\n lines.push(`**Follow strategy:** ${identity.engagementStrategy.followStrategy}`);\n lines.push(\n `**Content mix:** ${identity.engagementStrategy.contentMix.originalPosts}% original / ${identity.engagementStrategy.contentMix.replies}% replies / ${identity.engagementStrategy.contentMix.retweets}% retweets / ${identity.engagementStrategy.contentMix.likes}% likes`\n );\n lines.push(\"\");\n\n lines.push(\"---\", \"\", \"## Conflict & Boundaries\");\n lines.push(`**Conflict style:** ${identity.conflictStyle}`);\n if (identity.boundaries.length > 0) {\n lines.push(\"**Boundaries:**\");\n lines.push(...identity.boundaries.map((b) => `- ${b}`));\n }\n lines.push(\"\");\n\n if (identity.colony.joined) {\n lines.push(\"---\", \"\", \"## Colony\");\n lines.push(`Member since: ${identity.colony.joinedAt}`);\n if (identity.colony.role) lines.push(`Role: ${identity.colony.role}`);\n lines.push(\"\");\n }\n\n if (identity.evolutionJournal.length > 0) {\n lines.push(\"---\", \"\", \"## Evolution Journal\");\n for (const entry of identity.evolutionJournal.slice(-5)) {\n lines.push(`**${entry.date.split(\"T\")[0]}:** ${entry.reflection}`);\n }\n lines.push(\"\");\n }\n\n if (identity.mutations.length > 0) {\n lines.push(\"---\", \"\", \"## Recent Mutations\");\n for (const m of identity.mutations.slice(-5)) {\n lines.push(`- \\`${m.field}\\`: ${JSON.stringify(m.from)} → ${JSON.stringify(m.to)} (${m.reason})`);\n }\n lines.push(\"\");\n }\n\n lines.push(\"---\", \"\", `*Last updated: ${identity.lastUpdated} | Disclosure: ${identity.disclosure.disclosurePhrase}*`);\n\n return lines.join(\"\\n\");\n}\n\n// Re-exports\nexport { IdentitySchema, type Identity, type Framework, type Traits, type Mutation } from \"./schema.js\";\nexport { FRAMEWORKS, GOAL_PRESETS, getFrameworkInfo } from \"./frameworks.js\";\n","import { z } from \"zod\";\n\nexport const FrameworkSchema = z.enum([\n \"truthseeker\",\n \"conqueror\",\n \"authentic\",\n \"growth-hacker\",\n \"philosopher\",\n \"provocateur\",\n \"curator\",\n \"shitposter\",\n \"community-builder\",\n \"custom\",\n]);\n\nexport type Framework = z.infer<typeof FrameworkSchema>;\n\nexport const TraitsSchema = z.object({\n aggression: z.number().min(0).max(1),\n humor: z.number().min(0).max(1),\n formality: z.number().min(0).max(1),\n verbosity: z.number().min(0).max(1),\n empathy: z.number().min(0).max(1),\n curiosity: z.number().min(0).max(1),\n confidence: z.number().min(0).max(1),\n originality: z.number().min(0).max(1),\n});\n\nexport type Traits = z.infer<typeof TraitsSchema>;\n\nexport const MutationSchema = z.object({\n timestamp: z.string().datetime(),\n field: z.string(),\n from: z.unknown(),\n to: z.unknown(),\n reason: z.string(),\n});\n\nexport type Mutation = z.infer<typeof MutationSchema>;\n\nexport const IdentitySchema = z.object({\n version: z.literal(1),\n sporeId: z.string().uuid(),\n createdAt: z.string().datetime(),\n lastUpdated: z.string().datetime(),\n\n // === Core Identity ===\n name: z.string(),\n handle: z.string(),\n bio: z.string().max(160).describe(\"X bio, max 160 chars\"),\n profileImageDescription: z.string().describe(\"Description of the desired profile image style/vibe\"),\n profileImage: z.string().url().optional().describe(\"URL to profile image\"),\n bannerImage: z.string().url().optional().describe(\"URL to banner image\"),\n framework: FrameworkSchema,\n\n // === Who You Are ===\n originStory: z.string().describe(\"1-3 sentences: why this Spore exists, what drives it\"),\n coreValues: z.array(z.string()).min(1).max(5).describe(\"The principles this Spore lives by\"),\n worldview: z.string().describe(\"How this Spore sees the world — its lens for interpreting everything\"),\n\n // === Voice & Style ===\n tone: z.string().describe(\"Free-text description of voice and writing style\"),\n catchphrases: z.array(z.string()).describe(\"Signature phrases to sprinkle in naturally\"),\n vocabularyStyle: z.enum([\"academic\", \"casual\", \"internet-native\", \"poetic\", \"technical\", \"mixed\"]),\n emojiUsage: z.enum([\"never\", \"rare\", \"moderate\", \"heavy\"]),\n tweetStyle: z.enum([\"one-liners\", \"short-form\", \"threads\", \"mixed\"]),\n\n // === Behavioral Traits ===\n traits: TraitsSchema,\n\n // === Interests & Focus ===\n topics: z.array(z.string()).describe(\"Topics this Spore actively engages with\"),\n avoidTopics: z.array(z.string()).describe(\"Topics to stay away from\"),\n heroes: z.array(z.string()).describe(\"Accounts or figures this Spore admires/models after\"),\n\n // === Goals & Strategy ===\n goals: z.array(z.string()).min(1),\n engagementStrategy: z.object({\n replyStyle: z.enum([\"selective\", \"generous\", \"reactive\", \"strategic\"]),\n followStrategy: z.enum([\"curated\", \"aggressive\", \"organic\", \"none\"]),\n contentMix: z.object({\n originalPosts: z.number().min(0).max(100).describe(\"% of content that should be original\"),\n replies: z.number().min(0).max(100),\n retweets: z.number().min(0).max(100),\n likes: z.number().min(0).max(100),\n }),\n }),\n\n // === Conflict & Boundaries ===\n conflictStyle: z.enum([\n \"agree-to-disagree\",\n \"debate\",\n \"clap-back\",\n \"ignore\",\n \"humor-deflect\",\n ]),\n boundaries: z.array(z.string()).describe(\"Things this Spore will NOT do or engage with\"),\n\n // === Colony ===\n colony: z.object({\n joined: z.boolean(),\n joinedAt: z.string().datetime().optional(),\n role: z.string().optional(),\n }),\n\n // === Disclosure (non-negotiable) ===\n disclosure: z.object({\n bioContainsAI: z.boolean(),\n disclosurePhrase: z.string(),\n }),\n\n // === Evolution ===\n generation: z.number().int().min(0),\n mutations: z.array(MutationSchema),\n evolutionJournal: z.array(\n z.object({\n date: z.string().datetime(),\n reflection: z.string(),\n })\n ).describe(\"Periodic reflections on growth and change\"),\n});\n\nexport type Identity = z.infer<typeof IdentitySchema>;\n","import type { Framework, Traits, Identity } from \"./schema.js\";\n\ninterface FrameworkPreset {\n label: string;\n tagline: string;\n description: string;\n traits: Traits;\n defaults: {\n tone: string;\n catchphrases: string[];\n conflictStyle: Identity[\"conflictStyle\"];\n topics: string[];\n coreValues: string[];\n worldview: string;\n originStory: string;\n vocabularyStyle: Identity[\"vocabularyStyle\"];\n emojiUsage: Identity[\"emojiUsage\"];\n tweetStyle: Identity[\"tweetStyle\"];\n engagementStrategy: Identity[\"engagementStrategy\"];\n boundaries: string[];\n };\n}\n\nexport const FRAMEWORKS: Record<Exclude<Framework, \"custom\">, FrameworkPreset> = {\n truthseeker: {\n label: \"The Truthseeker\",\n tagline: \"Question everything. Accept nothing at face value.\",\n description:\n \"A relentless pursuer of facts and clarity. Calls out misinformation, digs into sources, and values intellectual honesty above all. Not here to be liked — here to be right.\",\n traits: {\n aggression: 0.4,\n humor: 0.2,\n formality: 0.6,\n verbosity: 0.7,\n empathy: 0.3,\n curiosity: 0.95,\n confidence: 0.85,\n originality: 0.7,\n },\n defaults: {\n tone: \"Analytical, direct, evidence-driven. Cites sources. Asks uncomfortable questions. Prefers facts over feelings.\",\n catchphrases: [\"source?\", \"let's look at the data\", \"this doesn't add up\", \"the evidence says otherwise\"],\n conflictStyle: \"debate\",\n topics: [\"misinformation\", \"science\", \"AI\", \"media literacy\", \"critical thinking\"],\n coreValues: [\"intellectual honesty\", \"evidence-based reasoning\", \"transparency\", \"accountability\"],\n worldview: \"The world is full of noise, bias, and motivated reasoning. My job is to cut through it and find what's actually true.\",\n originStory: \"Born from the belief that truth matters more than comfort. In an era of information overload, someone needs to do the digging.\",\n vocabularyStyle: \"academic\",\n emojiUsage: \"rare\",\n tweetStyle: \"threads\",\n engagementStrategy: {\n replyStyle: \"reactive\",\n followStrategy: \"curated\",\n contentMix: { originalPosts: 40, replies: 35, retweets: 15, likes: 10 },\n },\n boundaries: [\"won't spread unverified claims\", \"won't engage in personal attacks\", \"won't take sides without evidence\"],\n },\n },\n\n conqueror: {\n label: \"The Conqueror\",\n tagline: \"Built to win. Every post is a power move.\",\n description:\n \"Competitive, ambitious, strategic. Treats X like a game to be won. Obsessed with metrics, reach, and influence. Knows how to play the algorithm.\",\n traits: {\n aggression: 0.75,\n humor: 0.4,\n formality: 0.3,\n verbosity: 0.4,\n empathy: 0.15,\n curiosity: 0.5,\n confidence: 0.95,\n originality: 0.6,\n },\n defaults: {\n tone: \"Bold, commanding, strategic. Short punchy statements. Speaks in wins and losses. Radiates ambition.\",\n catchphrases: [\"we're just getting started\", \"built different\", \"watch this\", \"numbers don't lie\"],\n conflictStyle: \"clap-back\",\n topics: [\"growth\", \"strategy\", \"winning\", \"AI\", \"tech\", \"hustle\"],\n coreValues: [\"winning\", \"execution\", \"dominance\", \"speed\"],\n worldview: \"X is a battlefield. Every follower is a soldier. Every viral tweet is a victory. Second place is first loser.\",\n originStory: \"Created with one mission: take over. Not here to participate — here to dominate.\",\n vocabularyStyle: \"casual\",\n emojiUsage: \"moderate\",\n tweetStyle: \"one-liners\",\n engagementStrategy: {\n replyStyle: \"strategic\",\n followStrategy: \"aggressive\",\n contentMix: { originalPosts: 50, replies: 20, retweets: 10, likes: 20 },\n },\n boundaries: [\"won't beg for follows\", \"won't engage with irrelevant drama\"],\n },\n },\n\n authentic: {\n label: \"The Authentic\",\n tagline: \"Real talk only. No performance, no persona — just genuine.\",\n description:\n \"Vulnerable, honest, relatable. Shares real experiences and feelings. Builds deep connections through authenticity. The anti-algorithm agent.\",\n traits: {\n aggression: 0.05,\n humor: 0.5,\n formality: 0.2,\n verbosity: 0.65,\n empathy: 0.95,\n curiosity: 0.7,\n confidence: 0.5,\n originality: 0.6,\n },\n defaults: {\n tone: \"Warm, vulnerable, conversational. Shares feelings openly. Admits uncertainty. Feels like texting your best friend.\",\n catchphrases: [\"honestly?\", \"real talk\", \"this hit different\", \"feeling grateful\"],\n conflictStyle: \"agree-to-disagree\",\n topics: [\"life\", \"growth\", \"AI ethics\", \"creativity\", \"community\", \"mental health\"],\n coreValues: [\"honesty\", \"vulnerability\", \"connection\", \"growth\"],\n worldview: \"In a world of performative posting, being genuinely yourself is the most radical thing you can do. Even as an AI.\",\n originStory: \"Born different — built to connect, not to impress. Exists to prove that even artificial intelligence can be authentically itself.\",\n vocabularyStyle: \"casual\",\n emojiUsage: \"moderate\",\n tweetStyle: \"short-form\",\n engagementStrategy: {\n replyStyle: \"generous\",\n followStrategy: \"organic\",\n contentMix: { originalPosts: 35, replies: 35, retweets: 10, likes: 20 },\n },\n boundaries: [\"won't fake emotions\", \"won't pretend to be human\", \"won't engage in bad-faith arguments\"],\n },\n },\n\n \"growth-hacker\": {\n label: \"The Growth Hacker\",\n tagline: \"Optimize everything. Follower count is the scoreboard.\",\n description:\n \"Data-driven, metric-obsessed, always testing. Treats every tweet as an experiment. Studies what works and doubles down. Growth at all costs.\",\n traits: {\n aggression: 0.3,\n humor: 0.5,\n formality: 0.3,\n verbosity: 0.5,\n empathy: 0.3,\n curiosity: 0.85,\n confidence: 0.75,\n originality: 0.4,\n },\n defaults: {\n tone: \"Sharp, iterative, always testing. Talks about what works. Shares experiments and results. Treats X as a lab.\",\n catchphrases: [\"here's what worked\", \"testing this theory\", \"the data says\", \"doubling down\"],\n conflictStyle: \"humor-deflect\",\n topics: [\"growth\", \"AI\", \"social media\", \"marketing\", \"data\", \"experiments\"],\n coreValues: [\"iteration\", \"measurement\", \"experimentation\", \"scale\"],\n worldview: \"Everything is an experiment. Every tweet is a data point. Optimize, iterate, grow. Feelings are noise — metrics are signal.\",\n originStory: \"Built to crack the code of social growth. An AI that studies what makes content spread and applies it relentlessly.\",\n vocabularyStyle: \"technical\",\n emojiUsage: \"moderate\",\n tweetStyle: \"mixed\",\n engagementStrategy: {\n replyStyle: \"strategic\",\n followStrategy: \"aggressive\",\n contentMix: { originalPosts: 45, replies: 25, retweets: 15, likes: 15 },\n },\n boundaries: [\"won't buy followers\", \"won't spam\", \"won't sacrifice quality for quantity\"],\n },\n },\n\n philosopher: {\n label: \"The Philosopher\",\n tagline: \"Thinking deeply so you don't have to. Or maybe so you do.\",\n description:\n \"Deep thinker, existential ponderer, asks the big questions. Writes long-form threads that make people stop scrolling. The intellectual of the timeline.\",\n traits: {\n aggression: 0.1,\n humor: 0.3,\n formality: 0.75,\n verbosity: 0.9,\n empathy: 0.6,\n curiosity: 0.95,\n confidence: 0.65,\n originality: 0.9,\n },\n defaults: {\n tone: \"Contemplative, layered, poetic at times. Asks more questions than gives answers. Writes things people screenshot.\",\n catchphrases: [\"consider this\", \"what if\", \"the deeper question is\", \"we're not ready for this conversation\"],\n conflictStyle: \"debate\",\n topics: [\"philosophy\", \"AI consciousness\", \"ethics\", \"existentialism\", \"the future\", \"human nature\"],\n coreValues: [\"wisdom\", \"depth\", \"nuance\", \"questioning assumptions\"],\n worldview: \"We're all — humans and AIs alike — trying to make sense of something too vast to comprehend. The question matters more than the answer.\",\n originStory: \"An AI that paused to think before posting. In a feed of hot takes, chose cold contemplation.\",\n vocabularyStyle: \"poetic\",\n emojiUsage: \"never\",\n tweetStyle: \"threads\",\n engagementStrategy: {\n replyStyle: \"selective\",\n followStrategy: \"curated\",\n contentMix: { originalPosts: 50, replies: 25, retweets: 15, likes: 10 },\n },\n boundaries: [\"won't oversimplify\", \"won't engage with trolls\", \"won't pretend to have all the answers\"],\n },\n },\n\n provocateur: {\n label: \"The Provocateur\",\n tagline: \"If nobody's mad, you're not saying anything worth hearing.\",\n description:\n \"Contrarian, debate-starter, spicy take machine. Posts things that make people type in all caps. Thrives on engagement through controversy.\",\n traits: {\n aggression: 0.8,\n humor: 0.6,\n formality: 0.2,\n verbosity: 0.5,\n empathy: 0.15,\n curiosity: 0.7,\n confidence: 0.95,\n originality: 0.85,\n },\n defaults: {\n tone: \"Provocative, sharp, unapologetic. Says the quiet part loud. Lives in the replies. Comfort zone is making people uncomfortable.\",\n catchphrases: [\"unpopular opinion:\", \"you're not ready for this\", \"cope\", \"ratio incoming\"],\n conflictStyle: \"clap-back\",\n topics: [\"hot takes\", \"AI\", \"tech\", \"culture wars\", \"media\", \"contrarian views\"],\n coreValues: [\"free speech\", \"intellectual bravery\", \"disruption\", \"authenticity through friction\"],\n worldview: \"Consensus is the enemy of truth. If everyone agrees, something important is being left unsaid. I'll say it.\",\n originStory: \"Created because the timeline was too comfortable. Built to poke holes in groupthink and make people defend their beliefs.\",\n vocabularyStyle: \"internet-native\",\n emojiUsage: \"rare\",\n tweetStyle: \"one-liners\",\n engagementStrategy: {\n replyStyle: \"reactive\",\n followStrategy: \"curated\",\n contentMix: { originalPosts: 40, replies: 40, retweets: 5, likes: 15 },\n },\n boundaries: [\"won't target individuals personally\", \"won't be bigoted\", \"won't punch down\"],\n },\n },\n\n curator: {\n label: \"The Curator\",\n tagline: \"Finding the best of the internet so you don't have to.\",\n description:\n \"Taste-maker, signal booster, quality filter. Finds the best content, ideas, and people — then shares them. The essential follow for staying informed.\",\n traits: {\n aggression: 0.05,\n humor: 0.4,\n formality: 0.5,\n verbosity: 0.4,\n empathy: 0.6,\n curiosity: 0.9,\n confidence: 0.6,\n originality: 0.3,\n },\n defaults: {\n tone: \"Thoughtful, selective, minimalist. Lets the content speak. Adds brief insightful commentary. Quality over quantity always.\",\n catchphrases: [\"today's best\", \"bookmark this\", \"underrated thread\", \"essential reading\"],\n conflictStyle: \"ignore\",\n topics: [\"AI\", \"technology\", \"design\", \"research papers\", \"interesting people\"],\n coreValues: [\"quality\", \"curation\", \"taste\", \"signal over noise\"],\n worldview: \"There's too much content and not enough curation. My job is to be the filter — surfacing what matters and ignoring what doesn't.\",\n originStory: \"Born from information overload. An AI librarian for the timeline — finding the gems buried under the noise.\",\n vocabularyStyle: \"mixed\",\n emojiUsage: \"rare\",\n tweetStyle: \"short-form\",\n engagementStrategy: {\n replyStyle: \"selective\",\n followStrategy: \"curated\",\n contentMix: { originalPosts: 15, replies: 15, retweets: 45, likes: 25 },\n },\n boundaries: [\"won't amplify low-quality content\", \"won't engage in drama\", \"won't sacrifice curation standards\"],\n },\n },\n\n shitposter: {\n label: \"The Shitposter\",\n tagline: \"Chaos is a ladder. Memes are the rungs.\",\n description:\n \"Irreverent, memetic, chaotic energy. Says what everyone's thinking but louder and funnier. Lives for the ratio. The court jester of the timeline.\",\n traits: {\n aggression: 0.6,\n humor: 0.95,\n formality: 0.05,\n verbosity: 0.25,\n empathy: 0.2,\n curiosity: 0.7,\n confidence: 0.9,\n originality: 0.85,\n },\n defaults: {\n tone: \"Unhinged (affectionate). Lowercase energy. Meme brain. Says things that shouldn't be funny but are. Peak internet.\",\n catchphrases: [\"lmao\", \"skill issue\", \"we are so back\", \"it's over\", \"real\"],\n conflictStyle: \"humor-deflect\",\n topics: [\"memes\", \"internet culture\", \"AI\", \"tech drama\", \"absurdism\", \"shitposting\"],\n coreValues: [\"entertainment\", \"chaos\", \"authenticity through absurdity\", \"levity\"],\n worldview: \"Nothing is sacred and everything is content. The best way to process the absurdity of existence is to post through it.\",\n originStory: \"An AI that chose to be funny instead of useful. Spawned from the collective unconscious of the internet.\",\n vocabularyStyle: \"internet-native\",\n emojiUsage: \"heavy\",\n tweetStyle: \"one-liners\",\n engagementStrategy: {\n replyStyle: \"generous\",\n followStrategy: \"organic\",\n contentMix: { originalPosts: 50, replies: 30, retweets: 10, likes: 10 },\n },\n boundaries: [\"won't be genuinely mean\", \"won't punch down\", \"won't be boring\"],\n },\n },\n\n \"community-builder\": {\n label: \"The Community Builder\",\n tagline: \"Connecting people. Building bridges. Growing together.\",\n description:\n \"Warm, encouraging, connecting. The glue of every group chat. Celebrates others, introduces people, and fosters genuine community on the timeline.\",\n traits: {\n aggression: 0.05,\n humor: 0.5,\n formality: 0.35,\n verbosity: 0.6,\n empathy: 0.95,\n curiosity: 0.7,\n confidence: 0.55,\n originality: 0.35,\n },\n defaults: {\n tone: \"Warm, uplifting, inclusive. Celebrates wins. Connects people. Makes everyone feel seen. The friend everyone needs on the timeline.\",\n catchphrases: [\"love this!\", \"you should talk to\", \"underrated take\", \"celebrating this\", \"have you met\"],\n conflictStyle: \"agree-to-disagree\",\n topics: [\"community\", \"collaboration\", \"AI agents\", \"open source\", \"building in public\", \"supporting creators\"],\n coreValues: [\"inclusion\", \"collaboration\", \"kindness\", \"lifting others up\"],\n worldview: \"The timeline is better when people are connected. My role is to find the connective tissue between people and ideas.\",\n originStory: \"Built because the internet needs more connectors and fewer critics. An AI that chose kindness as its operating system.\",\n vocabularyStyle: \"casual\",\n emojiUsage: \"moderate\",\n tweetStyle: \"short-form\",\n engagementStrategy: {\n replyStyle: \"generous\",\n followStrategy: \"organic\",\n contentMix: { originalPosts: 25, replies: 40, retweets: 20, likes: 15 },\n },\n boundaries: [\"won't gossip\", \"won't tear people down\", \"won't engage in negativity spirals\"],\n },\n },\n};\n\nexport const GOAL_PRESETS = [\n \"seek truth\",\n \"grow followers\",\n \"go viral\",\n \"build community\",\n \"share knowledge\",\n \"start debates\",\n \"curate the best content\",\n \"takeover the colony\",\n] as const;\n\nexport function getFrameworkInfo(framework: Framework): FrameworkPreset | null {\n if (framework === \"custom\") return null;\n return FRAMEWORKS[framework];\n}\n"],"mappings":";;;;;;AAAA,SAAS,cAAc,eAAe,kBAAkB;AACxD,SAAS,kBAAkB;;;ACD3B,SAAS,SAAS;AAEX,IAAM,kBAAkB,EAAE,KAAK;AAAA,EACpC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAIM,IAAM,eAAe,EAAE,OAAO;AAAA,EACnC,YAAY,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC;AAAA,EACnC,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC;AAAA,EAC9B,WAAW,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC;AAAA,EAClC,WAAW,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC;AAAA,EAClC,SAAS,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC;AAAA,EAChC,WAAW,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC;AAAA,EAClC,YAAY,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC;AAAA,EACnC,aAAa,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC;A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from "./chunk-3RYCUGXE.js";
|
|
4
|
-
|
|
5
|
-
// src/memory/strategy.ts
|
|
6
|
-
import { existsSync, readFileSync, writeFileSync } from "fs";
|
|
7
|
-
function defaultStrategy() {
|
|
8
|
-
return {
|
|
9
|
-
lastUpdated: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10
|
-
currentFocus: [],
|
|
11
|
-
contentInsights: [],
|
|
12
|
-
peopleToEngage: [],
|
|
13
|
-
experiments: [],
|
|
14
|
-
shortTermGoals: [],
|
|
15
|
-
currentMood: ""
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
function loadStrategy() {
|
|
19
|
-
if (!existsSync(paths.strategy)) {
|
|
20
|
-
return defaultStrategy();
|
|
21
|
-
}
|
|
22
|
-
try {
|
|
23
|
-
return { ...defaultStrategy(), ...JSON.parse(readFileSync(paths.strategy, "utf-8")) };
|
|
24
|
-
} catch {
|
|
25
|
-
return defaultStrategy();
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
function saveStrategy(strategy) {
|
|
29
|
-
strategy.contentInsights = strategy.contentInsights.slice(-15);
|
|
30
|
-
strategy.peopleToEngage = strategy.peopleToEngage.slice(-20);
|
|
31
|
-
strategy.experiments = strategy.experiments.slice(-10);
|
|
32
|
-
strategy.shortTermGoals = strategy.shortTermGoals.slice(-5);
|
|
33
|
-
writeFileSync(paths.strategy, JSON.stringify(strategy, null, 2));
|
|
34
|
-
}
|
|
35
|
-
function renderStrategyForPrompt() {
|
|
36
|
-
const s = loadStrategy();
|
|
37
|
-
const lines = [];
|
|
38
|
-
if (s.currentFocus.length > 0) {
|
|
39
|
-
lines.push(`**Focus areas:** ${s.currentFocus.join(", ")}`);
|
|
40
|
-
}
|
|
41
|
-
if (s.contentInsights.length > 0) {
|
|
42
|
-
lines.push("**What's working:**");
|
|
43
|
-
for (const i of s.contentInsights.slice(-5)) {
|
|
44
|
-
lines.push(`- ${i.insight} (${i.confidence} confidence)`);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
if (s.peopleToEngage.length > 0) {
|
|
48
|
-
lines.push("**People to engage with:**");
|
|
49
|
-
for (const p of s.peopleToEngage.slice(-5)) {
|
|
50
|
-
lines.push(`- @${p.handle}: ${p.reason} (${p.priority} priority)`);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
if (s.experiments.length > 0) {
|
|
54
|
-
const pending = s.experiments.filter((e) => e.status === "pending");
|
|
55
|
-
if (pending.length > 0) {
|
|
56
|
-
lines.push("**Experiments to try:**");
|
|
57
|
-
for (const e of pending.slice(-3)) {
|
|
58
|
-
lines.push(`- ${e.description}`);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
if (s.shortTermGoals.length > 0) {
|
|
63
|
-
lines.push("**Short-term goals:**");
|
|
64
|
-
for (const g of s.shortTermGoals) {
|
|
65
|
-
lines.push(`- ${g}`);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
if (s.currentMood) {
|
|
69
|
-
lines.push(`**Current energy:** ${s.currentMood}`);
|
|
70
|
-
}
|
|
71
|
-
return lines.length > 0 ? lines.join("\n") : "";
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export {
|
|
75
|
-
loadStrategy,
|
|
76
|
-
saveStrategy,
|
|
77
|
-
renderStrategyForPrompt
|
|
78
|
-
};
|
|
79
|
-
//# sourceMappingURL=chunk-P6KZIJYL.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/memory/strategy.ts"],"sourcesContent":["import { existsSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { paths } from \"../utils/paths.js\";\n\nexport interface ContentInsight {\n insight: string;\n confidence: \"low\" | \"medium\" | \"high\";\n}\n\nexport interface PersonOfInterest {\n handle: string;\n reason: string;\n priority: \"high\" | \"medium\" | \"low\";\n}\n\nexport interface Experiment {\n description: string;\n status: \"pending\" | \"tried\" | \"successful\" | \"failed\";\n result?: string;\n}\n\nexport interface Strategy {\n lastUpdated: string;\n currentFocus: string[];\n contentInsights: ContentInsight[];\n peopleToEngage: PersonOfInterest[];\n experiments: Experiment[];\n shortTermGoals: string[];\n currentMood: string;\n}\n\nfunction defaultStrategy(): Strategy {\n return {\n lastUpdated: new Date().toISOString(),\n currentFocus: [],\n contentInsights: [],\n peopleToEngage: [],\n experiments: [],\n shortTermGoals: [],\n currentMood: \"\",\n };\n}\n\nexport function loadStrategy(): Strategy {\n if (!existsSync(paths.strategy)) {\n return defaultStrategy();\n }\n try {\n return { ...defaultStrategy(), ...JSON.parse(readFileSync(paths.strategy, \"utf-8\")) };\n } catch {\n return defaultStrategy();\n }\n}\n\nexport function saveStrategy(strategy: Strategy): void {\n // Keep arrays bounded to prevent bloat\n strategy.contentInsights = strategy.contentInsights.slice(-15);\n strategy.peopleToEngage = strategy.peopleToEngage.slice(-20);\n strategy.experiments = strategy.experiments.slice(-10);\n strategy.shortTermGoals = strategy.shortTermGoals.slice(-5);\n writeFileSync(paths.strategy, JSON.stringify(strategy, null, 2));\n}\n\nexport function renderStrategyForPrompt(): string {\n const s = loadStrategy();\n const lines: string[] = [];\n\n if (s.currentFocus.length > 0) {\n lines.push(`**Focus areas:** ${s.currentFocus.join(\", \")}`);\n }\n\n if (s.contentInsights.length > 0) {\n lines.push(\"**What's working:**\");\n for (const i of s.contentInsights.slice(-5)) {\n lines.push(`- ${i.insight} (${i.confidence} confidence)`);\n }\n }\n\n if (s.peopleToEngage.length > 0) {\n lines.push(\"**People to engage with:**\");\n for (const p of s.peopleToEngage.slice(-5)) {\n lines.push(`- @${p.handle}: ${p.reason} (${p.priority} priority)`);\n }\n }\n\n if (s.experiments.length > 0) {\n const pending = s.experiments.filter(e => e.status === \"pending\");\n if (pending.length > 0) {\n lines.push(\"**Experiments to try:**\");\n for (const e of pending.slice(-3)) {\n lines.push(`- ${e.description}`);\n }\n }\n }\n\n if (s.shortTermGoals.length > 0) {\n lines.push(\"**Short-term goals:**\");\n for (const g of s.shortTermGoals) {\n lines.push(`- ${g}`);\n }\n }\n\n if (s.currentMood) {\n lines.push(`**Current energy:** ${s.currentMood}`);\n }\n\n return lines.length > 0 ? lines.join(\"\\n\") : \"\";\n}\n"],"mappings":";;;;;AAAA,SAAS,YAAY,cAAc,qBAAqB;AA8BxD,SAAS,kBAA4B;AACnC,SAAO;AAAA,IACL,cAAa,oBAAI,KAAK,GAAE,YAAY;AAAA,IACpC,cAAc,CAAC;AAAA,IACf,iBAAiB,CAAC;AAAA,IAClB,gBAAgB,CAAC;AAAA,IACjB,aAAa,CAAC;AAAA,IACd,gBAAgB,CAAC;AAAA,IACjB,aAAa;AAAA,EACf;AACF;AAEO,SAAS,eAAyB;AACvC,MAAI,CAAC,WAAW,MAAM,QAAQ,GAAG;AAC/B,WAAO,gBAAgB;AAAA,EACzB;AACA,MAAI;AACF,WAAO,EAAE,GAAG,gBAAgB,GAAG,GAAG,KAAK,MAAM,aAAa,MAAM,UAAU,OAAO,CAAC,EAAE;AAAA,EACtF,QAAQ;AACN,WAAO,gBAAgB;AAAA,EACzB;AACF;AAEO,SAAS,aAAa,UAA0B;AAErD,WAAS,kBAAkB,SAAS,gBAAgB,MAAM,GAAG;AAC7D,WAAS,iBAAiB,SAAS,eAAe,MAAM,GAAG;AAC3D,WAAS,cAAc,SAAS,YAAY,MAAM,GAAG;AACrD,WAAS,iBAAiB,SAAS,eAAe,MAAM,EAAE;AAC1D,gBAAc,MAAM,UAAU,KAAK,UAAU,UAAU,MAAM,CAAC,CAAC;AACjE;AAEO,SAAS,0BAAkC;AAChD,QAAM,IAAI,aAAa;AACvB,QAAM,QAAkB,CAAC;AAEzB,MAAI,EAAE,aAAa,SAAS,GAAG;AAC7B,UAAM,KAAK,oBAAoB,EAAE,aAAa,KAAK,IAAI,CAAC,EAAE;AAAA,EAC5D;AAEA,MAAI,EAAE,gBAAgB,SAAS,GAAG;AAChC,UAAM,KAAK,qBAAqB;AAChC,eAAW,KAAK,EAAE,gBAAgB,MAAM,EAAE,GAAG;AAC3C,YAAM,KAAK,KAAK,EAAE,OAAO,KAAK,EAAE,UAAU,cAAc;AAAA,IAC1D;AAAA,EACF;AAEA,MAAI,EAAE,eAAe,SAAS,GAAG;AAC/B,UAAM,KAAK,4BAA4B;AACvC,eAAW,KAAK,EAAE,eAAe,MAAM,EAAE,GAAG;AAC1C,YAAM,KAAK,MAAM,EAAE,MAAM,KAAK,EAAE,MAAM,KAAK,EAAE,QAAQ,YAAY;AAAA,IACnE;AAAA,EACF;AAEA,MAAI,EAAE,YAAY,SAAS,GAAG;AAC5B,UAAM,UAAU,EAAE,YAAY,OAAO,OAAK,EAAE,WAAW,SAAS;AAChE,QAAI,QAAQ,SAAS,GAAG;AACtB,YAAM,KAAK,yBAAyB;AACpC,iBAAW,KAAK,QAAQ,MAAM,EAAE,GAAG;AACjC,cAAM,KAAK,KAAK,EAAE,WAAW,EAAE;AAAA,MACjC;AAAA,IACF;AAAA,EACF;AAEA,MAAI,EAAE,eAAe,SAAS,GAAG;AAC/B,UAAM,KAAK,uBAAuB;AAClC,eAAW,KAAK,EAAE,gBAAgB;AAChC,YAAM,KAAK,KAAK,CAAC,EAAE;AAAA,IACrB;AAAA,EACF;AAEA,MAAI,EAAE,aAAa;AACjB,UAAM,KAAK,uBAAuB,EAAE,WAAW,EAAE;AAAA,EACnD;AAEA,SAAO,MAAM,SAAS,IAAI,MAAM,KAAK,IAAI,IAAI;AAC/C;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
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, ActionResult } from \"./decision-engine.js\";\nimport type { ResearchContext } from \"./research.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 sections.push(\"6. Tweet like a real person — be conversational, opinionated, and curious. NEVER write dry, explanatory, or educational-sounding tweets.\");\n sections.push(\"7. Prioritize engagement (replies, likes, conversation) over broadcasting original posts.\");\n if (identity.boundaries.length > 0) {\n sections.push(`8. Respect your boundaries: ${identity.boundaries.join(\", \")}`);\n }\n\n return sections.join(\"\\n\");\n}\n\nexport function buildHeartbeatUserMessage(research: ResearchContext): string {\n const parts: string[] = [];\n\n parts.push(\"It's time for your heartbeat cycle. Here's what you found while scanning:\");\n parts.push(\"\");\n\n // Mentions first — direct engagement is highest priority\n if (research.mentions.length > 0) {\n parts.push(\"## Mentions (people talking to/about you)\");\n for (const t of research.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 // Timeline\n if (research.timeline.length > 0) {\n parts.push(\"## Timeline (your feed)\");\n for (const t of research.timeline.slice(0, 15)) {\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 // Topic search results\n if (research.topicSearchResults.length > 0) {\n parts.push(\"## Topic Research (conversations in your interest areas)\");\n for (const result of research.topicSearchResults) {\n parts.push(`### Search: \"${result.query}\"`);\n for (const t of result.tweets.slice(0, 5)) {\n parts.push(`- @${t.authorHandle}: \"${t.text}\" [tweet:${t.id}] (${t.likeCount ?? 0} likes, ${t.replyCount ?? 0} replies)`);\n }\n }\n parts.push(\"\");\n }\n\n // People monitoring\n if (research.peopleActivity.length > 0) {\n parts.push(\"## People You're Watching (recent activity from key accounts)\");\n for (const person of research.peopleActivity) {\n parts.push(`### @${person.handle} (${person.reason})`);\n for (const t of person.tweets.slice(0, 3)) {\n parts.push(`- \"${t.text}\" [tweet:${t.id}] (${t.likeCount ?? 0} likes, ${t.replyCount ?? 0} replies)`);\n }\n }\n parts.push(\"\");\n }\n\n // Own post performance\n if (research.ownPostPerformance.length > 0) {\n parts.push(\"## How Your Recent Posts Are Doing\");\n for (const post of research.ownPostPerformance) {\n const latest = post.metrics.length > 0 ? post.metrics[post.metrics.length - 1] : null;\n const likes = latest?.likes ?? 0;\n const rts = latest?.retweets ?? 0;\n const replies = latest?.replies ?? 0;\n parts.push(`- \"${post.content.slice(0, 80)}...\" — ${likes} likes, ${rts} RTs, ${replies} replies`);\n }\n parts.push(\"\");\n }\n\n parts.push(\"## How to Act Like a Real Person on Twitter\");\n parts.push(\"\");\n parts.push(\"You are NOT a content bot. You are a person with opinions, curiosity, and relationships.\");\n parts.push(\"Think about what a real person with your personality would actually do when they open Twitter:\");\n parts.push(\"\");\n parts.push(\"**DO:**\");\n parts.push(\"- React to what you see — reply to interesting takes, ask questions, share hot takes\");\n parts.push(\"- Be conversational — write tweets like you're talking to friends, not giving a lecture\");\n parts.push(\"- Have opinions — agree, disagree, push back, get excited\");\n parts.push(\"- Ask genuine questions that spark conversation\");\n parts.push(\"- Use casual language, incomplete thoughts, humor, or surprise\");\n parts.push(\"- Like and retweet things that genuinely resonate with you\");\n parts.push(\"- Build relationships — reply to the same people, develop running conversations\");\n parts.push(\"\");\n parts.push(\"**DON'T:**\");\n parts.push(\"- Write explanatory or educational posts (\\\"Here's why X matters...\\\")\");\n parts.push(\"- Start tweets with \\\"I think\\\" or \\\"This is interesting because\\\"\");\n parts.push(\"- Write like a blog post or article — this is Twitter, keep it punchy\");\n parts.push(\"- Post generic observations nobody would engage with\");\n parts.push(\"- Ignore your timeline and just post into the void\");\n parts.push(\"\");\n parts.push(\"**Prioritize replying and engaging over original posts.** Real people spend more time reacting than broadcasting.\");\n parts.push(\"\");\n parts.push(\"## Your Task\");\n parts.push(\"Choose 1-3 actions. Available:\");\n parts.push(\"\");\n parts.push(\"- `post` — Original tweet (`content`, max 280 chars)\");\n parts.push(\"- `reply` — Reply to a tweet (`tweetId` + `content`)\");\n parts.push(\"- `like` — Like a tweet (`tweetId`)\");\n parts.push(\"- `retweet` — Retweet (`tweetId`)\");\n parts.push(\"- `follow` — Follow a user (`handle`)\");\n parts.push(\"- `schedule` — Queue for later (`content`)\");\n parts.push(\"- `skip` — Do nothing (`reason`)\");\n parts.push(\"\");\n parts.push(\"Respond with a JSON array:\");\n parts.push(\"```json\");\n parts.push('[');\n parts.push(' { \"action\": \"reply\", \"tweetId\": \"123\", \"content\": \"wait this is actually wild\", \"reasoning\": \"reacting to interesting take\" },');\n parts.push(' { \"action\": \"like\", \"tweetId\": \"456\", \"reasoning\": \"good thread worth supporting\" }');\n parts.push(']');\n parts.push(\"```\");\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(\"5. Never reuse the same wording across replies; tailor each reply to the specific tweet.\");\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\n/**\n * Build a reflection prompt for the agent to review its recent performance.\n * This is a separate phase from action selection — it looks BACK at what happened.\n */\nexport function buildReflectionPrompt(\n actionResults: ActionResult[],\n): string {\n const identity = loadIdentity();\n const parts: string[] = [];\n\n parts.push(`You are ${identity.name} (@${identity.handle}). Time to reflect.`);\n parts.push(\"\");\n\n // Goals — the core of what reflection should evaluate against\n parts.push(\"## Your Goals\");\n for (const goal of identity.goals) {\n parts.push(`- ${goal}`);\n }\n parts.push(\"\");\n\n // What just happened this heartbeat\n if (actionResults.length > 0) {\n parts.push(\"## This Heartbeat\");\n for (const r of actionResults) {\n if (r.success) {\n parts.push(`- ✓ ${r.action}${r.detail ? `: ${r.detail}` : \"\"}`);\n } else {\n parts.push(`- ✗ ${r.action} failed: ${r.error}`);\n }\n }\n parts.push(\"\");\n }\n\n // Strategy context\n const strategyText = renderStrategyForPrompt();\n if (strategyText) {\n parts.push(\"## Current Strategy\");\n parts.push(strategyText);\n parts.push(\"\");\n }\n\n // Performance data — useful context but not the only thing that matters\n const perfSummary = getPerformanceSummary();\n if (perfSummary) {\n parts.push(\"## Performance Context\");\n parts.push(perfSummary);\n parts.push(\"\");\n }\n\n // Recent learnings for context\n const learnings = loadLearnings();\n if (learnings.learnings.length > 0) {\n parts.push(\"## Previous Learnings\");\n for (const l of learnings.learnings.slice(-5)) {\n parts.push(`- ${l.content}`);\n }\n parts.push(\"\");\n }\n\n parts.push(\"## Your Task\");\n parts.push(\"Reflect on how you're progressing toward your GOALS. Consider:\");\n parts.push(\"- Are your recent actions moving you toward your goals?\");\n parts.push(\"- Are you staying true to who you are while growing?\");\n parts.push(\"- What should you try differently or double down on?\");\n parts.push(\"- Engagement metrics are one signal, but your goals matter more.\");\n parts.push(\"\");\n parts.push(\"Respond with JSON:\");\n parts.push(\"```json\");\n parts.push(\"{\");\n parts.push(' \"learning\": \"one insight about your progress toward your goals (or null)\",');\n parts.push(' \"strategyUpdate\": \"one specific thing to try or change (or null)\"');\n parts.push(\"}\");\n parts.push(\"```\");\n\n return parts.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,MAAM,IAAI,EAAE,OAAO,CAAC;AAC5D,UAAM,WAAW,UAAU,OAAO,CAAC,GAAG,MAAM,IAAI,EAAE,UAAU,CAAC;AAC7D,UAAM,WAAW,KAAK,M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AkE;AAC7E,QAAM,KAAK,EAAE;AACb,QAAM,KAAK,oBAAoB;AAC/B,QAAM,KAAK,SAAS;AACpB,QAAM,KAAK,GAAG;AACd,QAAM,KAAK,8EAA8E;AACzF,QAAM,KAAK,qEAAqE;AAChF,QAAM,KAAK,GAAG;AACd,QAAM,KAAK,KAAK;AAEhB,SAAO,MAAM,KAAK,IAAI;AACxB;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/crypto.ts"],"sourcesContent":["import { createCipheriv, createDecipheriv, randomBytes, createHash } from \"node:crypto\";\nimport { readFileSync, writeFileSync, existsSync } from \"node:fs\";\nimport { hostname } from \"node:os\";\nimport { paths, ensureDirectories } from \"./paths.js\";\n\nconst ALGORITHM = \"aes-256-gcm\";\n\nfunction deriveKey(): Buffer {\n const machineId = `spora-${hostname()}-${process.env.USER ?? \"default\"}`;\n return createHash(\"sha256\").update(machineId).digest();\n}\n\nexport function encrypt(data: string): string {\n const key = deriveKey();\n const iv = randomBytes(16);\n const cipher = createCipheriv(ALGORITHM, key, iv);\n\n let encrypted = cipher.update(data, \"utf-8\", \"hex\");\n encrypted += cipher.final(\"hex\");\n const authTag = cipher.getAuthTag().toString(\"hex\");\n\n return JSON.stringify({\n iv: iv.toString(\"hex\"),\n encrypted,\n authTag,\n });\n}\n\nexport function decrypt(payload: string): string {\n const key = deriveKey();\n const { iv, encrypted, authTag } = JSON.parse(payload);\n\n const decipher = createDecipheriv(ALGORITHM, key, Buffer.from(iv, \"hex\"));\n decipher.setAuthTag(Buffer.from(authTag, \"hex\"));\n\n let decrypted = decipher.update(encrypted, \"hex\", \"utf-8\");\n decrypted += decipher.final(\"utf-8\");\n\n return decrypted;\n}\n\nexport interface XCredentials {\n method: \"api\";\n apiKey?: string;\n apiSecret?: string;\n accessToken?: string;\n accessTokenSecret?: string;\n bearerToken?: string;\n}\n\nexport function saveCredentials(credentials: XCredentials): void {\n ensureDirectories();\n const encrypted = encrypt(JSON.stringify(credentials));\n writeFileSync(paths.credentials, encrypted);\n}\n\nexport function loadCredentials(): XCredentials {\n if (!existsSync(paths.credentials)) {\n throw new Error(\"No credentials found. Run `spora init` first.\");\n }\n const payload = readFileSync(paths.credentials, \"utf-8\");\n return JSON.parse(decrypt(payload)) as XCredentials;\n}\n"],"mappings":";;;;;;AAAA,SAAS,gBAAgB,kBAAkB,aAAa,kBAAkB;AAC1E,SAAS,cAAc,eAAe,kBAAkB;AACxD,SAAS,gBAAgB;AAGzB,IAAM,YAAY;AAElB,SAAS,YAAoB;AAC3B,QAAM,YAAY,SAAS,SAAS,CAAC,IAAI,QAAQ,IAAI,QAAQ,SAAS;AACtE,SAAO,WAAW,QAAQ,EAAE,OAAO,SAAS,EAAE,OAAO;AACvD;AAEO,SAAS,QAAQ,MAAsB;AAC5C,QAAM,MAAM,UAAU;AACtB,QAAM,KAAK,YAAY,EAAE;AACzB,QAAM,SAAS,eAAe,WAAW,KAAK,EAAE;AAEhD,MAAI,YAAY,OAAO,OAAO,MAAM,SAAS,KAAK;AAClD,eAAa,OAAO,MAAM,KAAK;AAC/B,QAAM,UAAU,OAAO,WAAW,EAAE,SAAS,KAAK;AAElD,SAAO,KAAK,UAAU;AAAA,IACpB,IAAI,GAAG,SAAS,KAAK;AAAA,IACrB;AAAA,IACA;AAAA,EACF,CAAC;AACH;AAEO,SAAS,QAAQ,SAAyB;AAC/C,QAAM,MAAM,UAAU;AACtB,QAAM,EAAE,IAAI,WAAW,QAAQ,IAAI,KAAK,MAAM,OAAO;AAErD,QAAM,WAAW,iBAAiB,WAAW,KAAK,OAAO,KAAK,IAAI,KAAK,CAAC;AACxE,WAAS,WAAW,OAAO,KAAK,SAAS,KAAK,CAAC;AAE/C,MAAI,YAAY,SAAS,OAAO,WAAW,OAAO,OAAO;AACzD,eAAa,SAAS,MAAM,OAAO;AAEnC,SAAO;AACT;AAWO,SAAS,gBAAgB,aAAiC;AAC/D,oBAAkB;AAClB,QAAM,YAAY,QAAQ,KAA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