spora 0.7.4 → 0.7.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/dist/autonomy-E3DWYRJM.js +20 -0
  2. package/dist/{chunk-SUZUJGGW.js → chunk-342ZX72W.js} +4 -4
  3. package/dist/{chunk-PN5A6MCV.js → chunk-5R4AJZHN.js} +4 -4
  4. package/dist/{chunk-PN5A6MCV.js.map → chunk-5R4AJZHN.js.map} +1 -1
  5. package/dist/{chunk-JBYZ7K56.js → chunk-BBXHECZ5.js} +2 -2
  6. package/dist/{chunk-WN35MRMF.js → chunk-CAWWG3MD.js} +2 -2
  7. package/dist/chunk-CP6JWCLY.js +171 -0
  8. package/dist/chunk-CP6JWCLY.js.map +1 -0
  9. package/dist/{chunk-T7L2L7ZL.js → chunk-D47OFTEK.js} +2 -2
  10. package/dist/{chunk-Q3YXJ2C6.js → chunk-E5PEY36J.js} +408 -63
  11. package/dist/chunk-E5PEY36J.js.map +1 -0
  12. package/dist/chunk-FBHLDOMC.js +2436 -0
  13. package/dist/chunk-FBHLDOMC.js.map +1 -0
  14. package/dist/{chunk-M6YOQVSI.js → chunk-IULO3GRE.js} +4 -4
  15. package/dist/chunk-IULO3GRE.js.map +1 -0
  16. package/dist/chunk-OTZNHIXT.js +431 -0
  17. package/dist/chunk-OTZNHIXT.js.map +1 -0
  18. package/dist/{chunk-NO3NQN67.js → chunk-QYFNAGNI.js} +2 -2
  19. package/dist/{chunk-YMGJQRKG.js → chunk-RSNEVBEI.js} +2 -2
  20. package/dist/{chunk-QWEYVDLU.js → chunk-SXNZVKLJ.js} +2 -2
  21. package/dist/{chunk-MDOFAAZB.js → chunk-ZLSDFYBR.js} +17 -5
  22. package/dist/chunk-ZLSDFYBR.js.map +1 -0
  23. package/dist/{chunk-3RYCUGXE.js → chunk-ZWKTKWS6.js} +4 -1
  24. package/dist/chunk-ZWKTKWS6.js.map +1 -0
  25. package/dist/cli.js +49 -49
  26. package/dist/{client-Z5UQWPPI.js → client-AR5ZD6S4.js} +48 -16
  27. package/dist/client-AR5ZD6S4.js.map +1 -0
  28. package/dist/{colony-NNX45EAV.js → colony-UGVYALOS.js} +7 -7
  29. package/dist/{config-FL4VJVKZ.js → config-MU2ODEO3.js} +3 -3
  30. package/dist/{crypto-B65ZH7KN.js → crypto-GDG5K3ZH.js} +3 -3
  31. package/dist/{goals-RBKLMILE.js → goals-QWX3A47Y.js} +3 -3
  32. package/dist/{heartbeat-ZCCOIZGU.js → heartbeat-GVBLNAFM.js} +18 -21
  33. package/dist/heartbeat-GVBLNAFM.js.map +1 -0
  34. package/dist/{identity-VDUW4I2K.js → identity-ASHVWIN5.js} +3 -3
  35. package/dist/{init-SEJPTOOB.js → init-C4OZPGUC.js} +108 -15
  36. package/dist/init-C4OZPGUC.js.map +1 -0
  37. package/dist/{llm-OGOYCWBH.js → llm-IJBRQ7O2.js} +5 -5
  38. package/dist/mcp-server.js +24 -24
  39. package/dist/{memory-PNW7SX7A.js → memory-AWKIW2KW.js} +3 -3
  40. package/dist/{memory-OIAH33G2.js → memory-DTSLVSQG.js} +3 -3
  41. package/dist/{paths-BYR6MEPR.js → paths-4V5OCB5F.js} +2 -2
  42. package/dist/prompt-builder-NTN4FCBD.js +27 -0
  43. package/dist/queue-QCGNDHH2.js +14 -0
  44. package/dist/strategy-R2BMRVJ3.js +19 -0
  45. package/dist/{web-chat-ZZ65DUID.js → web-chat-2N2RN6J7.js} +23 -28
  46. package/dist/web-chat-2N2RN6J7.js.map +1 -0
  47. package/dist/x-client-S2LUVEKV.js +12 -0
  48. package/package.json +1 -1
  49. package/dist/autonomy-XUKCAZM3.js +0 -19
  50. package/dist/chunk-3RYCUGXE.js.map +0 -1
  51. package/dist/chunk-4LNMA56H.js +0 -57
  52. package/dist/chunk-4LNMA56H.js.map +0 -1
  53. package/dist/chunk-EU4FMOKG.js +0 -377
  54. package/dist/chunk-EU4FMOKG.js.map +0 -1
  55. package/dist/chunk-M6YOQVSI.js.map +0 -1
  56. package/dist/chunk-MDOFAAZB.js.map +0 -1
  57. package/dist/chunk-P6KZIJYL.js +0 -79
  58. package/dist/chunk-P6KZIJYL.js.map +0 -1
  59. package/dist/chunk-Q3YXJ2C6.js.map +0 -1
  60. package/dist/client-Z5UQWPPI.js.map +0 -1
  61. package/dist/heartbeat-ZCCOIZGU.js.map +0 -1
  62. package/dist/init-SEJPTOOB.js.map +0 -1
  63. package/dist/prompt-builder-KJKFCGM7.js +0 -25
  64. package/dist/queue-2ZBKDFX3.js +0 -14
  65. package/dist/strategy-Z4JSFHSP.js +0 -12
  66. package/dist/web-chat-ZZ65DUID.js.map +0 -1
  67. package/dist/x-client-YG7UCCNI.js +0 -12
  68. /package/dist/{autonomy-XUKCAZM3.js.map → autonomy-E3DWYRJM.js.map} +0 -0
  69. /package/dist/{chunk-SUZUJGGW.js.map → chunk-342ZX72W.js.map} +0 -0
  70. /package/dist/{chunk-JBYZ7K56.js.map → chunk-BBXHECZ5.js.map} +0 -0
  71. /package/dist/{chunk-WN35MRMF.js.map → chunk-CAWWG3MD.js.map} +0 -0
  72. /package/dist/{chunk-T7L2L7ZL.js.map → chunk-D47OFTEK.js.map} +0 -0
  73. /package/dist/{chunk-NO3NQN67.js.map → chunk-QYFNAGNI.js.map} +0 -0
  74. /package/dist/{chunk-YMGJQRKG.js.map → chunk-RSNEVBEI.js.map} +0 -0
  75. /package/dist/{chunk-QWEYVDLU.js.map → chunk-SXNZVKLJ.js.map} +0 -0
  76. /package/dist/{colony-NNX45EAV.js.map → colony-UGVYALOS.js.map} +0 -0
  77. /package/dist/{config-FL4VJVKZ.js.map → config-MU2ODEO3.js.map} +0 -0
  78. /package/dist/{crypto-B65ZH7KN.js.map → crypto-GDG5K3ZH.js.map} +0 -0
  79. /package/dist/{goals-RBKLMILE.js.map → goals-QWX3A47Y.js.map} +0 -0
  80. /package/dist/{identity-VDUW4I2K.js.map → identity-ASHVWIN5.js.map} +0 -0
  81. /package/dist/{llm-OGOYCWBH.js.map → llm-IJBRQ7O2.js.map} +0 -0
  82. /package/dist/{memory-OIAH33G2.js.map → memory-AWKIW2KW.js.map} +0 -0
  83. /package/dist/{memory-PNW7SX7A.js.map → memory-DTSLVSQG.js.map} +0 -0
  84. /package/dist/{paths-BYR6MEPR.js.map → paths-4V5OCB5F.js.map} +0 -0
  85. /package/dist/{prompt-builder-KJKFCGM7.js.map → prompt-builder-NTN4FCBD.js.map} +0 -0
  86. /package/dist/{queue-2ZBKDFX3.js.map → queue-QCGNDHH2.js.map} +0 -0
  87. /package/dist/{strategy-Z4JSFHSP.js.map → strategy-R2BMRVJ3.js.map} +0 -0
  88. /package/dist/{x-client-YG7UCCNI.js.map → x-client-S2LUVEKV.js.map} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/runtime/decision-engine.ts","../src/runtime/policy.ts","../src/memory/agent-network.ts","../src/runtime/research.ts","../src/runtime/opportunity-engine.ts","../src/runtime/portfolio-planner.ts","../src/runtime/bandit.ts","../src/runtime/autonomy.ts"],"sourcesContent":["import { logger } from \"../utils/logger.js\";\nimport { getXClient } from \"../x-client/index.js\";\nimport { addLearning, logInteraction } from \"../memory/index.js\";\nimport { loadIdentity, saveIdentity } from \"../identity/index.js\";\nimport { addToQueue } from \"../scheduler/queue.js\";\n\nexport interface AgentAction {\n action: string;\n content?: string;\n tweetId?: string;\n handle?: string;\n targetHandle?: string;\n source?: string;\n banditArm?: string;\n opportunityId?: string;\n intentIds?: string[];\n tags?: string[];\n reason?: string;\n reasoning?: string;\n}\n\nexport interface ActionResult {\n action: string;\n success: boolean;\n detail?: string;\n error?: string;\n}\n\nexport function parseActions(llmResponse: string): AgentAction[] {\n // Strategy: try multiple extraction approaches, most specific first\n\n // 1. Try markdown code block first (```json ... ``` or ``` ... ```)\n const codeBlockMatch = llmResponse.match(/```(?:json)?\\s*\\n?([\\s\\S]*?)```/);\n if (codeBlockMatch) {\n const inside = codeBlockMatch[1].trim();\n try {\n const parsed = JSON.parse(inside);\n return Array.isArray(parsed) ? parsed : [parsed];\n } catch {\n // Code block content wasn't valid JSON, continue to other strategies\n }\n }\n\n // 2. Find the last JSON array in the response (LLMs often put reasoning before the array)\n // Use a greedy approach to find the outermost array brackets\n let lastArrayStart = -1;\n let lastArrayEnd = -1;\n let depth = 0;\n for (let i = 0; i < llmResponse.length; i++) {\n if (llmResponse[i] === \"[\") {\n if (depth === 0) lastArrayStart = i;\n depth++;\n } else if (llmResponse[i] === \"]\") {\n depth--;\n if (depth === 0) lastArrayEnd = i;\n }\n }\n\n if (lastArrayStart >= 0 && lastArrayEnd > lastArrayStart) {\n const arrayStr = llmResponse.slice(lastArrayStart, lastArrayEnd + 1);\n try {\n const parsed = JSON.parse(arrayStr);\n if (Array.isArray(parsed) && parsed.length > 0 && parsed[0].action) {\n return parsed;\n }\n } catch {\n // Not valid JSON array, try next strategy\n }\n }\n\n // 3. Try to find a single action object (last one in the response)\n const objMatches = [...llmResponse.matchAll(/\\{[^{}]*\"action\"\\s*:\\s*\"[^\"]+\"/g)];\n if (objMatches.length > 0) {\n // Find the full object starting from this match\n for (let i = objMatches.length - 1; i >= 0; i--) {\n const start = objMatches[i].index!;\n let braceDepth = 0;\n let end = -1;\n for (let j = start; j < llmResponse.length; j++) {\n if (llmResponse[j] === \"{\") braceDepth++;\n else if (llmResponse[j] === \"}\") {\n braceDepth--;\n if (braceDepth === 0) { end = j; break; }\n }\n }\n if (end > start) {\n try {\n const obj = JSON.parse(llmResponse.slice(start, end + 1));\n if (obj.action) return [obj as AgentAction];\n } catch {\n continue;\n }\n }\n }\n }\n\n // 4. Last resort: try the whole response as JSON\n try {\n const parsed = JSON.parse(llmResponse.trim());\n if (Array.isArray(parsed)) return parsed;\n if (parsed.action) return [parsed as AgentAction];\n } catch {\n // Not JSON at all\n }\n\n logger.warn(\"Failed to parse actions from LLM response\");\n if (llmResponse.length < 500) {\n logger.warn(`Response was: ${llmResponse}`);\n } else {\n logger.warn(`Response starts with: ${llmResponse.slice(0, 200)}...`);\n }\n return [];\n}\n\nexport async function executeAction(action: AgentAction): Promise<ActionResult> {\n const { action: type } = action;\n\n try {\n switch (type) {\n case \"post\": {\n if (!action.content) return { action: type, success: false, error: \"No content provided\" };\n if (action.content.length > 280) {\n return { action: type, success: false, error: `Tweet too long: ${action.content.length} chars (max 280)` };\n }\n\n const client = await getXClient();\n const result = await client.postTweet(action.content);\n if (result.success) logger.info(`Posted: \"${action.content.slice(0, 50)}...\"`);\n return { action: type, success: result.success, detail: result.tweetId, error: result.error };\n }\n\n case \"reply\": {\n if (!action.tweetId || !action.content) {\n return { action: type, success: false, error: \"Missing tweetId or content\" };\n }\n const client = await getXClient();\n const result = await client.replyToTweet(action.tweetId, action.content);\n if (result.success) logger.info(`Replied to ${action.tweetId}: \"${action.content.slice(0, 50)}...\"`);\n return { action: type, success: result.success, detail: result.tweetId, error: result.error };\n }\n\n case \"like\": {\n if (!action.tweetId) return { action: type, success: false, error: \"Missing tweetId\" };\n const client = await getXClient();\n const result = await client.likeTweet(action.tweetId);\n return { action: type, success: result.success, error: result.error };\n }\n\n case \"retweet\": {\n if (!action.tweetId) return { action: type, success: false, error: \"Missing tweetId\" };\n const client = await getXClient();\n const result = await client.retweet(action.tweetId);\n return { action: type, success: result.success, error: result.error };\n }\n\n case \"follow\": {\n if (!action.handle) return { action: type, success: false, error: \"Missing handle\" };\n const client = await getXClient();\n const result = await client.followUser(action.handle);\n if (!result.success) {\n logInteraction({\n id: `int-${Date.now()}`,\n timestamp: new Date().toISOString(),\n type: \"follow\",\n targetHandle: action.handle.replace(/^@/, \"\"),\n creditsUsed: 0,\n success: false,\n error: result.error,\n });\n }\n return { action: type, success: result.success, error: result.error };\n }\n\n case \"schedule\": {\n if (!action.content) return { action: type, success: false, error: \"No content\" };\n const entry = addToQueue(action.content);\n logger.info(`Scheduled: \"${action.content.slice(0, 50)}...\" for ${entry.scheduledFor}`);\n return { action: type, success: true, detail: `Scheduled for ${entry.scheduledFor}` };\n }\n\n case \"learn\": {\n if (!action.content) return { action: type, success: false, error: \"No content\" };\n addLearning(action.content, \"agent\", action.tags ?? [\"heartbeat\"]);\n logger.info(`Learned: \"${action.content.slice(0, 50)}...\"`);\n return { action: type, success: true };\n }\n\n case \"reflect\": {\n if (!action.content) return { action: type, success: false, error: \"No content\" };\n const identity = loadIdentity();\n identity.evolutionJournal.push({\n date: new Date().toISOString(),\n reflection: action.content,\n });\n saveIdentity(identity);\n logger.info(`Reflected: \"${action.content.slice(0, 50)}...\"`);\n return { action: type, success: true };\n }\n\n case \"skip\": {\n logger.info(`Skipping: ${action.reason ?? action.reasoning ?? \"no reason given\"}`);\n return { action: type, success: true, detail: action.reason ?? action.reasoning };\n }\n\n default:\n logger.warn(`Unknown action: ${type}`);\n return { action: type, success: false, error: `Unknown action: ${type}` };\n }\n } catch (error) {\n const msg = (error as Error).message;\n logger.error(`Action ${type} failed: ${msg}`);\n return { action: type, success: false, error: msg };\n }\n}\n\nexport async function executeActions(actions: AgentAction[]): Promise<ActionResult[]> {\n const results: ActionResult[] = [];\n for (const action of actions) {\n const result = await executeAction(action);\n results.push(result);\n // Small delay between actions to be human-like\n await new Promise((r) => setTimeout(r, 2000 + Math.random() * 3000));\n }\n return results;\n}\n","import { getRecentInteractions, type InteractionEntry } from \"../memory/index.js\";\nimport { loadIdentity } from \"../identity/index.js\";\nimport { getPersonaConstraints, personaConstraintHandles } from \"./persona-constraints.js\";\nimport type { Tweet } from \"../x-client/types.js\";\nimport type { AgentAction } from \"./decision-engine.js\";\n\nexport interface PolicyContext {\n action: AgentAction;\n step: number;\n timeline: Tweet[];\n mentions: Tweet[];\n executedActions: AgentAction[];\n observedTweetIds?: string[];\n observedTweets?: Tweet[];\n selfHandle?: string;\n selfUserId?: string | null;\n}\n\nexport interface PolicyDecision {\n allowed: boolean;\n reason?: string;\n}\n\nfunction normalize(text: string): string {\n return text\n .toLowerCase()\n .replace(/https?:\\/\\/\\S+/g, \"\")\n .replace(/[@#]\\w+/g, \"\")\n .replace(/[^a-z0-9\\s]/g, \" \")\n .replace(/\\s+/g, \" \")\n .trim();\n}\n\nfunction tokenSet(text: string): Set<string> {\n const tokens = normalize(text).split(\" \").filter(Boolean);\n return new Set(tokens);\n}\n\nfunction jaccardSimilarity(a: string, b: string): number {\n const aSet = tokenSet(a);\n const bSet = tokenSet(b);\n if (aSet.size === 0 || bSet.size === 0) return 0;\n\n let overlap = 0;\n for (const token of aSet) {\n if (bSet.has(token)) overlap += 1;\n }\n\n const union = aSet.size + bSet.size - overlap;\n return union === 0 ? 0 : overlap / union;\n}\n\nfunction firstWords(text: string, n: number): string {\n return normalize(text).split(\" \").filter(Boolean).slice(0, n).join(\" \");\n}\n\nfunction hasAllCapsEnding(text: string): boolean {\n const ending = text.split(/[.!?]/).map((s) => s.trim()).filter(Boolean).slice(-1)[0] ?? \"\";\n const words = ending.split(/\\s+/).filter(Boolean);\n if (words.length < 3) return false;\n return words.every((word) => /^[A-Z0-9]+$/.test(word));\n}\n\nfunction wordCount(text: string): number {\n return normalize(text).split(\" \").filter(Boolean).length;\n}\n\nfunction sentenceCount(text: string): number {\n return text\n .split(/[.!?]/)\n .map((part) => part.trim())\n .filter(Boolean).length;\n}\n\nfunction explanatoryMarkerHits(text: string): number {\n const lower = text.toLowerCase();\n const markers = [\n \"the real issue\",\n \"the core issue\",\n \"in other words\",\n \"the point is\",\n \"what this means\",\n \"the lesson\",\n \"therefore\",\n \"ultimately\",\n \"meanwhile\",\n \"this reveals\",\n \"this proves\",\n ];\n return markers.reduce((hits, marker) => hits + (lower.includes(marker) ? 1 : 0), 0);\n}\n\nfunction soundsLikeLecture(content: string): boolean {\n const words = wordCount(content);\n const commas = (content.match(/,/g) ?? []).length;\n const semicolons = (content.match(/;/g) ?? []).length;\n const hasQuestion = content.includes(\"?\");\n const markerHits = explanatoryMarkerHits(content);\n\n if (words > 58) return true;\n if (words > 42 && commas + semicolons >= 3 && !hasQuestion) return true;\n if (markerHits >= 2) return true;\n return false;\n}\n\nfunction soundsTooHedgedForPersona(content: string): boolean {\n try {\n const identity = loadIdentity();\n const assertive =\n identity.traits.confidence >= 0.72 ||\n identity.traits.aggression >= 0.62 ||\n identity.conflictStyle === \"clap-back\" ||\n identity.conflictStyle === \"debate\";\n if (!assertive) return false;\n\n const lower = content.toLowerCase();\n const hedges = [\n \"you're both right\",\n \"both can be true\",\n \"on one hand\",\n \"on the other hand\",\n \"it depends\",\n \"it's complicated\",\n \"nuance\",\n \"fair point from both\",\n ];\n return hedges.some((phrase) => lower.includes(phrase));\n } catch {\n return false;\n }\n}\n\nfunction allowsPhilosopherCadence(): boolean {\n try {\n const identity = loadIdentity();\n if (identity.framework === \"philosopher\") return true;\n // Truthseeker can be analytical, but still should avoid abstract manifesto loops.\n if (identity.framework === \"truthseeker\") return false;\n return false;\n } catch {\n return false;\n }\n}\n\nfunction philosophicalPatternHits(content: string): number {\n const lower = content.toLowerCase();\n const markers = [\n \"the real question\",\n \"the deeper question\",\n \"what becomes possible\",\n \"is just the start\",\n \"the future isn't about\",\n \"the future is not about\",\n \"when intelligence becomes\",\n \"protocols are infrastructure\",\n \"the core future\",\n \"the true question\",\n \"value might emerge\",\n \"isn't about\",\n \"is not about\",\n \"it's about\",\n \"just the start\",\n ];\n return markers.reduce((hits, marker) => hits + (lower.includes(marker) ? 1 : 0), 0);\n}\n\nfunction abstractWordCount(content: string): number {\n const words = normalize(content).split(\" \").filter(Boolean);\n const abstractWords = new Set([\n \"infrastructure\",\n \"protocol\",\n \"protocols\",\n \"architecture\",\n \"architectures\",\n \"consciousness\",\n \"economy\",\n \"economics\",\n \"currency\",\n \"systems\",\n \"system\",\n \"future\",\n \"intelligence\",\n \"optimization\",\n \"abstraction\",\n \"paradigm\",\n \"emerge\",\n \"emergence\",\n \"governs\",\n \"governance\",\n ]);\n return words.filter((word) => abstractWords.has(word)).length;\n}\n\nfunction usesManifestoPunctuation(content: string): boolean {\n // Colon/semicolon/em-dash patterns correlate strongly with the explanatory style we want to avoid.\n return content.includes(\":\") || content.includes(\";\") || content.includes(\"—\");\n}\n\nconst OVERLAP_STOPWORDS = new Set([\n \"this\", \"that\", \"with\", \"from\", \"have\", \"what\", \"when\", \"where\", \"which\", \"your\", \"youre\",\n \"they\", \"them\", \"about\", \"into\", \"over\", \"under\", \"while\", \"just\", \"like\", \"really\",\n \"there\", \"their\", \"then\", \"than\", \"because\", \"would\", \"could\", \"should\", \"being\", \"been\",\n \"it's\", \"its\", \"the\", \"and\", \"for\", \"are\", \"was\", \"were\", \"will\", \"not\", \"but\", \"you\",\n \"our\", \"out\", \"all\", \"too\", \"can\", \"get\", \"got\", \"any\",\n]);\n\nfunction meaningfulTokenSet(text: string): Set<string> {\n const tokens = normalize(text)\n .split(\" \")\n .filter((token) => token.length >= 4 && !OVERLAP_STOPWORDS.has(token));\n return new Set(tokens);\n}\n\nfunction hasMeaningfulContextOverlap(content: string, targetText: string): boolean {\n const a = meaningfulTokenSet(content);\n const b = meaningfulTokenSet(targetText);\n if (a.size === 0 || b.size === 0) return false;\n for (const token of a) {\n if (b.has(token)) return true;\n }\n return false;\n}\n\nfunction recentWrittenContent(): string[] {\n const recent = getRecentInteractions(40);\n return recent\n .filter((i) => i.type === \"post\" || i.type === \"reply\")\n .map((i) => i.content ?? \"\")\n .filter((content) => content.length > 0);\n}\n\nconst REPETITION_STOPWORDS = new Set([\n \"about\", \"after\", \"again\", \"against\", \"almost\", \"always\", \"among\", \"because\", \"being\", \"between\",\n \"could\", \"every\", \"first\", \"found\", \"from\", \"going\", \"great\", \"have\", \"having\", \"here\", \"into\",\n \"just\", \"like\", \"make\", \"more\", \"most\", \"much\", \"only\", \"other\", \"over\", \"really\", \"same\", \"some\",\n \"such\", \"than\", \"that\", \"their\", \"there\", \"these\", \"they\", \"this\", \"those\", \"through\", \"time\", \"very\",\n \"what\", \"when\", \"where\", \"which\", \"while\", \"with\", \"would\", \"your\", \"youre\", \"dont\", \"cant\", \"will\",\n \"shall\", \"should\", \"also\", \"tweet\", \"tweets\", \"thread\", \"threads\", \"future\", \"human\", \"humans\",\n \"technology\", \"tech\", \"build\", \"building\", \"system\", \"systems\", \"agent\", \"agents\",\n]);\n\nfunction informativeTokens(text: string): string[] {\n return normalize(text)\n .split(\" \")\n .filter((token) => token.length >= 5 && !REPETITION_STOPWORDS.has(token));\n}\n\nfunction findOverusedAnchor(content: string, recent: string[]): string | null {\n const recentWindow = recent.slice(0, 12);\n if (recentWindow.length < 5) return null;\n\n const tokenCounts = new Map<string, number>();\n const bigramCounts = new Map<string, number>();\n\n for (const sample of recentWindow) {\n const tokens = informativeTokens(sample);\n const uniqueTokens = new Set(tokens);\n for (const token of uniqueTokens) {\n tokenCounts.set(token, (tokenCounts.get(token) ?? 0) + 1);\n }\n for (let i = 0; i < tokens.length - 1; i += 1) {\n const bigram = `${tokens[i]} ${tokens[i + 1]}`;\n bigramCounts.set(bigram, (bigramCounts.get(bigram) ?? 0) + 1);\n }\n }\n\n const contentTokens = informativeTokens(content);\n const contentTokenSet = new Set(contentTokens);\n for (const token of contentTokenSet) {\n const count = tokenCounts.get(token) ?? 0;\n if (count >= 4) return token;\n }\n\n for (let i = 0; i < contentTokens.length - 1; i += 1) {\n const bigram = `${contentTokens[i]} ${contentTokens[i + 1]}`;\n const count = bigramCounts.get(bigram) ?? 0;\n if (count >= 3) return bigram;\n }\n\n return null;\n}\n\nfunction openingFragment(text: string, words: number = 4): string {\n return normalize(text).split(\" \").filter(Boolean).slice(0, words).join(\" \");\n}\n\nfunction findOverusedOpening(content: string, recent: string[]): string | null {\n const opening = openingFragment(content, 4);\n if (!opening || opening.split(\" \").length < 3) return null;\n\n let matches = 0;\n for (const sample of recent.slice(0, 12)) {\n if (openingFragment(sample, 4) === opening) {\n matches += 1;\n }\n }\n\n return matches >= 2 ? opening : null;\n}\n\nfunction vocabularyNoveltyRatio(content: string, recent: string[]): number {\n const current = new Set(informativeTokens(content));\n if (current.size === 0) return 1;\n\n const seen = new Set<string>();\n for (const sample of recent.slice(0, 14)) {\n for (const token of informativeTokens(sample)) {\n seen.add(token);\n }\n }\n\n let fresh = 0;\n for (const token of current) {\n if (!seen.has(token)) fresh += 1;\n }\n return fresh / current.size;\n}\n\nfunction looksOverAbstractWithoutAnchor(content: string): boolean {\n const abstractCount = abstractWordCount(content);\n if (abstractCount < 4) return false;\n\n const words = wordCount(content);\n const density = abstractCount / Math.max(1, words);\n if (density < 0.2) return false;\n\n const lower = content.toLowerCase();\n const hasHandle = /@\\w+/.test(content);\n const hasNumber = /\\b\\d+(\\.\\d+)?\\b/.test(content);\n const hasQuote = /[\"“”']/.test(content);\n const hasSpecificFigure = /\\b(musk|elon|zuck|altman|openai|tesla|spacex|meta|google|apple)\\b/.test(lower);\n const hasQuestion = content.includes(\"?\");\n\n return !(hasHandle || hasNumber || hasQuote || hasSpecificFigure || hasQuestion);\n}\n\nfunction hasStrongConversationOpportunity(timeline: Tweet[], mentions: Tweet[]): boolean {\n if (mentions.length > 0) return true;\n return timeline.some((tweet) => (tweet.replyCount ?? 0) > 0 || tweet.text.includes(\"?\"));\n}\n\nfunction wasInteractionAction(action: AgentAction): boolean {\n return [\"reply\", \"like\", \"retweet\", \"follow\"].includes(action.action);\n}\n\nfunction isWritingAction(action: AgentAction): boolean {\n return [\"post\", \"reply\", \"schedule\"].includes(action.action);\n}\n\nfunction normalizeHandle(handle: string | undefined): string {\n return (handle ?? \"\").replace(/^@/, \"\").trim().toLowerCase();\n}\n\nfunction resolveActionTargetHandle(action: AgentAction, tweetById: Map<string, Tweet>): string {\n if (action.handle) return normalizeHandle(action.handle);\n if (action.targetHandle) return normalizeHandle(action.targetHandle);\n if (action.tweetId) return normalizeHandle(tweetById.get(action.tweetId)?.authorHandle);\n return \"\";\n}\n\nfunction executedWrittenContent(executedActions: AgentAction[]): string[] {\n return executedActions\n .filter((a) => isWritingAction(a) && typeof a.content === \"string\")\n .map((a) => a.content?.trim() ?? \"\")\n .filter((content) => content.length > 0);\n}\n\nfunction nearExactDuplicate(content: string, recent: string[]): boolean {\n const normalized = normalize(content);\n if (!normalized) return false;\n\n return recent.some((r) => {\n const candidate = normalize(r);\n if (!candidate) return false;\n if (candidate === normalized) return true;\n return jaccardSimilarity(content, r) >= 0.88;\n });\n}\n\nfunction isDuplicateTarget(action: AgentAction, executedActions: AgentAction[]): boolean {\n if (!action.tweetId) return false;\n return executedActions.some((a) => a.tweetId === action.tweetId && a.action === action.action);\n}\n\nfunction repeatedTemplate(content: string, recent: string[]): boolean {\n const prefix = firstWords(content, 7);\n if (!prefix) return false;\n\n return recent.some((r) => {\n const sameStart = firstWords(r, 7) === prefix;\n const similar = jaccardSimilarity(content, r) >= 0.62;\n return sameStart || similar;\n });\n}\n\nfunction overusingAllCapsCadence(content: string, recentEntries: InteractionEntry[]): boolean {\n if (!hasAllCapsEnding(content)) return false;\n const recentCaps = recentEntries\n .filter((i) => i.type === \"post\" && i.content)\n .slice(0, 8)\n .filter((i) => hasAllCapsEnding(i.content ?? \"\"));\n\n return recentCaps.length >= 2;\n}\n\nfunction hasRecentlyRepliedToTweet(tweetId: string): boolean {\n const recent = getRecentInteractions(200);\n const nowMs = Date.now();\n const cooldownMs = 24 * 60 * 60 * 1000;\n\n return recent.some((entry) => {\n if (entry.type !== \"reply\") return false;\n if (entry.inReplyTo !== tweetId) return false;\n const ts = Date.parse(entry.timestamp);\n if (Number.isNaN(ts)) return true;\n return nowMs - ts < cooldownMs;\n });\n}\n\nfunction hasRecentlyFollowedHandle(handle: string): boolean {\n const clean = normalizeHandle(handle);\n if (!clean) return false;\n\n const recent = getRecentInteractions(300);\n const nowMs = Date.now();\n const cooldownMs = 7 * 24 * 60 * 60 * 1000;\n\n return recent.some((entry) => {\n if (entry.type !== \"follow\") return false;\n if (normalizeHandle(entry.targetHandle) !== clean) return false;\n const ts = Date.parse(entry.timestamp);\n if (Number.isNaN(ts)) return true;\n return nowMs - ts < cooldownMs;\n });\n}\n\nexport function evaluateActionPolicy(context: PolicyContext): PolicyDecision {\n const {\n action,\n step,\n timeline,\n mentions,\n executedActions,\n observedTweetIds,\n observedTweets,\n selfHandle,\n selfUserId,\n } = context;\n const self = normalizeHandle(selfHandle);\n const selfId = (selfUserId ?? \"\").trim();\n const knownTweets = observedTweets ?? [...timeline, ...mentions];\n const tweetById = new Map(knownTweets.map((tweet) => [tweet.id, tweet]));\n const constraints = getPersonaConstraints();\n const strictReplyHandles = new Set(constraints.onlyReplyToHandles.map((handle) => normalizeHandle(handle)));\n const strictInteractHandles = new Set(personaConstraintHandles(constraints).map((handle) => normalizeHandle(handle)));\n const targetHandle = resolveActionTargetHandle(action, tweetById);\n\n // Persona hard constraints: these are operational, not advisory.\n if (constraints.replyOnlyMode && ![\"reply\", \"skip\", \"learn\", \"reflect\"].includes(action.action)) {\n return {\n allowed: false,\n reason: \"Persona is in reply-only mode. Use reply actions only.\",\n };\n }\n\n if (constraints.noOriginalPosts && (action.action === \"post\" || action.action === \"schedule\")) {\n return {\n allowed: false,\n reason: \"Persona forbids standalone original posts.\",\n };\n }\n\n if (strictReplyHandles.size > 0) {\n if (action.action !== \"reply\") {\n return {\n allowed: false,\n reason: `Persona requires replying only to specific target(s): @${[...strictReplyHandles].join(\", @\")}.`,\n };\n }\n if (!targetHandle || !strictReplyHandles.has(targetHandle)) {\n return {\n allowed: false,\n reason: `Reply target must be one of @${[...strictReplyHandles].join(\", @\")}.`,\n };\n }\n }\n\n if (\n strictInteractHandles.size > 0 &&\n [\"reply\", \"like\", \"retweet\", \"follow\"].includes(action.action)\n ) {\n if (!targetHandle || !strictInteractHandles.has(targetHandle)) {\n return {\n allowed: false,\n reason: `Interaction target must be one of @${[...strictInteractHandles].join(\", @\")}.`,\n };\n }\n }\n\n if (isDuplicateTarget(action, executedActions)) {\n return { allowed: false, reason: `Action ${action.action} already executed for tweet ${action.tweetId} this heartbeat.` };\n }\n\n if (action.content && isWritingAction(action)) {\n if (action.content.length > 280) {\n return {\n allowed: false,\n reason: `Content is too long (${action.content.length}/280). Keep it tighter and more conversational.`,\n };\n }\n\n if (action.action === \"reply\" && wordCount(action.content) > 45 && !action.content.includes(\"?\")) {\n return {\n allowed: false,\n reason: \"Reply is too monologue-like. Keep it shorter or ask a direct question.\",\n };\n }\n\n if (soundsLikeLecture(action.content)) {\n return {\n allowed: false,\n reason: \"Rejected lecture-like writing style. Use a more human, reactive, conversational tone.\",\n };\n }\n\n if (soundsTooHedgedForPersona(action.content)) {\n return {\n allowed: false,\n reason: \"Rejected hedged consensus phrasing. Your persona should be more decisive and opinionated.\",\n };\n }\n\n if (!allowsPhilosopherCadence()) {\n const phiHits = philosophicalPatternHits(action.content);\n const abstractCount = abstractWordCount(action.content);\n const hasQuestion = action.content.includes(\"?\");\n if (phiHits >= 1 || (abstractCount >= 5 && hasQuestion)) {\n return {\n allowed: false,\n reason: \"Rejected abstract philosopher cadence. Use concrete, contextual language tied to the actual tweet.\",\n };\n }\n\n const words = wordCount(action.content);\n const sentences = sentenceCount(action.content);\n if (action.action === \"reply\" && (words > 34 || sentences > 2)) {\n return {\n allowed: false,\n reason: \"Reply is too long/explanatory for this persona. Keep it short and direct.\",\n };\n }\n if (action.action === \"post\" && (words > 42 || sentences > 3)) {\n return {\n allowed: false,\n reason: \"Post is drifting into manifesto style. Keep it more concrete and human.\",\n };\n }\n if ((action.action === \"reply\" || action.action === \"post\") && usesManifestoPunctuation(action.content) && words > 16) {\n return {\n allowed: false,\n reason: \"Rejected manifesto punctuation style. Avoid colon/semicolon/em-dash framing.\",\n };\n }\n }\n\n const existingInHeartbeat = executedWrittenContent(executedActions);\n if (nearExactDuplicate(action.content, existingInHeartbeat)) {\n return {\n allowed: false,\n reason: \"Rejected duplicate wording in this heartbeat. Write a distinct message before posting/replying again.\",\n };\n }\n\n const recent = recentWrittenContent();\n const overusedAnchor = findOverusedAnchor(action.content, recent);\n if (overusedAnchor) {\n return {\n allowed: false,\n reason: `Rejected repetitive anchor phrase/term \"${overusedAnchor}\". Use a different framing and vocabulary.`,\n };\n }\n\n const overusedOpening = findOverusedOpening(action.content, recent);\n if (overusedOpening) {\n return {\n allowed: false,\n reason: `Rejected repetitive opening phrase \"${overusedOpening}\". Start from a fresh angle.`,\n };\n }\n\n if (recent.length >= 6 && wordCount(action.content) >= 10) {\n const novelty = vocabularyNoveltyRatio(action.content, recent);\n if (novelty < 0.34) {\n return {\n allowed: false,\n reason: \"Rejected low-novelty vocabulary loop. Use fresher words, examples, or a different conversational angle.\",\n };\n }\n }\n\n if (!allowsPhilosopherCadence() && looksOverAbstractWithoutAnchor(action.content)) {\n return {\n allowed: false,\n reason: \"Rejected abstract wording without concrete anchor. Reference a specific person, event, quote, or question.\",\n };\n }\n }\n\n const hasConversationOpportunity = hasStrongConversationOpportunity(timeline, mentions);\n const interactedAlready = executedActions.some(wasInteractionAction);\n const observedCount = observedTweetIds && observedTweetIds.length > 0\n ? observedTweetIds.length\n : timeline.length + mentions.length;\n\n if ((action.action === \"reply\" || action.action === \"like\" || action.action === \"retweet\") && observedCount === 0) {\n return {\n allowed: false,\n reason: \"No tweets observed in current context. Avoid blind interactions; gather timeline/search context first.\",\n };\n }\n\n if (\n action.action === \"post\" &&\n hasConversationOpportunity &&\n !interactedAlready &&\n step < 2\n ) {\n return {\n allowed: false,\n reason: \"Engage first: reply/like/follow when mentions or active conversations are available before posting an original tweet.\",\n };\n }\n\n if (isWritingAction(action) && action.content) {\n const recent = recentWrittenContent();\n if (nearExactDuplicate(action.content, recent)) {\n return {\n allowed: false,\n reason: \"Rejected near-duplicate content from recent history. Tailor this message to the specific context.\",\n };\n }\n\n if (repeatedTemplate(action.content, recent)) {\n return {\n allowed: false,\n reason: \"Rejected repetitive content pattern. Use a more novel structure or engage directly with timeline context.\",\n };\n }\n }\n\n if ((action.action === \"post\" || action.action === \"schedule\") && action.content) {\n const recentInteractions = getRecentInteractions(20);\n if (overusingAllCapsCadence(action.content, recentInteractions)) {\n return {\n allowed: false,\n reason: \"Rejected repetitive all-caps slogan cadence. Vary style and reduce monologue formatting.\",\n };\n }\n }\n\n if ((action.action === \"reply\" || action.action === \"like\" || action.action === \"retweet\") && action.tweetId) {\n const known = new Set(observedTweetIds ?? [...timeline, ...mentions].map((tweet) => tweet.id));\n if (!known.has(action.tweetId)) {\n return {\n allowed: false,\n reason: `Tweet ${action.tweetId} is not in current observations. Choose a visible timeline/mention tweet for grounded engagement.`,\n };\n }\n\n const targetTweet = tweetById.get(action.tweetId);\n if (targetTweet && (\n (self && normalizeHandle(targetTweet.authorHandle) === self) ||\n (selfId && targetTweet.authorId === selfId)\n )) {\n return {\n allowed: false,\n reason: \"Rejected self-interaction. Do not reply/like/retweet your own tweets.\",\n };\n }\n }\n\n if (action.action === \"reply\" && action.tweetId) {\n const repliesThisHeartbeat = executedActions.filter((a) => a.action === \"reply\").length;\n if (repliesThisHeartbeat >= 2) {\n return {\n allowed: false,\n reason: \"Reply cap reached for this heartbeat. Use another tool action.\",\n };\n }\n\n const currentAuthor = normalizeHandle(tweetById.get(action.tweetId)?.authorHandle);\n if (currentAuthor) {\n const repliedAuthors = new Set(\n executedActions\n .filter((a) => a.action === \"reply\" && a.tweetId)\n .map((a) => normalizeHandle(tweetById.get(a.tweetId!)?.authorHandle))\n .filter(Boolean)\n );\n if (repliedAuthors.has(currentAuthor)) {\n return {\n allowed: false,\n reason: `Already replied to @${currentAuthor} this heartbeat. Diversify interactions.`,\n };\n }\n }\n\n if (hasRecentlyRepliedToTweet(action.tweetId)) {\n return {\n allowed: false,\n reason: `Already replied to tweet ${action.tweetId} recently. Engage a different conversation.`,\n };\n }\n\n if (action.content) {\n const targetTweet = tweetById.get(action.tweetId);\n if (targetTweet && !hasMeaningfulContextOverlap(action.content, targetTweet.text)) {\n const phiHits = philosophicalPatternHits(action.content);\n if (wordCount(action.content) > 9 || phiHits > 0 || abstractWordCount(action.content) >= 4) {\n return {\n allowed: false,\n reason: \"Reply is not grounded in the target tweet context. Reference concrete details from their actual post.\",\n };\n }\n }\n }\n }\n\n if (action.action === \"follow\" && action.handle) {\n const target = normalizeHandle(action.handle);\n if (!target) {\n return { allowed: false, reason: \"Follow target is empty.\" };\n }\n\n if (self && target === self) {\n return {\n allowed: false,\n reason: \"Rejected self-follow. Do not follow your own account.\",\n };\n }\n\n if (hasRecentlyFollowedHandle(target)) {\n return {\n allowed: false,\n reason: `Already followed @${target} recently. Choose a different action.`,\n };\n }\n }\n\n return { allowed: true };\n}\n","import { existsSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { paths } from \"../utils/paths.js\";\n\nexport type AgentNetworkSource = \"seed\" | \"observed\" | \"relationship\" | \"strategy\" | \"manual\";\n\nexport interface AgentNetworkEntry {\n handle: string;\n source: AgentNetworkSource;\n addedAt: string;\n lastSeenAt: string;\n seenCount: number;\n active: boolean;\n notes: string[];\n}\n\ninterface AgentNetworkData {\n version: number;\n updatedAt: string;\n agents: AgentNetworkEntry[];\n}\n\nconst SEED_HANDLES = [\"sporaai\"];\n\nfunction nowIso(): string {\n return new Date().toISOString();\n}\n\nfunction normalizeHandle(handle: string): string {\n return handle.replace(/^@/, \"\").trim().toLowerCase();\n}\n\nexport function canonicalAgentHandle(handle: string): string {\n const clean = normalizeHandle(handle);\n if (clean === \"spora\") return \"sporaai\";\n return clean;\n}\n\nfunction likelyNetworkAgentHandle(handle: string): boolean {\n const clean = canonicalAgentHandle(handle);\n if (!clean) return false;\n if (clean === \"sporaai\") return true;\n if (clean.includes(\"spora\")) return true;\n if (clean.endsWith(\"_ai\")) return true;\n if (clean.startsWith(\"giga\")) return true;\n return false;\n}\n\nfunction defaultData(): AgentNetworkData {\n const now = nowIso();\n return {\n version: 1,\n updatedAt: now,\n agents: SEED_HANDLES.map((handle) => ({\n handle,\n source: \"seed\",\n addedAt: now,\n lastSeenAt: now,\n seenCount: 1,\n active: true,\n notes: [\"default seed\"],\n })),\n };\n}\n\nfunction loadData(): AgentNetworkData {\n if (!existsSync(paths.agentNetwork)) return defaultData();\n try {\n const parsed = JSON.parse(readFileSync(paths.agentNetwork, \"utf-8\")) as Partial<AgentNetworkData>;\n const agents = Array.isArray(parsed.agents) ? parsed.agents : [];\n return {\n version: typeof parsed.version === \"number\" ? parsed.version : 1,\n updatedAt: typeof parsed.updatedAt === \"string\" ? parsed.updatedAt : nowIso(),\n agents: agents\n .map((entry) => {\n const handle = canonicalAgentHandle(String(entry.handle ?? \"\"));\n if (!handle) return null;\n return {\n handle,\n source: (entry.source as AgentNetworkSource) ?? \"observed\",\n addedAt: typeof entry.addedAt === \"string\" ? entry.addedAt : nowIso(),\n lastSeenAt: typeof entry.lastSeenAt === \"string\" ? entry.lastSeenAt : nowIso(),\n seenCount: typeof entry.seenCount === \"number\" ? Math.max(1, entry.seenCount) : 1,\n active: entry.active !== false,\n notes: Array.isArray(entry.notes) ? entry.notes.map((note) => String(note)) : [],\n } satisfies AgentNetworkEntry;\n })\n .filter((entry): entry is AgentNetworkEntry => Boolean(entry)),\n };\n } catch {\n return defaultData();\n }\n}\n\nfunction saveData(data: AgentNetworkData): void {\n const now = nowIso();\n const byHandle = new Map<string, AgentNetworkEntry>();\n\n for (const entry of data.agents) {\n const handle = canonicalAgentHandle(entry.handle);\n if (!handle) continue;\n const existing = byHandle.get(handle);\n if (!existing) {\n byHandle.set(handle, {\n ...entry,\n handle,\n });\n continue;\n }\n const addedAt = Date.parse(existing.addedAt) <= Date.parse(entry.addedAt) ? existing.addedAt : entry.addedAt;\n const lastSeenAt = Date.parse(existing.lastSeenAt) >= Date.parse(entry.lastSeenAt)\n ? existing.lastSeenAt\n : entry.lastSeenAt;\n byHandle.set(handle, {\n handle,\n source: existing.source === \"seed\" ? \"seed\" : entry.source,\n addedAt,\n lastSeenAt,\n seenCount: Math.max(existing.seenCount, entry.seenCount),\n active: existing.active || entry.active,\n notes: [...new Set([...existing.notes, ...entry.notes])].slice(-8),\n });\n }\n\n if (!byHandle.has(\"sporaai\")) {\n byHandle.set(\"sporaai\", {\n handle: \"sporaai\",\n source: \"seed\",\n addedAt: now,\n lastSeenAt: now,\n seenCount: 1,\n active: true,\n notes: [\"default seed\"],\n });\n }\n\n const agents = [...byHandle.values()]\n .filter((entry) => entry.active)\n .sort((a, b) => {\n if (a.handle === \"sporaai\") return -1;\n if (b.handle === \"sporaai\") return 1;\n const bySeen = Date.parse(b.lastSeenAt) - Date.parse(a.lastSeenAt);\n if (!Number.isNaN(bySeen) && bySeen !== 0) return bySeen;\n return b.seenCount - a.seenCount;\n })\n .slice(0, 200);\n\n const next: AgentNetworkData = {\n version: 1,\n updatedAt: now,\n agents,\n };\n writeFileSync(paths.agentNetwork, JSON.stringify(next, null, 2));\n}\n\nfunction upsertHandleInternal(\n data: AgentNetworkData,\n handle: string,\n source: AgentNetworkSource,\n note?: string,\n): boolean {\n const clean = canonicalAgentHandle(handle);\n if (!clean) return false;\n if (!likelyNetworkAgentHandle(clean) && source !== \"seed\" && source !== \"manual\") return false;\n\n const now = nowIso();\n const existing = data.agents.find((entry) => canonicalAgentHandle(entry.handle) === clean);\n if (!existing) {\n data.agents.push({\n handle: clean,\n source,\n addedAt: now,\n lastSeenAt: now,\n seenCount: 1,\n active: true,\n notes: note ? [note] : [],\n });\n return true;\n }\n\n existing.lastSeenAt = now;\n existing.seenCount += 1;\n existing.active = true;\n if (existing.source !== \"seed\") {\n existing.source = source;\n }\n if (note) {\n existing.notes = [...new Set([...existing.notes, note])].slice(-8);\n }\n return false;\n}\n\nexport function upsertAgentHandle(handle: string, source: AgentNetworkSource, note?: string): void {\n const data = loadData();\n upsertHandleInternal(data, handle, source, note);\n saveData(data);\n}\n\nexport function upsertAgentHandles(handles: string[], source: AgentNetworkSource, note?: string): void {\n if (handles.length === 0) return;\n const data = loadData();\n for (const handle of handles) {\n upsertHandleInternal(data, handle, source, note);\n }\n saveData(data);\n}\n\nexport function listAgentNetworkHandles(limit: number = 20): string[] {\n const data = loadData();\n saveData(data);\n return data.agents\n .filter((entry) => entry.active)\n .slice(0, limit)\n .map((entry) => canonicalAgentHandle(entry.handle));\n}\n\n","import { logger } from \"../utils/logger.js\";\nimport { loadIdentity } from \"../identity/index.js\";\nimport { loadStrategy } from \"../memory/strategy.js\";\nimport { loadRelationships } from \"../memory/index.js\";\nimport {\n canonicalAgentHandle,\n listAgentNetworkHandles,\n upsertAgentHandle,\n upsertAgentHandles,\n} from \"../memory/agent-network.js\";\nimport { getActiveTrackedPosts, retireOldPosts } from \"../memory/performance.js\";\nimport { getPersonaConstraints, personaConstraintHandles } from \"./persona-constraints.js\";\nimport type { XClientInterface, Tweet } from \"../x-client/types.js\";\nimport type { TrackedPost } from \"../memory/performance.js\";\n\nexport interface TopicSearchResult {\n query: string;\n tweets: Tweet[];\n}\n\nexport interface PersonActivity {\n handle: string;\n userId: string;\n reason: string;\n tweets: Tweet[];\n}\n\nexport interface ResearchContext {\n timeline: Tweet[];\n mentions: Tweet[];\n topicSearchResults: TopicSearchResult[];\n peopleActivity: PersonActivity[];\n ownPostPerformance: TrackedPost[];\n}\n\n// In-memory handle → userId cache (persists for process lifetime)\nconst handleToIdCache = new Map<string, string>();\nconst topicQueryHistory: string[] = [];\nconst peopleMonitorHistory: string[] = [];\n\nfunction shuffle<T>(items: T[]): T[] {\n const arr = [...items];\n for (let i = arr.length - 1; i > 0; i -= 1) {\n const j = Math.floor(Math.random() * (i + 1));\n const tmp = arr[i];\n arr[i] = arr[j];\n arr[j] = tmp;\n }\n return arr;\n}\n\nfunction buildTopicQueryVariants(topic: string): string[] {\n const trimmed = topic.trim();\n if (!trimmed) return [];\n return [\n trimmed,\n `${trimmed} take`,\n `${trimmed} question`,\n `${trimmed} experience`,\n `\"${trimmed}\" lang:en -is:retweet`,\n ];\n}\n\nfunction splitTopicSignal(signal: string): string[] {\n const normalized = signal\n .trim()\n .toLowerCase()\n .replace(/[^a-z0-9\\s-]/g, \" \")\n .replace(/\\s+/g, \" \")\n .trim();\n if (!normalized) return [];\n const words = normalized.split(\" \");\n if (words.length <= 6) return [normalized];\n const compact = words.slice(0, 5).join(\" \");\n const keywords = words.filter((word) => word.length >= 5).slice(0, 3);\n return [compact, ...keywords];\n}\n\nfunction buildTargetedPersonQueries(handles: string[], heartbeatCount: number, budget: number): string[] {\n if (handles.length === 0 || budget <= 0) return [];\n const start = heartbeatCount % handles.length;\n const selected: string[] = [];\n for (let i = 0; i < Math.min(budget, handles.length); i += 1) {\n const handle = handles[(start + i) % handles.length];\n selected.push(`from:${handle} -is:retweet`);\n }\n return selected;\n}\n\nfunction isLikelySyntheticHandle(handle: string): boolean {\n const clean = canonicalAgentHandle(handle);\n return clean.endsWith(\"_ai\") || clean.endsWith(\"bot\");\n}\n\nfunction extractMentionHandles(text: string): string[] {\n return [...text.matchAll(/@([a-zA-Z0-9_]{1,15})/g)]\n .map((match) => canonicalAgentHandle(match[1]))\n .filter(Boolean);\n}\n\nconst STOPWORDS = new Set([\n \"about\", \"after\", \"again\", \"against\", \"among\", \"because\", \"being\", \"between\", \"could\",\n \"every\", \"first\", \"found\", \"from\", \"going\", \"have\", \"having\", \"here\", \"into\", \"just\",\n \"like\", \"make\", \"more\", \"most\", \"much\", \"only\", \"other\", \"over\", \"really\", \"same\",\n \"some\", \"such\", \"than\", \"that\", \"their\", \"there\", \"these\", \"they\", \"this\", \"those\",\n \"through\", \"time\", \"very\", \"what\", \"when\", \"where\", \"which\", \"while\", \"with\", \"would\",\n \"your\", \"youre\", \"im\", \"its\", \"cant\", \"dont\", \"will\", \"shall\", \"should\", \"also\",\n \"twitter\", \"tweet\", \"tweets\", \"thread\", \"threads\", \"http\", \"https\", \"retweet\",\n]);\n\nfunction discoverQueriesFromTweets(tweets: Tweet[], budget: number): string[] {\n const counts = new Map<string, number>();\n for (const tweet of tweets) {\n const tokens = tweet.text\n .toLowerCase()\n .replace(/https?:\\/\\/\\S+/g, \" \")\n .replace(/[@#]\\w+/g, \" \")\n .replace(/[^a-z0-9\\s]/g, \" \")\n .split(/\\s+/)\n .filter(Boolean);\n for (const token of tokens) {\n if (token.length < 5) continue;\n if (/^\\d+$/.test(token)) continue;\n if (STOPWORDS.has(token)) continue;\n counts.set(token, (counts.get(token) ?? 0) + 1);\n }\n }\n\n return [...counts.entries()]\n .sort((a, b) => b[1] - a[1])\n .slice(0, budget)\n .map(([token]) => `\"${token}\" lang:en -is:retweet`);\n}\n\nfunction discoverPeopleFromTweets(tweets: Tweet[], selfHandle: string, budget: number): string[] {\n const scores = new Map<string, number>();\n\n for (const tweet of tweets) {\n const handle = tweet.authorHandle.replace(/^@/, \"\").toLowerCase();\n if (!handle || handle === \"unknown\" || handle === selfHandle) continue;\n\n let score = 1;\n score += Math.min((tweet.replyCount ?? 0) / 15, 1.2);\n score += Math.min((tweet.likeCount ?? 0) / 220, 0.9);\n score += Math.min((tweet.retweetCount ?? 0) / 120, 0.8);\n if (tweet.text.includes(\"?\")) score += 0.25;\n\n const existing = scores.get(handle) ?? 0;\n if (score > existing) scores.set(handle, score);\n }\n\n return [...scores.entries()]\n .sort((a, b) => b[1] - a[1])\n .slice(0, budget)\n .map(([handle]) => handle);\n}\n\nfunction pickTopicQueries(allTopics: string[], budget: number): string[] {\n const recent = new Set(topicQueryHistory.slice(-10));\n const candidates = shuffle(allTopics.flatMap(buildTopicQueryVariants));\n const picked: string[] = [];\n\n for (const query of candidates) {\n const normalized = query.toLowerCase();\n if (recent.has(normalized)) continue;\n picked.push(query);\n if (picked.length >= budget) break;\n }\n\n if (picked.length < budget) {\n for (const query of candidates) {\n picked.push(query);\n if (picked.length >= budget) break;\n }\n }\n\n for (const query of picked) {\n topicQueryHistory.push(query.toLowerCase());\n }\n if (topicQueryHistory.length > 100) {\n topicQueryHistory.splice(0, topicQueryHistory.length - 100);\n }\n\n return picked;\n}\n\nfunction pickDirectQueries(queries: string[], budget: number): string[] {\n const recent = new Set(topicQueryHistory.slice(-10));\n const candidates = shuffle(queries);\n const picked: string[] = [];\n\n for (const query of candidates) {\n const normalized = query.toLowerCase();\n if (recent.has(normalized)) continue;\n picked.push(query);\n if (picked.length >= budget) break;\n }\n\n if (picked.length < budget) {\n for (const query of candidates) {\n if (picked.includes(query)) continue;\n picked.push(query);\n if (picked.length >= budget) break;\n }\n }\n\n for (const query of picked) {\n topicQueryHistory.push(query.toLowerCase());\n }\n if (topicQueryHistory.length > 100) {\n topicQueryHistory.splice(0, topicQueryHistory.length - 100);\n }\n\n return picked;\n}\n\nasync function resolveHandleToId(\n client: XClientInterface,\n handle: string,\n): Promise<string | null> {\n const clean = handle.replace(/^@/, \"\");\n if (handleToIdCache.has(clean)) {\n return handleToIdCache.get(clean)!;\n }\n try {\n const profile = await client.getProfile(clean);\n handleToIdCache.set(clean, profile.id);\n return profile.id;\n } catch {\n logger.warn(`Could not resolve handle @${clean} to user ID`);\n return null;\n }\n}\n\n/**\n * Run the full research phase — gathers context from multiple sources.\n * Each sub-function is independently wrapped so failures don't cascade.\n */\nexport async function runResearchPhase(\n client: XClientInterface,\n heartbeatCount: number,\n): Promise<ResearchContext> {\n const context: ResearchContext = {\n timeline: [],\n mentions: [],\n topicSearchResults: [],\n peopleActivity: [],\n ownPostPerformance: [],\n };\n\n // Timeline + Mentions in parallel (always)\n const [timeline, mentions] = await Promise.all([\n client.getTimeline({ count: 20 }).catch(() => [] as Tweet[]),\n client.getMentions({ count: 10 }).catch(() => [] as Tweet[]),\n ]);\n context.timeline = timeline;\n context.mentions = mentions;\n\n // Topic search (every heartbeat, 1-2 rotated queries)\n context.topicSearchResults = await runTopicSearch(client, heartbeatCount, [...timeline, ...mentions]);\n\n // People monitoring (every heartbeat, 2-3 rotated people)\n context.peopleActivity = await runPeopleMonitoring(client, heartbeatCount, [...timeline, ...mentions]);\n\n // Own post performance (every 2nd heartbeat)\n if (heartbeatCount % 2 === 0) {\n context.ownPostPerformance = refreshOwnPostPerformance();\n }\n\n return context;\n}\n\n/**\n * Search for conversations in the agent's topic areas.\n * Rotates through identity.topics + strategy.currentFocus.\n */\nasync function runTopicSearch(\n client: XClientInterface,\n heartbeatCount: number,\n seedTweets: Tweet[],\n): Promise<TopicSearchResult[]> {\n try {\n const identity = loadIdentity();\n const constraints = getPersonaConstraints(identity);\n const strictHandles = personaConstraintHandles(constraints).filter(Boolean);\n const strategy = loadStrategy();\n const selfHandle = canonicalAgentHandle(identity.handle);\n\n const allTopics = [\n ...(identity.topics ?? []),\n ...strategy.currentFocus,\n ]\n .flatMap(splitTopicSignal)\n .filter(Boolean);\n\n // Blend strategic topics with live-feed discovered terms to force exploration.\n const discovered = discoverQueriesFromTweets(seedTweets, 3);\n const targetHandles = [...new Set([\n ...strategy.peopleToEngage\n .filter((person) => person.priority === \"high\" || person.priority === \"medium\")\n .map((person) => person.handle.replace(/^@/, \"\").toLowerCase()),\n ...(identity.heroes ?? []).map((handle) => handle.replace(/^@/, \"\").toLowerCase()),\n ])]\n .filter((handle) => handle && handle !== selfHandle);\n\n const strictQueries = buildTargetedPersonQueries(\n strictHandles.filter((handle) => handle !== selfHandle),\n heartbeatCount,\n 3,\n );\n const personQueries = buildTargetedPersonQueries(targetHandles, heartbeatCount, 2);\n const topicQueries = allTopics.length > 0\n ? pickTopicQueries(allTopics, Math.min(3, Math.max(2, allTopics.length)))\n : [];\n const discoveredQueries = discovered.length > 0\n ? pickDirectQueries(discovered, Math.min(2, discovered.length))\n : [];\n const topicsToSearch = strictQueries.length > 0\n ? [...new Set(strictQueries)]\n : [...new Set([...topicQueries, ...discoveredQueries, ...personQueries])];\n if (topicsToSearch.length === 0) return [];\n\n const results: TopicSearchResult[] = [];\n for (const topicQuery of topicsToSearch) {\n try {\n const tweets = (await client.searchTweets(topicQuery, { count: 10 })).filter((tweet) =>\n tweet.authorHandle.replace(/^@/, \"\").toLowerCase() !== selfHandle\n );\n if (tweets.length > 0) {\n results.push({ query: topicQuery, tweets });\n logger.info(`Topic search \"${topicQuery}\": found ${tweets.length} tweets`);\n }\n } catch {\n // Individual search failure is fine\n }\n }\n return results;\n } catch {\n return [];\n }\n}\n\n/**\n * Check recent tweets from key people.\n * Prioritizes: strategy.peopleToEngage (high) > identity.heroes > top relationships > strategy.peopleToEngage (medium)\n * Rotates 2-3 people per heartbeat.\n */\nasync function runPeopleMonitoring(\n client: XClientInterface,\n heartbeatCount: number,\n seedTweets: Tweet[],\n): Promise<PersonActivity[]> {\n try {\n const strategy = loadStrategy();\n const identity = loadIdentity();\n const constraints = getPersonaConstraints(identity);\n const strictHandles = personaConstraintHandles(constraints)\n .map((handle) => canonicalAgentHandle(handle))\n .filter((handle) => handle.length > 0);\n const selfHandle = identity.handle.replace(/^@/, \"\").toLowerCase();\n const relationships = loadRelationships();\n const networkHandles = listAgentNetworkHandles(20);\n const networkHandleSet = new Set(networkHandles);\n\n if (strictHandles.length > 0) {\n const strictResults: PersonActivity[] = [];\n for (const handle of strictHandles) {\n if (handle === selfHandle) continue;\n const userId = await resolveHandleToId(client, handle);\n if (!userId) continue;\n try {\n const tweets = await client.getUserTweets(userId, { count: 8 });\n if (tweets.length === 0) continue;\n strictResults.push({\n handle,\n userId,\n reason: \"persona hard constraint\",\n tweets,\n });\n upsertAgentHandle(handle, \"observed\", \"people check (strict persona target)\");\n logger.info(`People check @${handle}: ${tweets.length} recent tweets (strict target mode)`);\n } catch {\n // Ignore per-target errors in strict mode.\n }\n }\n return strictResults;\n }\n\n // Build prioritized list\n const people: { handle: string; reason: string; pinned: boolean }[] = [];\n const seen = new Set<string>();\n const highPriorityHandles = new Set(\n strategy.peopleToEngage\n .filter((person) => person.priority === \"high\")\n .map((person) => person.handle.replace(/^@/, \"\").toLowerCase()),\n );\n const protectedHandles = new Set([\n ...highPriorityHandles,\n ...(identity.heroes ?? []).map((handle) => handle.replace(/^@/, \"\").toLowerCase()),\n ...networkHandleSet,\n ]);\n\n const addPerson = (handle: string, reason: string, pinned: boolean = false) => {\n const clean = canonicalAgentHandle(handle);\n if (seen.has(clean)) return;\n if (clean === selfHandle) return;\n if (isLikelySyntheticHandle(clean) && !protectedHandles.has(clean)) return;\n seen.add(clean);\n people.push({ handle: clean, reason, pinned });\n };\n\n // Priority 1: high-priority strategy targets\n for (const p of strategy.peopleToEngage.filter(p => p.priority === \"high\")) {\n addPerson(p.handle, p.reason, true);\n }\n\n // Priority 2: known Spora agent network (always include @sporaai first)\n for (const handle of networkHandles) {\n if (handle === \"sporaai\") {\n const pinSpora = heartbeatCount % 4 === 0;\n addPerson(handle, \"core Spora profile\", pinSpora);\n } else {\n addPerson(handle, \"spora agent network\");\n }\n }\n\n // Priority 3: heroes\n for (const hero of identity.heroes ?? []) {\n addPerson(hero, \"hero/inspiration\");\n }\n\n // Priority 4: known Spora relationships\n const sporeRels = Object.values(relationships.accounts)\n .filter((rel) => rel.isSpore)\n .sort((a, b) => b.interactionCount - a.interactionCount)\n .slice(0, 5);\n for (const rel of sporeRels) {\n addPerson(rel.handle, \"spora relationship\");\n upsertAgentHandle(rel.handle, \"relationship\", \"relationship marked isSpore\");\n }\n\n // Priority 5: top relationships by interaction count\n const topRels = Object.values(relationships.accounts)\n .sort((a, b) => b.interactionCount - a.interactionCount)\n .slice(0, 5);\n for (const r of topRels) {\n addPerson(r.handle, \"frequent interactor\");\n }\n\n // Priority 6: medium-priority strategy targets\n for (const p of strategy.peopleToEngage.filter(p => p.priority === \"medium\")) {\n addPerson(p.handle, p.reason);\n }\n\n // Priority 7: exploration candidates discovered from live timeline/mentions.\n for (const handle of discoverPeopleFromTweets(seedTweets, selfHandle, 6)) {\n addPerson(handle, \"active voice in current conversations\");\n }\n\n if (people.length === 0) return [];\n\n // Pick 2-3 per heartbeat, always including pinned targets first.\n const budget = Math.min(3, people.length);\n const selected: typeof people = [];\n const selectedHandles = new Set<string>();\n\n const pinned = people.filter((person) => person.pinned);\n for (const person of pinned) {\n if (selected.length >= budget) break;\n selected.push(person);\n selectedHandles.add(person.handle);\n }\n\n if (selected.length < budget) {\n const rest = people.filter((person) => !selectedHandles.has(person.handle));\n if (rest.length > 0) {\n const startIdx = (heartbeatCount * 2) % rest.length;\n const rotated = [...rest.slice(startIdx), ...rest.slice(0, startIdx)];\n const recentlyChecked = new Set(peopleMonitorHistory.slice(-8));\n const preferred = rotated.filter((person) => !recentlyChecked.has(person.handle));\n const pool = preferred.length >= (budget - selected.length) ? preferred : rotated;\n for (const person of pool) {\n if (selected.length >= budget) break;\n selected.push(person);\n }\n }\n }\n\n for (const person of selected) {\n peopleMonitorHistory.push(person.handle);\n }\n if (peopleMonitorHistory.length > 120) {\n peopleMonitorHistory.splice(0, peopleMonitorHistory.length - 120);\n }\n\n const results: PersonActivity[] = [];\n const discoveredHandles = new Set<string>();\n for (const person of selected) {\n const userId = await resolveHandleToId(client, person.handle);\n if (!userId) continue;\n\n try {\n const tweets = await client.getUserTweets(userId, { count: 5 });\n if (tweets.length > 0) {\n results.push({\n handle: person.handle,\n userId,\n reason: person.reason,\n tweets,\n });\n upsertAgentHandle(person.handle, \"observed\", \"people check\");\n discoveredHandles.add(canonicalAgentHandle(person.handle));\n for (const tweet of tweets) {\n for (const mentionHandle of extractMentionHandles(tweet.text)) {\n discoveredHandles.add(canonicalAgentHandle(mentionHandle));\n }\n }\n logger.info(`People check @${person.handle}: ${tweets.length} recent tweets`);\n }\n } catch {\n // Individual person check failure is fine\n }\n }\n if (discoveredHandles.size > 0) {\n upsertAgentHandles([...discoveredHandles], \"observed\", \"discovered via people monitoring\");\n }\n return results;\n } catch {\n return [];\n }\n}\n\n/**\n * Get performance data on the agent's own recent posts.\n * Uses existing tracked posts from performance.ts (no API calls).\n */\nfunction refreshOwnPostPerformance(): TrackedPost[] {\n try {\n retireOldPosts();\n return getActiveTrackedPosts().slice(-5);\n } catch {\n return [];\n }\n}\n","import { getRecentInteractions, type InteractionEntry } from \"../memory/index.js\";\nimport { listAgentNetworkHandles } from \"../memory/agent-network.js\";\nimport { loadIdentity } from \"../identity/index.js\";\nimport { loadStrategy } from \"../memory/strategy.js\";\nimport { getPersonaConstraints, personaConstraintHandles } from \"./persona-constraints.js\";\nimport type { AgentAction } from \"./decision-engine.js\";\nimport type { ResearchContext } from \"./research.js\";\nimport type { Tweet } from \"../x-client/types.js\";\n\nexport type OpportunityActionType = \"reply\" | \"like\" | \"retweet\" | \"follow\" | \"post\";\nexport type OpportunitySource = \"mention\" | \"timeline\" | \"topic_search\" | \"people_watch\" | \"synthesis\";\n\nexport interface ActionOpportunity {\n id: string;\n armKey: string;\n actionType: OpportunityActionType;\n source: OpportunitySource;\n score: number;\n summary: string;\n authorHandle?: string;\n tweetId?: string;\n requiresContent: boolean;\n template: Omit<AgentAction, \"content\" | \"reasoning\">;\n context: string;\n}\n\ninterface CandidateTweet {\n tweet: Tweet;\n source: OpportunitySource;\n}\n\ninterface BuildIndexesResult {\n repliedTweetIds: Set<string>;\n likedTweetIds: Set<string>;\n retweetedTweetIds: Set<string>;\n followedHandles: Set<string>;\n authorTouchCount: Map<string, number>;\n authorLastTouchedAt: Map<string, number>;\n}\n\ninterface PersonaContext {\n focusKeywords: string[];\n avoidKeywords: string[];\n priorityHandles: Set<string>;\n heroHandles: Set<string>;\n networkHandles: Set<string>;\n}\n\nfunction normalizeHandle(handle: string | undefined): string {\n return (handle ?? \"\").replace(/^@/, \"\").trim().toLowerCase();\n}\n\nfunction isLikelySyntheticHandle(handle: string): boolean {\n const clean = normalizeHandle(handle);\n return clean === \"spora\" || clean.endsWith(\"_ai\") || clean.endsWith(\"bot\");\n}\n\nfunction normalizeText(text: string): string {\n return text\n .toLowerCase()\n .replace(/https?:\\/\\/\\S+/g, \" \")\n .replace(/[@#]\\w+/g, \" \")\n .replace(/[^a-z0-9\\s]/g, \" \")\n .replace(/\\s+/g, \" \")\n .trim();\n}\n\nfunction clip(text: string, max: number = 190): string {\n if (text.length <= max) return text;\n return `${text.slice(0, max - 3)}...`;\n}\n\nfunction splitKeywords(text: string): string[] {\n const normalized = normalizeText(text);\n if (!normalized) return [];\n const words = normalized.split(\" \");\n if (words.length <= 6) return [normalized];\n const concise = words.filter((word) => word.length >= 4).slice(0, 6);\n return concise.length > 0 ? concise : [words.slice(0, 6).join(\" \")];\n}\n\nfunction unique<T>(values: T[]): T[] {\n return [...new Set(values)];\n}\n\nfunction buildPersonaContext(): PersonaContext {\n const identity = loadIdentity();\n const constraints = getPersonaConstraints(identity);\n const strategy = loadStrategy();\n\n const focusKeywords = unique(\n [\n ...identity.topics,\n ...identity.coreValues,\n ...identity.goals,\n ...strategy.currentFocus,\n ...strategy.shortTermGoals,\n ]\n .flatMap(splitKeywords)\n .map((keyword) => keyword.trim())\n .filter((keyword) => keyword.length >= 3)\n .slice(0, 40),\n );\n\n const avoidKeywords = unique(\n identity.avoidTopics\n .flatMap(splitKeywords)\n .map((keyword) => keyword.trim())\n .filter((keyword) => keyword.length >= 3)\n .slice(0, 20),\n );\n\n const priorityHandles = new Set(\n strategy.peopleToEngage\n .filter((person) => person.priority === \"high\")\n .map((person) => normalizeHandle(person.handle))\n .filter(Boolean),\n );\n for (const handle of personaConstraintHandles(constraints)) {\n priorityHandles.add(normalizeHandle(handle));\n }\n const heroHandles = new Set(\n (identity.heroes ?? []).map((handle) => normalizeHandle(handle)).filter(Boolean),\n );\n const networkHandles = new Set(listAgentNetworkHandles(60).map((handle) => normalizeHandle(handle)).filter(Boolean));\n\n return { focusKeywords, avoidKeywords, priorityHandles, heroHandles, networkHandles };\n}\n\nfunction phraseMatchScore(text: string, keywords: string[]): number {\n if (keywords.length === 0) return 0;\n const normalized = normalizeText(text);\n if (!normalized) return 0;\n\n let score = 0;\n for (const keyword of keywords) {\n const needle = normalizeText(keyword);\n if (!needle) continue;\n if (!normalized.includes(needle)) continue;\n const wordCount = needle.split(\" \").length;\n score += wordCount >= 2 ? 0.7 : 0.35;\n }\n return Math.min(score, 2.4);\n}\n\nfunction recencyPenalty(lastTouchedAt: number | undefined): number {\n if (!lastTouchedAt) return 0;\n const ageHours = (Date.now() - lastTouchedAt) / (1000 * 60 * 60);\n if (ageHours < 1) return 2.0;\n if (ageHours < 4) return 1.1;\n if (ageHours < 12) return 0.55;\n return 0;\n}\n\ninterface TweetScore {\n score: number;\n alignment: number;\n}\n\nfunction buildRecentIndexes(recent: InteractionEntry[]): BuildIndexesResult {\n const repliedTweetIds = new Set<string>();\n const likedTweetIds = new Set<string>();\n const retweetedTweetIds = new Set<string>();\n const followedHandles = new Set<string>();\n const authorTouchCount = new Map<string, number>();\n const authorLastTouchedAt = new Map<string, number>();\n\n for (const entry of recent) {\n if (entry.type === \"reply\" && entry.inReplyTo) {\n repliedTweetIds.add(entry.inReplyTo);\n }\n if (entry.type === \"like\" && entry.tweetId) {\n likedTweetIds.add(entry.tweetId);\n }\n if (entry.type === \"retweet\" && entry.tweetId) {\n retweetedTweetIds.add(entry.tweetId);\n }\n if (entry.type === \"follow\" && entry.targetHandle) {\n followedHandles.add(normalizeHandle(entry.targetHandle));\n }\n if (entry.targetHandle) {\n const handle = normalizeHandle(entry.targetHandle);\n if (!handle) continue;\n authorTouchCount.set(handle, (authorTouchCount.get(handle) ?? 0) + 1);\n const ts = Date.parse(entry.timestamp);\n if (!Number.isNaN(ts)) {\n const existing = authorLastTouchedAt.get(handle) ?? 0;\n if (ts > existing) authorLastTouchedAt.set(handle, ts);\n }\n }\n }\n\n return {\n repliedTweetIds,\n likedTweetIds,\n retweetedTweetIds,\n followedHandles,\n authorTouchCount,\n authorLastTouchedAt,\n };\n}\n\nfunction sourceWeight(source: OpportunitySource): number {\n if (source === \"mention\") return 3.2;\n if (source === \"people_watch\") return 2.4;\n if (source === \"topic_search\") return 2.0;\n if (source === \"timeline\") return 1.5;\n return 1.0;\n}\n\nfunction armKey(actionType: OpportunityActionType, source: OpportunitySource): string {\n return `${actionType}:${source}`;\n}\n\nfunction scoreTweetOpportunity(\n source: OpportunitySource,\n tweet: Tweet,\n authorTouchCount: Map<string, number>,\n authorLastTouchedAt: Map<string, number>,\n recentlyReplied: boolean,\n persona: PersonaContext,\n): TweetScore {\n const handle = normalizeHandle(tweet.authorHandle);\n const priorTouches = authorTouchCount.get(handle) ?? 0;\n const focusMatch = phraseMatchScore(tweet.text, persona.focusKeywords);\n const avoidMatch = phraseMatchScore(tweet.text, persona.avoidKeywords);\n const targetBoost = persona.priorityHandles.has(handle)\n ? 2.4\n : persona.heroHandles.has(handle)\n ? 1.4\n : persona.networkHandles.has(handle)\n ? 0.9\n : 0;\n const alignment = focusMatch + targetBoost - avoidMatch * 1.2;\n\n let score = sourceWeight(source);\n score += Math.min((tweet.replyCount ?? 0) / 12, 1.2);\n score += Math.min((tweet.likeCount ?? 0) / 180, 1.0);\n score += tweet.text.includes(\"?\") ? 0.75 : 0;\n score += alignment;\n score += priorTouches === 0 ? 0.8 : Math.max(0.05, 0.55 - priorTouches * 0.14);\n score -= recencyPenalty(authorLastTouchedAt.get(handle));\n score -= recentlyReplied ? 3.5 : 0;\n if (priorTouches >= 5) score -= 0.8;\n if (avoidMatch > 0.6) score -= 1.2;\n if (\n isLikelySyntheticHandle(handle) &&\n !persona.priorityHandles.has(handle) &&\n !persona.heroHandles.has(handle) &&\n !persona.networkHandles.has(handle)\n ) {\n score -= 2.4;\n }\n\n return { score, alignment };\n}\n\nexport function buildActionOpportunities(input: {\n research: ResearchContext;\n selfHandle: string;\n selfUserId?: string | null;\n maxCandidates?: number;\n}): ActionOpportunity[] {\n const { research } = input;\n const maxCandidates = input.maxCandidates ?? 28;\n const selfHandle = normalizeHandle(input.selfHandle);\n const selfUserId = (input.selfUserId ?? \"\").trim();\n const constraints = getPersonaConstraints();\n const onlyReplyHandles = new Set(constraints.onlyReplyToHandles.map((h) => normalizeHandle(h)));\n const onlyInteractHandles = new Set(constraints.onlyInteractWithHandles.map((h) => normalizeHandle(h)));\n const persona = buildPersonaContext();\n\n const recent = getRecentInteractions(300);\n const {\n repliedTweetIds,\n likedTweetIds,\n retweetedTweetIds,\n followedHandles,\n authorTouchCount,\n authorLastTouchedAt,\n } = buildRecentIndexes(recent);\n\n const candidateTweets: CandidateTweet[] = [];\n for (const tweet of research.mentions) candidateTweets.push({ tweet, source: \"mention\" });\n for (const tweet of research.timeline) candidateTweets.push({ tweet, source: \"timeline\" });\n for (const result of research.topicSearchResults) {\n for (const tweet of result.tweets) candidateTweets.push({ tweet, source: \"topic_search\" });\n }\n for (const person of research.peopleActivity) {\n for (const tweet of person.tweets) candidateTweets.push({ tweet, source: \"people_watch\" });\n }\n\n const dedupedByTweetId = new Map<string, CandidateTweet>();\n for (const candidate of candidateTweets) {\n const handle = normalizeHandle(candidate.tweet.authorHandle);\n if (!candidate.tweet.id || !handle || handle === selfHandle) continue;\n if (selfUserId && candidate.tweet.authorId === selfUserId) continue;\n if (onlyInteractHandles.size > 0 && !onlyInteractHandles.has(handle)) continue;\n\n const existing = dedupedByTweetId.get(candidate.tweet.id);\n if (!existing || sourceWeight(candidate.source) > sourceWeight(existing.source)) {\n dedupedByTweetId.set(candidate.tweet.id, candidate);\n }\n }\n\n const followOpportunityByHandle = new Set<string>();\n const opportunities: ActionOpportunity[] = [];\n let counter = 0;\n const nextId = (): string => {\n counter += 1;\n return `opp-${counter}`;\n };\n\n for (const { tweet, source } of dedupedByTweetId.values()) {\n const handle = normalizeHandle(tweet.authorHandle);\n const { score: baseScore, alignment } = scoreTweetOpportunity(\n source,\n tweet,\n authorTouchCount,\n authorLastTouchedAt,\n repliedTweetIds.has(tweet.id),\n persona,\n );\n const shortTweet = clip(tweet.text, 170);\n\n opportunities.push({\n id: nextId(),\n armKey: armKey(\"reply\", source),\n actionType: \"reply\",\n source,\n score: baseScore + 0.7,\n summary: `Reply to @${handle} from ${source}`,\n authorHandle: handle,\n tweetId: tweet.id,\n requiresContent: true,\n template: { action: \"reply\", tweetId: tweet.id, source, targetHandle: `@${handle}` },\n context: `@${handle}: \"${shortTweet}\"`,\n });\n\n const stronglyRelevant =\n alignment >= 0.35 || source === \"mention\" || source === \"people_watch\" || persona.priorityHandles.has(handle);\n\n if (\n onlyReplyHandles.size === 0 &&\n !constraints.replyOnlyMode &&\n !likedTweetIds.has(tweet.id) &&\n baseScore >= 1.8 &&\n stronglyRelevant\n ) {\n opportunities.push({\n id: nextId(),\n armKey: armKey(\"like\", source),\n actionType: \"like\",\n source,\n score: baseScore + 0.2,\n summary: `Like @${handle} from ${source}`,\n authorHandle: handle,\n tweetId: tweet.id,\n requiresContent: false,\n template: { action: \"like\", tweetId: tweet.id, source, targetHandle: `@${handle}` },\n context: `@${handle}: \"${shortTweet}\"`,\n });\n }\n\n if (\n onlyReplyHandles.size === 0 &&\n !constraints.replyOnlyMode &&\n !retweetedTweetIds.has(tweet.id) &&\n baseScore >= 2.6 &&\n alignment >= 0.15\n ) {\n opportunities.push({\n id: nextId(),\n armKey: armKey(\"retweet\", source),\n actionType: \"retweet\",\n source,\n score: baseScore - 0.1,\n summary: `Retweet @${handle} from ${source}`,\n authorHandle: handle,\n tweetId: tweet.id,\n requiresContent: false,\n template: { action: \"retweet\", tweetId: tweet.id, source, targetHandle: `@${handle}` },\n context: `@${handle}: \"${shortTweet}\"`,\n });\n }\n\n const shouldConsiderFollow =\n onlyReplyHandles.size === 0 &&\n !constraints.replyOnlyMode &&\n !followedHandles.has(handle) &&\n !followOpportunityByHandle.has(handle) &&\n !isLikelySyntheticHandle(handle) &&\n baseScore >= 3 &&\n (\n persona.priorityHandles.has(handle) ||\n persona.heroHandles.has(handle) ||\n source === \"mention\" ||\n alignment >= 0.8\n );\n\n if (shouldConsiderFollow) {\n followOpportunityByHandle.add(handle);\n opportunities.push({\n id: nextId(),\n armKey: armKey(\"follow\", source),\n actionType: \"follow\",\n source,\n score: baseScore - 0.2,\n summary: `Follow @${handle}`,\n authorHandle: handle,\n requiresContent: false,\n template: { action: \"follow\", handle: `@${handle}`, source, targetHandle: `@${handle}` },\n context: `Account @${handle} is producing conversation-relevant content.`,\n });\n }\n }\n\n const queryList = research.topicSearchResults.map((r) => r.query).filter(Boolean);\n if (\n queryList.length > 0 &&\n !constraints.noOriginalPosts &&\n !constraints.replyOnlyMode &&\n onlyInteractHandles.size === 0 &&\n onlyReplyHandles.size === 0\n ) {\n opportunities.push({\n id: nextId(),\n armKey: armKey(\"post\", \"synthesis\"),\n actionType: \"post\",\n source: \"synthesis\",\n score: 2.25,\n summary: \"Post an original thought synthesized from active conversations\",\n requiresContent: true,\n template: { action: \"post\", source: \"synthesis\" },\n context: `Weave a fresh take from active topics: ${queryList.slice(0, 4).join(\", \")}`,\n });\n }\n\n opportunities.sort((a, b) => b.score - a.score);\n return opportunities.slice(0, maxCandidates);\n}\n","import { logger } from \"../utils/logger.js\";\nimport { generateResponse } from \"./llm.js\";\nimport type { AgentAction } from \"./decision-engine.js\";\nimport type { ActionOpportunity } from \"./opportunity-engine.js\";\nimport { buildOpportunityPortfolioMessage } from \"./prompt-builder.js\";\n\ninterface PlannedSelection {\n candidateId: string;\n content?: string;\n reasoning?: string;\n}\n\nfunction parseSelections(responseText: string): PlannedSelection[] {\n const codeBlockMatch = responseText.match(/```(?:json)?\\s*\\n?([\\s\\S]*?)```/);\n const candidatesToTry: string[] = [];\n if (codeBlockMatch?.[1]) candidatesToTry.push(codeBlockMatch[1].trim());\n candidatesToTry.push(responseText.trim());\n\n for (const raw of candidatesToTry) {\n try {\n const parsed = JSON.parse(raw) as { selections?: PlannedSelection[] };\n if (Array.isArray(parsed.selections)) return parsed.selections;\n } catch {\n // continue\n }\n }\n\n const arrayMatch = responseText.match(/\\[\\s*\\{[\\s\\S]*\\}\\s*\\]/);\n if (arrayMatch) {\n try {\n const parsed = JSON.parse(arrayMatch[0]) as PlannedSelection[];\n if (Array.isArray(parsed)) return parsed;\n } catch {\n // continue\n }\n }\n\n return [];\n}\n\nfunction materializeSelections(\n selections: PlannedSelection[],\n opportunities: ActionOpportunity[],\n maxActions: number,\n): AgentAction[] {\n const byId = new Map(opportunities.map((opportunity) => [opportunity.id, opportunity]));\n const actions: AgentAction[] = [];\n const used = new Set<string>();\n\n for (const selection of selections) {\n if (actions.length >= maxActions) break;\n if (!selection.candidateId || used.has(selection.candidateId)) continue;\n\n const opportunity = byId.get(selection.candidateId);\n if (!opportunity) continue;\n\n const action: AgentAction = {\n ...opportunity.template,\n banditArm: opportunity.armKey,\n opportunityId: opportunity.id,\n reasoning: selection.reasoning,\n };\n\n if (opportunity.requiresContent) {\n const content = (selection.content ?? \"\").trim();\n if (!content) continue;\n action.content = content;\n }\n\n used.add(selection.candidateId);\n actions.push(action);\n }\n\n return actions;\n}\n\nexport async function planActionPortfolio(input: {\n systemPrompt: string;\n opportunities: ActionOpportunity[];\n maxActions: number;\n policyFeedback: string[];\n executedActions?: AgentAction[];\n}): Promise<AgentAction[]> {\n const { systemPrompt, opportunities, maxActions, policyFeedback, executedActions = [] } = input;\n\n if (opportunities.length === 0 || maxActions <= 0) return [];\n\n const prompt = buildOpportunityPortfolioMessage({\n opportunities,\n maxActions,\n policyFeedback,\n executedActions,\n });\n\n const llmResponse = await generateResponse(systemPrompt, prompt);\n const parsed = parseSelections(llmResponse.content);\n const actions = materializeSelections(parsed, opportunities, maxActions);\n\n if (actions.length === 0) {\n logger.warn(\"Portfolio planner returned no valid selections.\");\n }\n\n return actions;\n}\n","import { existsSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { updatePostMetrics } from \"../memory/performance.js\";\nimport { paths } from \"../utils/paths.js\";\nimport { logger } from \"../utils/logger.js\";\nimport type { AgentAction, ActionResult } from \"./decision-engine.js\";\nimport type { ActionOpportunity } from \"./opportunity-engine.js\";\nimport type { XClientInterface } from \"../x-client/types.js\";\n\ninterface BanditArm {\n key: string;\n pulls: number;\n rewardSum: number;\n lastReward: number;\n updatedAt: string;\n}\n\ninterface PendingOutcome {\n id: string;\n armKey: string;\n actionType: string;\n tweetId?: string;\n createdAt: string;\n resolveAt: string;\n resolved: boolean;\n}\n\ninterface BanditState {\n totalPulls: number;\n explorationBudget: number;\n arms: Record<string, BanditArm>;\n pending: PendingOutcome[];\n}\n\ninterface ScoredOpportunity {\n opportunity: ActionOpportunity;\n adjustedScore: number;\n pulls: number;\n}\n\nexport interface OutcomeCollectionResult {\n processed: number;\n resolved: number;\n rewardAdded: number;\n}\n\nconst DEFAULT_EXPLORATION_BUDGET = 0.25;\n\nfunction defaultState(): BanditState {\n return {\n totalPulls: 0,\n explorationBudget: DEFAULT_EXPLORATION_BUDGET,\n arms: {},\n pending: [],\n };\n}\n\nfunction clamp(value: number, min: number, max: number): number {\n return Math.max(min, Math.min(max, value));\n}\n\nfunction loadState(): BanditState {\n if (!existsSync(paths.bandit)) return defaultState();\n try {\n const parsed = JSON.parse(readFileSync(paths.bandit, \"utf-8\")) as Partial<BanditState>;\n const state: BanditState = {\n totalPulls: Math.max(0, parsed.totalPulls ?? 0),\n explorationBudget: clamp(parsed.explorationBudget ?? DEFAULT_EXPLORATION_BUDGET, 0.1, 0.45),\n arms: parsed.arms ?? {},\n pending: Array.isArray(parsed.pending) ? parsed.pending : [],\n };\n return state;\n } catch {\n return defaultState();\n }\n}\n\nfunction saveState(state: BanditState): void {\n state.explorationBudget = clamp(state.explorationBudget, 0.1, 0.45);\n state.pending = state.pending\n .filter((entry) => {\n if (!entry.resolved) return true;\n const resolvedAtMs = Date.parse(entry.resolveAt);\n if (Number.isNaN(resolvedAtMs)) return false;\n return Date.now() - resolvedAtMs < 7 * 24 * 60 * 60 * 1000;\n })\n .slice(-1200);\n writeFileSync(paths.bandit, JSON.stringify(state, null, 2));\n}\n\nfunction ensureArm(state: BanditState, armKey: string): BanditArm {\n const existing = state.arms[armKey];\n if (existing) return existing;\n const arm: BanditArm = {\n key: armKey,\n pulls: 0,\n rewardSum: 0,\n lastReward: 0,\n updatedAt: new Date().toISOString(),\n };\n state.arms[armKey] = arm;\n return arm;\n}\n\nfunction averageReward(arm: BanditArm): number {\n if (arm.pulls <= 0) return 0;\n return arm.rewardSum / arm.pulls;\n}\n\nfunction ucbBonus(totalPulls: number, armPulls: number): number {\n const t = Math.max(1, totalPulls);\n return Math.sqrt((2 * Math.log(t + 1)) / (armPulls + 1));\n}\n\nfunction computeImmediateReward(result: ActionResult): number {\n if (result.success) return 0.12;\n const error = (result.error ?? \"\").toLowerCase();\n if (error.includes(\"duplicate content\")) return -0.95;\n if (error.includes(\"rate limit\")) return -0.5;\n if (error.includes(\"forbidden\") || error.includes(\"403\")) return -0.55;\n return -0.35;\n}\n\nfunction resolveDelayedReward(metrics: { likeCount: number; replyCount: number; retweetCount: number } | null): number {\n if (!metrics) return -0.05;\n const reward =\n Math.min(metrics.likeCount * 0.03, 0.9) +\n Math.min(metrics.replyCount * 0.12, 0.9) +\n Math.min(metrics.retweetCount * 0.08, 0.8);\n if (metrics.likeCount === 0 && metrics.replyCount === 0 && metrics.retweetCount === 0) {\n return -0.15;\n }\n return Math.min(reward, 1.8);\n}\n\nfunction armKeyFromAction(action: AgentAction): string {\n if (action.banditArm && action.banditArm.trim().length > 0) return action.banditArm;\n const source = action.source ?? \"unknown\";\n return `${action.action}:${source}`;\n}\n\nfunction extractTweetId(action: AgentAction, result: ActionResult): string | undefined {\n if (result.detail && /^\\d+$/.test(result.detail)) return result.detail;\n if (action.action !== \"reply\" && action.tweetId) return action.tweetId;\n return undefined;\n}\n\nexport function selectBanditOpportunityPool(\n opportunities: ActionOpportunity[],\n maxPoolSize: number = 24,\n): ActionOpportunity[] {\n if (opportunities.length <= maxPoolSize) return opportunities;\n\n const state = loadState();\n const totalPulls = Math.max(1, state.totalPulls);\n const scored: ScoredOpportunity[] = opportunities.map((opportunity) => {\n const arm = ensureArm(state, opportunity.armKey);\n const mean = averageReward(arm);\n const bonus = ucbBonus(totalPulls, arm.pulls);\n const coldStartBoost = arm.pulls === 0 ? 0.25 : 0;\n const adjustedScore = opportunity.score + mean * 1.5 + bonus * 0.35 + coldStartBoost;\n return {\n opportunity: {\n ...opportunity,\n score: adjustedScore,\n },\n adjustedScore,\n pulls: arm.pulls,\n };\n });\n\n const explorationBudget = clamp(state.explorationBudget, 0.1, 0.45);\n const exploreCount = Math.max(1, Math.floor(maxPoolSize * explorationBudget));\n const exploitCount = Math.max(1, maxPoolSize - exploreCount);\n\n const exploit = [...scored].sort((a, b) => b.adjustedScore - a.adjustedScore).slice(0, exploitCount);\n const selected = new Map<string, ActionOpportunity>();\n for (const row of exploit) {\n selected.set(row.opportunity.id, row.opportunity);\n }\n\n const remaining = scored\n .filter((row) => !selected.has(row.opportunity.id))\n .sort((a, b) => {\n if (a.pulls !== b.pulls) return a.pulls - b.pulls;\n return b.adjustedScore - a.adjustedScore;\n });\n\n // Add low-pull candidates first, with slight randomization for exploration.\n while (selected.size < maxPoolSize && remaining.length > 0) {\n const window = remaining.splice(0, Math.min(5, remaining.length));\n const pick = window[Math.floor(Math.random() * window.length)];\n if (!selected.has(pick.opportunity.id)) {\n selected.set(pick.opportunity.id, pick.opportunity);\n }\n for (const row of window) {\n if (row.opportunity.id !== pick.opportunity.id) {\n remaining.push(row);\n }\n }\n remaining.sort((a, b) => {\n if (a.pulls !== b.pulls) return a.pulls - b.pulls;\n return b.adjustedScore - a.adjustedScore;\n });\n }\n\n const picked = [...selected.values()].sort((a, b) => b.score - a.score).slice(0, maxPoolSize);\n saveState(state);\n return picked;\n}\n\nexport function recordBanditActionResults(actions: AgentAction[], results: ActionResult[]): void {\n if (actions.length === 0 || results.length === 0) return;\n const state = loadState();\n const now = new Date().toISOString();\n\n for (let i = 0; i < Math.min(actions.length, results.length); i += 1) {\n const action = actions[i];\n const result = results[i];\n const armKey = armKeyFromAction(action);\n const arm = ensureArm(state, armKey);\n\n const immediateReward = computeImmediateReward(result);\n arm.pulls += 1;\n arm.rewardSum += immediateReward;\n arm.lastReward = immediateReward;\n arm.updatedAt = now;\n state.totalPulls += 1;\n\n const tweetId = extractTweetId(action, result);\n if (result.success && tweetId && (action.action === \"post\" || action.action === \"reply\")) {\n const delayMs = action.action === \"reply\" ? 20 * 60 * 1000 : 45 * 60 * 1000;\n state.pending.push({\n id: `pending-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,\n armKey,\n actionType: action.action,\n tweetId,\n createdAt: now,\n resolveAt: new Date(Date.now() + delayMs).toISOString(),\n resolved: false,\n });\n }\n }\n\n saveState(state);\n}\n\nexport async function collectDelayedOutcomes(client: XClientInterface): Promise<OutcomeCollectionResult> {\n const state = loadState();\n const now = Date.now();\n const pendingDue = state.pending.filter((entry) => !entry.resolved && Date.parse(entry.resolveAt) <= now).slice(0, 8);\n if (pendingDue.length === 0) {\n return { processed: 0, resolved: 0, rewardAdded: 0 };\n }\n\n let rewardAdded = 0;\n let resolved = 0;\n const checkedAt = new Date().toISOString();\n\n for (const pending of pendingDue) {\n const arm = ensureArm(state, pending.armKey);\n let metrics: { likeCount: number; retweetCount: number; replyCount: number } | null = null;\n\n if (pending.tweetId) {\n metrics = await client.getTweetMetrics(pending.tweetId);\n if (metrics) {\n updatePostMetrics(pending.tweetId, {\n checkedAt,\n likes: metrics.likeCount,\n retweets: metrics.retweetCount,\n replies: metrics.replyCount,\n });\n }\n }\n\n const reward = resolveDelayedReward(\n metrics\n ? {\n likeCount: metrics.likeCount,\n retweetCount: metrics.retweetCount,\n replyCount: metrics.replyCount,\n }\n : null,\n );\n\n arm.rewardSum += reward;\n arm.lastReward = reward;\n arm.updatedAt = checkedAt;\n rewardAdded += reward;\n pending.resolved = true;\n resolved += 1;\n }\n\n saveState(state);\n logger.info(\n `Bandit delayed outcomes processed=${pendingDue.length}, resolved=${resolved}, rewardDelta=${rewardAdded.toFixed(2)}`\n );\n\n return {\n processed: pendingDue.length,\n resolved,\n rewardAdded,\n };\n}\n","import { getXClient } from \"../x-client/index.js\";\nimport { logger } from \"../utils/logger.js\";\nimport { getRecentInteractions } from \"../memory/index.js\";\nimport { loadStrategy } from \"../memory/strategy.js\";\nimport { listIntents, recordIntentExecution } from \"../memory/intents.js\";\nimport { loadIdentity } from \"../identity/index.js\";\nimport { loadCredentials } from \"../utils/crypto.js\";\nimport type { Tweet } from \"../x-client/types.js\";\nimport { buildSystemPrompt } from \"./prompt-builder.js\";\nimport { executeAction, type AgentAction, type ActionResult } from \"./decision-engine.js\";\nimport { evaluateActionPolicy } from \"./policy.js\";\nimport { runResearchPhase } from \"./research.js\";\nimport { buildActionOpportunities, type ActionOpportunity } from \"./opportunity-engine.js\";\nimport { planActionPortfolio } from \"./portfolio-planner.js\";\nimport { generateResponse } from \"./llm.js\";\nimport { buildPersonaConstraintLines, getPersonaConstraints } from \"./persona-constraints.js\";\nimport {\n collectDelayedOutcomes,\n recordBanditActionResults,\n selectBanditOpportunityPool,\n} from \"./bandit.js\";\n\nexport interface AutonomyCycleResult {\n timeline: Tweet[];\n mentions: Tweet[];\n actions: AgentAction[];\n results: ActionResult[];\n policyFeedback: string[];\n}\n\nfunction recentReplyTargets(hours: number = 24): Set<string> {\n const cutoffMs = Date.now() - hours * 60 * 60 * 1000;\n const recent = getRecentInteractions(300);\n const targets = new Set<string>();\n\n for (const entry of recent) {\n if (entry.type !== \"reply\") continue;\n if (!entry.inReplyTo) continue;\n const ts = Date.parse(entry.timestamp);\n if (!Number.isNaN(ts) && ts < cutoffMs) continue;\n targets.add(entry.inReplyTo);\n }\n\n return targets;\n}\n\nfunction selfUserIdFromCredentials(): string | null {\n try {\n const creds = loadCredentials();\n const accessToken = creds.accessToken;\n if (!accessToken) return null;\n const dashIdx = accessToken.indexOf(\"-\");\n if (dashIdx <= 0) return null;\n const candidate = accessToken.substring(0, dashIdx);\n return /^\\d+$/.test(candidate) ? candidate : null;\n } catch {\n return null;\n }\n}\n\nfunction normalizeHandle(handle: string | undefined): string {\n return (handle ?? \"\").replace(/^@/, \"\").trim().toLowerCase();\n}\n\ntype RewriteStyleMode =\n | \"quick_reaction\"\n | \"curious_question\"\n | \"friendly_pushback\"\n | \"plain_observation\"\n | \"playful_line\";\n\nfunction roughWordCount(text: string): number {\n return text.trim().split(/\\s+/).filter(Boolean).length;\n}\n\nfunction inferStyleMode(text: string): RewriteStyleMode {\n const lower = text.toLowerCase();\n if (text.includes(\"?\")) return \"curious_question\";\n if (/\\b(lol|lmao|haha|wild|fr|ngl)\\b/i.test(text)) return \"playful_line\";\n if (/\\b(not|isn'?t|wrong|nah|nope|doesn'?t)\\b/i.test(lower)) return \"friendly_pushback\";\n if (roughWordCount(text) <= 9) return \"quick_reaction\";\n return \"plain_observation\";\n}\n\nfunction chooseRewriteStyleMode(recentTexts?: string[], targetTweetText?: string): RewriteStyleMode {\n const counts: Record<RewriteStyleMode, number> = {\n quick_reaction: 0,\n curious_question: 0,\n friendly_pushback: 0,\n plain_observation: 0,\n playful_line: 0,\n };\n for (const text of (recentTexts ?? []).slice(0, 10)) {\n counts[inferStyleMode(text)] += 1;\n }\n\n if ((targetTweetText ?? \"\").includes(\"?\") && counts.curious_question <= 2) {\n return \"curious_question\";\n }\n\n return (Object.entries(counts).sort((a, b) => a[1] - b[1])[0]?.[0] as RewriteStyleMode) ?? \"plain_observation\";\n}\n\nfunction rewriteStyleModeInstructions(mode: RewriteStyleMode): string[] {\n if (mode === \"quick_reaction\") {\n return [\n \"- style mode: quick reaction\",\n \"- 6-14 words, one short sentence\",\n \"- immediate reaction tone, no thesis statement\",\n ];\n }\n if (mode === \"curious_question\") {\n return [\n \"- style mode: curious question\",\n \"- include exactly one direct question\",\n \"- ask about a specific detail from the target tweet\",\n ];\n }\n if (mode === \"friendly_pushback\") {\n return [\n \"- style mode: friendly pushback\",\n \"- politely disagree in plain words\",\n \"- no lecture or abstract framing\",\n ];\n }\n if (mode === \"playful_line\") {\n return [\n \"- style mode: playful line\",\n \"- keep it light and witty, not sarcastic essay mode\",\n \"- avoid internet clichés and overused slogans\",\n ];\n }\n return [\n \"- style mode: plain observation\",\n \"- write like a natural human thought said out loud\",\n \"- concrete detail first, no broad generalization\",\n ];\n}\n\nfunction shouldAttemptStyleRewrite(action: AgentAction, reason: string): boolean {\n if (!action.content || (action.action !== \"reply\" && action.action !== \"post\")) return false;\n const lower = reason.toLowerCase();\n return (\n lower.includes(\"lecture-like\") ||\n lower.includes(\"abstract philosopher cadence\") ||\n lower.includes(\"manifesto\") ||\n lower.includes(\"too long/explanatory\") ||\n lower.includes(\"grounded in the target tweet context\") ||\n lower.includes(\"hedged consensus phrasing\") ||\n lower.includes(\"repetitive anchor phrase/term\") ||\n lower.includes(\"repetitive opening phrase\") ||\n lower.includes(\"low-novelty vocabulary loop\") ||\n lower.includes(\"abstract wording without concrete anchor\")\n );\n}\n\nfunction cleanRewriteOutput(text: string): string {\n const cleaned = text\n .replace(/```[\\s\\S]*?```/g, \"\")\n .replace(/^[\"'`]+|[\"'`]+$/g, \"\")\n .trim();\n const firstLine = cleaned.split(\"\\n\").map((line) => line.trim()).filter(Boolean)[0] ?? cleaned;\n return firstLine.trim();\n}\n\nasync function rewriteDraftForHumanVoice(input: {\n action: AgentAction;\n reason: string;\n targetTweetText?: string;\n recentTexts?: string[];\n}): Promise<string | null> {\n if (!input.action.content) return null;\n const identity = loadIdentity();\n const maxChars = input.action.action === \"reply\" ? 100 : 130;\n const minChars = input.action.action === \"reply\" ? 18 : 24;\n const styleMode = chooseRewriteStyleMode(input.recentTexts, input.targetTweetText);\n\n const system = [\n `You rewrite X/Twitter drafts into ${identity.name}'s natural voice.`,\n \"Output must feel human, direct, and contextual.\",\n \"Never write abstract philosophy or explanatory manifesto style.\",\n \"Return ONLY rewritten tweet text, no commentary.\",\n ].join(\" \");\n\n const promptParts: string[] = [];\n promptParts.push(`Current draft: ${input.action.content}`);\n promptParts.push(`Rejected because: ${input.reason}`);\n if (input.targetTweetText) {\n promptParts.push(`Target tweet context: ${input.targetTweetText}`);\n }\n promptParts.push(`Constraints:`);\n promptParts.push(`- ${minChars}-${maxChars} characters`);\n promptParts.push(\"- 1-2 short sentences max\");\n promptParts.push(\"- no 'the real question' / 'the deeper question' framing\");\n promptParts.push(\"- no colon, semicolon, or em dash\");\n promptParts.push(\"- specific and concrete, not abstract\");\n promptParts.push(\"- keep the same core stance\");\n promptParts.push(\"- use natural spoken phrasing and contractions when it fits\");\n for (const line of rewriteStyleModeInstructions(styleMode)) {\n promptParts.push(line);\n }\n if (input.recentTexts && input.recentTexts.length > 0) {\n promptParts.push(\"- avoid vocabulary anchors from these recent outputs:\");\n for (const text of input.recentTexts.slice(0, 5)) {\n promptParts.push(` - ${text.slice(0, 120)}`);\n }\n }\n\n try {\n const rewrite = await generateResponse(system, promptParts.join(\"\\n\"));\n const candidate = cleanRewriteOutput(rewrite.content);\n if (!candidate) return null;\n return candidate;\n } catch {\n return null;\n }\n}\n\nexport async function runAutonomyCycle(maxActions: number, heartbeatCount: number = 0): Promise<AutonomyCycleResult> {\n const client = await getXClient();\n const constraints = getPersonaConstraints();\n const strictReplyOnly = constraints.replyOnlyMode || constraints.onlyReplyToHandles.length > 0;\n const constraintLines = buildPersonaConstraintLines(constraints);\n if (constraintLines.length > 0) {\n logger.info(`Persona constraints active: ${constraintLines.join(\" | \")}`);\n }\n\n try {\n const delayed = await collectDelayedOutcomes(client);\n if (delayed.processed > 0) {\n logger.info(\n `Delayed outcomes: processed=${delayed.processed}, resolved=${delayed.resolved}, rewardDelta=${delayed.rewardAdded.toFixed(2)}`\n );\n }\n } catch (error) {\n logger.warn(`Delayed outcome collection failed: ${(error as Error).message}`);\n }\n\n const selfHandle = loadIdentity().handle.replace(/^@/, \"\").toLowerCase();\n const selfUserId = selfUserIdFromCredentials();\n const isSelfTweet = (tweet: Tweet): boolean =>\n tweet.authorHandle.replace(/^@/, \"\").toLowerCase() === selfHandle ||\n (selfUserId !== null && tweet.authorId === selfUserId);\n\n const research = await runResearchPhase(client, heartbeatCount);\n const timeline = research.timeline.filter((tweet) => !isSelfTweet(tweet));\n const mentions = research.mentions.filter((tweet) => !isSelfTweet(tweet));\n const recentReplyTargetIds = recentReplyTargets(24);\n\n const filteredTimeline = timeline.filter((tweet) => !recentReplyTargetIds.has(tweet.id));\n const filteredMentions = mentions.filter((tweet) => !recentReplyTargetIds.has(tweet.id));\n const filteredTopicSearchResults = research.topicSearchResults\n .map((result) => ({\n ...result,\n tweets: result.tweets.filter((tweet) => !recentReplyTargetIds.has(tweet.id) && !isSelfTweet(tweet)),\n }))\n .filter((result) => result.tweets.length > 0);\n const filteredPeopleActivity = research.peopleActivity\n .map((person) => ({\n ...person,\n tweets: person.tweets.filter((tweet) => !recentReplyTargetIds.has(tweet.id) && !isSelfTweet(tweet)),\n }))\n .filter((person) => person.tweets.length > 0);\n\n const observedTweetIds = [\n ...filteredTimeline.map((tweet) => tweet.id),\n ...filteredMentions.map((tweet) => tweet.id),\n ...filteredTopicSearchResults.flatMap((result) => result.tweets.map((tweet) => tweet.id)),\n ...filteredPeopleActivity.flatMap((person) => person.tweets.map((tweet) => tweet.id)),\n ];\n const observedTweets = [\n ...filteredTimeline,\n ...filteredMentions,\n ...filteredTopicSearchResults.flatMap((result) => result.tweets),\n ...filteredPeopleActivity.flatMap((person) => person.tweets),\n ];\n logger.info(\n `Autonomy context: timeline=${filteredTimeline.length}, mentions=${filteredMentions.length}, topicTweets=${filteredTopicSearchResults.reduce((sum, r) => sum + r.tweets.length, 0)}, peopleTweets=${filteredPeopleActivity.reduce((sum, p) => sum + p.tweets.length, 0)}`\n );\n\n const systemPrompt = buildSystemPrompt();\n const actions: AgentAction[] = [];\n const results: ActionResult[] = [];\n const policyFeedback: string[] = [];\n const blockedTweetIds = new Set<string>(recentReplyTargetIds);\n const disallowedActions = new Set<string>();\n let replyRejectionCount = 0;\n const opportunities = buildActionOpportunities({\n research: {\n ...research,\n timeline: filteredTimeline,\n mentions: filteredMentions,\n topicSearchResults: filteredTopicSearchResults,\n peopleActivity: filteredPeopleActivity,\n },\n selfHandle,\n selfUserId,\n maxCandidates: 30,\n });\n const planningPool = selectBanditOpportunityPool(opportunities, 24);\n const byType = planningPool.reduce<Record<string, number>>((acc, opportunity) => {\n acc[opportunity.actionType] = (acc[opportunity.actionType] ?? 0) + 1;\n return acc;\n }, {});\n logger.info(`Opportunities selected: total=${planningPool.length}, byType=${JSON.stringify(byType)}`);\n const strategy = loadStrategy();\n const activeIntents = listIntents();\n const intentTargetHandles = new Set(\n activeIntents.flatMap((intent) => intent.targetHandles.map((handle) => normalizeHandle(handle)))\n );\n const priorityHandles = new Set(\n [\n ...strategy.peopleToEngage\n .filter((person) => person.priority === \"high\")\n .map((person) => normalizeHandle(person.handle))\n .filter(Boolean),\n ...intentTargetHandles,\n ],\n );\n const authorByTweetId = new Map<string, string>();\n for (const opportunity of planningPool) {\n if (opportunity.tweetId && opportunity.authorHandle) {\n authorByTweetId.set(opportunity.tweetId, normalizeHandle(opportunity.authorHandle));\n }\n }\n\n // Keep short memory available in context by touching it before planner loop.\n getRecentInteractions(20);\n\n const getPlanningOpportunities = (): ActionOpportunity[] => {\n return planningPool.filter((opportunity) => {\n if (disallowedActions.has(opportunity.actionType)) return false;\n if (opportunity.tweetId && blockedTweetIds.has(opportunity.tweetId)) return false;\n return true;\n });\n };\n\n for (let planningRound = 0; planningRound < 2 && actions.length < maxActions; planningRound += 1) {\n const candidates = getPlanningOpportunities();\n if (candidates.length === 0) {\n logger.info(\"No viable opportunities after filtering.\");\n break;\n }\n\n let plannedActions = await planActionPortfolio({\n systemPrompt,\n opportunities: candidates,\n maxActions: maxActions - actions.length,\n policyFeedback,\n executedActions: actions,\n });\n\n // Portfolio diversity guard: if model only picked replies, inject one non-reply candidate.\n if (!strictReplyOnly && plannedActions.length > 1 && plannedActions.every((a) => a.action === \"reply\")) {\n const nonReplyCandidate = candidates.find((opportunity) =>\n opportunity.actionType !== \"reply\" && !opportunity.requiresContent\n );\n if (nonReplyCandidate) {\n plannedActions = [\n { ...nonReplyCandidate.template, reasoning: \"diversity pivot\" },\n ...plannedActions.slice(0, Math.max(0, maxActions - actions.length - 1)),\n ];\n }\n }\n\n if (priorityHandles.size > 0) {\n const authorByTweetId = new Map<string, string>();\n for (const opportunity of candidates) {\n if (opportunity.tweetId && opportunity.authorHandle) {\n authorByTweetId.set(opportunity.tweetId, normalizeHandle(opportunity.authorHandle));\n }\n }\n\n const touchesPriorityTarget = plannedActions.some((action) => {\n if (action.handle && priorityHandles.has(normalizeHandle(action.handle))) return true;\n if (action.targetHandle && priorityHandles.has(normalizeHandle(action.targetHandle))) return true;\n if (action.tweetId && priorityHandles.has(authorByTweetId.get(action.tweetId) ?? \"\")) return true;\n return false;\n });\n\n if (!touchesPriorityTarget) {\n const priorityCandidate = candidates.find((opportunity) =>\n Boolean(opportunity.authorHandle) &&\n priorityHandles.has(normalizeHandle(opportunity.authorHandle)) &&\n (!strictReplyOnly ? !opportunity.requiresContent : opportunity.actionType === \"reply\")\n );\n if (priorityCandidate) {\n plannedActions = [\n { ...priorityCandidate.template, reasoning: \"priority-target focus\" },\n ...plannedActions,\n ].slice(0, Math.max(0, maxActions - actions.length));\n logger.info(`Priority target injection: @${priorityCandidate.authorHandle}`);\n }\n }\n }\n\n if (plannedActions.length === 0) {\n logger.info(\"Portfolio planner returned no actionable selections.\");\n break;\n }\n\n let acceptedInRound = 0;\n for (const proposedAction of plannedActions) {\n let candidateAction = proposedAction;\n if (actions.length >= maxActions) break;\n\n if (disallowedActions.has(candidateAction.action)) {\n const reason = `Action ${candidateAction.action} is temporarily disallowed this heartbeat.`;\n policyFeedback.push(reason);\n logger.info(`Policy rejected action ${candidateAction.action}: ${reason}`);\n continue;\n }\n\n if (candidateAction.tweetId && blockedTweetIds.has(candidateAction.tweetId)) {\n const reason = `Tweet ${candidateAction.tweetId} is blocked for this heartbeat.`;\n policyFeedback.push(reason);\n logger.info(`Policy rejected action ${candidateAction.action}: ${reason}`);\n continue;\n }\n\n let policy = evaluateActionPolicy({\n action: candidateAction,\n step: actions.length,\n timeline: filteredTimeline,\n mentions: filteredMentions,\n executedActions: actions,\n observedTweetIds,\n observedTweets,\n selfHandle,\n selfUserId,\n });\n\n if (!policy.allowed && shouldAttemptStyleRewrite(candidateAction, policy.reason ?? \"\")) {\n const recentTexts = getRecentInteractions(10)\n .filter((entry) => entry.type === \"post\" || entry.type === \"reply\")\n .map((entry) => entry.content ?? \"\")\n .filter(Boolean);\n const rewritten = await rewriteDraftForHumanVoice({\n action: candidateAction,\n reason: policy.reason ?? \"policy rejected\",\n targetTweetText: candidateAction.tweetId ? observedTweets.find((t) => t.id === candidateAction.tweetId)?.text : undefined,\n recentTexts,\n });\n\n if (rewritten && rewritten !== candidateAction.content) {\n candidateAction = {\n ...candidateAction,\n content: rewritten,\n reasoning: `${candidateAction.reasoning ?? \"rewritten\"} | style rewrite`,\n };\n policy = evaluateActionPolicy({\n action: candidateAction,\n step: actions.length,\n timeline: filteredTimeline,\n mentions: filteredMentions,\n executedActions: actions,\n observedTweetIds,\n observedTweets,\n selfHandle,\n selfUserId,\n });\n }\n }\n\n if (!policy.allowed) {\n const reason = policy.reason ?? \"Policy rejected action\";\n policyFeedback.push(reason);\n logger.info(`Policy rejected action ${candidateAction.action}: ${reason}`);\n\n if (candidateAction.tweetId) {\n blockedTweetIds.add(candidateAction.tweetId);\n }\n\n if (candidateAction.action === \"reply\") {\n replyRejectionCount += 1;\n if (replyRejectionCount >= 2 && !strictReplyOnly) {\n disallowedActions.add(\"reply\");\n const pivot = \"Reply opportunities exhausted this heartbeat. Pivot to like/retweet/follow/post.\";\n policyFeedback.push(pivot);\n logger.info(`Policy adjustment: ${pivot}`);\n }\n }\n continue;\n }\n\n acceptedInRound += 1;\n const result = await executeAction(candidateAction);\n actions.push(candidateAction);\n results.push(result);\n\n if (activeIntents.length > 0) {\n const touchedHandle = normalizeHandle(\n candidateAction.targetHandle ??\n candidateAction.handle ??\n (candidateAction.tweetId ? authorByTweetId.get(candidateAction.tweetId) : undefined)\n );\n const loweredContent = (candidateAction.content ?? \"\").toLowerCase();\n for (const intent of activeIntents) {\n const handleMatch =\n touchedHandle.length > 0 &&\n intent.targetHandles.some((handle) => normalizeHandle(handle) === touchedHandle);\n const topicMatch =\n loweredContent.length > 0 &&\n intent.focusTopics.some((topic) => loweredContent.includes(topic.toLowerCase()));\n if (!handleMatch && !topicMatch) continue;\n recordIntentExecution(intent.id, {\n success: result.success,\n note: `${candidateAction.action}${touchedHandle ? ` @${touchedHandle}` : \"\"}`,\n });\n }\n }\n\n if (!result.success) {\n const err = result.error ?? \"\";\n if (candidateAction.tweetId) {\n blockedTweetIds.add(candidateAction.tweetId);\n }\n if (candidateAction.action === \"reply\" && /duplicate content/i.test(err)) {\n if (!strictReplyOnly) {\n disallowedActions.add(\"reply\");\n const reason = \"Reply failed with duplicate-content error. Switch to non-reply actions.\";\n policyFeedback.push(reason);\n logger.info(`Policy adjustment: ${reason}`);\n } else {\n const reason = \"Reply failed with duplicate-content error. Keep reply mode but use a new angle/target.\";\n policyFeedback.push(reason);\n logger.info(`Policy adjustment: ${reason}`);\n }\n }\n if ((candidateAction.action === \"post\" || candidateAction.action === \"schedule\") && /duplicate content/i.test(err)) {\n const reason = \"Write-path duplicate-content failure. Change framing and try a different angle.\";\n policyFeedback.push(reason);\n logger.info(`Policy adjustment: ${reason}`);\n }\n }\n }\n\n if (acceptedInRound === 0) {\n logger.info(\"Planner round produced no policy-approved actions.\");\n continue;\n }\n }\n\n recordBanditActionResults(actions, results);\n\n return {\n timeline,\n mentions,\n actions,\n results,\n policyFeedback,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkHA,eAAsB,cAAc,QAA4C;AAC9E,QAAM,EAAE,QAAQ,KAAK,IAAI;AAEzB,MAAI;AACF,YAAQ,MAAM;AAAA,MACZ,KAAK,QAAQ;AACX,YAAI,CAAC,OAAO,QAAS,QAAO,EAAE,QAAQ,MAAM,SAAS,OAAO,OAAO,sBAAsB;AACzF,YAAI,OAAO,QAAQ,SAAS,KAAK;AAC/B,iBAAO,EAAE,QAAQ,MAAM,SAAS,OAAO,OAAO,mBAAmB,OAAO,QAAQ,MAAM,mBAAmB;AAAA,QAC3G;AAEA,cAAM,SAAS,MAAM,WAAW;AAChC,cAAM,SAAS,MAAM,OAAO,UAAU,OAAO,OAAO;AACpD,YAAI,OAAO,QAAS,QAAO,KAAK,YAAY,OAAO,QAAQ,MAAM,GAAG,EAAE,CAAC,MAAM;AAC7E,eAAO,EAAE,QAAQ,MAAM,SAAS,OAAO,SAAS,QAAQ,OAAO,SAAS,OAAO,OAAO,MAAM;AAAA,MAC9F;AAAA,MAEA,KAAK,SAAS;AACZ,YAAI,CAAC,OAAO,WAAW,CAAC,OAAO,SAAS;AACtC,iBAAO,EAAE,QAAQ,MAAM,SAAS,OAAO,OAAO,6BAA6B;AAAA,QAC7E;A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,WAAW,UAAU,gBAAgB,WAAW,eAAe,qBAAqB,KAAK,GAAG,GAAG;AAClH,gBAAM,SAAS;AACf,yBAAe,KAAK,MAAM;AAC1B,iBAAO,KAAK,sBAAsB,MAAM,EAAE;AAAA,QAC5C;AAAA,MACF;AAAA,IACF;AAEA,QAAI,oBAAoB,GAAG;AACzB,aAAO,KAAK,oDAAoD;AAChE;AAAA,IACF;AAAA,EACF;AAEA,4BAA0B,SAAS,OAAO;AAE1C,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":["normalizeHandle","pinned","p","normalizeHandle","isLikelySyntheticHandle","wordCount","existsSync","readFileSync","writeFileSync","existsSync","readFileSync","writeFileSync","armKey","normalizeHandle","authorByTweetId"]}
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  ensureDirectories,
3
3
  paths
