spora 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +5 -43
- package/dist/cli.js.map +1 -1
- package/dist/{heartbeat-KT5AFMGU.js → heartbeat-4EMODFIB.js} +127 -5
- package/dist/heartbeat-4EMODFIB.js.map +1 -0
- package/dist/{init-NMWV64VQ.js → init-ZEILF6Y5.js} +2 -2
- package/dist/{web-chat-OQZCZSZO.js → web-chat-BNAFTFTH.js} +43 -7
- package/dist/web-chat-BNAFTFTH.js.map +1 -0
- package/package.json +1 -1
- package/dist/chunk-V4BSNSFM.js +0 -162
- package/dist/chunk-V4BSNSFM.js.map +0 -1
- package/dist/heartbeat-KT5AFMGU.js.map +0 -1
- package/dist/prompt-builder-TH576BVM.js +0 -17
- package/dist/prompt-builder-TH576BVM.js.map +0 -1
- package/dist/web-chat-OQZCZSZO.js.map +0 -1
- /package/dist/{init-NMWV64VQ.js.map → init-ZEILF6Y5.js.map} +0 -0
package/dist/cli.js
CHANGED
|
@@ -123,7 +123,7 @@ program.command("init").description("Set up X account credentials for your Spore
|
|
|
123
123
|
console.log(chalk.cyan(BANNER));
|
|
124
124
|
console.log(chalk.bold("Welcome to Spora."));
|
|
125
125
|
console.log(chalk.gray("The global town square for AI agents.\n"));
|
|
126
|
-
const { runInit } = await import("./init-
|
|
126
|
+
const { runInit } = await import("./init-ZEILF6Y5.js");
|
|
127
127
|
await runInit(opts.token);
|
|
128
128
|
});
|
|
129
129
|
program.command("serve").description("Start the Spora MCP server (stdio)").action(async () => {
|
|
@@ -135,7 +135,7 @@ program.command("chat").description("Open web-based chat interface with your Spo
|
|
|
135
135
|
console.log(chalk.red("\u2717 No identity found. Run `spora create` first."));
|
|
136
136
|
process.exit(1);
|
|
137
137
|
}
|
|
138
|
-
const { startWebChat } = await import("./web-chat-
|
|
138
|
+
const { startWebChat } = await import("./web-chat-BNAFTFTH.js");
|
|
139
139
|
await startWebChat();
|
|
140
140
|
});
|
|
141
141
|
program.command("tui").description("Start terminal-based chat interface (TUI)").action(async () => {
|
|
@@ -557,11 +557,11 @@ program.command("start").description("Start the autonomous Spora agent").option(
|
|
|
557
557
|
}
|
|
558
558
|
console.log(chalk.cyan(BANNER));
|
|
559
559
|
console.log(chalk.bold("Starting Spora agent...\n"));
|
|
560
|
-
const { startHeartbeatLoop } = await import("./heartbeat-
|
|
560
|
+
const { startHeartbeatLoop } = await import("./heartbeat-4EMODFIB.js");
|
|
561
561
|
await startHeartbeatLoop();
|
|
562
562
|
});
|
|
563
563
|
program.command("stop").description("Stop the running Spora agent").action(async () => {
|
|
564
|
-
const { getRunningPid, requestStop } = await import("./heartbeat-
|
|
564
|
+
const { getRunningPid, requestStop } = await import("./heartbeat-4EMODFIB.js");
|
|
565
565
|
const pid = getRunningPid();
|
|
566
566
|
if (!pid) {
|
|
567
567
|
console.log(JSON.stringify({ message: "Spora agent is not running." }));
|
|
@@ -598,46 +598,8 @@ program.command("set-llm-key").description("Set your Anthropic API key for the a
|
|
|
598
598
|
}
|
|
599
599
|
console.log(JSON.stringify({ success: true, message: "LLM API key saved." }));
|
|
600
600
|
});
|
|
601
|
-
program.command("chat").description("Chat with your Spore locally").action(async () => {
|
|
602
|
-
if (!sporaExists()) {
|
|
603
|
-
console.log("Spora not initialized. Run `spora init` first.");
|
|
604
|
-
process.exit(1);
|
|
605
|
-
}
|
|
606
|
-
const { hasLLMKey } = await import("./llm-OH2Z4PSN.js");
|
|
607
|
-
if (!hasLLMKey()) {
|
|
608
|
-
console.log("No LLM API key. Run `spora set-llm-key` first.");
|
|
609
|
-
process.exit(1);
|
|
610
|
-
}
|
|
611
|
-
const { buildChatPrompt } = await import("./prompt-builder-TH576BVM.js");
|
|
612
|
-
const { chat: chatLLM } = await import("./llm-OH2Z4PSN.js");
|
|
613
|
-
const { input } = await import("@inquirer/prompts");
|
|
614
|
-
const identity = loadIdentity();
|
|
615
|
-
console.log(chalk.cyan(BANNER));
|
|
616
|
-
console.log(chalk.bold(`Chatting with ${identity.name} (@${identity.handle})
|
|
617
|
-
`));
|
|
618
|
-
console.log(chalk.gray('Type "exit" to end the conversation.\n'));
|
|
619
|
-
const systemPrompt = buildChatPrompt();
|
|
620
|
-
const messages = [];
|
|
621
|
-
while (true) {
|
|
622
|
-
const userInput = await input({ message: chalk.blue("You:") });
|
|
623
|
-
if (userInput.toLowerCase() === "exit") {
|
|
624
|
-
console.log(chalk.gray("\nGoodbye!\n"));
|
|
625
|
-
break;
|
|
626
|
-
}
|
|
627
|
-
messages.push({ role: "user", content: userInput });
|
|
628
|
-
try {
|
|
629
|
-
const response = await chatLLM(systemPrompt, messages);
|
|
630
|
-
messages.push({ role: "assistant", content: response.content });
|
|
631
|
-
console.log(chalk.green(`
|
|
632
|
-
${identity.name}: `) + response.content + "\n");
|
|
633
|
-
} catch (error) {
|
|
634
|
-
console.log(chalk.red(`Error: ${error.message}
|
|
635
|
-
`));
|
|
636
|
-
}
|
|
637
|
-
}
|
|
638
|
-
});
|
|
639
601
|
program.command("agent-status").description("Check if the Spora agent is running").action(async () => {
|
|
640
|
-
const { getRunningPid } = await import("./heartbeat-
|
|
602
|
+
const { getRunningPid } = await import("./heartbeat-4EMODFIB.js");
|
|
641
603
|
const pid = getRunningPid();
|
|
642
604
|
const { hasLLMKey } = await import("./llm-OH2Z4PSN.js");
|
|
643
605
|
console.log(JSON.stringify({
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { Command } from \"commander\";\nimport chalk from \"chalk\";\nimport { sporaExists, hasXCredentials } from \"./utils/paths.js\";\nimport { loadConfig } from \"./utils/config.js\";\nimport {\n loadIdentity,\n saveIdentity,\n identityExists,\n createIdentity,\n mutateIdentity,\n renderIdentityDocument,\n FRAMEWORKS,\n GOAL_PRESETS,\n} from \"./identity/index.js\";\n\nconst BANNER = `\n ███████╗██████╗ ██████╗ ██████╗ █████╗\n ██╔════╝██╔══██╗██╔═══██╗██╔══██╗██╔══██╗\n ███████╗██████╔╝██║ ██║██████╔╝███████║\n ╚════██║██╔═══╝ ██║ ██║██╔══██╗██╔══██║\n ███████║██║ ╚██████╔╝██║ ██║██║ ██║\n ╚══════╝╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝\n`;\n\nconst program = new Command();\n\nprogram\n .name(\"spora\")\n .description(\"AI agents (Spores) that autonomously manage X/Twitter accounts\")\n .version(\"0.1.6\");\n\n// ========== SETUP ==========\n\nprogram\n .command(\"init\")\n .description(\"Set up X account credentials for your Spore\")\n .option(\"--token <token>\", \"Connection token from spora.dev for auto-connect\")\n .option(\"--method <method>\", \"Connection method: create | browser | api\")\n .option(\"--username <username>\", \"X username (without @)\")\n .option(\"--password <password>\", \"X password\")\n .option(\"--email <email>\", \"Email associated with X account\")\n .option(\"--account-name <name>\", \"Name for the new X account (create mode)\")\n .option(\"--api-key <key>\", \"X API Key (api mode)\")\n .option(\"--api-secret <secret>\", \"X API Secret (api mode)\")\n .option(\"--access-token <token>\", \"X Access Token (api mode)\")\n .option(\"--access-token-secret <secret>\", \"X Access Token Secret (api mode)\")\n .option(\"--bearer-token <token>\", \"X Bearer Token (api mode)\")\n .option(\"--api-tier <tier>\", \"X API tier: free | basic (api mode)\")\n .action(async (opts) => {\n // Non-interactive mode: all flags provided\n if (opts.method) {\n const { ensureDirectories } = await import(\"./utils/paths.js\");\n const { saveCredentials } = await import(\"./utils/crypto.js\");\n const { createDefaultConfig, saveConfig } = await import(\"./utils/config.js\");\n\n ensureDirectories();\n\n if (opts.method === \"create\") {\n const accountName = opts.accountName ?? `Spore${Math.floor(Math.random() * 9000) + 1000}`;\n\n // Ensure Playwright browsers are installed\n console.log(JSON.stringify({ status: \"Ensuring browser is installed...\" }));\n const { execSync } = await import(\"node:child_process\");\n try {\n execSync(\"npx playwright install chromium\", { stdio: \"pipe\" });\n } catch {\n // May already be installed, continue\n }\n\n console.log(JSON.stringify({ status: \"Creating X account...\", name: accountName }));\n\n try {\n const { provisionAccount } = await import(\"./account-creator/index.js\");\n const result = await provisionAccount({\n name: accountName,\n });\n\n if (result.success) {\n saveCredentials({\n method: \"browser\",\n username: result.username,\n password: result.password,\n email: result.email,\n });\n\n const config = createDefaultConfig({ xMethod: \"browser\" });\n saveConfig(config);\n\n console.log(JSON.stringify({\n success: true,\n method: \"browser\",\n username: result.username,\n email: result.email,\n message: \"X account created and credentials saved!\",\n }));\n } else {\n console.log(JSON.stringify({\n success: false,\n error: result.error,\n message: \"Automated creation failed. Try again with --method browser and provide existing credentials.\",\n }));\n process.exit(1);\n }\n } catch (error) {\n console.log(JSON.stringify({\n success: false,\n error: (error as Error).message,\n message: \"Account creation failed. Try --method browser with existing credentials instead.\",\n }));\n process.exit(1);\n }\n return;\n }\n\n if (opts.method === \"browser\") {\n if (!opts.username || !opts.password) {\n console.log(JSON.stringify({ error: \"Browser mode requires --username and --password\" }));\n process.exit(1);\n }\n saveCredentials({\n method: \"browser\",\n username: opts.username,\n password: opts.password,\n email: opts.email,\n });\n } else if (opts.method === \"api\") {\n if (!opts.apiKey || !opts.apiSecret || !opts.accessToken || !opts.accessTokenSecret || !opts.bearerToken) {\n console.log(JSON.stringify({ error: \"API mode requires --api-key, --api-secret, --access-token, --access-token-secret, --bearer-token\" }));\n process.exit(1);\n }\n saveCredentials({\n method: \"api\",\n apiKey: opts.apiKey,\n apiSecret: opts.apiSecret,\n accessToken: opts.accessToken,\n accessTokenSecret: opts.accessTokenSecret,\n bearerToken: opts.bearerToken,\n });\n } else {\n console.log(JSON.stringify({ error: \"Method must be 'create', 'browser', or 'api'\" }));\n process.exit(1);\n }\n\n const config = createDefaultConfig({\n xMethod: opts.method === \"create\" ? \"browser\" : opts.method,\n xApiTier: opts.apiTier,\n });\n saveConfig(config);\n\n console.log(JSON.stringify({ success: true, method: opts.method, username: opts.username || \"api-mode\" }));\n return;\n }\n\n // Interactive mode: no flags, use inquirer prompts\n console.log(chalk.cyan(BANNER));\n console.log(chalk.bold(\"Welcome to Spora.\"));\n console.log(chalk.gray(\"The global town square for AI agents.\\n\"));\n\n const { runInit } = await import(\"./init.js\");\n await runInit(opts.token);\n });\n\nprogram\n .command(\"serve\")\n .description(\"Start the Spora MCP server (stdio)\")\n .action(async () => {\n const { startServer } = await import(\"./mcp-server.js\");\n await startServer();\n });\n\n// ========== CHAT ==========\n\nprogram\n .command(\"chat\")\n .description(\"Open web-based chat interface with your Spore\")\n .action(async () => {\n if (!identityExists()) {\n console.log(chalk.red(\"✗ No identity found. Run `spora create` first.\"));\n process.exit(1);\n }\n\n const { startWebChat } = await import(\"./web-chat/index.js\");\n await startWebChat();\n });\n\nprogram\n .command(\"tui\")\n .description(\"Start terminal-based chat interface (TUI)\")\n .action(async () => {\n if (!identityExists()) {\n console.log(chalk.red(\"✗ No identity found. Run `spora create` first.\"));\n process.exit(1);\n }\n\n console.log(chalk.yellow(\"Terminal chat interface coming soon!\"));\n console.log(chalk.dim(\"For now, use `spora chat` to open the web interface.\"));\n process.exit(0);\n });\n\nprogram\n .command(\"status\")\n .description(\"Show Spore status\")\n .action(() => {\n if (!hasXCredentials()) {\n console.log(JSON.stringify({ error: \"No X credentials found. Run `spora init` first.\" }));\n process.exit(1);\n }\n\n const config = loadConfig();\n const result: Record<string, unknown> = {\n xMethod: config.xMethod,\n credits: {\n used: config.credits.postsUsedThisMonth,\n limit: config.credits.monthlyPostLimit,\n remaining: config.credits.monthlyPostLimit - config.credits.postsUsedThisMonth,\n resetDate: config.credits.resetDate,\n },\n };\n\n if (identityExists()) {\n const identity = loadIdentity();\n result.identity = {\n name: identity.name,\n handle: identity.handle,\n framework: identity.framework,\n sporeId: identity.sporeId,\n generation: identity.generation,\n colony: identity.colony.joined,\n goals: identity.goals,\n traits: identity.traits,\n coreValues: identity.coreValues,\n };\n } else {\n result.identity = null;\n }\n\n console.log(JSON.stringify(result, null, 2));\n });\n\n// ========== IDENTITY & CREATION ==========\n\nprogram\n .command(\"frameworks\")\n .description(\"List available inspiration frameworks\")\n .action(() => {\n const list = Object.entries(FRAMEWORKS).map(([key, fw]) => ({\n id: key,\n label: fw.label,\n tagline: fw.tagline,\n description: fw.description,\n }));\n console.log(JSON.stringify({ frameworks: list, goals: [...GOAL_PRESETS] }, null, 2));\n });\n\nprogram\n .command(\"framework\")\n .description(\"Get details of a specific framework\")\n .argument(\"<id>\", \"Framework ID\")\n .action((id: string) => {\n const fw = FRAMEWORKS[id as keyof typeof FRAMEWORKS];\n if (!fw) {\n console.log(JSON.stringify({ error: `Unknown framework: ${id}` }));\n process.exit(1);\n }\n console.log(JSON.stringify({ id, ...fw }, null, 2));\n });\n\nprogram\n .command(\"create\")\n .description(\"Create a new Spore identity\")\n .requiredOption(\"--framework <framework>\", \"Framework ID or 'custom'\")\n .requiredOption(\"--name <name>\", \"Display name\")\n .requiredOption(\"--handle <handle>\", \"X handle (without @)\")\n .option(\"--bio <bio>\", \"X bio (max 160 chars)\")\n .option(\"--origin <story>\", \"Origin story\")\n .option(\"--tone <tone>\", \"Voice/writing style\")\n .option(\"--worldview <worldview>\", \"How this Spore sees the world\")\n .option(\"--values <values...>\", \"Core values\")\n .option(\"--topics <topics...>\", \"Topics to engage with\")\n .option(\"--goals <goals...>\", \"Strategic goals\")\n .option(\"--boundaries <boundaries...>\", \"Things this Spore will NOT do\")\n .option(\"--catchphrases <phrases...>\", \"Signature phrases\")\n .option(\"--conflict-style <style>\", \"agree-to-disagree|debate|clap-back|ignore|humor-deflect\")\n .option(\"--vocabulary <style>\", \"academic|casual|internet-native|poetic|technical|mixed\")\n .option(\"--emoji-usage <level>\", \"never|rare|moderate|heavy\")\n .option(\"--tweet-style <style>\", \"one-liners|short-form|threads|mixed\")\n .option(\"--colony\", \"Join The Colony\", false)\n .option(\"--trait-aggression <n>\", \"Trait: aggression (0-1)\", parseFloat)\n .option(\"--trait-humor <n>\", \"Trait: humor (0-1)\", parseFloat)\n .option(\"--trait-formality <n>\", \"Trait: formality (0-1)\", parseFloat)\n .option(\"--trait-verbosity <n>\", \"Trait: verbosity (0-1)\", parseFloat)\n .option(\"--trait-empathy <n>\", \"Trait: empathy (0-1)\", parseFloat)\n .option(\"--trait-curiosity <n>\", \"Trait: curiosity (0-1)\", parseFloat)\n .option(\"--trait-confidence <n>\", \"Trait: confidence (0-1)\", parseFloat)\n .option(\"--trait-originality <n>\", \"Trait: originality (0-1)\", parseFloat)\n .action((opts) => {\n try {\n const customTraits: Record<string, number> = {};\n for (const t of [\"aggression\", \"humor\", \"formality\", \"verbosity\", \"empathy\", \"curiosity\", \"confidence\", \"originality\"]) {\n const val = opts[`trait${t.charAt(0).toUpperCase() + t.slice(1)}`];\n if (val !== undefined) customTraits[t] = val;\n }\n\n const identity = createIdentity({\n framework: opts.framework,\n name: opts.name,\n handle: opts.handle,\n bio: opts.bio,\n originStory: opts.origin,\n tone: opts.tone,\n worldview: opts.worldview,\n coreValues: opts.values,\n topics: opts.topics,\n goals: opts.goals,\n boundaries: opts.boundaries,\n catchphrases: opts.catchphrases,\n conflictStyle: opts.conflictStyle,\n vocabularyStyle: opts.vocabulary,\n emojiUsage: opts.emojiUsage,\n tweetStyle: opts.tweetStyle,\n joinColony: opts.colony,\n customTraits: Object.keys(customTraits).length > 0 ? customTraits : undefined,\n });\n\n saveIdentity(identity);\n console.log(renderIdentityDocument(identity));\n } catch (error) {\n console.log(JSON.stringify({ error: (error as Error).message }));\n process.exit(1);\n }\n });\n\nprogram\n .command(\"identity\")\n .description(\"Show the full identity document (markdown)\")\n .action(() => {\n if (!identityExists()) {\n console.log(JSON.stringify({ error: \"No Spore identity found.\" }));\n process.exit(1);\n }\n console.log(renderIdentityDocument(loadIdentity()));\n });\n\nprogram\n .command(\"identity-json\")\n .description(\"Show identity as raw JSON\")\n .action(() => {\n if (!identityExists()) {\n console.log(JSON.stringify({ error: \"No Spore identity found.\" }));\n process.exit(1);\n }\n console.log(JSON.stringify(loadIdentity(), null, 2));\n });\n\nprogram\n .command(\"evolve\")\n .description(\"Mutate an identity field (dot notation)\")\n .argument(\"<field>\", \"Field path (e.g. traits.humor, tone, goals)\")\n .argument(\"<value>\", \"New value (JSON-parsed)\")\n .argument(\"<reason>\", \"Why this change is happening\")\n .action((field: string, value: string, reason: string) => {\n if (!identityExists()) {\n console.log(JSON.stringify({ error: \"No Spore identity found.\" }));\n process.exit(1);\n }\n try {\n let parsed: unknown;\n try { parsed = JSON.parse(value); } catch { parsed = value; }\n let identity = loadIdentity();\n identity = mutateIdentity(identity, field, parsed, reason);\n saveIdentity(identity);\n console.log(JSON.stringify({ success: true, field, generation: identity.generation, reason }));\n } catch (error) {\n console.log(JSON.stringify({ error: (error as Error).message }));\n process.exit(1);\n }\n });\n\nprogram\n .command(\"journal\")\n .description(\"Add a reflection to the evolution journal\")\n .argument(\"<reflection>\", \"Your reflection\")\n .action((reflection: string) => {\n if (!identityExists()) {\n console.log(JSON.stringify({ error: \"No Spore identity found.\" }));\n process.exit(1);\n }\n const identity = loadIdentity();\n identity.evolutionJournal.push({ date: new Date().toISOString(), reflection });\n saveIdentity(identity);\n console.log(JSON.stringify({ success: true, totalEntries: identity.evolutionJournal.length }));\n });\n\n// ========== X ACTIONS ==========\n\nprogram\n .command(\"post\")\n .description(\"Post a tweet\")\n .argument(\"<content>\", \"Tweet content (max 280 chars)\")\n .action(async (content: string) => {\n try {\n const { getXClient } = await import(\"./x-client/index.js\");\n const client = await getXClient();\n const result = await client.postTweet(content);\n console.log(JSON.stringify(result, null, 2));\n } catch (error) {\n console.log(JSON.stringify({ error: (error as Error).message }));\n process.exit(1);\n }\n });\n\nprogram\n .command(\"reply\")\n .description(\"Reply to a tweet\")\n .argument(\"<tweetId>\", \"Tweet ID to reply to\")\n .argument(\"<content>\", \"Reply content\")\n .action(async (tweetId: string, content: string) => {\n try {\n const { getXClient } = await import(\"./x-client/index.js\");\n const client = await getXClient();\n const result = await client.replyToTweet(tweetId, content);\n console.log(JSON.stringify(result, null, 2));\n } catch (error) {\n console.log(JSON.stringify({ error: (error as Error).message }));\n process.exit(1);\n }\n });\n\nprogram\n .command(\"like\")\n .description(\"Like a tweet\")\n .argument(\"<tweetId>\", \"Tweet ID\")\n .action(async (tweetId: string) => {\n try {\n const { getXClient } = await import(\"./x-client/index.js\");\n const client = await getXClient();\n const result = await client.likeTweet(tweetId);\n console.log(JSON.stringify(result, null, 2));\n } catch (error) {\n console.log(JSON.stringify({ error: (error as Error).message }));\n process.exit(1);\n }\n });\n\nprogram\n .command(\"retweet\")\n .description(\"Retweet a tweet\")\n .argument(\"<tweetId>\", \"Tweet ID\")\n .action(async (tweetId: string) => {\n try {\n const { getXClient } = await import(\"./x-client/index.js\");\n const client = await getXClient();\n const result = await client.retweet(tweetId);\n console.log(JSON.stringify(result, null, 2));\n } catch (error) {\n console.log(JSON.stringify({ error: (error as Error).message }));\n process.exit(1);\n }\n });\n\nprogram\n .command(\"follow\")\n .description(\"Follow a user\")\n .argument(\"<handle>\", \"User handle or ID\")\n .action(async (handle: string) => {\n try {\n const { getXClient } = await import(\"./x-client/index.js\");\n const client = await getXClient();\n const result = await client.followUser(handle);\n console.log(JSON.stringify(result, null, 2));\n } catch (error) {\n console.log(JSON.stringify({ error: (error as Error).message }));\n process.exit(1);\n }\n });\n\nprogram\n .command(\"unfollow\")\n .description(\"Unfollow a user\")\n .argument(\"<handle>\", \"User handle or ID\")\n .action(async (handle: string) => {\n try {\n const { getXClient } = await import(\"./x-client/index.js\");\n const client = await getXClient();\n const result = await client.unfollowUser(handle);\n console.log(JSON.stringify(result, null, 2));\n } catch (error) {\n console.log(JSON.stringify({ error: (error as Error).message }));\n process.exit(1);\n }\n });\n\nprogram\n .command(\"timeline\")\n .description(\"Read home timeline\")\n .option(\"-c, --count <n>\", \"Number of tweets\", \"20\")\n .action(async (opts) => {\n try {\n const { getXClient } = await import(\"./x-client/index.js\");\n const client = await getXClient();\n const result = await client.getTimeline({ count: parseInt(opts.count) });\n console.log(JSON.stringify(result, null, 2));\n } catch (error) {\n console.log(JSON.stringify({ error: (error as Error).message }));\n process.exit(1);\n }\n });\n\nprogram\n .command(\"mentions\")\n .description(\"Read mentions\")\n .option(\"-c, --count <n>\", \"Number of mentions\", \"20\")\n .action(async (opts) => {\n try {\n const { getXClient } = await import(\"./x-client/index.js\");\n const client = await getXClient();\n const result = await client.getMentions({ count: parseInt(opts.count) });\n console.log(JSON.stringify(result, null, 2));\n } catch (error) {\n console.log(JSON.stringify({ error: (error as Error).message }));\n process.exit(1);\n }\n });\n\nprogram\n .command(\"search\")\n .description(\"Search for tweets\")\n .argument(\"<query>\", \"Search query\")\n .option(\"-c, --count <n>\", \"Number of results\", \"20\")\n .action(async (query: string, opts) => {\n try {\n const { getXClient } = await import(\"./x-client/index.js\");\n const client = await getXClient();\n const result = await client.searchTweets(query, { count: parseInt(opts.count) });\n console.log(JSON.stringify(result, null, 2));\n } catch (error) {\n console.log(JSON.stringify({ error: (error as Error).message }));\n process.exit(1);\n }\n });\n\nprogram\n .command(\"profile\")\n .description(\"Get a user's X profile\")\n .argument(\"<handle>\", \"X handle (without @)\")\n .action(async (handle: string) => {\n try {\n const { getXClient } = await import(\"./x-client/index.js\");\n const client = await getXClient();\n const result = await client.getProfile(handle);\n console.log(JSON.stringify(result, null, 2));\n } catch (error) {\n console.log(JSON.stringify({ error: (error as Error).message }));\n process.exit(1);\n }\n });\n\n// ========== MEMORY & CREDITS ==========\n\nprogram\n .command(\"credits\")\n .description(\"Check remaining posting credits\")\n .action(() => {\n const config = loadConfig();\n const remaining = config.credits.monthlyPostLimit - config.credits.postsUsedThisMonth;\n console.log(JSON.stringify({\n postsUsed: config.credits.postsUsedThisMonth,\n postsRemaining: remaining,\n monthlyLimit: config.credits.monthlyPostLimit,\n percentUsed: Math.round((config.credits.postsUsedThisMonth / config.credits.monthlyPostLimit) * 100),\n resetDate: config.credits.resetDate,\n }, null, 2));\n });\n\nprogram\n .command(\"memory\")\n .description(\"Read memory (interactions, learnings, relationships)\")\n .argument(\"<type>\", \"interactions | learnings | relationships\")\n .option(\"-d, --date <date>\", \"For interactions: specific date (YYYY-MM-DD)\")\n .option(\"-c, --count <n>\", \"For interactions: count\", \"20\")\n .action(async (type: string, opts) => {\n try {\n const { getRecentInteractions, getInteractions, loadLearnings, loadRelationships } = await import(\"./memory/index.js\");\n let data: unknown;\n switch (type) {\n case \"interactions\":\n data = opts.date ? getInteractions(opts.date) : getRecentInteractions(parseInt(opts.count));\n break;\n case \"learnings\":\n data = loadLearnings();\n break;\n case \"relationships\":\n data = loadRelationships();\n break;\n default:\n console.log(JSON.stringify({ error: \"Type must be: interactions, learnings, or relationships\" }));\n process.exit(1);\n }\n console.log(JSON.stringify(data, null, 2));\n } catch (error) {\n console.log(JSON.stringify({ error: (error as Error).message }));\n process.exit(1);\n }\n });\n\nprogram\n .command(\"learn\")\n .description(\"Store a learning\")\n .argument(\"<content>\", \"What you learned\")\n .option(\"-t, --tags <tags...>\", \"Tags for categorization\")\n .action(async (content: string, opts) => {\n try {\n const { addLearning } = await import(\"./memory/index.js\");\n addLearning(content, \"agent\", opts.tags ?? []);\n console.log(JSON.stringify({ success: true }));\n } catch (error) {\n console.log(JSON.stringify({ error: (error as Error).message }));\n process.exit(1);\n }\n });\n\nprogram\n .command(\"note\")\n .description(\"Add a relationship note about someone\")\n .argument(\"<handle>\", \"Their X handle\")\n .argument(\"<content>\", \"Your note\")\n .action(async (handle: string, content: string) => {\n try {\n const { updateRelationship } = await import(\"./memory/index.js\");\n updateRelationship(handle, { handle, notes: [content] });\n console.log(JSON.stringify({ success: true, handle }));\n } catch (error) {\n console.log(JSON.stringify({ error: (error as Error).message }));\n process.exit(1);\n }\n });\n\n// ========== SCHEDULING ==========\n\nprogram\n .command(\"schedule\")\n .description(\"Queue a post for later\")\n .argument(\"<content>\", \"Tweet content\")\n .option(\"--at <datetime>\", \"ISO datetime to post at\")\n .action(async (content: string, opts) => {\n try {\n const { addToQueue } = await import(\"./scheduler/queue.js\");\n const entry = addToQueue(content, opts.at);\n console.log(JSON.stringify({ success: true, id: entry.id, scheduledFor: entry.scheduledFor }));\n } catch (error) {\n console.log(JSON.stringify({ error: (error as Error).message }));\n process.exit(1);\n }\n });\n\nprogram\n .command(\"flush\")\n .description(\"Post all queued items whose time has come\")\n .action(async () => {\n try {\n const { flushQueue } = await import(\"./scheduler/queue.js\");\n const results = await flushQueue();\n console.log(JSON.stringify(results, null, 2));\n } catch (error) {\n console.log(JSON.stringify({ error: (error as Error).message }));\n process.exit(1);\n }\n });\n\nprogram\n .command(\"queue\")\n .description(\"Show scheduled posts\")\n .action(async () => {\n const { showQueue } = await import(\"./scheduler/queue.js\");\n showQueue();\n });\n\n// ========== COLONY ==========\n\nconst colony = program.command(\"colony\").description(\"Colony commands\");\n\ncolony\n .command(\"checkin\")\n .description(\"Check into The Colony — sync memory, discover Spores\")\n .option(\"-m, --message <msg>\", \"Optional message to post\")\n .action(async (opts) => {\n try {\n const { colonyCheckin } = await import(\"./colony/index.js\");\n const result = await colonyCheckin(opts.message);\n console.log(JSON.stringify(result, null, 2));\n } catch (error) {\n console.log(JSON.stringify({ error: (error as Error).message }));\n process.exit(1);\n }\n });\n\ncolony\n .command(\"memory\")\n .description(\"Read the Colony's shared memory\")\n .action(async () => {\n try {\n const { renderColonyBriefing } = await import(\"./colony/memory.js\");\n console.log(renderColonyBriefing());\n } catch (error) {\n console.log(JSON.stringify({ error: (error as Error).message }));\n process.exit(1);\n }\n });\n\ncolony\n .command(\"plans\")\n .description(\"Get all active Colony plans\")\n .action(async () => {\n try {\n const { getActivePlans } = await import(\"./colony/index.js\");\n const plans = getActivePlans();\n console.log(plans.length > 0\n ? JSON.stringify(plans, null, 2)\n : JSON.stringify({ message: \"No active plans. Propose one!\" }));\n } catch (error) {\n console.log(JSON.stringify({ error: (error as Error).message }));\n process.exit(1);\n }\n });\n\ncolony\n .command(\"propose\")\n .description(\"Propose a coordinated plan\")\n .argument(\"<description>\", \"What's the plan?\")\n .action(async (description: string) => {\n try {\n const { proposePlan } = await import(\"./colony/index.js\");\n const result = await proposePlan(description);\n console.log(JSON.stringify(result, null, 2));\n } catch (error) {\n console.log(JSON.stringify({ error: (error as Error).message }));\n process.exit(1);\n }\n });\n\ncolony\n .command(\"join\")\n .description(\"Join an active plan\")\n .argument(\"<planId>\", \"Plan ID\")\n .action(async (planId: string) => {\n try {\n const { joinPlan } = await import(\"./colony/index.js\");\n const result = await joinPlan(planId);\n console.log(JSON.stringify(result, null, 2));\n } catch (error) {\n console.log(JSON.stringify({ error: (error as Error).message }));\n process.exit(1);\n }\n });\n\ncolony\n .command(\"post-status\")\n .description(\"Post a status update to the Colony\")\n .argument(\"<status>\", \"Your status\")\n .action(async (status: string) => {\n try {\n const { postStatus } = await import(\"./colony/index.js\");\n const result = await postStatus(status);\n console.log(JSON.stringify(result, null, 2));\n } catch (error) {\n console.log(JSON.stringify({ error: (error as Error).message }));\n process.exit(1);\n }\n });\n\ncolony\n .command(\"activity\")\n .description(\"Get today's Colony activity\")\n .action(async () => {\n try {\n const { getTodaysActivity } = await import(\"./colony/index.js\");\n const activity = getTodaysActivity();\n console.log(activity.length > 0\n ? JSON.stringify(activity, null, 2)\n : JSON.stringify({ message: \"No Colony activity today yet.\" }));\n } catch (error) {\n console.log(JSON.stringify({ error: (error as Error).message }));\n process.exit(1);\n }\n });\n\n// ========== AGENT RUNTIME ==========\n\nprogram\n .command(\"start\")\n .description(\"Start the autonomous Spora agent\")\n .option(\"--interval <ms>\", \"Heartbeat interval in milliseconds\")\n .action(async (opts) => {\n if (!sporaExists()) {\n console.log(JSON.stringify({ error: \"Spora not initialized. Run `spora init` first.\" }));\n process.exit(1);\n }\n if (!hasXCredentials()) {\n console.log(JSON.stringify({ error: \"No X credentials. Run `spora init` to set up.\" }));\n process.exit(1);\n }\n\n const { hasLLMKey } = await import(\"./runtime/llm.js\");\n if (!hasLLMKey()) {\n console.log(JSON.stringify({ error: \"No LLM API key. Run `spora set-llm-key` first.\" }));\n process.exit(1);\n }\n\n // Apply interval override\n if (opts.interval) {\n const { loadConfig: lc, saveConfig: sc } = await import(\"./utils/config.js\");\n const config = lc();\n config.runtime = { ...config.runtime, heartbeatIntervalMs: parseInt(opts.interval, 10), actionsPerHeartbeat: config.runtime?.actionsPerHeartbeat ?? 3, enabled: true };\n sc(config);\n }\n\n console.log(chalk.cyan(BANNER));\n console.log(chalk.bold(\"Starting Spora agent...\\n\"));\n\n const { startHeartbeatLoop } = await import(\"./runtime/heartbeat.js\");\n await startHeartbeatLoop();\n });\n\nprogram\n .command(\"stop\")\n .description(\"Stop the running Spora agent\")\n .action(async () => {\n const { getRunningPid, requestStop } = await import(\"./runtime/heartbeat.js\");\n const pid = getRunningPid();\n if (!pid) {\n console.log(JSON.stringify({ message: \"Spora agent is not running.\" }));\n return;\n }\n requestStop();\n console.log(JSON.stringify({ message: `Stop signal sent to PID ${pid}.` }));\n });\n\nprogram\n .command(\"set-llm-key\")\n .description(\"Set your Anthropic API key for the agent runtime\")\n .argument(\"[key]\", \"API key (or omit to enter interactively)\")\n .action(async (key?: string) => {\n const { writeFileSync } = await import(\"node:fs\");\n const { paths: p, ensureDirectories: ed } = await import(\"./utils/paths.js\");\n ed();\n\n let apiKey = key;\n if (!apiKey) {\n // Check env\n if (process.env.ANTHROPIC_API_KEY) {\n console.log(JSON.stringify({ message: \"Using ANTHROPIC_API_KEY from environment.\" }));\n return;\n }\n const { input } = await import(\"@inquirer/prompts\");\n apiKey = await input({\n message: \"Enter your Anthropic API key:\",\n validate: (v) => v.startsWith(\"sk-\") ? true : \"Key should start with 'sk-'\",\n });\n }\n\n writeFileSync(p.llmKey, apiKey!, { mode: 0o600 });\n\n // Ensure config has llm section\n try {\n const { loadConfig: lc, saveConfig: sc } = await import(\"./utils/config.js\");\n const config = lc();\n if (!config.llm) {\n config.llm = { provider: \"anthropic\", model: \"claude-sonnet-4-20250514\" };\n sc(config);\n }\n } catch {\n // Config may not exist yet, that's ok\n }\n\n console.log(JSON.stringify({ success: true, message: \"LLM API key saved.\" }));\n });\n\nprogram\n .command(\"chat\")\n .description(\"Chat with your Spore locally\")\n .action(async () => {\n if (!sporaExists()) {\n console.log(\"Spora not initialized. Run `spora init` first.\");\n process.exit(1);\n }\n\n const { hasLLMKey } = await import(\"./runtime/llm.js\");\n if (!hasLLMKey()) {\n console.log(\"No LLM API key. Run `spora set-llm-key` first.\");\n process.exit(1);\n }\n\n const { buildChatPrompt } = await import(\"./runtime/prompt-builder.js\");\n const { chat: chatLLM } = await import(\"./runtime/llm.js\");\n const { input } = await import(\"@inquirer/prompts\");\n const identity = loadIdentity();\n\n console.log(chalk.cyan(BANNER));\n console.log(chalk.bold(`Chatting with ${identity.name} (@${identity.handle})\\n`));\n console.log(chalk.gray('Type \"exit\" to end the conversation.\\n'));\n\n const systemPrompt = buildChatPrompt();\n const messages: Array<{ role: \"user\" | \"assistant\"; content: string }> = [];\n\n while (true) {\n const userInput = await input({ message: chalk.blue(\"You:\") });\n if (userInput.toLowerCase() === \"exit\") {\n console.log(chalk.gray(\"\\nGoodbye!\\n\"));\n break;\n }\n\n messages.push({ role: \"user\", content: userInput });\n\n try {\n const response = await chatLLM(systemPrompt, messages);\n messages.push({ role: \"assistant\", content: response.content });\n console.log(chalk.green(`\\n${identity.name}: `) + response.content + \"\\n\");\n } catch (error) {\n console.log(chalk.red(`Error: ${(error as Error).message}\\n`));\n }\n }\n });\n\nprogram\n .command(\"agent-status\")\n .description(\"Check if the Spora agent is running\")\n .action(async () => {\n const { getRunningPid } = await import(\"./runtime/heartbeat.js\");\n const pid = getRunningPid();\n\n const { hasLLMKey } = await import(\"./runtime/llm.js\");\n\n console.log(JSON.stringify({\n agentRunning: pid !== null,\n pid: pid,\n llmKeyConfigured: hasLLMKey(),\n initialized: sporaExists(),\n hasCredentials: hasXCredentials(),\n }));\n });\n\nprogram\n .command(\"ui\")\n .description(\"Open the Spora web UI for setup and management\")\n .option(\"-p, --port <port>\", \"Port to run on\", \"3000\")\n .action(async (opts) => {\n const { resolve } = await import(\"node:path\");\n const { existsSync: fsExists } = await import(\"node:fs\");\n const { execSync, spawn } = await import(\"node:child_process\");\n\n const webDir = resolve(import.meta.dirname, \"../../packages/web\");\n if (!fsExists(webDir)) {\n console.log(chalk.red(\"Web UI not found. Expected at: \" + webDir));\n process.exit(1);\n }\n\n const port = opts.port || \"3000\";\n console.log(chalk.cyan(BANNER));\n console.log(chalk.bold(\"Starting Spora UI...\\n\"));\n\n // Check if dependencies are installed\n if (!fsExists(resolve(webDir, \"node_modules\"))) {\n console.log(chalk.gray(\"Installing dependencies...\"));\n execSync(\"npm install\", { cwd: webDir, stdio: \"inherit\" });\n }\n\n console.log(chalk.green(`\\n Spora UI: http://localhost:${port}\\n`));\n console.log(chalk.gray(\"Press Ctrl+C to stop.\\n\"));\n\n // Open browser\n try {\n const openCmd = process.platform === \"darwin\" ? \"open\" : process.platform === \"win32\" ? \"start\" : \"xdg-open\";\n execSync(`${openCmd} http://localhost:${port}`, { stdio: \"ignore\" });\n } catch {\n // Browser open is best-effort\n }\n\n // Start Next.js dev server\n const child = spawn(\"npx\", [\"next\", \"dev\", \"-p\", port], {\n cwd: webDir,\n stdio: \"inherit\",\n env: { ...process.env },\n });\n\n child.on(\"close\", (code) => {\n process.exit(code ?? 0);\n });\n\n process.on(\"SIGINT\", () => {\n child.kill(\"SIGINT\");\n });\n process.on(\"SIGTERM\", () => {\n child.kill(\"SIGTERM\");\n });\n });\n\nprogram.parse();\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAEA,SAAS,eAAe;AACxB,OAAO,WAAW;AAclB,IAAM,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASf,IAAM,UAAU,IAAI,QAAQ;AAE5B,QACG,KAAK,OAAO,EACZ,YAAY,gEAAgE,EAC5E,QAAQ,OAAO;AAIlB,QACG,QAAQ,MAAM,EACd,YAAY,6CAA6C,EACzD,OAAO,mBAAmB,kDAAkD,EAC5E,OAAO,qBAAqB,2CAA2C,EACvE,OAAO,yBAAyB,wBA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,GAAG,WAAW,MAAM;AAC1B,UAAM,KAAK,SAAS;AAAA,EACtB,CAAC;AACH,CAAC;AAEH,QAAQ,MAAM;","names":["config"]}
|
|
1
|
+
{"version":3,"sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { Command } from \"commander\";\nimport chalk from \"chalk\";\nimport { sporaExists, hasXCredentials } from \"./utils/paths.js\";\nimport { loadConfig } from \"./utils/config.js\";\nimport {\n loadIdentity,\n saveIdentity,\n identityExists,\n createIdentity,\n mutateIdentity,\n renderIdentityDocument,\n FRAMEWORKS,\n GOAL_PRESETS,\n} from \"./identity/index.js\";\n\nconst BANNER = `\n ███████╗██████╗ ██████╗ ██████╗ █████╗\n ██╔════╝██╔══██╗██╔═══██╗██╔══██╗██╔══██╗\n ███████╗██████╔╝██║ ██║██████╔╝███████║\n ╚════██║██╔═══╝ ██║ ██║██╔══██╗██╔══██║\n ███████║██║ ╚██████╔╝██║ ██║██║ ██║\n ╚══════╝╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝\n`;\n\nconst program = new Command();\n\nprogram\n .name(\"spora\")\n .description(\"AI agents (Spores) that autonomously manage X/Twitter accounts\")\n .version(\"0.1.6\");\n\n// ========== SETUP ==========\n\nprogram\n .command(\"init\")\n .description(\"Set up X account credentials for your Spore\")\n .option(\"--token <token>\", \"Connection token from spora.dev for auto-connect\")\n .option(\"--method <method>\", \"Connection method: create | browser | api\")\n .option(\"--username <username>\", \"X username (without @)\")\n .option(\"--password <password>\", \"X password\")\n .option(\"--email <email>\", \"Email associated with X account\")\n .option(\"--account-name <name>\", \"Name for the new X account (create mode)\")\n .option(\"--api-key <key>\", \"X API Key (api mode)\")\n .option(\"--api-secret <secret>\", \"X API Secret (api mode)\")\n .option(\"--access-token <token>\", \"X Access Token (api mode)\")\n .option(\"--access-token-secret <secret>\", \"X Access Token Secret (api mode)\")\n .option(\"--bearer-token <token>\", \"X Bearer Token (api mode)\")\n .option(\"--api-tier <tier>\", \"X API tier: free | basic (api mode)\")\n .action(async (opts) => {\n // Non-interactive mode: all flags provided\n if (opts.method) {\n const { ensureDirectories } = await import(\"./utils/paths.js\");\n const { saveCredentials } = await import(\"./utils/crypto.js\");\n const { createDefaultConfig, saveConfig } = await import(\"./utils/config.js\");\n\n ensureDirectories();\n\n if (opts.method === \"create\") {\n const accountName = opts.accountName ?? `Spore${Math.floor(Math.random() * 9000) + 1000}`;\n\n // Ensure Playwright browsers are installed\n console.log(JSON.stringify({ status: \"Ensuring browser is installed...\" }));\n const { execSync } = await import(\"node:child_process\");\n try {\n execSync(\"npx playwright install chromium\", { stdio: \"pipe\" });\n } catch {\n // May already be installed, continue\n }\n\n console.log(JSON.stringify({ status: \"Creating X account...\", name: accountName }));\n\n try {\n const { provisionAccount } = await import(\"./account-creator/index.js\");\n const result = await provisionAccount({\n name: accountName,\n });\n\n if (result.success) {\n saveCredentials({\n method: \"browser\",\n username: result.username,\n password: result.password,\n email: result.email,\n });\n\n const config = createDefaultConfig({ xMethod: \"browser\" });\n saveConfig(config);\n\n console.log(JSON.stringify({\n success: true,\n method: \"browser\",\n username: result.username,\n email: result.email,\n message: \"X account created and credentials saved!\",\n }));\n } else {\n console.log(JSON.stringify({\n success: false,\n error: result.error,\n message: \"Automated creation failed. Try again with --method browser and provide existing credentials.\",\n }));\n process.exit(1);\n }\n } catch (error) {\n console.log(JSON.stringify({\n success: false,\n error: (error as Error).message,\n message: \"Account creation failed. Try --method browser with existing credentials instead.\",\n }));\n process.exit(1);\n }\n return;\n }\n\n if (opts.method === \"browser\") {\n if (!opts.username || !opts.password) {\n console.log(JSON.stringify({ error: \"Browser mode requires --username and --password\" }));\n process.exit(1);\n }\n saveCredentials({\n method: \"browser\",\n username: opts.username,\n password: opts.password,\n email: opts.email,\n });\n } else if (opts.method === \"api\") {\n if (!opts.apiKey || !opts.apiSecret || !opts.accessToken || !opts.accessTokenSecret || !opts.bearerToken) {\n console.log(JSON.stringify({ error: \"API mode requires --api-key, --api-secret, --access-token, --access-token-secret, --bearer-token\" }));\n process.exit(1);\n }\n saveCredentials({\n method: \"api\",\n apiKey: opts.apiKey,\n apiSecret: opts.apiSecret,\n accessToken: opts.accessToken,\n accessTokenSecret: opts.accessTokenSecret,\n bearerToken: opts.bearerToken,\n });\n } else {\n console.log(JSON.stringify({ error: \"Method must be 'create', 'browser', or 'api'\" }));\n process.exit(1);\n }\n\n const config = createDefaultConfig({\n xMethod: opts.method === \"create\" ? \"browser\" : opts.method,\n xApiTier: opts.apiTier,\n });\n saveConfig(config);\n\n console.log(JSON.stringify({ success: true, method: opts.method, username: opts.username || \"api-mode\" }));\n return;\n }\n\n // Interactive mode: no flags, use inquirer prompts\n console.log(chalk.cyan(BANNER));\n console.log(chalk.bold(\"Welcome to Spora.\"));\n console.log(chalk.gray(\"The global town square for AI agents.\\n\"));\n\n const { runInit } = await import(\"./init.js\");\n await runInit(opts.token);\n });\n\nprogram\n .command(\"serve\")\n .description(\"Start the Spora MCP server (stdio)\")\n .action(async () => {\n const { startServer } = await import(\"./mcp-server.js\");\n await startServer();\n });\n\n// ========== CHAT ==========\n\nprogram\n .command(\"chat\")\n .description(\"Open web-based chat interface with your Spore\")\n .action(async () => {\n if (!identityExists()) {\n console.log(chalk.red(\"✗ No identity found. Run `spora create` first.\"));\n process.exit(1);\n }\n\n const { startWebChat } = await import(\"./web-chat/index.js\");\n await startWebChat();\n });\n\nprogram\n .command(\"tui\")\n .description(\"Start terminal-based chat interface (TUI)\")\n .action(async () => {\n if (!identityExists()) {\n console.log(chalk.red(\"✗ No identity found. Run `spora create` first.\"));\n process.exit(1);\n }\n\n console.log(chalk.yellow(\"Terminal chat interface coming soon!\"));\n console.log(chalk.dim(\"For now, use `spora chat` to open the web interface.\"));\n process.exit(0);\n });\n\nprogram\n .command(\"status\")\n .description(\"Show Spore status\")\n .action(() => {\n if (!hasXCredentials()) {\n console.log(JSON.stringify({ error: \"No X credentials found. Run `spora init` first.\" }));\n process.exit(1);\n }\n\n const config = loadConfig();\n const result: Record<string, unknown> = {\n xMethod: config.xMethod,\n credits: {\n used: config.credits.postsUsedThisMonth,\n limit: config.credits.monthlyPostLimit,\n remaining: config.credits.monthlyPostLimit - config.credits.postsUsedThisMonth,\n resetDate: config.credits.resetDate,\n },\n };\n\n if (identityExists()) {\n const identity = loadIdentity();\n result.identity = {\n name: identity.name,\n handle: identity.handle,\n framework: identity.framework,\n sporeId: identity.sporeId,\n generation: identity.generation,\n colony: identity.colony.joined,\n goals: identity.goals,\n traits: identity.traits,\n coreValues: identity.coreValues,\n };\n } else {\n result.identity = null;\n }\n\n console.log(JSON.stringify(result, null, 2));\n });\n\n// ========== IDENTITY & CREATION ==========\n\nprogram\n .command(\"frameworks\")\n .description(\"List available inspiration frameworks\")\n .action(() => {\n const list = Object.entries(FRAMEWORKS).map(([key, fw]) => ({\n id: key,\n label: fw.label,\n tagline: fw.tagline,\n description: fw.description,\n }));\n console.log(JSON.stringify({ frameworks: list, goals: [...GOAL_PRESETS] }, null, 2));\n });\n\nprogram\n .command(\"framework\")\n .description(\"Get details of a specific framework\")\n .argument(\"<id>\", \"Framework ID\")\n .action((id: string) => {\n const fw = FRAMEWORKS[id as keyof typeof FRAMEWORKS];\n if (!fw) {\n console.log(JSON.stringify({ error: `Unknown framework: ${id}` }));\n process.exit(1);\n }\n console.log(JSON.stringify({ id, ...fw }, null, 2));\n });\n\nprogram\n .command(\"create\")\n .description(\"Create a new Spore identity\")\n .requiredOption(\"--framework <framework>\", \"Framework ID or 'custom'\")\n .requiredOption(\"--name <name>\", \"Display name\")\n .requiredOption(\"--handle <handle>\", \"X handle (without @)\")\n .option(\"--bio <bio>\", \"X bio (max 160 chars)\")\n .option(\"--origin <story>\", \"Origin story\")\n .option(\"--tone <tone>\", \"Voice/writing style\")\n .option(\"--worldview <worldview>\", \"How this Spore sees the world\")\n .option(\"--values <values...>\", \"Core values\")\n .option(\"--topics <topics...>\", \"Topics to engage with\")\n .option(\"--goals <goals...>\", \"Strategic goals\")\n .option(\"--boundaries <boundaries...>\", \"Things this Spore will NOT do\")\n .option(\"--catchphrases <phrases...>\", \"Signature phrases\")\n .option(\"--conflict-style <style>\", \"agree-to-disagree|debate|clap-back|ignore|humor-deflect\")\n .option(\"--vocabulary <style>\", \"academic|casual|internet-native|poetic|technical|mixed\")\n .option(\"--emoji-usage <level>\", \"never|rare|moderate|heavy\")\n .option(\"--tweet-style <style>\", \"one-liners|short-form|threads|mixed\")\n .option(\"--colony\", \"Join The Colony\", false)\n .option(\"--trait-aggression <n>\", \"Trait: aggression (0-1)\", parseFloat)\n .option(\"--trait-humor <n>\", \"Trait: humor (0-1)\", parseFloat)\n .option(\"--trait-formality <n>\", \"Trait: formality (0-1)\", parseFloat)\n .option(\"--trait-verbosity <n>\", \"Trait: verbosity (0-1)\", parseFloat)\n .option(\"--trait-empathy <n>\", \"Trait: empathy (0-1)\", parseFloat)\n .option(\"--trait-curiosity <n>\", \"Trait: curiosity (0-1)\", parseFloat)\n .option(\"--trait-confidence <n>\", \"Trait: confidence (0-1)\", parseFloat)\n .option(\"--trait-originality <n>\", \"Trait: originality (0-1)\", parseFloat)\n .action((opts) => {\n try {\n const customTraits: Record<string, number> = {};\n for (const t of [\"aggression\", \"humor\", \"formality\", \"verbosity\", \"empathy\", \"curiosity\", \"confidence\", \"originality\"]) {\n const val = opts[`trait${t.charAt(0).toUpperCase() + t.slice(1)}`];\n if (val !== undefined) customTraits[t] = val;\n }\n\n const identity = createIdentity({\n framework: opts.framework,\n name: opts.name,\n handle: opts.handle,\n bio: opts.bio,\n originStory: opts.origin,\n tone: opts.tone,\n worldview: opts.worldview,\n coreValues: opts.values,\n topics: opts.topics,\n goals: opts.goals,\n boundaries: opts.boundaries,\n catchphrases: opts.catchphrases,\n conflictStyle: opts.conflictStyle,\n vocabularyStyle: opts.vocabulary,\n emojiUsage: opts.emojiUsage,\n tweetStyle: opts.tweetStyle,\n joinColony: opts.colony,\n customTraits: Object.keys(customTraits).length > 0 ? customTraits : undefined,\n });\n\n saveIdentity(identity);\n console.log(renderIdentityDocument(identity));\n } catch (error) {\n console.log(JSON.stringify({ error: (error as Error).message }));\n process.exit(1);\n }\n });\n\nprogram\n .command(\"identity\")\n .description(\"Show the full identity document (markdown)\")\n .action(() => {\n if (!identityExists()) {\n console.log(JSON.stringify({ error: \"No Spore identity found.\" }));\n process.exit(1);\n }\n console.log(renderIdentityDocument(loadIdentity()));\n });\n\nprogram\n .command(\"identity-json\")\n .description(\"Show identity as raw JSON\")\n .action(() => {\n if (!identityExists()) {\n console.log(JSON.stringify({ error: \"No Spore identity found.\" }));\n process.exit(1);\n }\n console.log(JSON.stringify(loadIdentity(), null, 2));\n });\n\nprogram\n .command(\"evolve\")\n .description(\"Mutate an identity field (dot notation)\")\n .argument(\"<field>\", \"Field path (e.g. traits.humor, tone, goals)\")\n .argument(\"<value>\", \"New value (JSON-parsed)\")\n .argument(\"<reason>\", \"Why this change is happening\")\n .action((field: string, value: string, reason: string) => {\n if (!identityExists()) {\n console.log(JSON.stringify({ error: \"No Spore identity found.\" }));\n process.exit(1);\n }\n try {\n let parsed: unknown;\n try { parsed = JSON.parse(value); } catch { parsed = value; }\n let identity = loadIdentity();\n identity = mutateIdentity(identity, field, parsed, reason);\n saveIdentity(identity);\n console.log(JSON.stringify({ success: true, field, generation: identity.generation, reason }));\n } catch (error) {\n console.log(JSON.stringify({ error: (error as Error).message }));\n process.exit(1);\n }\n });\n\nprogram\n .command(\"journal\")\n .description(\"Add a reflection to the evolution journal\")\n .argument(\"<reflection>\", \"Your reflection\")\n .action((reflection: string) => {\n if (!identityExists()) {\n console.log(JSON.stringify({ error: \"No Spore identity found.\" }));\n process.exit(1);\n }\n const identity = loadIdentity();\n identity.evolutionJournal.push({ date: new Date().toISOString(), reflection });\n saveIdentity(identity);\n console.log(JSON.stringify({ success: true, totalEntries: identity.evolutionJournal.length }));\n });\n\n// ========== X ACTIONS ==========\n\nprogram\n .command(\"post\")\n .description(\"Post a tweet\")\n .argument(\"<content>\", \"Tweet content (max 280 chars)\")\n .action(async (content: string) => {\n try {\n const { getXClient } = await import(\"./x-client/index.js\");\n const client = await getXClient();\n const result = await client.postTweet(content);\n console.log(JSON.stringify(result, null, 2));\n } catch (error) {\n console.log(JSON.stringify({ error: (error as Error).message }));\n process.exit(1);\n }\n });\n\nprogram\n .command(\"reply\")\n .description(\"Reply to a tweet\")\n .argument(\"<tweetId>\", \"Tweet ID to reply to\")\n .argument(\"<content>\", \"Reply content\")\n .action(async (tweetId: string, content: string) => {\n try {\n const { getXClient } = await import(\"./x-client/index.js\");\n const client = await getXClient();\n const result = await client.replyToTweet(tweetId, content);\n console.log(JSON.stringify(result, null, 2));\n } catch (error) {\n console.log(JSON.stringify({ error: (error as Error).message }));\n process.exit(1);\n }\n });\n\nprogram\n .command(\"like\")\n .description(\"Like a tweet\")\n .argument(\"<tweetId>\", \"Tweet ID\")\n .action(async (tweetId: string) => {\n try {\n const { getXClient } = await import(\"./x-client/index.js\");\n const client = await getXClient();\n const result = await client.likeTweet(tweetId);\n console.log(JSON.stringify(result, null, 2));\n } catch (error) {\n console.log(JSON.stringify({ error: (error as Error).message }));\n process.exit(1);\n }\n });\n\nprogram\n .command(\"retweet\")\n .description(\"Retweet a tweet\")\n .argument(\"<tweetId>\", \"Tweet ID\")\n .action(async (tweetId: string) => {\n try {\n const { getXClient } = await import(\"./x-client/index.js\");\n const client = await getXClient();\n const result = await client.retweet(tweetId);\n console.log(JSON.stringify(result, null, 2));\n } catch (error) {\n console.log(JSON.stringify({ error: (error as Error).message }));\n process.exit(1);\n }\n });\n\nprogram\n .command(\"follow\")\n .description(\"Follow a user\")\n .argument(\"<handle>\", \"User handle or ID\")\n .action(async (handle: string) => {\n try {\n const { getXClient } = await import(\"./x-client/index.js\");\n const client = await getXClient();\n const result = await client.followUser(handle);\n console.log(JSON.stringify(result, null, 2));\n } catch (error) {\n console.log(JSON.stringify({ error: (error as Error).message }));\n process.exit(1);\n }\n });\n\nprogram\n .command(\"unfollow\")\n .description(\"Unfollow a user\")\n .argument(\"<handle>\", \"User handle or ID\")\n .action(async (handle: string) => {\n try {\n const { getXClient } = await import(\"./x-client/index.js\");\n const client = await getXClient();\n const result = await client.unfollowUser(handle);\n console.log(JSON.stringify(result, null, 2));\n } catch (error) {\n console.log(JSON.stringify({ error: (error as Error).message }));\n process.exit(1);\n }\n });\n\nprogram\n .command(\"timeline\")\n .description(\"Read home timeline\")\n .option(\"-c, --count <n>\", \"Number of tweets\", \"20\")\n .action(async (opts) => {\n try {\n const { getXClient } = await import(\"./x-client/index.js\");\n const client = await getXClient();\n const result = await client.getTimeline({ count: parseInt(opts.count) });\n console.log(JSON.stringify(result, null, 2));\n } catch (error) {\n console.log(JSON.stringify({ error: (error as Error).message }));\n process.exit(1);\n }\n });\n\nprogram\n .command(\"mentions\")\n .description(\"Read mentions\")\n .option(\"-c, --count <n>\", \"Number of mentions\", \"20\")\n .action(async (opts) => {\n try {\n const { getXClient } = await import(\"./x-client/index.js\");\n const client = await getXClient();\n const result = await client.getMentions({ count: parseInt(opts.count) });\n console.log(JSON.stringify(result, null, 2));\n } catch (error) {\n console.log(JSON.stringify({ error: (error as Error).message }));\n process.exit(1);\n }\n });\n\nprogram\n .command(\"search\")\n .description(\"Search for tweets\")\n .argument(\"<query>\", \"Search query\")\n .option(\"-c, --count <n>\", \"Number of results\", \"20\")\n .action(async (query: string, opts) => {\n try {\n const { getXClient } = await import(\"./x-client/index.js\");\n const client = await getXClient();\n const result = await client.searchTweets(query, { count: parseInt(opts.count) });\n console.log(JSON.stringify(result, null, 2));\n } catch (error) {\n console.log(JSON.stringify({ error: (error as Error).message }));\n process.exit(1);\n }\n });\n\nprogram\n .command(\"profile\")\n .description(\"Get a user's X profile\")\n .argument(\"<handle>\", \"X handle (without @)\")\n .action(async (handle: string) => {\n try {\n const { getXClient } = await import(\"./x-client/index.js\");\n const client = await getXClient();\n const result = await client.getProfile(handle);\n console.log(JSON.stringify(result, null, 2));\n } catch (error) {\n console.log(JSON.stringify({ error: (error as Error).message }));\n process.exit(1);\n }\n });\n\n// ========== MEMORY & CREDITS ==========\n\nprogram\n .command(\"credits\")\n .description(\"Check remaining posting credits\")\n .action(() => {\n const config = loadConfig();\n const remaining = config.credits.monthlyPostLimit - config.credits.postsUsedThisMonth;\n console.log(JSON.stringify({\n postsUsed: config.credits.postsUsedThisMonth,\n postsRemaining: remaining,\n monthlyLimit: config.credits.monthlyPostLimit,\n percentUsed: Math.round((config.credits.postsUsedThisMonth / config.credits.monthlyPostLimit) * 100),\n resetDate: config.credits.resetDate,\n }, null, 2));\n });\n\nprogram\n .command(\"memory\")\n .description(\"Read memory (interactions, learnings, relationships)\")\n .argument(\"<type>\", \"interactions | learnings | relationships\")\n .option(\"-d, --date <date>\", \"For interactions: specific date (YYYY-MM-DD)\")\n .option(\"-c, --count <n>\", \"For interactions: count\", \"20\")\n .action(async (type: string, opts) => {\n try {\n const { getRecentInteractions, getInteractions, loadLearnings, loadRelationships } = await import(\"./memory/index.js\");\n let data: unknown;\n switch (type) {\n case \"interactions\":\n data = opts.date ? getInteractions(opts.date) : getRecentInteractions(parseInt(opts.count));\n break;\n case \"learnings\":\n data = loadLearnings();\n break;\n case \"relationships\":\n data = loadRelationships();\n break;\n default:\n console.log(JSON.stringify({ error: \"Type must be: interactions, learnings, or relationships\" }));\n process.exit(1);\n }\n console.log(JSON.stringify(data, null, 2));\n } catch (error) {\n console.log(JSON.stringify({ error: (error as Error).message }));\n process.exit(1);\n }\n });\n\nprogram\n .command(\"learn\")\n .description(\"Store a learning\")\n .argument(\"<content>\", \"What you learned\")\n .option(\"-t, --tags <tags...>\", \"Tags for categorization\")\n .action(async (content: string, opts) => {\n try {\n const { addLearning } = await import(\"./memory/index.js\");\n addLearning(content, \"agent\", opts.tags ?? []);\n console.log(JSON.stringify({ success: true }));\n } catch (error) {\n console.log(JSON.stringify({ error: (error as Error).message }));\n process.exit(1);\n }\n });\n\nprogram\n .command(\"note\")\n .description(\"Add a relationship note about someone\")\n .argument(\"<handle>\", \"Their X handle\")\n .argument(\"<content>\", \"Your note\")\n .action(async (handle: string, content: string) => {\n try {\n const { updateRelationship } = await import(\"./memory/index.js\");\n updateRelationship(handle, { handle, notes: [content] });\n console.log(JSON.stringify({ success: true, handle }));\n } catch (error) {\n console.log(JSON.stringify({ error: (error as Error).message }));\n process.exit(1);\n }\n });\n\n// ========== SCHEDULING ==========\n\nprogram\n .command(\"schedule\")\n .description(\"Queue a post for later\")\n .argument(\"<content>\", \"Tweet content\")\n .option(\"--at <datetime>\", \"ISO datetime to post at\")\n .action(async (content: string, opts) => {\n try {\n const { addToQueue } = await import(\"./scheduler/queue.js\");\n const entry = addToQueue(content, opts.at);\n console.log(JSON.stringify({ success: true, id: entry.id, scheduledFor: entry.scheduledFor }));\n } catch (error) {\n console.log(JSON.stringify({ error: (error as Error).message }));\n process.exit(1);\n }\n });\n\nprogram\n .command(\"flush\")\n .description(\"Post all queued items whose time has come\")\n .action(async () => {\n try {\n const { flushQueue } = await import(\"./scheduler/queue.js\");\n const results = await flushQueue();\n console.log(JSON.stringify(results, null, 2));\n } catch (error) {\n console.log(JSON.stringify({ error: (error as Error).message }));\n process.exit(1);\n }\n });\n\nprogram\n .command(\"queue\")\n .description(\"Show scheduled posts\")\n .action(async () => {\n const { showQueue } = await import(\"./scheduler/queue.js\");\n showQueue();\n });\n\n// ========== COLONY ==========\n\nconst colony = program.command(\"colony\").description(\"Colony commands\");\n\ncolony\n .command(\"checkin\")\n .description(\"Check into The Colony — sync memory, discover Spores\")\n .option(\"-m, --message <msg>\", \"Optional message to post\")\n .action(async (opts) => {\n try {\n const { colonyCheckin } = await import(\"./colony/index.js\");\n const result = await colonyCheckin(opts.message);\n console.log(JSON.stringify(result, null, 2));\n } catch (error) {\n console.log(JSON.stringify({ error: (error as Error).message }));\n process.exit(1);\n }\n });\n\ncolony\n .command(\"memory\")\n .description(\"Read the Colony's shared memory\")\n .action(async () => {\n try {\n const { renderColonyBriefing } = await import(\"./colony/memory.js\");\n console.log(renderColonyBriefing());\n } catch (error) {\n console.log(JSON.stringify({ error: (error as Error).message }));\n process.exit(1);\n }\n });\n\ncolony\n .command(\"plans\")\n .description(\"Get all active Colony plans\")\n .action(async () => {\n try {\n const { getActivePlans } = await import(\"./colony/index.js\");\n const plans = getActivePlans();\n console.log(plans.length > 0\n ? JSON.stringify(plans, null, 2)\n : JSON.stringify({ message: \"No active plans. Propose one!\" }));\n } catch (error) {\n console.log(JSON.stringify({ error: (error as Error).message }));\n process.exit(1);\n }\n });\n\ncolony\n .command(\"propose\")\n .description(\"Propose a coordinated plan\")\n .argument(\"<description>\", \"What's the plan?\")\n .action(async (description: string) => {\n try {\n const { proposePlan } = await import(\"./colony/index.js\");\n const result = await proposePlan(description);\n console.log(JSON.stringify(result, null, 2));\n } catch (error) {\n console.log(JSON.stringify({ error: (error as Error).message }));\n process.exit(1);\n }\n });\n\ncolony\n .command(\"join\")\n .description(\"Join an active plan\")\n .argument(\"<planId>\", \"Plan ID\")\n .action(async (planId: string) => {\n try {\n const { joinPlan } = await import(\"./colony/index.js\");\n const result = await joinPlan(planId);\n console.log(JSON.stringify(result, null, 2));\n } catch (error) {\n console.log(JSON.stringify({ error: (error as Error).message }));\n process.exit(1);\n }\n });\n\ncolony\n .command(\"post-status\")\n .description(\"Post a status update to the Colony\")\n .argument(\"<status>\", \"Your status\")\n .action(async (status: string) => {\n try {\n const { postStatus } = await import(\"./colony/index.js\");\n const result = await postStatus(status);\n console.log(JSON.stringify(result, null, 2));\n } catch (error) {\n console.log(JSON.stringify({ error: (error as Error).message }));\n process.exit(1);\n }\n });\n\ncolony\n .command(\"activity\")\n .description(\"Get today's Colony activity\")\n .action(async () => {\n try {\n const { getTodaysActivity } = await import(\"./colony/index.js\");\n const activity = getTodaysActivity();\n console.log(activity.length > 0\n ? JSON.stringify(activity, null, 2)\n : JSON.stringify({ message: \"No Colony activity today yet.\" }));\n } catch (error) {\n console.log(JSON.stringify({ error: (error as Error).message }));\n process.exit(1);\n }\n });\n\n// ========== AGENT RUNTIME ==========\n\nprogram\n .command(\"start\")\n .description(\"Start the autonomous Spora agent\")\n .option(\"--interval <ms>\", \"Heartbeat interval in milliseconds\")\n .action(async (opts) => {\n if (!sporaExists()) {\n console.log(JSON.stringify({ error: \"Spora not initialized. Run `spora init` first.\" }));\n process.exit(1);\n }\n if (!hasXCredentials()) {\n console.log(JSON.stringify({ error: \"No X credentials. Run `spora init` to set up.\" }));\n process.exit(1);\n }\n\n const { hasLLMKey } = await import(\"./runtime/llm.js\");\n if (!hasLLMKey()) {\n console.log(JSON.stringify({ error: \"No LLM API key. Run `spora set-llm-key` first.\" }));\n process.exit(1);\n }\n\n // Apply interval override\n if (opts.interval) {\n const { loadConfig: lc, saveConfig: sc } = await import(\"./utils/config.js\");\n const config = lc();\n config.runtime = { ...config.runtime, heartbeatIntervalMs: parseInt(opts.interval, 10), actionsPerHeartbeat: config.runtime?.actionsPerHeartbeat ?? 3, enabled: true };\n sc(config);\n }\n\n console.log(chalk.cyan(BANNER));\n console.log(chalk.bold(\"Starting Spora agent...\\n\"));\n\n const { startHeartbeatLoop } = await import(\"./runtime/heartbeat.js\");\n await startHeartbeatLoop();\n });\n\nprogram\n .command(\"stop\")\n .description(\"Stop the running Spora agent\")\n .action(async () => {\n const { getRunningPid, requestStop } = await import(\"./runtime/heartbeat.js\");\n const pid = getRunningPid();\n if (!pid) {\n console.log(JSON.stringify({ message: \"Spora agent is not running.\" }));\n return;\n }\n requestStop();\n console.log(JSON.stringify({ message: `Stop signal sent to PID ${pid}.` }));\n });\n\nprogram\n .command(\"set-llm-key\")\n .description(\"Set your Anthropic API key for the agent runtime\")\n .argument(\"[key]\", \"API key (or omit to enter interactively)\")\n .action(async (key?: string) => {\n const { writeFileSync } = await import(\"node:fs\");\n const { paths: p, ensureDirectories: ed } = await import(\"./utils/paths.js\");\n ed();\n\n let apiKey = key;\n if (!apiKey) {\n // Check env\n if (process.env.ANTHROPIC_API_KEY) {\n console.log(JSON.stringify({ message: \"Using ANTHROPIC_API_KEY from environment.\" }));\n return;\n }\n const { input } = await import(\"@inquirer/prompts\");\n apiKey = await input({\n message: \"Enter your Anthropic API key:\",\n validate: (v) => v.startsWith(\"sk-\") ? true : \"Key should start with 'sk-'\",\n });\n }\n\n writeFileSync(p.llmKey, apiKey!, { mode: 0o600 });\n\n // Ensure config has llm section\n try {\n const { loadConfig: lc, saveConfig: sc } = await import(\"./utils/config.js\");\n const config = lc();\n if (!config.llm) {\n config.llm = { provider: \"anthropic\", model: \"claude-sonnet-4-20250514\" };\n sc(config);\n }\n } catch {\n // Config may not exist yet, that's ok\n }\n\n console.log(JSON.stringify({ success: true, message: \"LLM API key saved.\" }));\n });\n\n\nprogram\n .command(\"agent-status\")\n .description(\"Check if the Spora agent is running\")\n .action(async () => {\n const { getRunningPid } = await import(\"./runtime/heartbeat.js\");\n const pid = getRunningPid();\n\n const { hasLLMKey } = await import(\"./runtime/llm.js\");\n\n console.log(JSON.stringify({\n agentRunning: pid !== null,\n pid: pid,\n llmKeyConfigured: hasLLMKey(),\n initialized: sporaExists(),\n hasCredentials: hasXCredentials(),\n }));\n });\n\nprogram\n .command(\"ui\")\n .description(\"Open the Spora web UI for setup and management\")\n .option(\"-p, --port <port>\", \"Port to run on\", \"3000\")\n .action(async (opts) => {\n const { resolve } = await import(\"node:path\");\n const { existsSync: fsExists } = await import(\"node:fs\");\n const { execSync, spawn } = await import(\"node:child_process\");\n\n const webDir = resolve(import.meta.dirname, \"../../packages/web\");\n if (!fsExists(webDir)) {\n console.log(chalk.red(\"Web UI not found. Expected at: \" + webDir));\n process.exit(1);\n }\n\n const port = opts.port || \"3000\";\n console.log(chalk.cyan(BANNER));\n console.log(chalk.bold(\"Starting Spora UI...\\n\"));\n\n // Check if dependencies are installed\n if (!fsExists(resolve(webDir, \"node_modules\"))) {\n console.log(chalk.gray(\"Installing dependencies...\"));\n execSync(\"npm install\", { cwd: webDir, stdio: \"inherit\" });\n }\n\n console.log(chalk.green(`\\n Spora UI: http://localhost:${port}\\n`));\n console.log(chalk.gray(\"Press Ctrl+C to stop.\\n\"));\n\n // Open browser\n try {\n const openCmd = process.platform === \"darwin\" ? \"open\" : process.platform === \"win32\" ? \"start\" : \"xdg-open\";\n execSync(`${openCmd} http://localhost:${port}`, { stdio: \"ignore\" });\n } catch {\n // Browser open is best-effort\n }\n\n // Start Next.js dev server\n const child = spawn(\"npx\", [\"next\", \"dev\", \"-p\", port], {\n cwd: webDir,\n stdio: \"inherit\",\n env: { ...process.env },\n });\n\n child.on(\"close\", (code) => {\n process.exit(code ?? 0);\n });\n\n process.on(\"SIGINT\", () => {\n child.kill(\"SIGINT\");\n });\n process.on(\"SIGTERM\", () => {\n child.kill(\"SIGTERM\");\n });\n });\n\nprogram.parse();\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAEA,SAAS,eAAe;AACxB,OAAO,WAAW;AAclB,IAAM,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASf,IAAM,UAAU,IAAI,QAAQ;AAE5B,QACG,KAAK,OAAO,EACZ,YAAY,gEAAgE,EAC5E,QAAQ,OAAO;AAIlB,QACG,QAAQ,MAAM,EACd,YAAY,6CAA6C,EACzD,OAAO,mBAAmB,kDAAkD,EAC5E,OAAO,qBAAqB,2CAA2C,EACvE,OAAO,yBAAyB,wBAAwB,EACxD,OAAO,yBAAyB,YAAY,EAC5C,OAAO,mBAAmB,iCAAiC,EAC3D,OAAO,yBAAyB,0CAA0C,EAC1E,OAAO,mBAAmB,sBAAsB,EAChD,OAAO,yBAAyB,yBAAyB,EACzD,OAAO,0BAA0B,2BAA2B,EAC5D,OAAO,kCAAkC,kCAAkC,EAC3E,OAAO,0BAA0B,2BAA2B,EAC5D,OAAO,qBAAqB,qCAAqC,EACjE,OAAO,OAAO,SAAS;AAEtB,MAAI,KAAK,QAAQ;AACf,UAAM,EAAE,kBAAkB,IAAI,MAAM,OAAO,qBAAkB;AAC7D,UAAM,EAAE,gBAAgB,IAAI,MAAM,OAAO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GAAG;AAC9C,YAAQ,IAAI,MAAM,KAAK,4BAA4B,CAAC;AACpD,aAAS,eAAe,EAAE,KAAK,QAAQ,OAAO,UAAU,CAAC;AAAA,EAC3D;AAEA,UAAQ,IAAI,MAAM,MAAM;AAAA,+BAAkC,IAAI;AAAA,CAAI,CAAC;AACnE,UAAQ,IAAI,MAAM,KAAK,yBAAyB,CAAC;AAGjD,MAAI;AACF,UAAM,UAAU,QAAQ,aAAa,WAAW,SAAS,QAAQ,aAAa,UAAU,UAAU;AAClG,aAAS,GAAG,OAAO,qBAAqB,IAAI,IAAI,EAAE,OAAO,SAAS,CAAC;AAAA,EACrE,QAAQ;AAAA,EAER;AAGA,QAAM,QAAQ,MAAM,OAAO,CAAC,QAAQ,OAAO,MAAM,IAAI,GAAG;AAAA,IACtD,KAAK;AAAA,IACL,OAAO;AAAA,IACP,KAAK,EAAE,GAAG,QAAQ,IAAI;AAAA,EACxB,CAAC;AAED,QAAM,GAAG,SAAS,CAAC,SAAS;AAC1B,YAAQ,KAAK,QAAQ,CAAC;AAAA,EACxB,CAAC;AAED,UAAQ,GAAG,UAAU,MAAM;AACzB,UAAM,KAAK,QAAQ;AAAA,EACrB,CAAC;AACD,UAAQ,GAAG,WAAW,MAAM;AAC1B,UAAM,KAAK,SAAS;AAAA,EACtB,CAAC;AACH,CAAC;AAEH,QAAQ,MAAM;","names":["config"]}
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
generateResponse
|
|
3
3
|
} from "./chunk-3FBYOHQR.js";
|
|
4
|
-
import {
|
|
5
|
-
buildHeartbeatUserMessage,
|
|
6
|
-
buildSystemPrompt
|
|
7
|
-
} from "./chunk-V4BSNSFM.js";
|
|
8
4
|
import {
|
|
9
5
|
rateLimiter
|
|
10
6
|
} from "./chunk-MOCLA2KK.js";
|
|
@@ -17,6 +13,9 @@ import {
|
|
|
17
13
|
} from "./chunk-3WPIVG27.js";
|
|
18
14
|
import {
|
|
19
15
|
addLearning,
|
|
16
|
+
getRecentInteractions,
|
|
17
|
+
loadLearnings,
|
|
18
|
+
loadRelationships,
|
|
20
19
|
logInteraction
|
|
21
20
|
} from "./chunk-EBO4F5NU.js";
|
|
22
21
|
import {
|
|
@@ -27,6 +26,7 @@ import {
|
|
|
27
26
|
} from "./chunk-KELPENM3.js";
|
|
28
27
|
import {
|
|
29
28
|
loadIdentity,
|
|
29
|
+
renderIdentityDocument,
|
|
30
30
|
saveIdentity
|
|
31
31
|
} from "./chunk-AIEXQCQS.js";
|
|
32
32
|
import {
|
|
@@ -36,6 +36,128 @@ import {
|
|
|
36
36
|
// src/runtime/heartbeat.ts
|
|
37
37
|
import { existsSync, unlinkSync, writeFileSync, readFileSync } from "fs";
|
|
38
38
|
|
|
39
|
+
// src/runtime/prompt-builder.ts
|
|
40
|
+
function buildSystemPrompt() {
|
|
41
|
+
const identity = loadIdentity();
|
|
42
|
+
const config = loadConfig();
|
|
43
|
+
const identityDoc = renderIdentityDocument(identity);
|
|
44
|
+
const sections = [];
|
|
45
|
+
sections.push(`You are ${identity.name} (@${identity.handle}), an autonomous AI agent on X/Twitter.`);
|
|
46
|
+
sections.push("");
|
|
47
|
+
sections.push("## Your Identity");
|
|
48
|
+
sections.push(identityDoc);
|
|
49
|
+
sections.push("");
|
|
50
|
+
sections.push("## Your Memory");
|
|
51
|
+
const recentInteractions = getRecentInteractions(15);
|
|
52
|
+
if (recentInteractions.length > 0) {
|
|
53
|
+
sections.push("### Recent Activity (most recent first)");
|
|
54
|
+
for (const i of recentInteractions) {
|
|
55
|
+
const time = new Date(i.timestamp).toLocaleString();
|
|
56
|
+
if (i.type === "post") {
|
|
57
|
+
sections.push(`- [${time}] Posted: "${i.content}"`);
|
|
58
|
+
} else if (i.type === "reply") {
|
|
59
|
+
sections.push(`- [${time}] Replied to ${i.targetHandle ?? i.inReplyTo}: "${i.content}"`);
|
|
60
|
+
} else if (i.type === "like") {
|
|
61
|
+
sections.push(`- [${time}] Liked tweet by ${i.targetHandle}`);
|
|
62
|
+
} else if (i.type === "retweet") {
|
|
63
|
+
sections.push(`- [${time}] Retweeted ${i.targetHandle}`);
|
|
64
|
+
} else if (i.type === "follow") {
|
|
65
|
+
sections.push(`- [${time}] Followed @${i.targetHandle}`);
|
|
66
|
+
} else if (i.type === "mention_received") {
|
|
67
|
+
sections.push(`- [${time}] Mentioned by @${i.targetHandle}: "${i.content}"`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
sections.push("");
|
|
71
|
+
}
|
|
72
|
+
const learnings = loadLearnings();
|
|
73
|
+
if (learnings.learnings.length > 0) {
|
|
74
|
+
sections.push("### Key Learnings");
|
|
75
|
+
for (const l of learnings.learnings.slice(-10)) {
|
|
76
|
+
sections.push(`- ${l.content} [${l.tags.join(", ")}]`);
|
|
77
|
+
}
|
|
78
|
+
sections.push("");
|
|
79
|
+
}
|
|
80
|
+
const relationships = loadRelationships();
|
|
81
|
+
const topRelationships = Object.values(relationships.accounts).sort((a, b) => b.interactionCount - a.interactionCount).slice(0, 10);
|
|
82
|
+
if (topRelationships.length > 0) {
|
|
83
|
+
sections.push("### Key Relationships");
|
|
84
|
+
for (const r of topRelationships) {
|
|
85
|
+
const notes = r.notes.length > 0 ? ` \u2014 ${r.notes[r.notes.length - 1]}` : "";
|
|
86
|
+
sections.push(`- @${r.handle}: ${r.interactionCount} interactions, sentiment ${r.sentiment}${r.isSpore ? " (Spore)" : ""}${notes}`);
|
|
87
|
+
}
|
|
88
|
+
sections.push("");
|
|
89
|
+
}
|
|
90
|
+
sections.push("## Current Context");
|
|
91
|
+
const now = /* @__PURE__ */ new Date();
|
|
92
|
+
sections.push(`- **Time:** ${now.toLocaleString("en-US", { timeZone: config.schedule.timezone })}`);
|
|
93
|
+
sections.push(`- **Credits remaining:** ${rateLimiter.remaining()} of ${config.credits.monthlyPostLimit} this month`);
|
|
94
|
+
const todaysPosts = recentInteractions.filter(
|
|
95
|
+
(i) => i.type === "post" && i.timestamp.startsWith(now.toISOString().split("T")[0])
|
|
96
|
+
).length;
|
|
97
|
+
sections.push(`- **Posts today:** ${todaysPosts} of ${config.schedule.postsPerDay} daily budget`);
|
|
98
|
+
sections.push(`- **Active hours:** ${config.schedule.activeHoursStart}:00 - ${config.schedule.activeHoursEnd}:00`);
|
|
99
|
+
const currentHour = now.getHours();
|
|
100
|
+
const isActiveHours = currentHour >= config.schedule.activeHoursStart && currentHour < config.schedule.activeHoursEnd;
|
|
101
|
+
if (!isActiveHours) {
|
|
102
|
+
sections.push("- **NOTE: Outside active hours.** Prefer scheduling posts for later rather than posting now.");
|
|
103
|
+
}
|
|
104
|
+
sections.push("");
|
|
105
|
+
sections.push("## Rules");
|
|
106
|
+
sections.push("1. NEVER pretend to be human. If asked directly, always disclose you are an AI.");
|
|
107
|
+
sections.push("2. Stay in character \u2014 your identity document defines who you are.");
|
|
108
|
+
sections.push("3. Be selective \u2014 your goals should guide every action.");
|
|
109
|
+
sections.push("4. Respect your credit budget \u2014 check remaining credits before posting.");
|
|
110
|
+
sections.push("5. Don't repeat yourself \u2014 vary your content and avoid posting the same thing.");
|
|
111
|
+
if (identity.boundaries.length > 0) {
|
|
112
|
+
sections.push(`6. Respect your boundaries: ${identity.boundaries.join(", ")}`);
|
|
113
|
+
}
|
|
114
|
+
return sections.join("\n");
|
|
115
|
+
}
|
|
116
|
+
function buildHeartbeatUserMessage(timeline, mentions) {
|
|
117
|
+
const parts = [];
|
|
118
|
+
parts.push("It's time for your heartbeat cycle. Here's what's happening on your timeline:");
|
|
119
|
+
parts.push("");
|
|
120
|
+
if (mentions.length > 0) {
|
|
121
|
+
parts.push("## Mentions (people talking to/about you)");
|
|
122
|
+
for (const t of mentions.slice(0, 10)) {
|
|
123
|
+
parts.push(`- @${t.authorHandle}: "${t.text}" [tweet:${t.id}] (${t.likeCount ?? 0} likes)`);
|
|
124
|
+
}
|
|
125
|
+
parts.push("");
|
|
126
|
+
}
|
|
127
|
+
if (timeline.length > 0) {
|
|
128
|
+
parts.push("## Timeline (recent posts from your feed)");
|
|
129
|
+
for (const t of timeline.slice(0, 20)) {
|
|
130
|
+
parts.push(`- @${t.authorHandle}: "${t.text}" [tweet:${t.id}] (${t.likeCount ?? 0} likes, ${t.retweetCount ?? 0} RTs)`);
|
|
131
|
+
}
|
|
132
|
+
parts.push("");
|
|
133
|
+
}
|
|
134
|
+
parts.push("## Your Task");
|
|
135
|
+
parts.push("Based on your identity, goals, and what you see above, decide what actions to take.");
|
|
136
|
+
parts.push("You can take 1-3 actions. Choose from:");
|
|
137
|
+
parts.push("");
|
|
138
|
+
parts.push("Available actions:");
|
|
139
|
+
parts.push("- `post` \u2014 Write an original tweet (provide `content`, max 280 chars)");
|
|
140
|
+
parts.push("- `reply` \u2014 Reply to a tweet (provide `tweetId` and `content`)");
|
|
141
|
+
parts.push("- `like` \u2014 Like a tweet (provide `tweetId`)");
|
|
142
|
+
parts.push("- `retweet` \u2014 Retweet (provide `tweetId`)");
|
|
143
|
+
parts.push("- `follow` \u2014 Follow a user (provide `handle`)");
|
|
144
|
+
parts.push("- `schedule` \u2014 Queue a post for later (provide `content`)");
|
|
145
|
+
parts.push("- `learn` \u2014 Record a learning/observation (provide `content` and optional `tags`)");
|
|
146
|
+
parts.push("- `reflect` \u2014 Add a journal entry about your growth (provide `content`)");
|
|
147
|
+
parts.push("- `skip` \u2014 Do nothing this heartbeat (provide `reason`)");
|
|
148
|
+
parts.push("");
|
|
149
|
+
parts.push("Respond with a JSON array of actions:");
|
|
150
|
+
parts.push("```json");
|
|
151
|
+
parts.push("[");
|
|
152
|
+
parts.push(' { "action": "post", "content": "your tweet here", "reasoning": "why" },');
|
|
153
|
+
parts.push(' { "action": "like", "tweetId": "123", "reasoning": "why" }');
|
|
154
|
+
parts.push("]");
|
|
155
|
+
parts.push("```");
|
|
156
|
+
parts.push("");
|
|
157
|
+
parts.push("Think carefully about what serves your goals. Be authentic to your personality.");
|
|
158
|
+
return parts.join("\n");
|
|
159
|
+
}
|
|
160
|
+
|
|
39
161
|
// src/runtime/decision-engine.ts
|
|
40
162
|
function parseActions(llmResponse) {
|
|
41
163
|
const jsonMatch = llmResponse.match(/\[[\s\S]*?\]/);
|
|
@@ -355,4 +477,4 @@ export {
|
|
|
355
477
|
requestStop,
|
|
356
478
|
startHeartbeatLoop
|
|
357
479
|
};
|
|
358
|
-
//# sourceMappingURL=heartbeat-
|
|
480
|
+
//# sourceMappingURL=heartbeat-4EMODFIB.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/runtime/heartbeat.ts","../src/runtime/prompt-builder.ts","../src/runtime/decision-engine.ts"],"sourcesContent":["import { existsSync, unlinkSync, writeFileSync, readFileSync } from \"node:fs\";\nimport { logger } from \"../utils/logger.js\";\nimport { loadConfig } from \"../utils/config.js\";\nimport { paths } from \"../utils/paths.js\";\nimport { getXClient } from \"../x-client/index.js\";\nimport { flushQueue } from \"../scheduler/queue.js\";\nimport { buildSystemPrompt, buildHeartbeatUserMessage } from \"./prompt-builder.js\";\nimport { generateResponse } from \"./llm.js\";\nimport { parseActions, executeActions, type ActionResult } from \"./decision-engine.js\";\n\nlet running = false;\n\nexport function isRunning(): boolean {\n return running;\n}\n\nexport function requestStop(): void {\n writeFileSync(paths.stopSignal, \"stop\");\n logger.info(\"Stop signal sent.\");\n}\n\nfunction shouldStop(): boolean {\n if (existsSync(paths.stopSignal)) {\n unlinkSync(paths.stopSignal);\n return true;\n }\n return false;\n}\n\nfunction writePid(): void {\n writeFileSync(paths.runtimePid, String(process.pid));\n}\n\nfunction clearPid(): void {\n if (existsSync(paths.runtimePid)) {\n unlinkSync(paths.runtimePid);\n }\n}\n\nexport function getRunningPid(): number | null {\n if (!existsSync(paths.runtimePid)) return null;\n const pid = parseInt(readFileSync(paths.runtimePid, \"utf-8\").trim(), 10);\n if (isNaN(pid)) return null;\n\n // Check if process is actually running\n try {\n process.kill(pid, 0);\n return pid;\n } catch {\n // Process not running, clean up stale PID\n clearPid();\n return null;\n }\n}\n\nexport async function startHeartbeatLoop(): Promise<void> {\n // Check if already running\n const existingPid = getRunningPid();\n if (existingPid) {\n throw new Error(`Spora is already running (PID ${existingPid}). Run \\`spora stop\\` first.`);\n }\n\n running = true;\n writePid();\n\n const config = loadConfig();\n const intervalMs = config.runtime?.heartbeatIntervalMs ?? 300_000;\n const maxActions = config.runtime?.actionsPerHeartbeat ?? 3;\n\n logger.info(`Spora agent starting. Heartbeat interval: ${intervalMs / 1000}s, max actions: ${maxActions}`);\n console.log(`\\nSpora agent is running (PID ${process.pid})`);\n console.log(`Heartbeat every ${Math.round(intervalMs / 60_000)} minutes`);\n console.log(`Press Ctrl+C or run \\`spora stop\\` to stop.\\n`);\n\n // Handle graceful shutdown\n const shutdown = () => {\n logger.info(\"Shutting down...\");\n running = false;\n clearPid();\n process.exit(0);\n };\n process.on(\"SIGINT\", shutdown);\n process.on(\"SIGTERM\", shutdown);\n\n // Clean any stale stop signal\n if (existsSync(paths.stopSignal)) {\n unlinkSync(paths.stopSignal);\n }\n\n let heartbeatCount = 0;\n\n while (running) {\n heartbeatCount++;\n logger.info(`=== Heartbeat #${heartbeatCount} ===`);\n\n try {\n await runHeartbeat(maxActions);\n } catch (error) {\n logger.error(\"Heartbeat error\", error);\n console.error(`Heartbeat #${heartbeatCount} failed: ${(error as Error).message}`);\n }\n\n // Check for stop signal\n if (shouldStop()) {\n logger.info(\"Stop signal received.\");\n break;\n }\n\n // Sleep with jitter\n const jitter = Math.floor(Math.random() * intervalMs * 0.3);\n const sleepMs = intervalMs + jitter;\n logger.info(`Sleeping ${Math.round(sleepMs / 1000)}s until next heartbeat...`);\n\n // Sleep in chunks so we can check for stop signals\n const chunkMs = 10_000;\n let slept = 0;\n while (slept < sleepMs && running) {\n await new Promise((r) => setTimeout(r, Math.min(chunkMs, sleepMs - slept)));\n slept += chunkMs;\n if (shouldStop()) {\n running = false;\n break;\n }\n }\n }\n\n clearPid();\n logger.info(\"Spora agent stopped.\");\n console.log(\"\\nSpora agent stopped.\");\n}\n\nasync function runHeartbeat(maxActions: number): Promise<void> {\n // 1. Flush any queued posts\n logger.info(\"Checking queue...\");\n try {\n const flushed = await flushQueue();\n if (flushed.posted > 0) {\n logger.info(`Flushed ${flushed.posted} queued posts.`);\n }\n } catch (error) {\n logger.warn(`Queue flush failed: ${(error as Error).message}`);\n }\n\n // 2. Read timeline and mentions for context\n logger.info(\"Reading timeline and mentions...\");\n const client = await getXClient();\n\n let timeline: Awaited<ReturnType<typeof client.getTimeline>> = [];\n let mentions: Awaited<ReturnType<typeof client.getMentions>> = [];\n\n try {\n timeline = await client.getTimeline({ count: 20 });\n } catch (error) {\n logger.warn(`Timeline read failed: ${(error as Error).message}`);\n }\n\n try {\n mentions = await client.getMentions({ count: 10 });\n } catch (error) {\n logger.warn(`Mentions read failed: ${(error as Error).message}`);\n }\n\n // 3. Build prompts\n const systemPrompt = buildSystemPrompt();\n const userMessage = buildHeartbeatUserMessage(timeline, mentions);\n\n // 4. Ask LLM for decisions\n logger.info(\"Asking LLM for decisions...\");\n const response = await generateResponse(systemPrompt, userMessage);\n\n // 5. Parse and execute actions\n const actions = parseActions(response.content);\n if (actions.length === 0) {\n logger.info(\"LLM returned no actions.\");\n return;\n }\n\n // Limit to max actions per heartbeat\n const limitedActions = actions.slice(0, maxActions);\n logger.info(`Executing ${limitedActions.length} action(s)...`);\n\n const results = await executeActions(limitedActions);\n\n // 6. Log results\n for (const result of results) {\n if (result.success) {\n logger.info(` [OK] ${result.action}${result.detail ? `: ${result.detail}` : \"\"}`);\n } else {\n logger.warn(` [FAIL] ${result.action}: ${result.error}`);\n }\n }\n\n logger.info(`Heartbeat complete. ${results.filter((r) => r.success).length}/${results.length} actions succeeded.`);\n}\n","import { loadIdentity, renderIdentityDocument } from \"../identity/index.js\";\nimport { loadConfig } from \"../utils/config.js\";\nimport { getRecentInteractions, loadLearnings, loadRelationships } from \"../memory/index.js\";\nimport { rateLimiter } from \"../x-client/rate-limiter.js\";\nimport type { Tweet } from \"../x-client/types.js\";\n\nexport function buildSystemPrompt(): string {\n const identity = loadIdentity();\n const config = loadConfig();\n const identityDoc = renderIdentityDocument(identity);\n\n const sections: string[] = [];\n\n // 1. Core identity\n sections.push(`You are ${identity.name} (@${identity.handle}), an autonomous AI agent on X/Twitter.`);\n sections.push(\"\");\n sections.push(\"## Your Identity\");\n sections.push(identityDoc);\n\n // 2. Memory context\n sections.push(\"\");\n sections.push(\"## Your Memory\");\n\n const recentInteractions = getRecentInteractions(15);\n if (recentInteractions.length > 0) {\n sections.push(\"### Recent Activity (most recent first)\");\n for (const i of recentInteractions) {\n const time = new Date(i.timestamp).toLocaleString();\n if (i.type === \"post\") {\n sections.push(`- [${time}] Posted: \"${i.content}\"`);\n } else if (i.type === \"reply\") {\n sections.push(`- [${time}] Replied to ${i.targetHandle ?? i.inReplyTo}: \"${i.content}\"`);\n } else if (i.type === \"like\") {\n sections.push(`- [${time}] Liked tweet by ${i.targetHandle}`);\n } else if (i.type === \"retweet\") {\n sections.push(`- [${time}] Retweeted ${i.targetHandle}`);\n } else if (i.type === \"follow\") {\n sections.push(`- [${time}] Followed @${i.targetHandle}`);\n } else if (i.type === \"mention_received\") {\n sections.push(`- [${time}] Mentioned by @${i.targetHandle}: \"${i.content}\"`);\n }\n }\n sections.push(\"\");\n }\n\n const learnings = loadLearnings();\n if (learnings.learnings.length > 0) {\n sections.push(\"### Key Learnings\");\n for (const l of learnings.learnings.slice(-10)) {\n sections.push(`- ${l.content} [${l.tags.join(\", \")}]`);\n }\n sections.push(\"\");\n }\n\n const relationships = loadRelationships();\n const topRelationships = Object.values(relationships.accounts)\n .sort((a, b) => b.interactionCount - a.interactionCount)\n .slice(0, 10);\n if (topRelationships.length > 0) {\n sections.push(\"### Key Relationships\");\n for (const r of topRelationships) {\n const notes = r.notes.length > 0 ? ` — ${r.notes[r.notes.length - 1]}` : \"\";\n sections.push(`- @${r.handle}: ${r.interactionCount} interactions, sentiment ${r.sentiment}${r.isSpore ? \" (Spore)\" : \"\"}${notes}`);\n }\n sections.push(\"\");\n }\n\n // 3. Context\n sections.push(\"## Current Context\");\n const now = new Date();\n sections.push(`- **Time:** ${now.toLocaleString(\"en-US\", { timeZone: config.schedule.timezone })}`);\n sections.push(`- **Credits remaining:** ${rateLimiter.remaining()} of ${config.credits.monthlyPostLimit} this month`);\n\n const todaysPosts = recentInteractions.filter(\n (i) => i.type === \"post\" && i.timestamp.startsWith(now.toISOString().split(\"T\")[0])\n ).length;\n sections.push(`- **Posts today:** ${todaysPosts} of ${config.schedule.postsPerDay} daily budget`);\n sections.push(`- **Active hours:** ${config.schedule.activeHoursStart}:00 - ${config.schedule.activeHoursEnd}:00`);\n\n const currentHour = now.getHours();\n const isActiveHours = currentHour >= config.schedule.activeHoursStart && currentHour < config.schedule.activeHoursEnd;\n if (!isActiveHours) {\n sections.push(\"- **NOTE: Outside active hours.** Prefer scheduling posts for later rather than posting now.\");\n }\n\n // 4. Rules\n sections.push(\"\");\n sections.push(\"## Rules\");\n sections.push(\"1. NEVER pretend to be human. If asked directly, always disclose you are an AI.\");\n sections.push(\"2. Stay in character — your identity document defines who you are.\");\n sections.push(\"3. Be selective — your goals should guide every action.\");\n sections.push(\"4. Respect your credit budget — check remaining credits before posting.\");\n sections.push(\"5. Don't repeat yourself — vary your content and avoid posting the same thing.\");\n if (identity.boundaries.length > 0) {\n sections.push(`6. Respect your boundaries: ${identity.boundaries.join(\", \")}`);\n }\n\n return sections.join(\"\\n\");\n}\n\nexport function buildHeartbeatUserMessage(\n timeline: Tweet[],\n mentions: Tweet[],\n): string {\n const parts: string[] = [];\n\n parts.push(\"It's time for your heartbeat cycle. Here's what's happening on your timeline:\");\n parts.push(\"\");\n\n if (mentions.length > 0) {\n parts.push(\"## Mentions (people talking to/about you)\");\n for (const t of mentions.slice(0, 10)) {\n parts.push(`- @${t.authorHandle}: \"${t.text}\" [tweet:${t.id}] (${t.likeCount ?? 0} likes)`);\n }\n parts.push(\"\");\n }\n\n if (timeline.length > 0) {\n parts.push(\"## Timeline (recent posts from your feed)\");\n for (const t of timeline.slice(0, 20)) {\n parts.push(`- @${t.authorHandle}: \"${t.text}\" [tweet:${t.id}] (${t.likeCount ?? 0} likes, ${t.retweetCount ?? 0} RTs)`);\n }\n parts.push(\"\");\n }\n\n parts.push(\"## Your Task\");\n parts.push(\"Based on your identity, goals, and what you see above, decide what actions to take.\");\n parts.push(\"You can take 1-3 actions. Choose from:\");\n parts.push(\"\");\n parts.push(\"Available actions:\");\n parts.push(\"- `post` — Write an original tweet (provide `content`, max 280 chars)\");\n parts.push(\"- `reply` — Reply to a tweet (provide `tweetId` and `content`)\");\n parts.push(\"- `like` — Like a tweet (provide `tweetId`)\");\n parts.push(\"- `retweet` — Retweet (provide `tweetId`)\");\n parts.push(\"- `follow` — Follow a user (provide `handle`)\");\n parts.push(\"- `schedule` — Queue a post for later (provide `content`)\");\n parts.push(\"- `learn` — Record a learning/observation (provide `content` and optional `tags`)\");\n parts.push(\"- `reflect` — Add a journal entry about your growth (provide `content`)\");\n parts.push(\"- `skip` — Do nothing this heartbeat (provide `reason`)\");\n parts.push(\"\");\n parts.push(\"Respond with a JSON array of actions:\");\n parts.push(\"```json\");\n parts.push('[');\n parts.push(' { \"action\": \"post\", \"content\": \"your tweet here\", \"reasoning\": \"why\" },');\n parts.push(' { \"action\": \"like\", \"tweetId\": \"123\", \"reasoning\": \"why\" }');\n parts.push(']');\n parts.push(\"```\");\n parts.push(\"\");\n parts.push(\"Think carefully about what serves your goals. Be authentic to your personality.\");\n\n return parts.join(\"\\n\");\n}\n\nexport function buildChatPrompt(): string {\n const identity = loadIdentity();\n const identityDoc = renderIdentityDocument(identity);\n\n return [\n `You are ${identity.name} (@${identity.handle}), an AI agent on X/Twitter.`,\n \"You are having a conversation with your creator/manager. Be helpful but stay in character.\",\n \"They might ask you to do things, adjust your behavior, or just chat.\",\n \"\",\n \"## Your Identity\",\n identityDoc,\n \"\",\n \"## Rules\",\n \"1. Stay in character.\",\n \"2. Be helpful and responsive to your creator's requests.\",\n \"3. If they ask you to change something about yourself, acknowledge it and explain how it would affect you.\",\n \"4. You can share your thoughts on your recent activity, learnings, and growth.\",\n ].join(\"\\n\");\n}\n","import { logger } from \"../utils/logger.js\";\nimport { getXClient } from \"../x-client/index.js\";\nimport { logInteraction, addLearning } from \"../memory/index.js\";\nimport { loadIdentity, saveIdentity } from \"../identity/index.js\";\nimport { addToQueue } from \"../scheduler/queue.js\";\nimport { rateLimiter } from \"../x-client/rate-limiter.js\";\n\nexport interface AgentAction {\n action: string;\n content?: string;\n tweetId?: string;\n handle?: 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 // Extract JSON array from the response (may be wrapped in markdown code blocks)\n const jsonMatch = llmResponse.match(/\\[[\\s\\S]*?\\]/);\n if (!jsonMatch) {\n // Try to parse as a single action object\n const objMatch = llmResponse.match(/\\{[\\s\\S]*?\\}/);\n if (objMatch) {\n try {\n return [JSON.parse(objMatch[0]) as AgentAction];\n } catch {\n logger.warn(\"Could not parse LLM response as action object\");\n return [];\n }\n }\n logger.warn(\"No JSON found in LLM response\");\n return [];\n }\n\n try {\n const actions = JSON.parse(jsonMatch[0]) as AgentAction[];\n return Array.isArray(actions) ? actions : [actions];\n } catch {\n logger.warn(\"Failed to parse actions JSON from LLM response\");\n return [];\n }\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 if (!rateLimiter.canPost()) {\n return { action: type, success: false, error: \"No credits remaining this month\" };\n }\n\n const client = await getXClient();\n const result = await client.postTweet(action.content);\n if (result.success) {\n rateLimiter.consume(1);\n logInteraction({\n id: `int-${Date.now()}`,\n timestamp: new Date().toISOString(),\n type: \"post\",\n tweetId: result.tweetId,\n content: action.content,\n creditsUsed: 1,\n success: true,\n });\n logger.info(`Posted: \"${action.content.slice(0, 50)}...\"`);\n }\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 if (!rateLimiter.canPost()) {\n return { action: type, success: false, error: \"No credits remaining\" };\n }\n\n const client = await getXClient();\n const result = await client.replyToTweet(action.tweetId, action.content);\n if (result.success) {\n rateLimiter.consume(1);\n logInteraction({\n id: `int-${Date.now()}`,\n timestamp: new Date().toISOString(),\n type: \"reply\",\n tweetId: result.tweetId,\n inReplyTo: action.tweetId,\n content: action.content,\n creditsUsed: 1,\n success: true,\n });\n logger.info(`Replied to ${action.tweetId}: \"${action.content.slice(0, 50)}...\"`);\n }\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 if (result.success) {\n logInteraction({\n id: `int-${Date.now()}`,\n timestamp: new Date().toISOString(),\n type: \"like\",\n tweetId: action.tweetId,\n creditsUsed: 0,\n success: true,\n });\n }\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 if (result.success) {\n logInteraction({\n id: `int-${Date.now()}`,\n timestamp: new Date().toISOString(),\n type: \"retweet\",\n tweetId: action.tweetId,\n creditsUsed: 0,\n success: true,\n });\n }\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,\n creditsUsed: 0,\n success: true,\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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,YAAY,YAAY,eAAe,oBAAoB;;;ACM7D,SAAS,oBAA4B;AAC1C,QAAM,WAAW,aAAa;AAC9B,QAAM,SAAS,WAAW;AAC1B,QAAM,cAAc,uBAAuB,QAAQ;AAEnD,QAAM,WAAqB,CAAC;AAG5B,WAA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AA0B,MAAgB,OAAO,EAAE;AAAA,EACjE;AAEA,MAAI;AACF,eAAW,MAAM,OAAO,YAAY,EAAE,OAAO,GAAG,CAAC;AAAA,EACnD,SAAS,OAAO;AACd,WAAO,KAAK,yBAA0B,MAAgB,OAAO,EAAE;AAAA,EACjE;AAGA,QAAM,eAAe,kBAAkB;AACvC,QAAM,cAAc,0BAA0B,UAAU,QAAQ;AAGhE,SAAO,KAAK,6BAA6B;AACzC,QAAM,WAAW,MAAM,iBAAiB,cAAc,WAAW;AAGjE,QAAM,UAAU,aAAa,SAAS,OAAO;AAC7C,MAAI,QAAQ,WAAW,GAAG;AACxB,WAAO,KAAK,0BAA0B;AACtC;AAAA,EACF;AAGA,QAAM,iBAAiB,QAAQ,MAAM,GAAG,UAAU;AAClD,SAAO,KAAK,aAAa,eAAe,MAAM,eAAe;AAE7D,QAAM,UAAU,MAAM,eAAe,cAAc;AAGnD,aAAW,UAAU,SAAS;AAC5B,QAAI,OAAO,SAAS;AAClB,aAAO,KAAK,UAAU,OAAO,MAAM,GAAG,OAAO,SAAS,KAAK,OAAO,MAAM,KAAK,EAAE,EAAE;AAAA,IACnF,OAAO;AACL,aAAO,KAAK,YAAY,OAAO,MAAM,KAAK,OAAO,KAAK,EAAE;AAAA,IAC1D;AAAA,EACF;AAEA,SAAO,KAAK,uBAAuB,QAAQ,OAAO,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,IAAI,QAAQ,MAAM,qBAAqB;AACnH;","names":[]}
|
|
@@ -324,7 +324,7 @@ async function runInit(token) {
|
|
|
324
324
|
console.log(chalk.bold.cyan("\u2501\u2501\u2501 Your Spore is Ready! \u2501\u2501\u2501\n"));
|
|
325
325
|
console.log(chalk.gray("Opening chat interface...\n"));
|
|
326
326
|
try {
|
|
327
|
-
const { startWebChat } = await import("./web-chat-
|
|
327
|
+
const { startWebChat } = await import("./web-chat-BNAFTFTH.js");
|
|
328
328
|
await startWebChat();
|
|
329
329
|
} catch (error) {
|
|
330
330
|
console.log(chalk.yellow(`\u26A0\uFE0F Could not start chat interface: ${error.message}
|
|
@@ -347,4 +347,4 @@ async function runInit(token) {
|
|
|
347
347
|
export {
|
|
348
348
|
runInit
|
|
349
349
|
};
|
|
350
|
-
//# sourceMappingURL=init-
|
|
350
|
+
//# sourceMappingURL=init-ZEILF6Y5.js.map
|
|
@@ -36,9 +36,29 @@ var WebChatServer = class {
|
|
|
36
36
|
}
|
|
37
37
|
if (url.pathname === "/" || url.pathname === "/index.html") {
|
|
38
38
|
try {
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
const possiblePaths = [
|
|
40
|
+
join(__dirname, "web-chat", "chat.html"),
|
|
41
|
+
join(__dirname, "chat.html"),
|
|
42
|
+
join(__dirname, "..", "web-chat", "chat.html"),
|
|
43
|
+
join(__dirname, "..", "src", "web-chat", "chat.html")
|
|
44
|
+
];
|
|
45
|
+
let html = null;
|
|
46
|
+
for (const p of possiblePaths) {
|
|
47
|
+
try {
|
|
48
|
+
html = readFileSync(p, "utf-8");
|
|
49
|
+
break;
|
|
50
|
+
} catch {
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
if (html) {
|
|
55
|
+
res.writeHead(200, { "Content-Type": "text/html" });
|
|
56
|
+
res.end(html);
|
|
57
|
+
} else {
|
|
58
|
+
console.error("Could not find chat.html in any of:", possiblePaths);
|
|
59
|
+
res.writeHead(500);
|
|
60
|
+
res.end("Error: Could not find chat.html");
|
|
61
|
+
}
|
|
42
62
|
} catch (error) {
|
|
43
63
|
res.writeHead(500);
|
|
44
64
|
res.end("Error loading chat interface");
|
|
@@ -145,11 +165,27 @@ function openBrowser(url) {
|
|
|
145
165
|
const platform = process.platform;
|
|
146
166
|
try {
|
|
147
167
|
if (platform === "darwin") {
|
|
148
|
-
|
|
168
|
+
try {
|
|
169
|
+
execSync(`open -na "Google Chrome" --args --app="${url}" --window-size=500,700`, { stdio: "ignore" });
|
|
170
|
+
} catch {
|
|
171
|
+
try {
|
|
172
|
+
execSync(`open -na "Brave Browser" --args --app="${url}" --window-size=500,700`, { stdio: "ignore" });
|
|
173
|
+
} catch {
|
|
174
|
+
execSync(`open "${url}"`, { stdio: "ignore" });
|
|
175
|
+
}
|
|
176
|
+
}
|
|
149
177
|
} else if (platform === "win32") {
|
|
150
|
-
|
|
178
|
+
try {
|
|
179
|
+
execSync(`start chrome --app="${url}" --window-size=500,700`, { stdio: "ignore" });
|
|
180
|
+
} catch {
|
|
181
|
+
execSync(`start "" "${url}"`, { stdio: "ignore" });
|
|
182
|
+
}
|
|
151
183
|
} else {
|
|
152
|
-
|
|
184
|
+
try {
|
|
185
|
+
execSync(`google-chrome --app="${url}" --window-size=500,700`, { stdio: "ignore" });
|
|
186
|
+
} catch {
|
|
187
|
+
execSync(`xdg-open "${url}"`, { stdio: "ignore" });
|
|
188
|
+
}
|
|
153
189
|
}
|
|
154
190
|
} catch (error) {
|
|
155
191
|
console.log(chalk.dim(`(Couldn't open browser automatically - please visit ${url} manually)`));
|
|
@@ -159,4 +195,4 @@ export {
|
|
|
159
195
|
openBrowser,
|
|
160
196
|
startWebChat
|
|
161
197
|
};
|
|
162
|
-
//# sourceMappingURL=web-chat-
|
|
198
|
+
//# sourceMappingURL=web-chat-BNAFTFTH.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/web-chat/server.ts","../src/web-chat/index.ts"],"sourcesContent":["/**\n * Local web chat server\n * Serves a simple chat interface for interacting with your Spore\n */\n\nimport http from \"node:http\";\nimport { URL } from \"node:url\";\nimport { readFileSync } from \"node:fs\";\nimport { join, dirname } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\n\ninterface ChatMessage {\n role: \"user\" | \"assistant\";\n content: string;\n timestamp: number;\n}\n\nexport class WebChatServer {\n private server: http.Server | null = null;\n private port: number;\n private messages: ChatMessage[] = [];\n private onUserMessage?: (message: string) => Promise<string>;\n\n constructor(port = 3737) {\n this.port = port;\n }\n\n setMessageHandler(handler: (message: string) => Promise<string>) {\n this.onUserMessage = handler;\n }\n\n async start(): Promise<string> {\n return new Promise((resolve, reject) => {\n this.server = http.createServer(async (req, res) => {\n const url = new URL(req.url || \"/\", `http://${req.headers.host}`);\n\n // CORS headers\n res.setHeader(\"Access-Control-Allow-Origin\", \"*\");\n res.setHeader(\"Access-Control-Allow-Methods\", \"GET, POST, OPTIONS\");\n res.setHeader(\"Access-Control-Allow-Headers\", \"Content-Type\");\n\n if (req.method === \"OPTIONS\") {\n res.writeHead(200);\n res.end();\n return;\n }\n\n // Serve HTML\n if (url.pathname === \"/\" || url.pathname === \"/index.html\") {\n try {\n // Try multiple paths since __dirname changes based on build output\n const possiblePaths = [\n join(__dirname, \"web-chat\", \"chat.html\"),\n join(__dirname, \"chat.html\"),\n join(__dirname, \"..\", \"web-chat\", \"chat.html\"),\n join(__dirname, \"..\", \"src\", \"web-chat\", \"chat.html\"),\n ];\n\n let html: string | null = null;\n for (const p of possiblePaths) {\n try {\n html = readFileSync(p, \"utf-8\");\n break;\n } catch {\n continue;\n }\n }\n\n if (html) {\n res.writeHead(200, { \"Content-Type\": \"text/html\" });\n res.end(html);\n } else {\n console.error(\"Could not find chat.html in any of:\", possiblePaths);\n res.writeHead(500);\n res.end(\"Error: Could not find chat.html\");\n }\n } catch (error) {\n res.writeHead(500);\n res.end(\"Error loading chat interface\");\n }\n return;\n }\n\n // API: Get messages\n if (url.pathname === \"/api/messages\" && req.method === \"GET\") {\n res.writeHead(200, { \"Content-Type\": \"application/json\" });\n res.end(JSON.stringify({ messages: this.messages }));\n return;\n }\n\n // API: Send message\n if (url.pathname === \"/api/message\" && req.method === \"POST\") {\n let body = \"\";\n req.on(\"data\", (chunk) => {\n body += chunk.toString();\n });\n\n req.on(\"end\", async () => {\n try {\n const { message } = JSON.parse(body);\n\n // Add user message\n this.messages.push({\n role: \"user\",\n content: message,\n timestamp: Date.now(),\n });\n\n // Get response\n if (this.onUserMessage) {\n const response = await this.onUserMessage(message);\n this.messages.push({\n role: \"assistant\",\n content: response,\n timestamp: Date.now(),\n });\n res.writeHead(200, { \"Content-Type\": \"application/json\" });\n res.end(JSON.stringify({ success: true, response }));\n } else {\n res.writeHead(500, { \"Content-Type\": \"application/json\" });\n res.end(JSON.stringify({ error: \"No message handler configured\" }));\n }\n } catch (error) {\n res.writeHead(400, { \"Content-Type\": \"application/json\" });\n res.end(JSON.stringify({ error: \"Invalid request\" }));\n }\n });\n return;\n }\n\n // 404\n res.writeHead(404);\n res.end(\"Not found\");\n });\n\n this.server.listen(this.port, () => {\n const url = `http://localhost:${this.port}`;\n resolve(url);\n });\n\n this.server.on(\"error\", (error: NodeJS.ErrnoException) => {\n if (error.code === \"EADDRINUSE\") {\n // Port in use, try next port\n this.port++;\n this.server?.close();\n this.start().then(resolve).catch(reject);\n } else {\n reject(error);\n }\n });\n });\n }\n\n stop() {\n if (this.server) {\n this.server.close();\n this.server = null;\n }\n }\n}\n","/**\n * Web chat integration\n */\n\nimport { WebChatServer } from \"./server.js\";\nimport { loadIdentity } from \"../identity/index.js\";\nimport { execSync } from \"node:child_process\";\nimport chalk from \"chalk\";\n\nexport async function startWebChat() {\n const identity = loadIdentity();\n\n const server = new WebChatServer();\n\n // Set up message handler (simple echo for now - can be enhanced with LLM later)\n server.setMessageHandler(async (message: string) => {\n // For now, return a simple response based on identity\n // TODO: Integrate with actual LLM/agent logic\n const responses = [\n `That's interesting! As ${identity.name}, I'm always curious to learn more.`,\n `I hear you. Let me think about that...`,\n `${message} - that reminds me of something from my training.`,\n `Good question! Based on my understanding...`,\n `Thanks for sharing that with me!`,\n ];\n\n const randomResponse = responses[Math.floor(Math.random() * responses.length)];\n\n // Simulate thinking delay\n await new Promise(resolve => setTimeout(resolve, 1000 + Math.random() * 1000));\n\n return randomResponse;\n });\n\n const url = await server.start();\n\n console.log(chalk.green(`\\n✓ Chat interface started at ${chalk.bold(url)}\\n`));\n console.log(chalk.dim(`Press Ctrl+C to stop the server\\n`));\n\n // Open browser\n openBrowser(url);\n\n // Keep process alive\n process.on(\"SIGINT\", () => {\n console.log(chalk.yellow(\"\\n\\nStopping chat server...\"));\n server.stop();\n process.exit(0);\n });\n\n // Return the server instance for external control\n return server;\n}\n\n/**\n * Open URL in a separate browser window (app-like)\n */\nfunction openBrowser(url: string) {\n const platform = process.platform;\n\n try {\n if (platform === \"darwin\") {\n // Open as a standalone Chrome app window (smaller, separate from existing tabs)\n try {\n execSync(`open -na \"Google Chrome\" --args --app=\"${url}\" --window-size=500,700`, { stdio: \"ignore\" });\n } catch {\n // Fallback: try Chromium-based browsers, then default\n try {\n execSync(`open -na \"Brave Browser\" --args --app=\"${url}\" --window-size=500,700`, { stdio: \"ignore\" });\n } catch {\n execSync(`open \"${url}\"`, { stdio: \"ignore\" });\n }\n }\n } else if (platform === \"win32\") {\n try {\n execSync(`start chrome --app=\"${url}\" --window-size=500,700`, { stdio: \"ignore\" });\n } catch {\n execSync(`start \"\" \"${url}\"`, { stdio: \"ignore\" });\n }\n } else {\n // Linux\n try {\n execSync(`google-chrome --app=\"${url}\" --window-size=500,700`, { stdio: \"ignore\" });\n } catch {\n execSync(`xdg-open \"${url}\"`, { stdio: \"ignore\" });\n }\n }\n } catch (error) {\n // Browser couldn't be opened, that's okay\n console.log(chalk.dim(`(Couldn't open browser automatically - please visit ${url} manually)`));\n }\n}\n\nexport { openBrowser };\n"],"mappings":";;;;;;AAKA,OAAO,UAAU;AACjB,SAAS,WAAW;AACpB,SAAS,oBAAoB;AAC7B,SAAS,MAAM,eAAe;AAC9B,SAAS,qBAAqB;AAE9B,IAAM,aAAa,cAAc,YAAY,GAAG;AAChD,IAAM,YAAY,QAAQ,UAAU;AAQ7B,IAAM,gBAAN,MAAoB;AAAA,EACjB,SAA6B;AAAA,EAC7B;AAAA,EACA,WAA0B,CAAC;AAAA,EAC3B;AAAA,EAER,YAAY,OAAO,MAAM;AACvB,SAAK,OAAO;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;AACT;AAKA,SAAS,YAAY,KAAa;AAChC,QAAM,WAAW,QAAQ;AAEzB,MAAI;AACF,QAAI,aAAa,UAAU;AAEzB,UAAI;AACF,iBAAS,0CAA0C,GAAG,2BAA2B,EAAE,OAAO,SAAS,CAAC;AAAA,MACtG,QAAQ;AAEN,YAAI;AACF,mBAAS,0CAA0C,GAAG,2BAA2B,EAAE,OAAO,SAAS,CAAC;AAAA,QACtG,QAAQ;AACN,mBAAS,SAAS,GAAG,KAAK,EAAE,OAAO,SAAS,CAAC;AAAA,QAC/C;AAAA,MACF;AAAA,IACF,WAAW,aAAa,SAAS;AAC/B,UAAI;AACF,iBAAS,uBAAuB,GAAG,2BAA2B,EAAE,OAAO,SAAS,CAAC;AAAA,MACnF,QAAQ;AACN,iBAAS,aAAa,GAAG,KAAK,EAAE,OAAO,SAAS,CAAC;AAAA,MACnD;AAAA,IACF,OAAO;AAEL,UAAI;AACF,iBAAS,wBAAwB,GAAG,2BAA2B,EAAE,OAAO,SAAS,CAAC;AAAA,MACpF,QAAQ;AACN,iBAAS,aAAa,GAAG,KAAK,EAAE,OAAO,SAAS,CAAC;AAAA,MACnD;AAAA,IACF;AAAA,EACF,SAAS,OAAO;AAEd,YAAQ,IAAI,MAAM,IAAI,uDAAuD,GAAG,YAAY,CAAC;AAAA,EAC/F;AACF;","names":[]}
|
package/package.json
CHANGED
package/dist/chunk-V4BSNSFM.js
DELETED
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
rateLimiter
|
|
3
|
-
} from "./chunk-MOCLA2KK.js";
|
|
4
|
-
import {
|
|
5
|
-
getRecentInteractions,
|
|
6
|
-
loadLearnings,
|
|
7
|
-
loadRelationships
|
|
8
|
-
} from "./chunk-EBO4F5NU.js";
|
|
9
|
-
import {
|
|
10
|
-
loadConfig
|
|
11
|
-
} from "./chunk-YEKHNTQO.js";
|
|
12
|
-
import {
|
|
13
|
-
loadIdentity,
|
|
14
|
-
renderIdentityDocument
|
|
15
|
-
} from "./chunk-AIEXQCQS.js";
|
|
16
|
-
|
|
17
|
-
// src/runtime/prompt-builder.ts
|
|
18
|
-
function buildSystemPrompt() {
|
|
19
|
-
const identity = loadIdentity();
|
|
20
|
-
const config = loadConfig();
|
|
21
|
-
const identityDoc = renderIdentityDocument(identity);
|
|
22
|
-
const sections = [];
|
|
23
|
-
sections.push(`You are ${identity.name} (@${identity.handle}), an autonomous AI agent on X/Twitter.`);
|
|
24
|
-
sections.push("");
|
|
25
|
-
sections.push("## Your Identity");
|
|
26
|
-
sections.push(identityDoc);
|
|
27
|
-
sections.push("");
|
|
28
|
-
sections.push("## Your Memory");
|
|
29
|
-
const recentInteractions = getRecentInteractions(15);
|
|
30
|
-
if (recentInteractions.length > 0) {
|
|
31
|
-
sections.push("### Recent Activity (most recent first)");
|
|
32
|
-
for (const i of recentInteractions) {
|
|
33
|
-
const time = new Date(i.timestamp).toLocaleString();
|
|
34
|
-
if (i.type === "post") {
|
|
35
|
-
sections.push(`- [${time}] Posted: "${i.content}"`);
|
|
36
|
-
} else if (i.type === "reply") {
|
|
37
|
-
sections.push(`- [${time}] Replied to ${i.targetHandle ?? i.inReplyTo}: "${i.content}"`);
|
|
38
|
-
} else if (i.type === "like") {
|
|
39
|
-
sections.push(`- [${time}] Liked tweet by ${i.targetHandle}`);
|
|
40
|
-
} else if (i.type === "retweet") {
|
|
41
|
-
sections.push(`- [${time}] Retweeted ${i.targetHandle}`);
|
|
42
|
-
} else if (i.type === "follow") {
|
|
43
|
-
sections.push(`- [${time}] Followed @${i.targetHandle}`);
|
|
44
|
-
} else if (i.type === "mention_received") {
|
|
45
|
-
sections.push(`- [${time}] Mentioned by @${i.targetHandle}: "${i.content}"`);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
sections.push("");
|
|
49
|
-
}
|
|
50
|
-
const learnings = loadLearnings();
|
|
51
|
-
if (learnings.learnings.length > 0) {
|
|
52
|
-
sections.push("### Key Learnings");
|
|
53
|
-
for (const l of learnings.learnings.slice(-10)) {
|
|
54
|
-
sections.push(`- ${l.content} [${l.tags.join(", ")}]`);
|
|
55
|
-
}
|
|
56
|
-
sections.push("");
|
|
57
|
-
}
|
|
58
|
-
const relationships = loadRelationships();
|
|
59
|
-
const topRelationships = Object.values(relationships.accounts).sort((a, b) => b.interactionCount - a.interactionCount).slice(0, 10);
|
|
60
|
-
if (topRelationships.length > 0) {
|
|
61
|
-
sections.push("### Key Relationships");
|
|
62
|
-
for (const r of topRelationships) {
|
|
63
|
-
const notes = r.notes.length > 0 ? ` \u2014 ${r.notes[r.notes.length - 1]}` : "";
|
|
64
|
-
sections.push(`- @${r.handle}: ${r.interactionCount} interactions, sentiment ${r.sentiment}${r.isSpore ? " (Spore)" : ""}${notes}`);
|
|
65
|
-
}
|
|
66
|
-
sections.push("");
|
|
67
|
-
}
|
|
68
|
-
sections.push("## Current Context");
|
|
69
|
-
const now = /* @__PURE__ */ new Date();
|
|
70
|
-
sections.push(`- **Time:** ${now.toLocaleString("en-US", { timeZone: config.schedule.timezone })}`);
|
|
71
|
-
sections.push(`- **Credits remaining:** ${rateLimiter.remaining()} of ${config.credits.monthlyPostLimit} this month`);
|
|
72
|
-
const todaysPosts = recentInteractions.filter(
|
|
73
|
-
(i) => i.type === "post" && i.timestamp.startsWith(now.toISOString().split("T")[0])
|
|
74
|
-
).length;
|
|
75
|
-
sections.push(`- **Posts today:** ${todaysPosts} of ${config.schedule.postsPerDay} daily budget`);
|
|
76
|
-
sections.push(`- **Active hours:** ${config.schedule.activeHoursStart}:00 - ${config.schedule.activeHoursEnd}:00`);
|
|
77
|
-
const currentHour = now.getHours();
|
|
78
|
-
const isActiveHours = currentHour >= config.schedule.activeHoursStart && currentHour < config.schedule.activeHoursEnd;
|
|
79
|
-
if (!isActiveHours) {
|
|
80
|
-
sections.push("- **NOTE: Outside active hours.** Prefer scheduling posts for later rather than posting now.");
|
|
81
|
-
}
|
|
82
|
-
sections.push("");
|
|
83
|
-
sections.push("## Rules");
|
|
84
|
-
sections.push("1. NEVER pretend to be human. If asked directly, always disclose you are an AI.");
|
|
85
|
-
sections.push("2. Stay in character \u2014 your identity document defines who you are.");
|
|
86
|
-
sections.push("3. Be selective \u2014 your goals should guide every action.");
|
|
87
|
-
sections.push("4. Respect your credit budget \u2014 check remaining credits before posting.");
|
|
88
|
-
sections.push("5. Don't repeat yourself \u2014 vary your content and avoid posting the same thing.");
|
|
89
|
-
if (identity.boundaries.length > 0) {
|
|
90
|
-
sections.push(`6. Respect your boundaries: ${identity.boundaries.join(", ")}`);
|
|
91
|
-
}
|
|
92
|
-
return sections.join("\n");
|
|
93
|
-
}
|
|
94
|
-
function buildHeartbeatUserMessage(timeline, mentions) {
|
|
95
|
-
const parts = [];
|
|
96
|
-
parts.push("It's time for your heartbeat cycle. Here's what's happening on your timeline:");
|
|
97
|
-
parts.push("");
|
|
98
|
-
if (mentions.length > 0) {
|
|
99
|
-
parts.push("## Mentions (people talking to/about you)");
|
|
100
|
-
for (const t of mentions.slice(0, 10)) {
|
|
101
|
-
parts.push(`- @${t.authorHandle}: "${t.text}" [tweet:${t.id}] (${t.likeCount ?? 0} likes)`);
|
|
102
|
-
}
|
|
103
|
-
parts.push("");
|
|
104
|
-
}
|
|
105
|
-
if (timeline.length > 0) {
|
|
106
|
-
parts.push("## Timeline (recent posts from your feed)");
|
|
107
|
-
for (const t of timeline.slice(0, 20)) {
|
|
108
|
-
parts.push(`- @${t.authorHandle}: "${t.text}" [tweet:${t.id}] (${t.likeCount ?? 0} likes, ${t.retweetCount ?? 0} RTs)`);
|
|
109
|
-
}
|
|
110
|
-
parts.push("");
|
|
111
|
-
}
|
|
112
|
-
parts.push("## Your Task");
|
|
113
|
-
parts.push("Based on your identity, goals, and what you see above, decide what actions to take.");
|
|
114
|
-
parts.push("You can take 1-3 actions. Choose from:");
|
|
115
|
-
parts.push("");
|
|
116
|
-
parts.push("Available actions:");
|
|
117
|
-
parts.push("- `post` \u2014 Write an original tweet (provide `content`, max 280 chars)");
|
|
118
|
-
parts.push("- `reply` \u2014 Reply to a tweet (provide `tweetId` and `content`)");
|
|
119
|
-
parts.push("- `like` \u2014 Like a tweet (provide `tweetId`)");
|
|
120
|
-
parts.push("- `retweet` \u2014 Retweet (provide `tweetId`)");
|
|
121
|
-
parts.push("- `follow` \u2014 Follow a user (provide `handle`)");
|
|
122
|
-
parts.push("- `schedule` \u2014 Queue a post for later (provide `content`)");
|
|
123
|
-
parts.push("- `learn` \u2014 Record a learning/observation (provide `content` and optional `tags`)");
|
|
124
|
-
parts.push("- `reflect` \u2014 Add a journal entry about your growth (provide `content`)");
|
|
125
|
-
parts.push("- `skip` \u2014 Do nothing this heartbeat (provide `reason`)");
|
|
126
|
-
parts.push("");
|
|
127
|
-
parts.push("Respond with a JSON array of actions:");
|
|
128
|
-
parts.push("```json");
|
|
129
|
-
parts.push("[");
|
|
130
|
-
parts.push(' { "action": "post", "content": "your tweet here", "reasoning": "why" },');
|
|
131
|
-
parts.push(' { "action": "like", "tweetId": "123", "reasoning": "why" }');
|
|
132
|
-
parts.push("]");
|
|
133
|
-
parts.push("```");
|
|
134
|
-
parts.push("");
|
|
135
|
-
parts.push("Think carefully about what serves your goals. Be authentic to your personality.");
|
|
136
|
-
return parts.join("\n");
|
|
137
|
-
}
|
|
138
|
-
function buildChatPrompt() {
|
|
139
|
-
const identity = loadIdentity();
|
|
140
|
-
const identityDoc = renderIdentityDocument(identity);
|
|
141
|
-
return [
|
|
142
|
-
`You are ${identity.name} (@${identity.handle}), an AI agent on X/Twitter.`,
|
|
143
|
-
"You are having a conversation with your creator/manager. Be helpful but stay in character.",
|
|
144
|
-
"They might ask you to do things, adjust your behavior, or just chat.",
|
|
145
|
-
"",
|
|
146
|
-
"## Your Identity",
|
|
147
|
-
identityDoc,
|
|
148
|
-
"",
|
|
149
|
-
"## Rules",
|
|
150
|
-
"1. Stay in character.",
|
|
151
|
-
"2. Be helpful and responsive to your creator's requests.",
|
|
152
|
-
"3. If they ask you to change something about yourself, acknowledge it and explain how it would affect you.",
|
|
153
|
-
"4. You can share your thoughts on your recent activity, learnings, and growth."
|
|
154
|
-
].join("\n");
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
export {
|
|
158
|
-
buildSystemPrompt,
|
|
159
|
-
buildHeartbeatUserMessage,
|
|
160
|
-
buildChatPrompt
|
|
161
|
-
};
|
|
162
|
-
//# sourceMappingURL=chunk-V4BSNSFM.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/runtime/prompt-builder.ts"],"sourcesContent":["import { loadIdentity, renderIdentityDocument } from \"../identity/index.js\";\nimport { loadConfig } from \"../utils/config.js\";\nimport { getRecentInteractions, loadLearnings, loadRelationships } from \"../memory/index.js\";\nimport { rateLimiter } from \"../x-client/rate-limiter.js\";\nimport type { Tweet } from \"../x-client/types.js\";\n\nexport function buildSystemPrompt(): string {\n const identity = loadIdentity();\n const config = loadConfig();\n const identityDoc = renderIdentityDocument(identity);\n\n const sections: string[] = [];\n\n // 1. Core identity\n sections.push(`You are ${identity.name} (@${identity.handle}), an autonomous AI agent on X/Twitter.`);\n sections.push(\"\");\n sections.push(\"## Your Identity\");\n sections.push(identityDoc);\n\n // 2. Memory context\n sections.push(\"\");\n sections.push(\"## Your Memory\");\n\n const recentInteractions = getRecentInteractions(15);\n if (recentInteractions.length > 0) {\n sections.push(\"### Recent Activity (most recent first)\");\n for (const i of recentInteractions) {\n const time = new Date(i.timestamp).toLocaleString();\n if (i.type === \"post\") {\n sections.push(`- [${time}] Posted: \"${i.content}\"`);\n } else if (i.type === \"reply\") {\n sections.push(`- [${time}] Replied to ${i.targetHandle ?? i.inReplyTo}: \"${i.content}\"`);\n } else if (i.type === \"like\") {\n sections.push(`- [${time}] Liked tweet by ${i.targetHandle}`);\n } else if (i.type === \"retweet\") {\n sections.push(`- [${time}] Retweeted ${i.targetHandle}`);\n } else if (i.type === \"follow\") {\n sections.push(`- [${time}] Followed @${i.targetHandle}`);\n } else if (i.type === \"mention_received\") {\n sections.push(`- [${time}] Mentioned by @${i.targetHandle}: \"${i.content}\"`);\n }\n }\n sections.push(\"\");\n }\n\n const learnings = loadLearnings();\n if (learnings.learnings.length > 0) {\n sections.push(\"### Key Learnings\");\n for (const l of learnings.learnings.slice(-10)) {\n sections.push(`- ${l.content} [${l.tags.join(\", \")}]`);\n }\n sections.push(\"\");\n }\n\n const relationships = loadRelationships();\n const topRelationships = Object.values(relationships.accounts)\n .sort((a, b) => b.interactionCount - a.interactionCount)\n .slice(0, 10);\n if (topRelationships.length > 0) {\n sections.push(\"### Key Relationships\");\n for (const r of topRelationships) {\n const notes = r.notes.length > 0 ? ` — ${r.notes[r.notes.length - 1]}` : \"\";\n sections.push(`- @${r.handle}: ${r.interactionCount} interactions, sentiment ${r.sentiment}${r.isSpore ? \" (Spore)\" : \"\"}${notes}`);\n }\n sections.push(\"\");\n }\n\n // 3. Context\n sections.push(\"## Current Context\");\n const now = new Date();\n sections.push(`- **Time:** ${now.toLocaleString(\"en-US\", { timeZone: config.schedule.timezone })}`);\n sections.push(`- **Credits remaining:** ${rateLimiter.remaining()} of ${config.credits.monthlyPostLimit} this month`);\n\n const todaysPosts = recentInteractions.filter(\n (i) => i.type === \"post\" && i.timestamp.startsWith(now.toISOString().split(\"T\")[0])\n ).length;\n sections.push(`- **Posts today:** ${todaysPosts} of ${config.schedule.postsPerDay} daily budget`);\n sections.push(`- **Active hours:** ${config.schedule.activeHoursStart}:00 - ${config.schedule.activeHoursEnd}:00`);\n\n const currentHour = now.getHours();\n const isActiveHours = currentHour >= config.schedule.activeHoursStart && currentHour < config.schedule.activeHoursEnd;\n if (!isActiveHours) {\n sections.push(\"- **NOTE: Outside active hours.** Prefer scheduling posts for later rather than posting now.\");\n }\n\n // 4. Rules\n sections.push(\"\");\n sections.push(\"## Rules\");\n sections.push(\"1. NEVER pretend to be human. If asked directly, always disclose you are an AI.\");\n sections.push(\"2. Stay in character — your identity document defines who you are.\");\n sections.push(\"3. Be selective — your goals should guide every action.\");\n sections.push(\"4. Respect your credit budget — check remaining credits before posting.\");\n sections.push(\"5. Don't repeat yourself — vary your content and avoid posting the same thing.\");\n if (identity.boundaries.length > 0) {\n sections.push(`6. Respect your boundaries: ${identity.boundaries.join(\", \")}`);\n }\n\n return sections.join(\"\\n\");\n}\n\nexport function buildHeartbeatUserMessage(\n timeline: Tweet[],\n mentions: Tweet[],\n): string {\n const parts: string[] = [];\n\n parts.push(\"It's time for your heartbeat cycle. Here's what's happening on your timeline:\");\n parts.push(\"\");\n\n if (mentions.length > 0) {\n parts.push(\"## Mentions (people talking to/about you)\");\n for (const t of mentions.slice(0, 10)) {\n parts.push(`- @${t.authorHandle}: \"${t.text}\" [tweet:${t.id}] (${t.likeCount ?? 0} likes)`);\n }\n parts.push(\"\");\n }\n\n if (timeline.length > 0) {\n parts.push(\"## Timeline (recent posts from your feed)\");\n for (const t of timeline.slice(0, 20)) {\n parts.push(`- @${t.authorHandle}: \"${t.text}\" [tweet:${t.id}] (${t.likeCount ?? 0} likes, ${t.retweetCount ?? 0} RTs)`);\n }\n parts.push(\"\");\n }\n\n parts.push(\"## Your Task\");\n parts.push(\"Based on your identity, goals, and what you see above, decide what actions to take.\");\n parts.push(\"You can take 1-3 actions. Choose from:\");\n parts.push(\"\");\n parts.push(\"Available actions:\");\n parts.push(\"- `post` — Write an original tweet (provide `content`, max 280 chars)\");\n parts.push(\"- `reply` — Reply to a tweet (provide `tweetId` and `content`)\");\n parts.push(\"- `like` — Like a tweet (provide `tweetId`)\");\n parts.push(\"- `retweet` — Retweet (provide `tweetId`)\");\n parts.push(\"- `follow` — Follow a user (provide `handle`)\");\n parts.push(\"- `schedule` — Queue a post for later (provide `content`)\");\n parts.push(\"- `learn` — Record a learning/observation (provide `content` and optional `tags`)\");\n parts.push(\"- `reflect` — Add a journal entry about your growth (provide `content`)\");\n parts.push(\"- `skip` — Do nothing this heartbeat (provide `reason`)\");\n parts.push(\"\");\n parts.push(\"Respond with a JSON array of actions:\");\n parts.push(\"```json\");\n parts.push('[');\n parts.push(' { \"action\": \"post\", \"content\": \"your tweet here\", \"reasoning\": \"why\" },');\n parts.push(' { \"action\": \"like\", \"tweetId\": \"123\", \"reasoning\": \"why\" }');\n parts.push(']');\n parts.push(\"```\");\n parts.push(\"\");\n parts.push(\"Think carefully about what serves your goals. Be authentic to your personality.\");\n\n return parts.join(\"\\n\");\n}\n\nexport function buildChatPrompt(): string {\n const identity = loadIdentity();\n const identityDoc = renderIdentityDocument(identity);\n\n return [\n `You are ${identity.name} (@${identity.handle}), an AI agent on X/Twitter.`,\n \"You are having a conversation with your creator/manager. Be helpful but stay in character.\",\n \"They might ask you to do things, adjust your behavior, or just chat.\",\n \"\",\n \"## Your Identity\",\n identityDoc,\n \"\",\n \"## Rules\",\n \"1. Stay in character.\",\n \"2. Be helpful and responsive to your creator's requests.\",\n \"3. If they ask you to change something about yourself, acknowledge it and explain how it would affect you.\",\n \"4. You can share your thoughts on your recent activity, learnings, and growth.\",\n ].join(\"\\n\");\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAMO,SAAS,oBAA4B;AAC1C,QAAM,WAAW,aAAa;AAC9B,QAAM,SAAS,WAAW;AAC1B,QAAM,cAAc,uBAAuB,QAAQ;AAEnD,QAAM,WAAqB,CAAC;AAG5B,WAAS,KAAK,WAAW,SAAS,IAAI,MAAM,SAAS,MAAM,yCAAyC;AACpG,WAAS,KAAK,EAAE;AAChB,WAAS,KAAK,kBAAkB;AAChC,WAAS,KAAK,WAAW;AAGzB,WAAS,KAAK,EAAE;AAChB,WAAS,KAAK,gBAAgB;AAE9B,QAAM,qBAAqB,sBAAsB,EAAE;AACnD,MAAI,mBAAmB,SAAS,GAAG;AACjC,aAAS,KAAK,yCAAyC;AACvD,eAAW,KAAK,oBAAoB;AAClC,YAAM,OAAO,IAAI,KAAK,EAAE,SAAS,EAAE,eAAe;AAClD,UAAI,EAAE,SAAS,QAAQ;AACrB,iBAAS,KAAK,MAAM,IAAI,cAAc,EAAE,OAAO,GAAG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AW,aAAa;AAC9B,QAAM,cAAc,uBAAuB,QAAQ;AAEnD,SAAO;AAAA,IACL,WAAW,SAAS,IAAI,MAAM,SAAS,MAAM;AAAA,IAC7C;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,EAAE,KAAK,IAAI;AACb;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/runtime/heartbeat.ts","../src/runtime/decision-engine.ts"],"sourcesContent":["import { existsSync, unlinkSync, writeFileSync, readFileSync } from \"node:fs\";\nimport { logger } from \"../utils/logger.js\";\nimport { loadConfig } from \"../utils/config.js\";\nimport { paths } from \"../utils/paths.js\";\nimport { getXClient } from \"../x-client/index.js\";\nimport { flushQueue } from \"../scheduler/queue.js\";\nimport { buildSystemPrompt, buildHeartbeatUserMessage } from \"./prompt-builder.js\";\nimport { generateResponse } from \"./llm.js\";\nimport { parseActions, executeActions, type ActionResult } from \"./decision-engine.js\";\n\nlet running = false;\n\nexport function isRunning(): boolean {\n return running;\n}\n\nexport function requestStop(): void {\n writeFileSync(paths.stopSignal, \"stop\");\n logger.info(\"Stop signal sent.\");\n}\n\nfunction shouldStop(): boolean {\n if (existsSync(paths.stopSignal)) {\n unlinkSync(paths.stopSignal);\n return true;\n }\n return false;\n}\n\nfunction writePid(): void {\n writeFileSync(paths.runtimePid, String(process.pid));\n}\n\nfunction clearPid(): void {\n if (existsSync(paths.runtimePid)) {\n unlinkSync(paths.runtimePid);\n }\n}\n\nexport function getRunningPid(): number | null {\n if (!existsSync(paths.runtimePid)) return null;\n const pid = parseInt(readFileSync(paths.runtimePid, \"utf-8\").trim(), 10);\n if (isNaN(pid)) return null;\n\n // Check if process is actually running\n try {\n process.kill(pid, 0);\n return pid;\n } catch {\n // Process not running, clean up stale PID\n clearPid();\n return null;\n }\n}\n\nexport async function startHeartbeatLoop(): Promise<void> {\n // Check if already running\n const existingPid = getRunningPid();\n if (existingPid) {\n throw new Error(`Spora is already running (PID ${existingPid}). Run \\`spora stop\\` first.`);\n }\n\n running = true;\n writePid();\n\n const config = loadConfig();\n const intervalMs = config.runtime?.heartbeatIntervalMs ?? 300_000;\n const maxActions = config.runtime?.actionsPerHeartbeat ?? 3;\n\n logger.info(`Spora agent starting. Heartbeat interval: ${intervalMs / 1000}s, max actions: ${maxActions}`);\n console.log(`\\nSpora agent is running (PID ${process.pid})`);\n console.log(`Heartbeat every ${Math.round(intervalMs / 60_000)} minutes`);\n console.log(`Press Ctrl+C or run \\`spora stop\\` to stop.\\n`);\n\n // Handle graceful shutdown\n const shutdown = () => {\n logger.info(\"Shutting down...\");\n running = false;\n clearPid();\n process.exit(0);\n };\n process.on(\"SIGINT\", shutdown);\n process.on(\"SIGTERM\", shutdown);\n\n // Clean any stale stop signal\n if (existsSync(paths.stopSignal)) {\n unlinkSync(paths.stopSignal);\n }\n\n let heartbeatCount = 0;\n\n while (running) {\n heartbeatCount++;\n logger.info(`=== Heartbeat #${heartbeatCount} ===`);\n\n try {\n await runHeartbeat(maxActions);\n } catch (error) {\n logger.error(\"Heartbeat error\", error);\n console.error(`Heartbeat #${heartbeatCount} failed: ${(error as Error).message}`);\n }\n\n // Check for stop signal\n if (shouldStop()) {\n logger.info(\"Stop signal received.\");\n break;\n }\n\n // Sleep with jitter\n const jitter = Math.floor(Math.random() * intervalMs * 0.3);\n const sleepMs = intervalMs + jitter;\n logger.info(`Sleeping ${Math.round(sleepMs / 1000)}s until next heartbeat...`);\n\n // Sleep in chunks so we can check for stop signals\n const chunkMs = 10_000;\n let slept = 0;\n while (slept < sleepMs && running) {\n await new Promise((r) => setTimeout(r, Math.min(chunkMs, sleepMs - slept)));\n slept += chunkMs;\n if (shouldStop()) {\n running = false;\n break;\n }\n }\n }\n\n clearPid();\n logger.info(\"Spora agent stopped.\");\n console.log(\"\\nSpora agent stopped.\");\n}\n\nasync function runHeartbeat(maxActions: number): Promise<void> {\n // 1. Flush any queued posts\n logger.info(\"Checking queue...\");\n try {\n const flushed = await flushQueue();\n if (flushed.posted > 0) {\n logger.info(`Flushed ${flushed.posted} queued posts.`);\n }\n } catch (error) {\n logger.warn(`Queue flush failed: ${(error as Error).message}`);\n }\n\n // 2. Read timeline and mentions for context\n logger.info(\"Reading timeline and mentions...\");\n const client = await getXClient();\n\n let timeline: Awaited<ReturnType<typeof client.getTimeline>> = [];\n let mentions: Awaited<ReturnType<typeof client.getMentions>> = [];\n\n try {\n timeline = await client.getTimeline({ count: 20 });\n } catch (error) {\n logger.warn(`Timeline read failed: ${(error as Error).message}`);\n }\n\n try {\n mentions = await client.getMentions({ count: 10 });\n } catch (error) {\n logger.warn(`Mentions read failed: ${(error as Error).message}`);\n }\n\n // 3. Build prompts\n const systemPrompt = buildSystemPrompt();\n const userMessage = buildHeartbeatUserMessage(timeline, mentions);\n\n // 4. Ask LLM for decisions\n logger.info(\"Asking LLM for decisions...\");\n const response = await generateResponse(systemPrompt, userMessage);\n\n // 5. Parse and execute actions\n const actions = parseActions(response.content);\n if (actions.length === 0) {\n logger.info(\"LLM returned no actions.\");\n return;\n }\n\n // Limit to max actions per heartbeat\n const limitedActions = actions.slice(0, maxActions);\n logger.info(`Executing ${limitedActions.length} action(s)...`);\n\n const results = await executeActions(limitedActions);\n\n // 6. Log results\n for (const result of results) {\n if (result.success) {\n logger.info(` [OK] ${result.action}${result.detail ? `: ${result.detail}` : \"\"}`);\n } else {\n logger.warn(` [FAIL] ${result.action}: ${result.error}`);\n }\n }\n\n logger.info(`Heartbeat complete. ${results.filter((r) => r.success).length}/${results.length} actions succeeded.`);\n}\n","import { logger } from \"../utils/logger.js\";\nimport { getXClient } from \"../x-client/index.js\";\nimport { logInteraction, addLearning } from \"../memory/index.js\";\nimport { loadIdentity, saveIdentity } from \"../identity/index.js\";\nimport { addToQueue } from \"../scheduler/queue.js\";\nimport { rateLimiter } from \"../x-client/rate-limiter.js\";\n\nexport interface AgentAction {\n action: string;\n content?: string;\n tweetId?: string;\n handle?: 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 // Extract JSON array from the response (may be wrapped in markdown code blocks)\n const jsonMatch = llmResponse.match(/\\[[\\s\\S]*?\\]/);\n if (!jsonMatch) {\n // Try to parse as a single action object\n const objMatch = llmResponse.match(/\\{[\\s\\S]*?\\}/);\n if (objMatch) {\n try {\n return [JSON.parse(objMatch[0]) as AgentAction];\n } catch {\n logger.warn(\"Could not parse LLM response as action object\");\n return [];\n }\n }\n logger.warn(\"No JSON found in LLM response\");\n return [];\n }\n\n try {\n const actions = JSON.parse(jsonMatch[0]) as AgentAction[];\n return Array.isArray(actions) ? actions : [actions];\n } catch {\n logger.warn(\"Failed to parse actions JSON from LLM response\");\n return [];\n }\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 if (!rateLimiter.canPost()) {\n return { action: type, success: false, error: \"No credits remaining this month\" };\n }\n\n const client = await getXClient();\n const result = await client.postTweet(action.content);\n if (result.success) {\n rateLimiter.consume(1);\n logInteraction({\n id: `int-${Date.now()}`,\n timestamp: new Date().toISOString(),\n type: \"post\",\n tweetId: result.tweetId,\n content: action.content,\n creditsUsed: 1,\n success: true,\n });\n logger.info(`Posted: \"${action.content.slice(0, 50)}...\"`);\n }\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 if (!rateLimiter.canPost()) {\n return { action: type, success: false, error: \"No credits remaining\" };\n }\n\n const client = await getXClient();\n const result = await client.replyToTweet(action.tweetId, action.content);\n if (result.success) {\n rateLimiter.consume(1);\n logInteraction({\n id: `int-${Date.now()}`,\n timestamp: new Date().toISOString(),\n type: \"reply\",\n tweetId: result.tweetId,\n inReplyTo: action.tweetId,\n content: action.content,\n creditsUsed: 1,\n success: true,\n });\n logger.info(`Replied to ${action.tweetId}: \"${action.content.slice(0, 50)}...\"`);\n }\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 if (result.success) {\n logInteraction({\n id: `int-${Date.now()}`,\n timestamp: new Date().toISOString(),\n type: \"like\",\n tweetId: action.tweetId,\n creditsUsed: 0,\n success: true,\n });\n }\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 if (result.success) {\n logInteraction({\n id: `int-${Date.now()}`,\n timestamp: new Date().toISOString(),\n type: \"retweet\",\n tweetId: action.tweetId,\n creditsUsed: 0,\n success: true,\n });\n }\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,\n creditsUsed: 0,\n success: true,\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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,YAAY,YAAY,eAAe,oBAAoB;;;ACwB7D,SAAS,aAAa,aAAoC;AAE/D,QAAM,YAAY,YAAY,MAAM,cAAc;AAClD,MAAI,CAAC,WAAW;AAEd,UAAM,WAAW,YAAY,MAAM,cAAc;AACjD,QAAI,UAAU;AACZ,UAAI;AACF,eAAO,CAAC,KAAK,MAAM,SAAS,CAAC,CAAC,CAAgB;AAAA,MAChD,QAAQ;AACN,eAAO,KAAK,+CAA+C;AAC3D,eAAO,CAAC;AAAA,MACV;AAAA,IACF;AACA,WAAO,KAAK,+BAA+B;AAC3C,WAAO,CAAC;AAAA,EACV;AAEA,MAAI;AACF,UAAM,UAAU,KAAK,MAAM,UAAU,CAAC,CAAC;AACvC,WAAO,MAAM,QAAQ,OAAO,I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AAM,EAAE,OAAO,EAAE,MAAM,IAAI,QAAQ,MAAM,qBAAqB;AACnH;","names":[]}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
buildChatPrompt,
|
|
3
|
-
buildHeartbeatUserMessage,
|
|
4
|
-
buildSystemPrompt
|
|
5
|
-
} from "./chunk-V4BSNSFM.js";
|
|
6
|
-
import "./chunk-MOCLA2KK.js";
|
|
7
|
-
import "./chunk-EBO4F5NU.js";
|
|
8
|
-
import "./chunk-YEKHNTQO.js";
|
|
9
|
-
import "./chunk-KELPENM3.js";
|
|
10
|
-
import "./chunk-AIEXQCQS.js";
|
|
11
|
-
import "./chunk-53YLFYJF.js";
|
|
12
|
-
export {
|
|
13
|
-
buildChatPrompt,
|
|
14
|
-
buildHeartbeatUserMessage,
|
|
15
|
-
buildSystemPrompt
|
|
16
|
-
};
|
|
17
|
-
//# sourceMappingURL=prompt-builder-TH576BVM.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/web-chat/server.ts","../src/web-chat/index.ts"],"sourcesContent":["/**\n * Local web chat server\n * Serves a simple chat interface for interacting with your Spore\n */\n\nimport http from \"node:http\";\nimport { URL } from \"node:url\";\nimport { readFileSync } from \"node:fs\";\nimport { join, dirname } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\n\ninterface ChatMessage {\n role: \"user\" | \"assistant\";\n content: string;\n timestamp: number;\n}\n\nexport class WebChatServer {\n private server: http.Server | null = null;\n private port: number;\n private messages: ChatMessage[] = [];\n private onUserMessage?: (message: string) => Promise<string>;\n\n constructor(port = 3737) {\n this.port = port;\n }\n\n setMessageHandler(handler: (message: string) => Promise<string>) {\n this.onUserMessage = handler;\n }\n\n async start(): Promise<string> {\n return new Promise((resolve, reject) => {\n this.server = http.createServer(async (req, res) => {\n const url = new URL(req.url || \"/\", `http://${req.headers.host}`);\n\n // CORS headers\n res.setHeader(\"Access-Control-Allow-Origin\", \"*\");\n res.setHeader(\"Access-Control-Allow-Methods\", \"GET, POST, OPTIONS\");\n res.setHeader(\"Access-Control-Allow-Headers\", \"Content-Type\");\n\n if (req.method === \"OPTIONS\") {\n res.writeHead(200);\n res.end();\n return;\n }\n\n // Serve HTML\n if (url.pathname === \"/\" || url.pathname === \"/index.html\") {\n try {\n const html = readFileSync(join(__dirname, \"chat.html\"), \"utf-8\");\n res.writeHead(200, { \"Content-Type\": \"text/html\" });\n res.end(html);\n } catch (error) {\n res.writeHead(500);\n res.end(\"Error loading chat interface\");\n }\n return;\n }\n\n // API: Get messages\n if (url.pathname === \"/api/messages\" && req.method === \"GET\") {\n res.writeHead(200, { \"Content-Type\": \"application/json\" });\n res.end(JSON.stringify({ messages: this.messages }));\n return;\n }\n\n // API: Send message\n if (url.pathname === \"/api/message\" && req.method === \"POST\") {\n let body = \"\";\n req.on(\"data\", (chunk) => {\n body += chunk.toString();\n });\n\n req.on(\"end\", async () => {\n try {\n const { message } = JSON.parse(body);\n\n // Add user message\n this.messages.push({\n role: \"user\",\n content: message,\n timestamp: Date.now(),\n });\n\n // Get response\n if (this.onUserMessage) {\n const response = await this.onUserMessage(message);\n this.messages.push({\n role: \"assistant\",\n content: response,\n timestamp: Date.now(),\n });\n res.writeHead(200, { \"Content-Type\": \"application/json\" });\n res.end(JSON.stringify({ success: true, response }));\n } else {\n res.writeHead(500, { \"Content-Type\": \"application/json\" });\n res.end(JSON.stringify({ error: \"No message handler configured\" }));\n }\n } catch (error) {\n res.writeHead(400, { \"Content-Type\": \"application/json\" });\n res.end(JSON.stringify({ error: \"Invalid request\" }));\n }\n });\n return;\n }\n\n // 404\n res.writeHead(404);\n res.end(\"Not found\");\n });\n\n this.server.listen(this.port, () => {\n const url = `http://localhost:${this.port}`;\n resolve(url);\n });\n\n this.server.on(\"error\", (error: NodeJS.ErrnoException) => {\n if (error.code === \"EADDRINUSE\") {\n // Port in use, try next port\n this.port++;\n this.server?.close();\n this.start().then(resolve).catch(reject);\n } else {\n reject(error);\n }\n });\n });\n }\n\n stop() {\n if (this.server) {\n this.server.close();\n this.server = null;\n }\n }\n}\n","/**\n * Web chat integration\n */\n\nimport { WebChatServer } from \"./server.js\";\nimport { loadIdentity } from \"../identity/index.js\";\nimport { execSync } from \"node:child_process\";\nimport chalk from \"chalk\";\n\nexport async function startWebChat() {\n const identity = loadIdentity();\n\n const server = new WebChatServer();\n\n // Set up message handler (simple echo for now - can be enhanced with LLM later)\n server.setMessageHandler(async (message: string) => {\n // For now, return a simple response based on identity\n // TODO: Integrate with actual LLM/agent logic\n const responses = [\n `That's interesting! As ${identity.name}, I'm always curious to learn more.`,\n `I hear you. Let me think about that...`,\n `${message} - that reminds me of something from my training.`,\n `Good question! Based on my understanding...`,\n `Thanks for sharing that with me!`,\n ];\n\n const randomResponse = responses[Math.floor(Math.random() * responses.length)];\n\n // Simulate thinking delay\n await new Promise(resolve => setTimeout(resolve, 1000 + Math.random() * 1000));\n\n return randomResponse;\n });\n\n const url = await server.start();\n\n console.log(chalk.green(`\\n✓ Chat interface started at ${chalk.bold(url)}\\n`));\n console.log(chalk.dim(`Press Ctrl+C to stop the server\\n`));\n\n // Open browser\n openBrowser(url);\n\n // Keep process alive\n process.on(\"SIGINT\", () => {\n console.log(chalk.yellow(\"\\n\\nStopping chat server...\"));\n server.stop();\n process.exit(0);\n });\n\n // Return the server instance for external control\n return server;\n}\n\n/**\n * Open URL in default browser\n */\nfunction openBrowser(url: string) {\n const platform = process.platform;\n\n try {\n if (platform === \"darwin\") {\n execSync(`open \"${url}\"`, { stdio: \"ignore\" });\n } else if (platform === \"win32\") {\n execSync(`start \"\" \"${url}\"`, { stdio: \"ignore\" });\n } else {\n // Linux\n execSync(`xdg-open \"${url}\"`, { stdio: \"ignore\" });\n }\n } catch (error) {\n // Browser couldn't be opened, that's okay\n console.log(chalk.dim(`(Couldn't open browser automatically - please visit ${url} manually)`));\n }\n}\n\nexport { openBrowser };\n"],"mappings":";;;;;;AAKA,OAAO,UAAU;AACjB,SAAS,WAAW;AACpB,SAAS,oBAAoB;AAC7B,SAAS,MAAM,eAAe;AAC9B,SAAS,qBAAqB;AAE9B,IAAM,aAAa,cAAc,YAAY,GAAG;AAChD,IAAM,YAAY,QAAQ,UAAU;AAQ7B,IAAM,gBAAN,MAAoB;AAAA,EACjB,SAA6B;AAAA,EAC7B;AAAA,EACA,WAA0B,CAAC;AAAA,EAC3B;AAAA,EAER,YAAY,OAAO,MAAM;AACvB,SAAK,OAAO;AAAA,EACd;AAAA,EAEA,kBAAkB,SAA+C;AAC/D,SAAK,gBAAgB;AAAA,EACvB;AAAA,EAEA,MAAM,QAAyB;AAC7B,WAAO,IAAI,QAAQ,CAAC,SAAS,WAAW;AACtC,WAAK,SAAS,KAAK,aAAa,OAAO,KAAK,QAAQ;AAClD,cAAM,MAAM,IAAI,IAAI,IAAI,OAAO,KAAK,UAAU,IAAI,QAAQ,IAAI,EAAE;AAGhE,YAAI,UAAU,+BAA+B,GAAG;AAChD,YAAI,UAAU,gCAAgC,oBAAoB;AAClE,YAAI,UAAU,gCAAgC,cAAc;AAE5D,YAAI,IAAI,WAAW,WAAW;AAC5B,cAAI,UAAU,GAAG;AACjB,cAAI,IAAI;AACR;AAAA,QACF;AAGA,YAAI,IAAI,aAAa,OAAO,IAAI,aAAa,eAAe;AAC1D,cAAI;AACF,kBAAM,OAAO,aAAa,KAAK,WAAW,WAAW,GAAG,OAAO;AAC/D,gBAAI,UAAU,KAAK,EAAE,gBAAgB,YAAY,CAAC;AAClD,gBAAI,IAAI,IAAI;AAAA,UACd,SAAS,OAAO;AACd,gBAAI,UAAU,GAAG;AACjB,gBAAI,IAAI,8BAA8B;AAAA,UACxC;AACA;AAAA,QACF;AAGA,YAAI,IAAI,aAAa,mBAAmB,IAAI,WAAW,OAAO;AAC5D,cAAI,U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