Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 6 additions & 13 deletions agent_core/core/impl/onboarding/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,28 +28,21 @@ def _get_config_file() -> Path:

# Hard onboarding steps configuration
# Each step has: id, required (must complete), title (display name)
# Note: User name is collected during soft onboarding (conversational interview)
# User profile (name, location, language, tone, etc.) is collected in the
# user_profile form step during hard onboarding.
HARD_ONBOARDING_STEPS = [
{"id": "provider", "required": True, "title": "LLM Provider"},
{"id": "api_key", "required": True, "title": "API Key"},
{"id": "agent_name", "required": False, "title": "Agent Name"},
{"id": "user_profile", "required": False, "title": "User Profile"},
{"id": "mcp", "required": False, "title": "MCP Servers"},
{"id": "skills", "required": False, "title": "Skills"},
]

# Soft onboarding interview questions template
# Questions are grouped to reduce conversation turns
# Identity/preferences are now collected in hard onboarding.
# Soft onboarding focuses on job/role and deep life goals exploration.
SOFT_ONBOARDING_QUESTIONS = [
# Batch 1: Identity (asked together)
"name", # What should I call you?
"job", # What do you do for work?
"location", # Where are you located? (timezone inferred from this)
# Batch 2: Preferences (asked together)
"tone", # How would you like me to communicate?
"proactivity", # Should I be proactive or wait for instructions?
"approval", # What actions need your approval?
# Batch 3: Messaging
"preferred_messaging_platform", # Where should I send notifications? (telegram/whatsapp/discord/slack/tui)
# Batch 4: Life goals
"life_goals", # What are your life goals and what do you want help with?
"life_goals", # Deep life goals exploration (multiple rounds)
]
4 changes: 2 additions & 2 deletions agent_core/core/prompts/routing.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@

<output_format>
Return ONLY a valid JSON object:
- Route to existing: {{ "action": "route", "session_id": "<session_id>", "reason": "<brief>" }}
- Create new: {{ "action": "new", "session_id": "new", "reason": "<brief>" }}
- Route to existing: {{ "reason": "<brief>", "action": "route", "session_id": "<session_id>" }}
- Create new: {{ "reason": "<brief>", "action": "new", "session_id": "new" }}
</output_format>
"""

Expand Down
15 changes: 8 additions & 7 deletions app/agent_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2115,6 +2115,8 @@ def _reset_agent_file_system_sync(self) -> None:

logger.info("[RESET] Agent file system reinitialized from templates")

_soft_onboarding_triggered: bool = False

async def trigger_soft_onboarding(self, reset: bool = False) -> Optional[str]:
"""
Trigger soft onboarding interview task.
Expand All @@ -2133,6 +2135,12 @@ async def trigger_soft_onboarding(self, reset: bool = False) -> Optional[str]:
from app.trigger import Trigger
import time

# Prevent double-triggering (multiple adapters/paths may call this)
if not reset and self._soft_onboarding_triggered:
logger.debug("[ONBOARDING] Soft onboarding already triggered, skipping")
return None
self._soft_onboarding_triggered = True

if reset:
onboarding_manager.reset_soft_onboarding()

Expand Down Expand Up @@ -2741,13 +2749,6 @@ def print_startup_step(step: int, total: int, message: str):
# Resume triggers for tasks restored from previous session
await self._schedule_restored_task_triggers()

# Trigger soft onboarding if needed (BEFORE starting interface)
# This ensures agent handles onboarding logic, not the interfaces
from app.onboarding import onboarding_manager
if onboarding_manager.needs_soft_onboarding:
logger.info("[ONBOARDING] Soft onboarding needed, triggering from agent")
await self.trigger_soft_onboarding()

