@channels.command("imessage-start")
@click.argument("chat_identifier")
@click.option(
"--background/--foreground",
default=True,
help="Run in background.",
)
def imessage_start(
chat_identifier: str,
background: bool,
) -> None:
"""Start the iMessage daemon for CHAT_IDENTIFIER.
CHAT_IDENTIFIER is the phone number or email to monitor.
"""
from openjarvis.channels.imessage_daemon import (
is_running,
run_daemon,
)
console = Console()
if is_running():
console.print("[yellow]iMessage daemon already running.[/yellow]")
return
if background:
import subprocess
proc = subprocess.Popen(
[
sys.executable,
"-m",
"openjarvis.channels.imessage_daemon",
"--chat",
chat_identifier,
],
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
start_new_session=True,
)
console.print(
f"[green]iMessage daemon started[/green] "
f"(PID {proc.pid})\n"
f"Monitoring: {chat_identifier}\n"
"Text this contact from your iPhone "
"to chat with the agent."
)
else:
console.print(
f"[green]Starting iMessage daemon[/green] — monitoring {chat_identifier}"
)
console.print("Press Ctrl+C to stop.\n")
from openjarvis.agents.deep_research import (
DeepResearchAgent,
)
from openjarvis.connectors.retriever import (
TwoStageRetriever,
)
from openjarvis.connectors.store import KnowledgeStore
from openjarvis.core.config import load_config
from openjarvis.core.events import EventBus
from openjarvis.engine.ollama import OllamaEngine
from openjarvis.security import setup_security
from openjarvis.tools.knowledge_search import (
KnowledgeSearchTool,
)
from openjarvis.tools.knowledge_sql import (
KnowledgeSQLTool,
)
from openjarvis.tools.scan_chunks import ScanChunksTool
from openjarvis.tools.think import ThinkTool
config = load_config()
bus = EventBus(record_history=False)
security = setup_security(config, OllamaEngine(), bus)
engine = security.engine
store = KnowledgeStore()
retriever = TwoStageRetriever(store)
tools = [
KnowledgeSearchTool(retriever=retriever),
KnowledgeSQLTool(store=store),
ScanChunksTool(
store=store,
engine=engine,
model="qwen3.5:4b",
),
ThinkTool(),
]
agent = DeepResearchAgent(
engine=engine,
model="qwen3.5:4b",
tools=tools,
bus=bus,
capability_policy=security.capability_policy,
rate_limiter=security.rate_limiter,
agent_id="channel:imessage",
)
def handler(text: str) -> str:
result = agent.run(text)
return result.content or "No results found."
run_daemon(
chat_identifier=chat_identifier,
handler=handler,
)