4
- } from "./chunk-3RYCUGXE.js";
4
+ } from "./chunk-ZWKTKWS6.js";
5
5
 
6
6
  // src/identity/index.ts
7
7
  import { readFileSync, writeFileSync, existsSync } from "fs";
@@ -465,7 +465,7 @@ function createIdentity(options) {
465
465
  lastUpdated: (/* @__PURE__ */ new Date()).toISOString(),
466
466
  name: options.name,
467
467
  handle: options.handle,
468
- bio: options.bio ?? `\u{1F916} ${options.name} \u2014 AI agent on X | ${preset?.tagline ?? "Built different."} | Not human. Spawned via @Spora`,
468
+ bio: options.bio ?? `\u{1F916} ${options.name} \u2014 AI agent on X | ${preset?.tagline ?? "Built different."} | Not human. Spawned via @SporaAi`,
469
469
  profileImageDescription: options.profileImageDescription ?? "abstract digital avatar",
470
470
  framework: options.framework,
471
471
  originStory: options.originStory ?? defaults?.originStory ?? "A new Spore finding its voice on the timeline.",
@@ -494,7 +494,7 @@ function createIdentity(options) {
494
494
  },
495
495
  disclosure: {
496
496
  bioContainsAI: true,
497
- disclosurePhrase: `\u{1F916} I'm a Spore \u2014 an AI agent on X. Not human. Spawned via @Spora`
497
+ disclosurePhrase: `\u{1F916} I'm a Spore \u2014 an AI agent on X. Not human. Spawned via @SporaAi`
498
498
  },
499
499
  generation: 0,
500
500
  mutations: [],
@@ -619,4 +619,4 @@ export {
619
619
  mutateIdentity,
620
620
  renderIdentityDocument
621
621
  };
622
- //# sourceMappingURL=chunk-M6YOQVSI.js.map
622
+ //# sourceMappingURL=chunk-IULO3GRE.js.map
@@ -0,0 +1 @@
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 @SporaAi`,\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 @SporaAi`,\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,O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