# Initialize external communications (WhatsApp, Telegram)
print_startup_step(8, 8, "Starting communications")
from app.external_comms import ExternalCommsManager
Expand Down
92 changes: 90 additions & 2 deletions app/cli/onboarding.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
ProviderStep,
ApiKeyStep,
AgentNameStep,
UserProfileStep,
MCPStep,
SkillsStep,
)
Expand Down Expand Up @@ -173,6 +174,72 @@ async def _select_multiple(

return list(selections)

async def _input_form(self, step) -> Dict[str, Any]:
"""Present a multi-field form and return collected data as a dict."""
form_fields = step.get_form_fields()
result: Dict[str, Any] = {}

print(f"\n{step.title}:")
print(f"{step.description}\n")

for f in form_fields:
if f.field_type == "text":
default_display = f.default or ""
prompt = f" {f.label}"
if default_display:
prompt += f" (default: {default_display})"
prompt += ": "
try:
value = await self._async_input(prompt)
except (EOFError, KeyboardInterrupt):
value = ""
result[f.name] = value.strip() if value.strip() else (f.default or "")

elif f.field_type == "select":
print(f"\n {f.label}:")
for i, opt in enumerate(f.options, 1):
marker = "*" if (opt.value == f.default or opt.default) else " "
label = f" {i}. [{marker}] {opt.label}"
if opt.description and opt.description != opt.label:
label += f" - {opt.description}"
print(label)
try:
choice = await self._async_input(f" Enter number [1-{len(f.options)}]: ")
except (EOFError, KeyboardInterrupt):
choice = ""
choice = choice.strip()
if choice:
try:
idx = int(choice) - 1
if 0 <= idx < len(f.options):
result[f.name] = f.options[idx].value
continue
except ValueError:
pass
result[f.name] = f.default

elif f.field_type == "multi_checkbox":
print(f"\n {f.label}:")
for i, opt in enumerate(f.options, 1):
print(f" {i}. [ ] {opt.label} - {opt.description}")
print(" Enter numbers to select (comma-separated), or press Enter to skip:")
try:
choice = await self._async_input(" > ")
except (EOFError, KeyboardInterrupt):
choice = ""
selected = []
for part in choice.split(","):
part = part.strip()
try:
idx = int(part) - 1
if 0 <= idx < len(f.options):
selected.append(f.options[idx].value)
except ValueError:
continue
result[f.name] = selected

return result

async def run_hard_onboarding(self) -> Dict[str, Any]:
"""Execute CLI-based hard onboarding wizard."""
print(CLIFormatter.format_header("CraftBot Setup"))
Expand Down Expand Up @@ -206,7 +273,21 @@ async def run_hard_onboarding(self) -> Dict[str, Any]:
)
self._collected_data["agent_name"] = agent_name or "Agent"

# Step 4: MCP servers (optional)
# Step 4: User Profile (optional)
profile_step = UserProfileStep()
print("\nWould you like to set up your profile? (Y/n)")
try:
configure_profile = await self._async_input("> ")
except (EOFError, KeyboardInterrupt):
configure_profile = "n"

if not configure_profile.lower().startswith("n"):
profile_data = await self._input_form(profile_step)
self._collected_data["user_profile"] = profile_data
else:
self._collected_data["user_profile"] = {}

# Step 5: MCP servers (optional)
mcp_step = MCPStep()
mcp_options = mcp_step.get_options()
if mcp_options:
Expand Down Expand Up @@ -271,9 +352,16 @@ def on_complete(self, cancelled: bool = False) -> None:
save_settings_to_json(provider, api_key)
logger.info(f"[CLI ONBOARDING] Saved provider={provider} to settings.json")

# Write user profile data to USER.md
profile_data = self._collected_data.get("user_profile", {})
if profile_data:
from app.onboarding.profile_writer import write_profile_to_user_md
write_profile_to_user_md(profile_data)

# Mark hard onboarding as complete
agent_name = self._collected_data.get("agent_name", "Agent")
onboarding_manager.mark_hard_complete(agent_name=agent_name)
user_name = profile_data.get("user_name") if profile_data else None
onboarding_manager.mark_hard_complete(user_name=user_name, agent_name=agent_name)

logger.info("[CLI ONBOARDING] Hard onboarding completed successfully")

Expand Down
1 change: 1 addition & 0 deletions app/config/skills_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"auto_load": true,
"enabled_skills": [
"docx",
"file-format",
"pdf",
"playwright-mcp",
"pptx",
Expand Down
4 changes: 2 additions & 2 deletions app/data/agent_file_system_template/USER.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
- **Approval Required For:** (Ask the users for info)

## Life Goals
- **Goals:** (Ask the users for info)
- **Help Wanted:** (Ask the users for info)

(Ask the users for info)

## Personality

Expand Down
4 changes: 2 additions & 2 deletions app/internal_action_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,14 @@ def describe_screen(cls) -> Dict[str, str]:
@staticmethod
async def do_chat(
message: str,
platform: str = "CraftBot TUI",
platform: str = "CraftBot Interface",
session_id: Optional[str] = None,
) -> None:
"""Record an agent-authored chat message to the event stream.

Args:
message: The message content to record.
platform: The platform the message is sent to (default: "CraftBot TUI").
platform: The platform the message is sent to (default: "CraftBot Interface").
session_id: Optional task/session ID for multi-task isolation.
"""
if InternalActionInterface.state_manager is None:
Expand Down
Loading