polyrob 0.5.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (745) hide show
  1. agents/README.md +453 -0
  2. agents/__init__.py +164 -0
  3. agents/base_agent.py +743 -0
  4. agents/personality/character.py +119 -0
  5. agents/personality/character_manager.py +309 -0
  6. agents/personality/characters/rob.character.json +56 -0
  7. agents/personality/characters/trump.character.json +63 -0
  8. agents/personality/persona_render.py +78 -0
  9. agents/personality/persona_resolver.py +115 -0
  10. agents/prompt/__init__.py +58 -0
  11. agents/prompt/base_prompt.py +92 -0
  12. agents/prompt/system.py +417 -0
  13. agents/task/README_PATH_MANAGEMENT.md +141 -0
  14. agents/task/__init__.py +162 -0
  15. agents/task/agent/__init__.py +70 -0
  16. agents/task/agent/agent_state.py +408 -0
  17. agents/task/agent/async_delegation.py +274 -0
  18. agents/task/agent/autonomy_state.py +275 -0
  19. agents/task/agent/conversation.py +75 -0
  20. agents/task/agent/core/__init__.py +6 -0
  21. agents/task/agent/core/aux_metering.py +61 -0
  22. agents/task/agent/core/background_review.py +157 -0
  23. agents/task/agent/core/construction.py +1179 -0
  24. agents/task/agent/core/conversational_exit.py +49 -0
  25. agents/task/agent/core/correspondent_gate.py +227 -0
  26. agents/task/agent/core/curator.py +246 -0
  27. agents/task/agent/core/episodic_digest.py +103 -0
  28. agents/task/agent/core/error_recovery.py +480 -0
  29. agents/task/agent/core/history_io.py +257 -0
  30. agents/task/agent/core/llm_provisioning.py +287 -0
  31. agents/task/agent/core/llm_runner.py +547 -0
  32. agents/task/agent/core/logging_io.py +276 -0
  33. agents/task/agent/core/loop_detection.py +262 -0
  34. agents/task/agent/core/memory_prefetch.py +325 -0
  35. agents/task/agent/core/memory_writer.py +667 -0
  36. agents/task/agent/core/model_introspection.py +82 -0
  37. agents/task/agent/core/model_swap.py +177 -0
  38. agents/task/agent/core/next_action_internal.py +1331 -0
  39. agents/task/agent/core/output_validation.py +303 -0
  40. agents/task/agent/core/project_context.py +272 -0
  41. agents/task/agent/core/resources.py +93 -0
  42. agents/task/agent/core/result_processing.py +389 -0
  43. agents/task/agent/core/run_loop.py +661 -0
  44. agents/task/agent/core/safety_lifecycle.py +228 -0
  45. agents/task/agent/core/secret_guard.py +293 -0
  46. agents/task/agent/core/self_wake.py +280 -0
  47. agents/task/agent/core/session_metadata.py +104 -0
  48. agents/task/agent/core/step.py +781 -0
  49. agents/task/agent/core/step_execution.py +398 -0
  50. agents/task/agent/core/step_telemetry.py +222 -0
  51. agents/task/agent/core/test_aux_metering.py +50 -0
  52. agents/task/agent/core/test_billing_failover.py +68 -0
  53. agents/task/agent/core/test_fatal_error_classifier.py +38 -0
  54. agents/task/agent/core/test_judge_validation.py +275 -0
  55. agents/task/agent/core/test_model_swap.py +190 -0
  56. agents/task/agent/core/test_reflection_offload.py +54 -0
  57. agents/task/agent/core/turn_input.py +8 -0
  58. agents/task/agent/core/untrusted_wrap.py +103 -0
  59. agents/task/agent/core/user_ingress.py +228 -0
  60. agents/task/agent/hitl_manager.py +396 -0
  61. agents/task/agent/log_sanitize.py +36 -0
  62. agents/task/agent/message_manager/config.py +97 -0
  63. agents/task/agent/message_manager/service.py +758 -0
  64. agents/task/agent/message_manager/tests.py +305 -0
  65. agents/task/agent/message_manager/tool_call_builder.py +539 -0
  66. agents/task/agent/message_manager/tool_message_repair.py +364 -0
  67. agents/task/agent/message_manager/views.py +143 -0
  68. agents/task/agent/messages/__init__.py +8 -0
  69. agents/task/agent/messages/builders.py +309 -0
  70. agents/task/agent/messages/compactor.py +611 -0
  71. agents/task/agent/messages/context_references.py +271 -0
  72. agents/task/agent/messages/filters.py +333 -0
  73. agents/task/agent/messages/guidance.py +328 -0
  74. agents/task/agent/messages/persistence.py +448 -0
  75. agents/task/agent/messages/retrieval.py +506 -0
  76. agents/task/agent/messages/sqlite_persistence.py +85 -0
  77. agents/task/agent/messages/test_compaction_upgrade.py +349 -0
  78. agents/task/agent/messages/test_persistence_subdir_fix.py +28 -0
  79. agents/task/agent/messages/test_sqlite_persistence.py +54 -0
  80. agents/task/agent/messages/token_counter.py +532 -0
  81. agents/task/agent/orchestrator.py +776 -0
  82. agents/task/agent/profile_manager.py +105 -0
  83. agents/task/agent/profile_registry.py +173 -0
  84. agents/task/agent/prompts.py +1090 -0
  85. agents/task/agent/scenario_registry.py +226 -0
  86. agents/task/agent/service.py +509 -0
  87. agents/task/agent/session.py +984 -0
  88. agents/task/agent/skill_discovery.py +110 -0
  89. agents/task/agent/skill_frontmatter.py +94 -0
  90. agents/task/agent/skill_manager.py +1201 -0
  91. agents/task/agent/skill_store.py +627 -0
  92. agents/task/agent/skill_validation.py +56 -0
  93. agents/task/agent/skill_writer.py +492 -0
  94. agents/task/agent/sub_agent_manager.py +1137 -0
  95. agents/task/agent/test_session_disk_recovery.py +34 -0
  96. agents/task/agent/tests.py +513 -0
  97. agents/task/agent/tool_call_tracker.py +511 -0
  98. agents/task/agent/views.py +469 -0
  99. agents/task/config.py +432 -0
  100. agents/task/constants.py +1384 -0
  101. agents/task/flag_defaults.py +63 -0
  102. agents/task/goals/__init__.py +1 -0
  103. agents/task/goals/autonomy_marker.py +28 -0
  104. agents/task/goals/board.py +690 -0
  105. agents/task/goals/completion_judge.py +247 -0
  106. agents/task/goals/context.py +62 -0
  107. agents/task/goals/dispatcher.py +848 -0
  108. agents/task/goals/escalation.py +102 -0
  109. agents/task/goals/planner.py +114 -0
  110. agents/task/logging_config.py +155 -0
  111. agents/task/path.py +991 -0
  112. agents/task/robust_parse_config.py +400 -0
  113. agents/task/runtime/__init__.py +0 -0
  114. agents/task/runtime/run_as_session.py +130 -0
  115. agents/task/runtime_safety.py +308 -0
  116. agents/task/session/__init__.py +5 -0
  117. agents/task/session/browser_pool.py +130 -0
  118. agents/task/session/cleanup.py +612 -0
  119. agents/task/session/execution.py +397 -0
  120. agents/task/session/feed.py +200 -0
  121. agents/task/session/hitl_ingress.py +201 -0
  122. agents/task/session/hooks.py +83 -0
  123. agents/task/session/multi_agent.py +243 -0
  124. agents/task/session/workspace.py +91 -0
  125. agents/task/session_registry.py +91 -0
  126. agents/task/session_route.py +35 -0
  127. agents/task/sqlite_session_registry.py +261 -0
  128. agents/task/surface_config.py +185 -0
  129. agents/task/telemetry/__init__.py +58 -0
  130. agents/task/telemetry/event_log.py +180 -0
  131. agents/task/telemetry/formatters.py +642 -0
  132. agents/task/telemetry/manager.py +571 -0
  133. agents/task/telemetry/memory_events.py +66 -0
  134. agents/task/telemetry/self_events.py +53 -0
  135. agents/task/telemetry/sequence.py +160 -0
  136. agents/task/telemetry/service.py +1265 -0
  137. agents/task/telemetry/views.py +882 -0
  138. agents/task/templates.py +98 -0
  139. agents/task/test_aux_chain.py +151 -0
  140. agents/task/test_aux_router.py +41 -0
  141. agents/task/tests/test_parse_robustness.py +170 -0
  142. agents/task/tool_defaults.py +110 -0
  143. agents/task/utils.py +762 -0
  144. agents/task/utils_json.py +768 -0
  145. agents/task/utils_webview.py +86 -0
  146. agents/task/workspace_context.py +229 -0
  147. agents/task_agent_lite.py +2398 -0
  148. api/README.md +683 -0
  149. api/TASK_API_DOCS.md +151 -0
  150. api/__init__.py +0 -0
  151. api/a2a/__init__.py +37 -0
  152. api/a2a/agent_card.py +337 -0
  153. api/a2a/client.py +657 -0
  154. api/a2a/endpoints.py +375 -0
  155. api/a2a/models.py +268 -0
  156. api/a2a/streaming.py +419 -0
  157. api/a2a/task_handler.py +929 -0
  158. api/admin_endpoints.py +1584 -0
  159. api/app.py +923 -0
  160. api/auth_constants.py +28 -0
  161. api/auth_endpoints.py +402 -0
  162. api/auth_state.py +36 -0
  163. api/chat_via_task.py +42 -0
  164. api/conversation_manager.py +231 -0
  165. api/dependencies.py +186 -0
  166. api/eip8004_endpoints.py +452 -0
  167. api/hyperliquid_models.py +174 -0
  168. api/hyperliquid_routes.py +450 -0
  169. api/interfaces.py +207 -0
  170. api/jwt_middleware.py +83 -0
  171. api/kb/__init__.py +1 -0
  172. api/kb/endpoints.py +314 -0
  173. api/mcp_models.py +279 -0
  174. api/mcp_routes.py +438 -0
  175. api/middleware.py +526 -0
  176. api/models.py +176 -0
  177. api/openai_compat/__init__.py +0 -0
  178. api/openai_compat/model_map.py +25 -0
  179. api/openai_compat/models.py +59 -0
  180. api/openai_compat/router.py +140 -0
  181. api/payment_endpoints.py +444 -0
  182. api/payment_verification.py +138 -0
  183. api/polymarket_models.py +155 -0
  184. api/polymarket_routes.py +501 -0
  185. api/pricing_endpoints.py +89 -0
  186. api/session_routing.py +54 -0
  187. api/skill_endpoints.py +453 -0
  188. api/task_http_api.py +1856 -0
  189. api/webhooks.py +52 -0
  190. api/x402_endpoints.py +280 -0
  191. avatar/README.md +44 -0
  192. avatar/__init__.py +1 -0
  193. avatar/config/rob.json +7 -0
  194. avatar/mindprint.js +395 -0
  195. avatar/renders/rob.meta.json +20 -0
  196. avatar/renders/rob.png +0 -0
  197. avatar/studio.html +373 -0
  198. avatar/webview/avatar-live.js +44 -0
  199. cli/README.md +89 -0
  200. cli/__init__.py +0 -0
  201. cli/cli_surface.py +67 -0
  202. cli/commands/__init__.py +0 -0
  203. cli/commands/_bootstrap.py +49 -0
  204. cli/commands/_errors.py +53 -0
  205. cli/commands/chat.py +973 -0
  206. cli/commands/config.py +100 -0
  207. cli/commands/dashboard.py +103 -0
  208. cli/commands/doctor.py +222 -0
  209. cli/commands/email.py +174 -0
  210. cli/commands/gateway.py +346 -0
  211. cli/commands/goals.py +509 -0
  212. cli/commands/init.py +276 -0
  213. cli/commands/journey.py +30 -0
  214. cli/commands/kb.py +280 -0
  215. cli/commands/model.py +107 -0
  216. cli/commands/owner.py +431 -0
  217. cli/commands/pfp.py +232 -0
  218. cli/commands/run.py +414 -0
  219. cli/commands/serve.py +41 -0
  220. cli/commands/session.py +684 -0
  221. cli/commands/skill_install.py +786 -0
  222. cli/commands/skills.py +128 -0
  223. cli/commands/subagents.py +100 -0
  224. cli/commands/surface.py +81 -0
  225. cli/commands/telegram.py +185 -0
  226. cli/commands/todos.py +209 -0
  227. cli/commands/tools.py +102 -0
  228. cli/commands/update.py +316 -0
  229. cli/commands/whatsapp.py +175 -0
  230. cli/config_store.py +276 -0
  231. cli/gitignore.py +43 -0
  232. cli/inventory.py +46 -0
  233. cli/keys.py +101 -0
  234. cli/persona.py +17 -0
  235. cli/polyrob.py +137 -0
  236. cli/ui/__init__.py +64 -0
  237. cli/ui/activity.py +141 -0
  238. cli/ui/app.py +538 -0
  239. cli/ui/banner.py +233 -0
  240. cli/ui/blocks.py +534 -0
  241. cli/ui/bootstrap_notice.py +47 -0
  242. cli/ui/commands/__init__.py +41 -0
  243. cli/ui/commands/h_cron.py +64 -0
  244. cli/ui/commands/h_journey.py +164 -0
  245. cli/ui/commands/h_kb.py +121 -0
  246. cli/ui/commands/h_learn.py +100 -0
  247. cli/ui/commands/h_mcp.py +215 -0
  248. cli/ui/commands/h_self.py +113 -0
  249. cli/ui/commands/h_skills.py +314 -0
  250. cli/ui/commands/handlers.py +1672 -0
  251. cli/ui/commands/registry.py +426 -0
  252. cli/ui/dialog.py +425 -0
  253. cli/ui/event_registry.py +110 -0
  254. cli/ui/event_specs.py +45 -0
  255. cli/ui/events.py +433 -0
  256. cli/ui/identity.py +15 -0
  257. cli/ui/lifecycle.py +159 -0
  258. cli/ui/live_hooks.py +43 -0
  259. cli/ui/model_selector.py +532 -0
  260. cli/ui/persistent_loop.py +181 -0
  261. cli/ui/pick.py +113 -0
  262. cli/ui/plain_renderer.py +351 -0
  263. cli/ui/renderer.py +384 -0
  264. cli/ui/rich_renderer.py +533 -0
  265. cli/ui/secrets.py +115 -0
  266. cli/ui/state.py +376 -0
  267. cli/ui/statusbar.py +231 -0
  268. cli/ui/streaming.py +254 -0
  269. cli/ui/terminal_render.py +105 -0
  270. cli/ui/theme.py +132 -0
  271. cli/update/__init__.py +6 -0
  272. cli/update/context.py +121 -0
  273. cli/update/detect.py +176 -0
  274. cli/update/engine.py +95 -0
  275. cli/update/migrate_guarded.py +55 -0
  276. cli/update/process_guard.py +215 -0
  277. cli/update/runners.py +78 -0
  278. cli/update/snapshot.py +270 -0
  279. cli/update/versions.py +205 -0
  280. core/README.md +377 -0
  281. core/__init__.py +174 -0
  282. core/assets.py +87 -0
  283. core/async_bridge.py +76 -0
  284. core/autonomy_runtime.py +259 -0
  285. core/base_component.py +302 -0
  286. core/bootstrap.py +681 -0
  287. core/bot.py +310 -0
  288. core/config.py +833 -0
  289. core/constants.py +126 -0
  290. core/container.py +462 -0
  291. core/db_manifest.py +101 -0
  292. core/embedding.py +57 -0
  293. core/env.py +39 -0
  294. core/exceptions.py +287 -0
  295. core/flags.py +144 -0
  296. core/flags_catalog.py +345 -0
  297. core/home_migration.py +62 -0
  298. core/identity.py +118 -0
  299. core/initialization.py +1004 -0
  300. core/instance.py +537 -0
  301. core/interactive_gate.py +96 -0
  302. core/logging.py +436 -0
  303. core/owner_doc_writer.py +176 -0
  304. core/pairing.py +193 -0
  305. core/path_safety.py +20 -0
  306. core/paths.py +27 -0
  307. core/payment_config.py +21 -0
  308. core/permissions.py +322 -0
  309. core/runtime_config.py +96 -0
  310. core/runtime_paths.py +135 -0
  311. core/seams.py +35 -0
  312. core/secret_scan.py +25 -0
  313. core/secret_scrub.py +71 -0
  314. core/secrets.py +35 -0
  315. core/security_logging_filter.py +148 -0
  316. core/self_context_writer.py +333 -0
  317. core/self_evolution.py +294 -0
  318. core/session_context.py +47 -0
  319. core/sqlite_util.py +59 -0
  320. core/surfaces/__init__.py +16 -0
  321. core/surfaces/access.py +118 -0
  322. core/surfaces/binding.py +88 -0
  323. core/surfaces/bootstrap.py +78 -0
  324. core/surfaces/circuit.py +168 -0
  325. core/surfaces/continuity.py +77 -0
  326. core/surfaces/correspondents.py +228 -0
  327. core/surfaces/dispatcher.py +216 -0
  328. core/surfaces/envelopes.py +75 -0
  329. core/surfaces/gc.py +30 -0
  330. core/surfaces/idempotency.py +57 -0
  331. core/surfaces/inbound_webhook.py +124 -0
  332. core/surfaces/media.py +32 -0
  333. core/surfaces/message_router.py +91 -0
  334. core/surfaces/outbound_allowlist.py +80 -0
  335. core/surfaces/outbound_dispatcher.py +110 -0
  336. core/surfaces/outbound_mirror.py +37 -0
  337. core/surfaces/outbound_queue.py +107 -0
  338. core/surfaces/outbound_target.py +12 -0
  339. core/surfaces/owner_admin.py +29 -0
  340. core/surfaces/proactive.py +78 -0
  341. core/surfaces/progress.py +108 -0
  342. core/surfaces/rate_bucket.py +21 -0
  343. core/surfaces/registry.py +51 -0
  344. core/surfaces/rendering.py +53 -0
  345. core/surfaces/send_policy.py +14 -0
  346. core/surfaces/serialize.py +24 -0
  347. core/surfaces/session_chat_registry.py +112 -0
  348. core/surfaces/session_policy.py +60 -0
  349. core/surfaces/surface.py +288 -0
  350. core/surfaces/transcription.py +88 -0
  351. core/surfaces/voice_echo.py +26 -0
  352. core/surfaces/voice_guard.py +23 -0
  353. core/tickers.py +174 -0
  354. core/tool_catalog.py +192 -0
  355. core/version.py +75 -0
  356. core/wallet/__init__.py +5 -0
  357. core/wallet/agent_wallet.py +59 -0
  358. core/wallet/audit_sink.py +61 -0
  359. core/wallet/config.py +70 -0
  360. core/wallet/factory.py +87 -0
  361. core/wallet/policy.py +104 -0
  362. core/wallet/signer.py +51 -0
  363. cron/README.md +65 -0
  364. cron/__init__.py +0 -0
  365. cron/delivery.py +277 -0
  366. cron/digest.py +124 -0
  367. cron/jobs.py +207 -0
  368. cron/runner.py +297 -0
  369. cron/schedule.py +194 -0
  370. cron/scheduler.py +201 -0
  371. cron/service.py +57 -0
  372. cron/wake_gate.py +223 -0
  373. data/__init__.py +1 -0
  374. data/prompts/autov2_prompts.json +87 -0
  375. data/prompts/skills/browser-automation/SKILL.md +43 -0
  376. data/prompts/skills/coding-workflow/SKILL.md +36 -0
  377. data/prompts/skills/crypto-trading-safety/SKILL.md +53 -0
  378. data/prompts/skills/document-writing/SKILL.md +33 -0
  379. data/prompts/skills/email-comms/SKILL.md +33 -0
  380. data/prompts/skills/file-data-ops/SKILL.md +35 -0
  381. data/prompts/skills/hyperliquid-account-review/SKILL.md +48 -0
  382. data/prompts/skills/hyperliquid-market-data/SKILL.md +52 -0
  383. data/prompts/skills/hyperliquid-trading/SKILL.md +59 -0
  384. data/prompts/skills/lead-research/SKILL.md +86 -0
  385. data/prompts/skills/market-research-brief/SKILL.md +104 -0
  386. data/prompts/skills/person-analyzer/SKILL.md +124 -0
  387. data/prompts/skills/polymarket-market-research/SKILL.md +54 -0
  388. data/prompts/skills/polymarket-portfolio-review/SKILL.md +50 -0
  389. data/prompts/skills/polymarket-trading/SKILL.md +55 -0
  390. data/prompts/skills/presentation-creator/SKILL.md +36 -0
  391. data/prompts/skills/project-analyzer/SKILL.md +169 -0
  392. data/prompts/skills/rules.json +268 -0
  393. data/prompts/skills/secret-handling/SKILL.md +20 -0
  394. data/prompts/skills/skill-authoring/SKILL.md +31 -0
  395. data/prompts/skills/skill-security-review/SKILL.md +27 -0
  396. data/prompts/skills/social-discovery/SKILL.md +57 -0
  397. data/prompts/skills/task-planning/SKILL.md +33 -0
  398. data/prompts/skills/web-research/SKILL.md +39 -0
  399. data/prompts/skills/web-scraping/SKILL.md +73 -0
  400. data/prompts/skills/x-engagement/SKILL.md +69 -0
  401. data/prompts/system_prompts.json +4 -0
  402. data/subscription_channels.json +5 -0
  403. modules/README.md +503 -0
  404. modules/__init__.py +124 -0
  405. modules/auth/__init__.py +13 -0
  406. modules/auth/api_key_manager.py +157 -0
  407. modules/auth/identity_mapper.py +380 -0
  408. modules/auth/siwe_auth.py +273 -0
  409. modules/auth/tier_manager.py +173 -0
  410. modules/base_module.py +190 -0
  411. modules/credits/__init__.py +29 -0
  412. modules/credits/balance_manager.py +237 -0
  413. modules/credits/cost_utils.py +129 -0
  414. modules/credits/pricing.py +139 -0
  415. modules/credits/unified_ledger.py +148 -0
  416. modules/credits/usage_meter.py +310 -0
  417. modules/credits/usage_tracker.py +674 -0
  418. modules/database/__init__.py +33 -0
  419. modules/database/audit_log.py +322 -0
  420. modules/database/auth_tables.py +276 -0
  421. modules/database/connection.py +644 -0
  422. modules/database/connection_pool.py +305 -0
  423. modules/database/conversation_contexts.py +446 -0
  424. modules/database/database_manager.py +237 -0
  425. modules/database/hyperliquid.py +375 -0
  426. modules/database/polymarket.py +574 -0
  427. modules/database/user_mcp_servers.py +728 -0
  428. modules/database/user_profiles.py +562 -0
  429. modules/database/utils.py +107 -0
  430. modules/database/x402_tables.py +92 -0
  431. modules/eip8004/README.md +1069 -0
  432. modules/eip8004/__init__.py +65 -0
  433. modules/eip8004/contracts.py +498 -0
  434. modules/eip8004/models.py +271 -0
  435. modules/eip8004/registration.py +148 -0
  436. modules/eip8004/reputation.py +367 -0
  437. modules/eip8004/validation.py +277 -0
  438. modules/llm/__init__.py +97 -0
  439. modules/llm/adapters.py +963 -0
  440. modules/llm/anthropic_client.py +831 -0
  441. modules/llm/available_models.py +106 -0
  442. modules/llm/brain_scrubber.py +137 -0
  443. modules/llm/cache_hints.py +162 -0
  444. modules/llm/deepseek_client.py +562 -0
  445. modules/llm/gemini_client.py +1367 -0
  446. modules/llm/llm_client.py +1139 -0
  447. modules/llm/llm_client_registry.py +188 -0
  448. modules/llm/llm_factory.py +237 -0
  449. modules/llm/llm_manager.py +1036 -0
  450. modules/llm/messages.py +374 -0
  451. modules/llm/model_registry.py +1935 -0
  452. modules/llm/nvidia_client.py +125 -0
  453. modules/llm/openai_client.py +800 -0
  454. modules/llm/openrouter_client.py +969 -0
  455. modules/llm/profiles.py +178 -0
  456. modules/llm/test_anthropic_cache_capture.py +35 -0
  457. modules/llm/test_cached_pricing_derivation.py +24 -0
  458. modules/llm/think_scrubber.py +444 -0
  459. modules/llm/token_counter.py +268 -0
  460. modules/memory/__init__.py +35 -0
  461. modules/memory/backend_factory.py +83 -0
  462. modules/memory/cache_manager.py +186 -0
  463. modules/memory/episodic.py +108 -0
  464. modules/memory/local_vector_memory_provider.py +552 -0
  465. modules/memory/memory_manager.py +225 -0
  466. modules/memory/models.py +312 -0
  467. modules/memory/provider.py +210 -0
  468. modules/memory/registry.py +205 -0
  469. modules/memory/sqlite_memory_provider.py +767 -0
  470. modules/memory/task/__init__.py +52 -0
  471. modules/memory/task/compaction_manager.py +157 -0
  472. modules/memory/task/context_retriever.py +809 -0
  473. modules/memory/task/hierarchical_memory.py +1002 -0
  474. modules/memory/task/lexical_retriever.py +71 -0
  475. modules/memory/task/null_context_manager.py +213 -0
  476. modules/memory/task/phase_manager.py +625 -0
  477. modules/memory/task/reflection_service.py +157 -0
  478. modules/memory/task/semantic_retriever.py +218 -0
  479. modules/memory/task/task_context_manager.py +1165 -0
  480. modules/memory/task/test_forgetting_engages.py +24 -0
  481. modules/memory/task/test_reflection_llm.py +39 -0
  482. modules/memory/task/test_threat_scan.py +53 -0
  483. modules/memory/task/threat_scan.py +90 -0
  484. modules/memory/test_sqlite_memory_provider.py +106 -0
  485. modules/memory/user_profile_manager.py +527 -0
  486. modules/payments/__init__.py +11 -0
  487. modules/payments/deposit_monitor.py +478 -0
  488. modules/payments/price_oracle.py +70 -0
  489. modules/payments/treasury_sweeper.py +401 -0
  490. modules/payments/wallet_generator.py +145 -0
  491. modules/pfp/__init__.py +1 -0
  492. modules/pfp/config.py +92 -0
  493. modules/pfp/mesh.py +565 -0
  494. modules/pfp/push.py +69 -0
  495. modules/pfp/renderer.py +85 -0
  496. modules/pfp/store.py +82 -0
  497. modules/skills/__init__.py +1 -0
  498. modules/skills/skill_usage.py +248 -0
  499. modules/transcription/__init__.py +24 -0
  500. modules/transcription/base.py +20 -0
  501. modules/transcription/faster_whisper_transcriber.py +55 -0
  502. modules/x402/README.md +249 -0
  503. modules/x402/__init__.py +22 -0
  504. modules/x402/invoicing.py +416 -0
  505. modules/x402/middleware.py +364 -0
  506. modules/x402/settlement_watcher.py +145 -0
  507. modules/x402/x402_integration.py +344 -0
  508. polyrob-0.5.0.dist-info/METADATA +482 -0
  509. polyrob-0.5.0.dist-info/RECORD +745 -0
  510. polyrob-0.5.0.dist-info/WHEEL +5 -0
  511. polyrob-0.5.0.dist-info/entry_points.txt +2 -0
  512. polyrob-0.5.0.dist-info/licenses/LICENSE +21 -0
  513. polyrob-0.5.0.dist-info/top_level.txt +12 -0
  514. surfaces/README.md +70 -0
  515. surfaces/__init__.py +0 -0
  516. surfaces/email/__init__.py +0 -0
  517. surfaces/email/dedup.py +44 -0
  518. surfaces/email/harness.py +187 -0
  519. surfaces/email/inbound.py +159 -0
  520. surfaces/email/seed.py +60 -0
  521. surfaces/email/surface.py +105 -0
  522. surfaces/telegram/__init__.py +0 -0
  523. surfaces/telegram/dedup.py +83 -0
  524. surfaces/telegram/harness.py +886 -0
  525. surfaces/telegram/inbound.py +145 -0
  526. surfaces/telegram/interactive_tools.py +49 -0
  527. surfaces/telegram/markdown.py +347 -0
  528. surfaces/telegram/rate_limit.py +167 -0
  529. surfaces/telegram/surface.py +187 -0
  530. surfaces/telegram/voice.py +52 -0
  531. surfaces/whatsapp/__init__.py +0 -0
  532. surfaces/whatsapp/client.py +51 -0
  533. surfaces/whatsapp/harness.py +62 -0
  534. surfaces/whatsapp/inbound.py +132 -0
  535. surfaces/whatsapp/surface.py +64 -0
  536. surfaces/whatsapp/window.py +34 -0
  537. tools/README.md +578 -0
  538. tools/__init__.py +424 -0
  539. tools/alchemy/__init__.py +5 -0
  540. tools/alchemy/alchemy_tool.py +389 -0
  541. tools/anysite/__init__.py +17 -0
  542. tools/anysite/client.py +88 -0
  543. tools/anysite/tool.py +89 -0
  544. tools/base_tool.py +468 -0
  545. tools/browser/__init__.py +22 -0
  546. tools/browser/actions.py +118 -0
  547. tools/browser/browser.py +1457 -0
  548. tools/browser/browser_manager.py +690 -0
  549. tools/browser/context.py +1748 -0
  550. tools/browser/playwright_utils.py +137 -0
  551. tools/browser/views.py +56 -0
  552. tools/code_exec/SANDBOX_SECURITY.md +144 -0
  553. tools/code_exec/__init__.py +178 -0
  554. tools/code_exec/backend.py +73 -0
  555. tools/code_exec/backends/__init__.py +1 -0
  556. tools/code_exec/backends/docker.py +779 -0
  557. tools/code_exec/backends/local_subprocess.py +154 -0
  558. tools/code_exec/env_policy.py +45 -0
  559. tools/code_exec/result.py +42 -0
  560. tools/code_exec/sandbox_guard.py +59 -0
  561. tools/code_exec/tool.py +227 -0
  562. tools/coding/__init__.py +50 -0
  563. tools/coding/edit.py +107 -0
  564. tools/coding/search.py +113 -0
  565. tools/coding/tool.py +353 -0
  566. tools/collabland/__init__.py +5 -0
  567. tools/collabland/collabland_tool.py +471 -0
  568. tools/controller/__init__.py +0 -0
  569. tools/controller/_helpers.py +165 -0
  570. tools/controller/action_registration.py +1765 -0
  571. tools/controller/approval.py +244 -0
  572. tools/controller/approval_interactive.py +90 -0
  573. tools/controller/delegation.py +195 -0
  574. tools/controller/execution.py +797 -0
  575. tools/controller/execution_context.py +141 -0
  576. tools/controller/hooks.py +135 -0
  577. tools/controller/introspection.py +344 -0
  578. tools/controller/mcp_registrar.py +190 -0
  579. tools/controller/message_send.py +31 -0
  580. tools/controller/registry/__init__.py +4 -0
  581. tools/controller/registry/schema_generators.py +395 -0
  582. tools/controller/registry/schema_sanitizer.py +406 -0
  583. tools/controller/registry/service.py +1266 -0
  584. tools/controller/registry/views.py +151 -0
  585. tools/controller/service.py +409 -0
  586. tools/controller/tool_management.py +334 -0
  587. tools/controller/types.py +28 -0
  588. tools/controller/views.py +450 -0
  589. tools/cronjob_tools.py +166 -0
  590. tools/crypto_trade_gate.py +59 -0
  591. tools/descriptors.py +452 -0
  592. tools/dom/__init__.py +0 -0
  593. tools/dom/history_tree_processor/service.py +244 -0
  594. tools/dom/history_tree_processor/view.py +99 -0
  595. tools/dom/service.py +471 -0
  596. tools/dom/views.py +346 -0
  597. tools/email_tool.py +403 -0
  598. tools/exceptions.py +169 -0
  599. tools/filesystem.py +1038 -0
  600. tools/filesystem_docproc.py +331 -0
  601. tools/filesystem_pdf.py +755 -0
  602. tools/git/__init__.py +42 -0
  603. tools/git/tool.py +258 -0
  604. tools/github/__init__.py +33 -0
  605. tools/github/client.py +94 -0
  606. tools/github/tool.py +237 -0
  607. tools/goal_tools.py +309 -0
  608. tools/hyperliquid/__init__.py +56 -0
  609. tools/hyperliquid/models.py +233 -0
  610. tools/hyperliquid/service.py +1680 -0
  611. tools/knowledge_ingest.py +950 -0
  612. tools/mcp/README.md +535 -0
  613. tools/mcp/__init__.py +52 -0
  614. tools/mcp/catalog.py +115 -0
  615. tools/mcp/config.py +337 -0
  616. tools/mcp/mcp_tool.py +1415 -0
  617. tools/mcp/param_coercion.py +289 -0
  618. tools/mcp/protocol.py +1520 -0
  619. tools/mcp/rate_limit.py +50 -0
  620. tools/mcp/security.py +424 -0
  621. tools/mcp/self_install.py +111 -0
  622. tools/mcp/server_manager.py +829 -0
  623. tools/mcp/subscriptions.py +72 -0
  624. tools/mcp/user_mcp_service.py +899 -0
  625. tools/mcp/validation_tracker.py +89 -0
  626. tools/mcp/views.py +346 -0
  627. tools/oauth/__init__.py +17 -0
  628. tools/oauth/manager.py +75 -0
  629. tools/oauth/provider.py +69 -0
  630. tools/oauth/providers/__init__.py +1 -0
  631. tools/oauth/providers/generic_oauth2.py +96 -0
  632. tools/perplexity_tool.py +280 -0
  633. tools/polymarket/__init__.py +41 -0
  634. tools/polymarket/clob_adapter.py +76 -0
  635. tools/polymarket/models.py +182 -0
  636. tools/polymarket/service.py +2082 -0
  637. tools/self_env/__init__.py +61 -0
  638. tools/self_env/tool.py +274 -0
  639. tools/shell/__init__.py +80 -0
  640. tools/shell/backend_pool.py +118 -0
  641. tools/shell/discipline.py +62 -0
  642. tools/shell/executor.py +157 -0
  643. tools/shell/loopback_allow.py +87 -0
  644. tools/shell/process_registry.py +113 -0
  645. tools/shell/process_tool.py +131 -0
  646. tools/shell/state.py +129 -0
  647. tools/shell/tool.py +151 -0
  648. tools/task_tool.py +637 -0
  649. tools/twitter_tool.py +2086 -0
  650. tools/user_directory.py +179 -0
  651. tools/web_fetch/__init__.py +3 -0
  652. tools/web_fetch/fetcher.py +144 -0
  653. tools/web_fetch/render.py +44 -0
  654. tools/web_fetch/tool.py +60 -0
  655. tools/x402/__init__.py +60 -0
  656. tools/x402/client.py +47 -0
  657. tools/x402/invoice_tool.py +143 -0
  658. tools/x402/real_client.py +250 -0
  659. tools/x402/service.py +131 -0
  660. utils/README.md +498 -0
  661. utils/__init__.py +46 -0
  662. utils/auth_utils.py +114 -0
  663. utils/bounded_collections.py +162 -0
  664. utils/circuit_breaker.py +389 -0
  665. utils/gif_utils.py +435 -0
  666. utils/markdown_utils.py +291 -0
  667. utils/message_utils.py +147 -0
  668. utils/metrics.py +36 -0
  669. utils/path_validator.py +227 -0
  670. utils/rate_limit_manager.py +399 -0
  671. utils/result_size.py +296 -0
  672. utils/time_utils.py +206 -0
  673. utils/user_utils.py +188 -0
  674. webview/README.md +111 -0
  675. webview/RENAME_AND_ALIGN_HANDOFF.md +200 -0
  676. webview/__init__.py +8 -0
  677. webview/activity.py +636 -0
  678. webview/owner_auth.py +108 -0
  679. webview/pages.py +448 -0
  680. webview/repair_sessions.py +399 -0
  681. webview/server.py +4323 -0
  682. webview/server_launcher.py +112 -0
  683. webview/static/css/activity.css +89 -0
  684. webview/static/css/chat.css +1772 -0
  685. webview/static/css/components.css +1190 -0
  686. webview/static/css/config-panel.css +651 -0
  687. webview/static/css/pages/admin.css +766 -0
  688. webview/static/css/pages/profile.css +231 -0
  689. webview/static/css/pages/settings.css +297 -0
  690. webview/static/css/pages/signin.css +316 -0
  691. webview/static/css/style.css +4250 -0
  692. webview/static/css/variables.css +147 -0
  693. webview/static/css/workspace-fullwidth-fix.css +109 -0
  694. webview/static/img/favicon.ico +0 -0
  695. webview/static/js/activity.js +394 -0
  696. webview/static/js/admin/activity.js +186 -0
  697. webview/static/js/admin/dashboard.js +163 -0
  698. webview/static/js/admin/user_detail.js +400 -0
  699. webview/static/js/admin/users.js +174 -0
  700. webview/static/js/admin/utils.js +214 -0
  701. webview/static/js/chat.js +3178 -0
  702. webview/static/js/config-panel.js +522 -0
  703. webview/static/js/constants.js +20 -0
  704. webview/static/js/error-handler.js +226 -0
  705. webview/static/js/ethers.min.js +1 -0
  706. webview/static/js/event-filter.js +137 -0
  707. webview/static/js/event-store.js +351 -0
  708. webview/static/js/file-attachments.js +374 -0
  709. webview/static/js/file-loader.js +163 -0
  710. webview/static/js/index.js +103 -0
  711. webview/static/js/performance-utils.js +196 -0
  712. webview/static/js/profile.js +396 -0
  713. webview/static/js/screenshot.js +386 -0
  714. webview/static/js/session.js +1527 -0
  715. webview/static/js/settings.js +1288 -0
  716. webview/static/js/sidebar-data.js +766 -0
  717. webview/static/js/sidebar-toggle.js +296 -0
  718. webview/static/js/socket.io.min.js +7 -0
  719. webview/static/js/stats.js +355 -0
  720. webview/static/js/ui-utils.js +420 -0
  721. webview/static/js/workspace.js +966 -0
  722. webview/stats_service.py +613 -0
  723. webview/templates/__init__.py +1 -0
  724. webview/templates/__pycache__/__init__.cpython-311.pyc +0 -0
  725. webview/templates/activity.html +36 -0
  726. webview/templates/admin/activity.html +122 -0
  727. webview/templates/admin/dashboard.html +112 -0
  728. webview/templates/admin/user_detail.html +228 -0
  729. webview/templates/admin/users.html +105 -0
  730. webview/templates/autonomy.html +60 -0
  731. webview/templates/error.html +133 -0
  732. webview/templates/finance.html +90 -0
  733. webview/templates/identity.html +73 -0
  734. webview/templates/index.html +42 -0
  735. webview/templates/layout.html +125 -0
  736. webview/templates/memory.html +59 -0
  737. webview/templates/owner_login.html +15 -0
  738. webview/templates/profile.html +121 -0
  739. webview/templates/session.html +312 -0
  740. webview/templates/settings.html +534 -0
  741. webview/templates/sidebar.html +112 -0
  742. webview/templates/signin.html +213 -0
  743. webview/templates/status.html +14 -0
  744. webview/templates/system.html +45 -0
  745. webview/webgate.py +196 -0
avatar/studio.html ADDED
@@ -0,0 +1,373 @@
1
+ <title>Mindprint v2 — versatile agent avatars</title>
2
+ <link rel="preconnect" href="https://fonts.googleapis.com">
3
+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
4
+ <link href="https://fonts.googleapis.com/css2?family=VT323&family=JetBrains+Mono:wght@400;700&display=swap" rel="stylesheet">
5
+ <style>
6
+ :root{
7
+ /* aligned to polyrob dev portal — web/portal/styles/variables.css (terminal aesthetic) */
8
+ --bg:#080808;--panel:#0c0c0c;--panel-2:#0e0e0e;--terminal:#050505;
9
+ --line:#1a1a1a;--line-2:#242424;
10
+ --ink:#c0c0c0;--ink-dim:#909090;--ink-faint:#555;--ink-hi:#e6e6e6;
11
+ --accent:#56e2c2;--accent-blue:#56c2ff;--accent-dim:#1c4a42;
12
+ --mono:'JetBrains Mono','Courier New',monospace;
13
+ --display:'VT323',monospace;
14
+ --sans:'JetBrains Mono','Courier New',monospace;
15
+ }
16
+ *{box-sizing:border-box}
17
+ html,body{margin:0;background:var(--bg);color:var(--ink);font-family:var(--sans);-webkit-font-smoothing:antialiased}
18
+ body{padding:0 clamp(16px,4vw,56px) 80px;max-width:1400px;margin:0 auto}
19
+ .mono{font-family:var(--mono)}
20
+ header{padding:40px 0 26px;border-bottom:1px solid var(--line)}
21
+ .eyebrow{font-family:var(--mono);font-size:11px;letter-spacing:.34em;text-transform:uppercase;color:var(--accent);opacity:.9}
22
+ h1{font-weight:300;font-size:clamp(32px,6vw,62px);letter-spacing:-.02em;margin:.28em 0 .12em;line-height:.98}
23
+ h1 b{font-weight:600}
24
+ .lede{max-width:62ch;color:var(--ink-dim);font-size:15px;line-height:1.55;margin:0}
25
+ .lede em{color:var(--ink);font-style:normal}
26
+ .studio{display:grid;grid-template-columns:minmax(0,1.15fr) minmax(320px,.85fr);gap:clamp(20px,3vw,40px);margin-top:34px;align-items:start}
27
+ @media (max-width:900px){.studio{grid-template-columns:1fr}}
28
+ .stage{position:relative;border:1px solid var(--line);border-radius:8px;overflow:hidden;background:radial-gradient(120% 120% at 50% 34%,#070c11 0%,#000 72%)}
29
+ .stage canvas{display:block;width:100%;height:auto;aspect-ratio:1/1}
30
+ .hud{position:absolute;inset:0;pointer-events:none;padding:14px 16px;display:flex;flex-direction:column;justify-content:space-between}
31
+ .hud .row{display:flex;justify-content:space-between;align-items:flex-start;gap:12px}
32
+ .hud .tag{font-family:var(--mono);font-size:10.5px;letter-spacing:.18em;text-transform:uppercase;color:var(--ink-faint)}
33
+ .hud .seed{font-family:var(--mono);font-size:11px;color:var(--accent);opacity:.85}
34
+ .hud .traits{font-family:var(--mono);font-size:10.5px;color:var(--ink-dim);text-align:right;line-height:1.5;max-width:60%}
35
+ .panel{border:1px solid var(--line);border-radius:8px;background:var(--panel);overflow:hidden}
36
+ .panel+.panel{margin-top:14px}
37
+ .panel h2{margin:0;padding:11px 15px;font-family:var(--mono);font-size:11px;letter-spacing:.24em;text-transform:uppercase;color:var(--ink-dim);border-bottom:1px solid var(--line);background:var(--panel-2);display:flex;justify-content:space-between}
38
+ .panel h2 .k{color:var(--ink-faint);letter-spacing:.1em}
39
+ .pad{padding:15px}
40
+ .field{margin:0 0 14px}.field:last-child{margin-bottom:0}
41
+ label.cap{display:block;font-family:var(--mono);font-size:10.5px;letter-spacing:.16em;text-transform:uppercase;color:var(--ink-faint);margin-bottom:7px}
42
+ .val{color:var(--accent);float:right;text-transform:none;letter-spacing:0}
43
+ input[type=text]{width:100%;background:#05070a;border:1px solid var(--line-2);border-radius:5px;color:var(--ink);font-family:var(--mono);font-size:13px;padding:9px 11px;outline:none}
44
+ input[type=text]:focus{border-color:var(--accent-dim);box-shadow:0 0 0 1px var(--accent-dim)}
45
+ input[type=range]{-webkit-appearance:none;width:100%;height:2px;background:var(--line-2);border-radius:2px;outline:none;margin:6px 0}
46
+ input[type=range]::-webkit-slider-thumb{-webkit-appearance:none;width:14px;height:14px;border-radius:50%;background:var(--ink);border:2px solid var(--accent);cursor:pointer;box-shadow:0 0 8px rgba(67,230,255,.5)}
47
+ input[type=color]{width:46px;height:32px;border:1px solid var(--line-2);border-radius:6px;background:#05070a;cursor:pointer;padding:2px}
48
+ .colrow{display:flex;align-items:center;gap:10px}
49
+ .chips{display:flex;flex-wrap:wrap;gap:6px}
50
+ .chip{font-family:var(--mono);font-size:11px;padding:6px 10px;border-radius:5px;border:1px solid var(--line-2);background:#06090c;color:var(--ink-dim);cursor:pointer;transition:.14s}
51
+ .chip:hover{border-color:var(--ink-faint);color:var(--ink)}
52
+ .chip.on{border-color:var(--accent);color:var(--ink);background:rgba(67,230,255,.08)}
53
+ .btnrow{display:flex;gap:8px;flex-wrap:wrap}
54
+ button.act{flex:1;min-width:90px;font-family:var(--mono);font-size:11.5px;letter-spacing:.1em;text-transform:uppercase;padding:11px 12px;border-radius:5px;border:1px solid var(--line-2);background:#06090c;color:var(--ink);cursor:pointer;transition:.14s}
55
+ button.act:hover{border-color:var(--ink-faint)}
56
+ button.act.primary{background:var(--accent);color:#001a20;border-color:var(--accent);font-weight:600}
57
+ .hint{font-size:11.5px;color:var(--ink-faint);line-height:1.5;margin:10px 0 0}
58
+ .section{margin-top:56px;padding-top:30px;border-top:1px solid var(--line)}
59
+ .section h3{font-weight:300;font-size:clamp(22px,3vw,30px);margin:6px 0 6px}
60
+ .section p{color:var(--ink-dim);max-width:64ch;margin:0 0 22px;line-height:1.55;font-size:14px}
61
+ .wall{display:grid;grid-template-columns:repeat(auto-fill,minmax(140px,1fr));gap:12px}
62
+ .cell{border:1px solid var(--line);border-radius:8px;overflow:hidden;background:#000;cursor:pointer;transition:.16s;position:relative}
63
+ .cell:hover{border-color:var(--accent-dim);transform:translateY(-2px)}
64
+ .cell canvas{display:block;width:100%;aspect-ratio:1/1}
65
+ .cell .cap{position:absolute;left:0;right:0;bottom:0;padding:7px 9px;background:linear-gradient(0deg,rgba(0,0,0,.86),transparent);font-family:var(--mono);font-size:10.5px;color:var(--ink)}
66
+ .cell .cap small{display:block;color:var(--ink-faint);font-size:9px;letter-spacing:.1em;text-transform:uppercase;margin-top:1px}
67
+ footer{margin-top:60px;padding-top:20px;border-top:1px solid var(--line);font-family:var(--mono);font-size:11px;color:var(--ink-faint);display:flex;justify-content:space-between;flex-wrap:wrap;gap:10px}
68
+ textarea#cfgOut{width:100%;height:70px;background:#05070a;border:1px solid var(--line-2);border-radius:5px;color:var(--accent);font-family:var(--mono);font-size:11px;padding:8px;resize:vertical}
69
+
70
+ /* ── aligned to polyrob dev portal: sharp corners, display headings, terminal bg ── */
71
+ h1{font-family:var(--display);font-weight:400;letter-spacing:1px;color:var(--ink-hi)}
72
+ h1 b{font-family:var(--display);font-weight:400;color:var(--accent)}
73
+ .section h3{font-family:var(--display);letter-spacing:1px;color:var(--ink-hi)}
74
+ .panel,.stage,.chip,button.act,input[type=text],input[type=color],.cell,textarea#cfgOut{border-radius:0}
75
+ input[type=range]::-webkit-slider-thumb,input[type=range]::-moz-range-thumb{border-radius:0}
76
+ input[type=text],textarea#cfgOut{background:var(--terminal)}
77
+ .chip,button.act{background:var(--panel-2)}
78
+ .panel h2{background:var(--terminal)}
79
+ button.act.primary{color:#04140f}
80
+ </style>
81
+
82
+ <header>
83
+ <span class="eyebrow">POLYROB · avatar system · v2 versatile</span>
84
+ <h1>Mindprint<b>.</b></h1>
85
+ <p class="lede">Give your agent a face and a voice in four steps —
86
+ <em>① name it · ② shuffle a look · ③ give it a voice · ④ save</em>.
87
+ Deterministic from the name; face and voice shuffle independently.</p>
88
+ </header>
89
+
90
+ <div class="studio">
91
+ <div class="stage">
92
+ <canvas id="hero" width="720" height="720" aria-label="Live generated agent avatar"></canvas>
93
+ <div class="hud">
94
+ <div class="row"><span class="tag">mindprint · v2</span><span class="seed mono" id="seedOut">0x0000</span></div>
95
+ <div class="row" style="align-items:flex-end"><span class="tag" id="nameOut">—</span><span class="traits" id="traitsOut"></span></div>
96
+ </div>
97
+ </div>
98
+
99
+ <div class="controls">
100
+ <div class="panel">
101
+ <h2>① Name <span class="k">seed</span></h2>
102
+ <div class="pad">
103
+ <div class="field">
104
+ <label class="cap" for="nameIn">Agent name / id</label>
105
+ <input type="text" id="nameIn" value="Rob Ottmachin" spellcheck="false" autocomplete="off">
106
+ </div>
107
+ <div class="btnrow">
108
+ <button class="act primary" id="shuffle">⤮ Shuffle face</button>
109
+ </div>
110
+ <p class="hint">Name → seed → face. <b>Shuffle face</b> rolls a new look (traits + color) and <b>keeps your voice</b>. Or click any face in the gallery below.</p>
111
+ </div>
112
+ </div>
113
+
114
+ <div class="panel">
115
+ <h2>② Look <span class="k">color · unified</span></h2>
116
+ <div class="pad">
117
+ <div class="field">
118
+ <label class="cap">Base color <span class="val" id="colName">auto</span></label>
119
+ <div class="colrow">
120
+ <input type="color" id="colIn" value="#43e6ff">
121
+ <button class="chip" id="colAuto">auto (from seed)</button>
122
+ <button class="chip" id="colRand">random color</button>
123
+ </div>
124
+ <p class="hint">Face, eyes &amp; mouth all share this one hue. “auto” derives it from the name.</p>
125
+ </div>
126
+ <div class="field">
127
+ <label class="cap">Palette mode <span class="val" id="modeName">solid</span></label>
128
+ <div class="chips" id="modeChips"></div>
129
+ </div>
130
+ </div>
131
+ </div>
132
+
133
+ <div class="panel">
134
+ <h2>Mesh <span class="k">advanced · optional</span></h2>
135
+ <div class="pad">
136
+ <div class="field"><label class="cap" for="densIn">Density <span class="val" id="densVal">56</span></label>
137
+ <input type="range" id="densIn" min="30" max="76" value="56" step="2"></div>
138
+ <div class="field"><label class="cap" for="grainIn">Data grain <span class="val" id="grainVal">0.18</span></label>
139
+ <input type="range" id="grainIn" min="0" max="100" value="18"></div>
140
+ <div class="field"><label class="cap" for="shapeSel">Cell shape <span class="val" id="shapeName">dot</span></label>
141
+ <div class="chips" id="shapeChips"></div></div>
142
+ </div>
143
+ </div>
144
+
145
+ <div class="panel">
146
+ <h2>③ Voice <span class="k">signature · separate from face</span></h2>
147
+ <div class="pad">
148
+ <div class="field">
149
+ <label class="cap" for="sayIn">Say something</label>
150
+ <input type="text" id="sayIn" value="Hi, I'm Rob — your agent. What can I help with?" spellcheck="false">
151
+ </div>
152
+ <div class="btnrow">
153
+ <button class="act primary" id="shuffleVoice">🎲 Shuffle voice</button>
154
+ <button class="act" id="speak">▶ Speak</button>
155
+ <button class="act" id="voiceAuto">auto</button>
156
+ </div>
157
+ <div class="field"><label class="cap" for="pitchIn">Pitch <span class="val" id="pitchVal">1.00</span></label>
158
+ <input type="range" id="pitchIn" min="0" max="200" value="100"></div>
159
+ <div class="field"><label class="cap" for="rateIn">Rate <span class="val" id="rateVal">1.00</span></label>
160
+ <input type="range" id="rateIn" min="50" max="160" value="100"></div>
161
+ <div class="field"><label class="cap" for="timbreIn">Timbre <span class="val" id="timbreVal">0.50</span></label>
162
+ <input type="range" id="timbreIn" min="0" max="100" value="50"></div>
163
+ <p class="hint" id="voiceHint">Seeded per agent and <em>saved into the config</em> — clear
164
+ English voices only. The face opens its mouth as it speaks; the picked voice shows here.</p>
165
+ </div>
166
+ </div>
167
+
168
+ <div class="panel">
169
+ <h2>④ Save <span class="k">freeze rob.json</span></h2>
170
+ <div class="pad">
171
+ <div class="btnrow">
172
+ <button class="act primary" id="copyCfg">Copy config JSON</button>
173
+ <button class="act" id="export">Export PNG</button>
174
+ </div>
175
+ <textarea id="cfgOut" readonly spellcheck="false"></textarea>
176
+ <p class="hint">This is the exact reproducible config the pipeline freezes into <span class="mono">avatar/config/rob.json</span>.</p>
177
+ </div>
178
+ </div>
179
+ </div>
180
+ </div>
181
+
182
+ <div class="section">
183
+ <span class="eyebrow">versatility · same engine</span>
184
+ <h3>One species, endless characters</h3>
185
+ <p>Sixteen agents, each a deterministic Mindprint from its name — different colors, eyes,
186
+ mouths, antennas, auras. Click any to load it. Rare rolls (cyclops, three-eyes, heart
187
+ antenna, halo) show up occasionally, exactly like an NFT collection.</p>
188
+ <div class="wall" id="wall"></div>
189
+ </div>
190
+
191
+ <footer><span>MINDPRINT v2 — versatile generative avatars</span><span>deterministic · client-side</span></footer>
192
+
193
+ <script src="mindprint.js"></script>
194
+ <script>
195
+ "use strict";
196
+ const clamp=(x,a,b)=>x<a?a:x>b?b:x, lerp=(a,b,t)=>a+(b-a)*t;
197
+ /* ---------------- Studio wiring ---------------- */
198
+ const reduceMotion=matchMedia("(prefers-reduced-motion: reduce)").matches;
199
+ const heroCanvas=document.getElementById("hero"),hctx=heroCanvas.getContext("2d");
200
+ let hero=new Mindprint("Rob Ottmachin");
201
+ const nameIn=document.getElementById("nameIn");
202
+ let variant="";
203
+
204
+ const modeChips=document.getElementById("modeChips");
205
+ ["auto",...MODES].forEach((m,i)=>{const b=document.createElement("button");
206
+ b.className="chip"+(i===0?" on":"");b.dataset.mode=m;b.textContent=m;modeChips.appendChild(b);});
207
+ modeChips.addEventListener("click",e=>{const b=e.target.closest(".chip");if(!b)return;
208
+ [...modeChips.children].forEach(c=>c.classList.remove("on"));b.classList.add("on");
209
+ hero.override.mode=b.dataset.mode==="auto"?null:b.dataset.mode;
210
+ document.getElementById("modeName").textContent=b.dataset.mode;syncCfg();});
211
+
212
+ const shapeChips=document.getElementById("shapeChips");
213
+ ["auto",...SHAPES].forEach((s,i)=>{const b=document.createElement("button");
214
+ b.className="chip"+(i===0?" on":"");b.dataset.shape=s;b.textContent=s;shapeChips.appendChild(b);});
215
+ shapeChips.addEventListener("click",e=>{const b=e.target.closest(".chip");if(!b)return;
216
+ [...shapeChips.children].forEach(c=>c.classList.remove("on"));b.classList.add("on");
217
+ hero.override.shape=b.dataset.shape==="auto"?null:SHAPES.indexOf(b.dataset.shape);hero.N=0;
218
+ document.getElementById("shapeName").textContent=b.dataset.shape;syncCfg();});
219
+
220
+ const colIn=document.getElementById("colIn");
221
+ colIn.addEventListener("input",()=>{hero.override.color=colIn.value;
222
+ document.getElementById("colName").textContent=colIn.value;syncCfg();});
223
+ document.getElementById("colAuto").addEventListener("click",()=>{delete hero.override.color;
224
+ document.getElementById("colName").textContent="auto";syncCfg();});
225
+ document.getElementById("colRand").addEventListener("click",()=>{
226
+ const h=Math.floor(Math.random()*360),rgb=hsl2rgb(h,0.85,0.55);
227
+ const hex="#"+rgb.map(v=>("0"+(v|0).toString(16)).slice(-2)).join("");
228
+ colIn.value=hex;hero.override.color=hex;document.getElementById("colName").textContent=hex;syncCfg();});
229
+
230
+ function bindRange(id,valId,map,apply){const el=document.getElementById(id),out=document.getElementById(valId);
231
+ el.addEventListener("input",()=>{const v=map(+el.value);out.textContent=v.toString();apply(v);syncCfg();});}
232
+ bindRange("densIn","densVal",v=>v,v=>{hero.override.dens=v;hero.N=0;});
233
+ bindRange("grainIn","grainVal",v=>+(v/100).toFixed(2),v=>{hero.override.grain=v;});
234
+
235
+ /* ---- voice ---- */
236
+ const audio={amp:0,target:0,floor:0,speaking:false};
237
+ const synth=window.speechSynthesis; let voices=[];
238
+ /* Many system voices are non-English or novelty (macOS: Zarvox, Whisper, Bells, Bubbles…),
239
+ which sound mumbly/unintelligible. Restrict the timbre pool to CLEAR English voices so
240
+ every roll is understandable. (The stored timbre 0-1 is unchanged — this is preview only.) */
241
+ const NOVELTY=/\b(albert|bad news|bahh|bells|boing|bubbles|cellos|deranged|good news|jester|organ|superstar|trinoids|whisper|wobble|zarvox|flo|grandma|grandpa|reed|rocko|sandy|shelley|eddy|junior|kathy|princess|ralph)\b/i;
242
+ function loadVoices(){voices=synth?synth.getVoices():[];}
243
+ if(synth){loadVoices();synth.onvoiceschanged=loadVoices;}
244
+ function englishVoices(){
245
+ const en=voices.filter(v=>/^en(-|_|$)/i.test(v.lang||""));
246
+ const clear=en.filter(v=>!NOVELTY.test(v.name||""));
247
+ const pool=(clear.length?clear:(en.length?en:voices)).slice();
248
+ pool.sort((a,b)=>(a.name||"").localeCompare(b.name||"")); // stable timbre→voice mapping
249
+ return pool;
250
+ }
251
+ function setVoiceOverride(k,v){hero.override.voice=hero.override.voice||{};hero.override.voice[k]=v;syncCfg();}
252
+ document.getElementById("pitchIn").addEventListener("input",e=>{const v=+(e.target.value/100).toFixed(2);
253
+ document.getElementById("pitchVal").textContent=v.toFixed(2);setVoiceOverride("pitch",v);});
254
+ document.getElementById("rateIn").addEventListener("input",e=>{const v=+(e.target.value/100).toFixed(2);
255
+ document.getElementById("rateVal").textContent=v.toFixed(2);setVoiceOverride("rate",v);});
256
+ document.getElementById("timbreIn").addEventListener("input",e=>{const v=+(e.target.value/100).toFixed(2);
257
+ document.getElementById("timbreVal").textContent=v.toFixed(2);setVoiceOverride("timbre",v);});
258
+ document.getElementById("voiceAuto").addEventListener("click",()=>{delete hero.override.voice;syncVoice();syncCfg();});
259
+ document.getElementById("shuffleVoice").addEventListener("click",()=>{ // voice ONLY — face untouched
260
+ hero.override.voice={
261
+ pitch:+(0.75+Math.random()*0.70).toFixed(2), // 0.75–1.45
262
+ rate: +(0.90+Math.random()*0.35).toFixed(2), // 0.90–1.25
263
+ timbre:+Math.random().toFixed(2) // 0–1 (picks a different clear-English voice)
264
+ };
265
+ syncVoice();syncCfg();speakNow(); // hear it immediately
266
+ });
267
+ document.getElementById("speak").addEventListener("click",speakNow);
268
+ function speakNow(){
269
+ const vc=hero.voiceCfg();
270
+ if(!synth){audio.speaking=true;audio.target=0.7;audio.floor=0.18;setTimeout(()=>{audio.speaking=false;audio.target=0;audio.floor=0;},1500);return;}
271
+ synth.cancel();
272
+ const u=new SpeechSynthesisUtterance(document.getElementById("sayIn").value||"Hello!");
273
+ const pool=englishVoices();
274
+ if(pool.length){
275
+ u.voice=pool[Math.floor(vc.timbre*pool.length)%pool.length];
276
+ document.getElementById("voiceHint").textContent=
277
+ "voice: "+u.voice.name+" ("+u.voice.lang+") · pitch "+vc.pitch.toFixed(2)+" · rate "+vc.rate.toFixed(2);
278
+ }
279
+ u.lang=(u.voice&&u.voice.lang)||"en-US";
280
+ u.pitch=vc.pitch;u.rate=vc.rate;
281
+ u.onstart=()=>{audio.speaking=true;};
282
+ u.onboundary=()=>{audio.target=0.55+Math.random()*0.45;audio.floor=0.18;};
283
+ u.onend=()=>{audio.speaking=false;audio.target=0;audio.floor=0;};
284
+ audio.speaking=true;audio.target=0.7;audio.floor=0.18;synth.speak(u);
285
+ }
286
+ function updateAmp(dt){
287
+ if(audio.speaking){audio.target=Math.max(audio.floor,audio.target*Math.pow(0.12,dt));
288
+ const fl=0.12*(Math.sin(performance.now()*0.03)+Math.sin(performance.now()*0.017))*0.5;
289
+ audio.amp=lerp(audio.amp,clamp(audio.target+fl*audio.target,0,1),0.35);
290
+ }else audio.amp=lerp(audio.amp,0,0.12);
291
+ }
292
+ function syncVoice(){const v=hero.voiceCfg();
293
+ document.getElementById("pitchIn").value=Math.round(v.pitch*100);document.getElementById("pitchVal").textContent=v.pitch.toFixed(2);
294
+ document.getElementById("rateIn").value=Math.round(v.rate*100);document.getElementById("rateVal").textContent=v.rate.toFixed(2);
295
+ document.getElementById("timbreIn").value=Math.round(v.timbre*100);document.getElementById("timbreVal").textContent=v.timbre.toFixed(2);}
296
+
297
+ function reseed(keepVoice){
298
+ const kv = keepVoice ? hero.override.voice : undefined; // preserve a pinned voice across a face shuffle
299
+ hero.setSeed(nameIn.value+variant);hero.override={};hero.N=0;
300
+ if(kv) hero.override.voice=kv;
301
+ [...modeChips.children].forEach((c,i)=>c.classList.toggle("on",i===0));
302
+ [...shapeChips.children].forEach((c,i)=>c.classList.toggle("on",i===0));
303
+ document.getElementById("colName").textContent="auto";
304
+ document.getElementById("modeName").textContent="auto";
305
+ document.getElementById("shapeName").textContent="auto";
306
+ refreshHud();syncDials();syncVoice();syncCfg();
307
+ }
308
+ function refreshHud(){
309
+ document.getElementById("nameOut").textContent=nameIn.value||"—";
310
+ document.getElementById("seedOut").textContent=hero.hex;
311
+ const tr=hero.traitList();
312
+ document.getElementById("traitsOut").innerHTML=
313
+ `<b style="color:var(--accent)">${tr.tier}</b> · ${tr.mode} · ${tr.head}<br>eyes ${tr.eyes} · mouth ${tr.mouth}<br>ant ${tr.antenna} · ${tr.aura}`;
314
+ }
315
+ function syncDials(){const p=hero.p;
316
+ document.getElementById("densIn").value=p.densAuto;document.getElementById("densVal").textContent=p.densAuto;
317
+ document.getElementById("grainIn").value=Math.round(p.grainAuto*100);document.getElementById("grainVal").textContent=p.grainAuto.toFixed(2);}
318
+ function syncCfg(){
319
+ refreshHud();
320
+ const o=hero.override,tr=hero.traitList();
321
+ const cfg={seed:nameIn.value,variant,override:{},size:768,generator:"mindprint@v2",
322
+ traits:{tier:tr.tier,eyes:tr.eyes,brow:tr.brow,mouth:tr.mouth,antenna:tr.antenna,aura:tr.aura,head:tr.head,mode:tr.mode},
323
+ voice:hero.voiceCfg()};
324
+ if(o.color)cfg.override.color=o.color;
325
+ if(o.mode!=null)cfg.override.mode=o.mode;
326
+ if(o.dens!=null)cfg.override.dens=o.dens;
327
+ if(o.grain!=null)cfg.override.grain=+o.grain;
328
+ if(o.shape!=null)cfg.override.shape=SHAPES[o.shape];
329
+ if(o.voice)cfg.override.voice=o.voice;
330
+ document.getElementById("cfgOut").value=JSON.stringify(cfg);
331
+ }
332
+ nameIn.addEventListener("input",()=>{variant="";reseed(false);}); // new name = fresh everything
333
+ document.getElementById("shuffle").addEventListener("click",()=>{ // face only; keeps a pinned voice
334
+ variant="#"+Math.floor(Math.random()*1e9).toString(36);reseed(true);});
335
+ document.getElementById("copyCfg").addEventListener("click",()=>{
336
+ const ta=document.getElementById("cfgOut");ta.select();
337
+ navigator.clipboard.writeText(ta.value).catch(()=>document.execCommand("copy"));
338
+ const b=document.getElementById("copyCfg");b.textContent="copied ✓";setTimeout(()=>b.textContent="Copy config JSON",1200);});
339
+ document.getElementById("export").addEventListener("click",()=>{
340
+ const off=document.createElement("canvas");off.width=off.height=768;
341
+ const octx=off.getContext("2d");hero.N=0;hero.render(octx,768,1.0,0,{still:true});hero.N=0;
342
+ const a=document.createElement("a");
343
+ a.download=(nameIn.value.replace(/[^\w]+/g,"_")||"mindprint")+".png";
344
+ a.href=off.toDataURL("image/png");a.click();});
345
+
346
+ /* gallery */
347
+ const AGENTS=["Rob Ottmachin","Ada Nine","Vesper Kade","Kilo Prime","Juno-7","Marrow",
348
+ "Echo Vane","Sable Quinn","Nyx Orbital","Orrery","Pixel","Wren Halcyon",
349
+ "Tycho","Bloom","Quill","Nova Pax"];
350
+ const wall=document.getElementById("wall"),gals=[];
351
+ AGENTS.forEach((name,k)=>{
352
+ const cell=document.createElement("div");cell.className="cell";
353
+ const cv=document.createElement("canvas");cv.width=cv.height=280;
354
+ const cap=document.createElement("div");cap.className="cap";
355
+ const mp=new Mindprint(name);const tr=mp.traitList();
356
+ cap.innerHTML=`${name}<small>${tr.eyes} · ${tr.antenna} · ${tr.aura}</small>`;
357
+ cell.appendChild(cv);cell.appendChild(cap);wall.appendChild(cell);
358
+ cell.addEventListener("click",()=>{variant="";nameIn.value=name;reseed(false);window.scrollTo({top:0,behavior:reduceMotion?"auto":"smooth"});});
359
+ gals.push({mp,ctx:cv.getContext("2d"),size:280,phase:(k*1.7)%6});
360
+ });
361
+
362
+ let last=performance.now(),galTick=0;
363
+ function frame(now){
364
+ const dt=Math.min(0.05,(now-last)/1000);last=now;const t=now/1000;
365
+ updateAmp(dt);
366
+ hero.render(hctx,heroCanvas.width,t,audio.amp,{still:reduceMotion});
367
+ galTick+=dt;
368
+ if(galTick>0.05){galTick=0;for(const g of gals)g.mp.render(g.ctx,g.size,t+g.phase,0,{still:reduceMotion});}
369
+ requestAnimationFrame(frame);
370
+ }
371
+ reseed();
372
+ requestAnimationFrame(frame);
373
+ </script>
@@ -0,0 +1,44 @@
1
+ /* Read-only live avatar embed for the POLYROB console.
2
+ * Loads AFTER avatar/mindprint.js (which set window.Mindprint), fetches the
3
+ * instance's frozen /pfp.json, and animates the EXACT engine on a <canvas>.
4
+ * Progressive enhancement: if there is no avatar / no engine / reduced motion,
5
+ * it leaves the <img src="/pfp.png"> fallback in place. */
6
+ (async function () {
7
+ "use strict";
8
+ var cv = document.getElementById("agent-avatar");
9
+ if (!cv || typeof window.Mindprint === "undefined") return;
10
+
11
+ var cfg;
12
+ try {
13
+ var res = await fetch("/pfp.json");
14
+ if (!res.ok) return; // 404 -> no avatar yet, keep the fallback
15
+ cfg = await res.json();
16
+ } catch (e) { return; }
17
+ if (!cfg || !cfg.seed) return;
18
+
19
+ var SHAPES = window.SHAPES || ["dot", "square", "scanline"];
20
+ var mp = new window.Mindprint((cfg.seed || "") + (cfg.variant || ""));
21
+ var ov = Object.assign({}, cfg.override || {});
22
+ if (typeof ov.shape === "string") ov.shape = SHAPES.indexOf(ov.shape); // name -> index
23
+ Object.assign(mp.override, ov);
24
+
25
+ var ctx = cv.getContext("2d");
26
+ var size = cv.width;
27
+
28
+ // the live canvas is up: reveal it, hide the <img> fallback
29
+ var img = document.getElementById("agent-avatar-fallback");
30
+ if (img) img.style.display = "none";
31
+ cv.style.display = "block";
32
+
33
+ var reduce = window.matchMedia && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
34
+ if (reduce) { mp.N = 0; mp.render(ctx, size, 1.0, 0, { still: true }); mp.N = 0; return; }
35
+
36
+ var t0 = null, running = true;
37
+ document.addEventListener("visibilitychange", function () { running = !document.hidden; });
38
+ function loop(ts) {
39
+ if (t0 === null) t0 = ts;
40
+ if (running) mp.render(ctx, size, (ts - t0) / 1000, 0, { still: false });
41
+ requestAnimationFrame(loop);
42
+ }
43
+ requestAnimationFrame(loop);
44
+ })();
cli/README.md ADDED
@@ -0,0 +1,89 @@
1
+ # CLI Package — terminal-native `polyrob`
2
+
3
+ _Last reviewed: 2026-06-30. For the user-facing command reference see [../docs/guide/cli.md](../docs/guide/cli.md); for env flags see ../docs/CONFIGURATION.md._
4
+
5
+ ## Overview
6
+
7
+ The `cli` package is the terminal-native surface for polyrob. It is a **first-class
8
+ surface** that runs the *same* Task agent as the API — not a thin wrapper. It
9
+ provides:
10
+
11
+ - `polyrob run <task>` — one-shot, non-interactive execution.
12
+ - `polyrob` / `polyrob chat` — an interactive REPL with live tool transcripts,
13
+ slash commands, and a bottom-anchored status toolbar.
14
+ - `polyrob init` / `doctor` / `config` — setup, diagnostics, and configuration.
15
+ - Surface runners and admin: `serve`, `dashboard`, `telegram`, `email`, `owner`,
16
+ `kb`, plus `tools`, `skills`, `model`, `session`.
17
+
18
+ ## Design principles
19
+
20
+ - **One agent core.** The REPL connects to the agent through the same `Surface`
21
+ contract the network surfaces use (`cli_surface.py::CLISurface`), so CLI output
22
+ ordering matches every other surface.
23
+ - **The renderer owns pixels.** All bubble/dedup/finalize logic lives in the Rich
24
+ renderer; the surface only forwards the unified outbound stream into it.
25
+ - **Fail-open rendering.** A rendering error must never break the agent loop.
26
+ - **Local-first.** Under `POLYROB_LOCAL=true` the CLI container defaults the *safe*
27
+ autonomy flags on as a group; the server never does this.
28
+
29
+ ## Package structure
30
+
31
+ ```
32
+ cli/
33
+ ├── polyrob.py # Click entry point (console_scripts) — registers every
34
+ │ # subcommand; bare invocation / `chat` open the REPL
35
+ ├── cli_surface.py # CLISurface — the CLI as a Surface contract consumer;
36
+ │ # forwards the outbound stream into the renderer
37
+ ├── config_store.py # Key-aware provider/model resolution from ~/.polyrob/.env
38
+ │ # (auto-detects the provider whose API key is present)
39
+ ├── inventory.py # Product-facing tool catalog backing `polyrob tools`
40
+ ├── keys.py # API-key helpers
41
+ ├── gitignore.py # ensures ./.polyrob is gitignored in a project
42
+ ├── commands/ # One Click module per subcommand (thin entry points)
43
+ │ ├── _bootstrap.py # shared container/bootstrap helpers
44
+ │ ├── _errors.py # uniform error formatting
45
+ │ ├── run.py # `polyrob run` (--model/-m, --provider/-p, --tools/-t,
46
+ │ │ # --toolset, --max-steps, --plain, --verbose/-v)
47
+ │ ├── chat.py # REPL launcher (run_repl)
48
+ │ ├── init.py # first-run setup wizard
49
+ │ ├── doctor.py # environment diagnostics
50
+ │ ├── config.py # show / set / path
51
+ │ ├── model.py # set-default <provider> <model> (alias: models)
52
+ │ ├── session.py # cancel <id> (alias: sessions)
53
+ │ ├── tools.py skills.py kb.py
54
+ │ ├── serve.py dashboard.py # local REST API + single-user web dashboard
55
+ │ └── telegram.py email.py owner.py # chat-surface runners + owner admin
56
+ └── ui/ # REPL rendering + input
57
+ ├── app.py # prompt_toolkit PromptSession + bottom toolbar
58
+ ├── persistent_loop.py# bottom-anchored persistent-input loop
59
+ │ # (gated POLYROB_PERSISTENT_INPUT)
60
+ ├── rich_renderer.py # Rich inline-scrollback renderer (the pixel owner)
61
+ ├── blocks.py # pure RenderEvent → Rich renderable builders
62
+ ├── activity.py # the single transient "working…" indicator
63
+ ├── lifecycle.py # SSOT for "is a turn active, and for how long"
64
+ ├── live_hooks.py events.py event_registry.py
65
+ ├── banner.py dialog.py bootstrap_notice.py
66
+ └── commands/ # slash-command registry + handlers
67
+ ├── registry.py # CommandRegistry / Command
68
+ └── handlers.py # /help /status /model /memory /autonomy /goals … (25)
69
+ ```
70
+
71
+ ## Key invariants
72
+
73
+ - **Provider/model auto-resolves** from whichever API key is present
74
+ (`config_store.resolve_provider_model`); explicit `-p`/`-m` or `DEFAULT_PROVIDER`
75
+ still win.
76
+ - **Interactive idle-gate.** The REPL marks itself busy per turn so background
77
+ goal/cron tickers skip a tick while a live turn runs — they share one CWD, so
78
+ this prevents file corruption (`core/interactive_gate.py`).
79
+ - **Sub-agent output is suppressed** in the transcript (a producer-side concern;
80
+ the surface carries no agent id).
81
+ - **Tool calls are visible by default** (`→ name(args)` / `✓ name·dur·preview`);
82
+ `/quiet` mutes them, `/verbose` shows the raw trace. Args/previews are
83
+ secret-scrubbed before display (`cli/ui/secrets.py`).
84
+
85
+ ## Related
86
+
87
+ - Surface contract: `core/surfaces/surface.py`
88
+ - Autonomy tickers started by the REPL under local mode: `core/autonomy_runtime.py`
89
+ - Network chat surfaces: [`../surfaces/`](../surfaces/README.md)
cli/__init__.py ADDED
File without changes
cli/cli_surface.py ADDED
@@ -0,0 +1,67 @@
1
+ """P2a: CLISurface — the CLI as a Surface contract consumer.
2
+
3
+ Thin transport over the existing renderer: the renderer stays the pixel owner
4
+ (all the R1/R2/OR-2/OR-7 bubble/dedup logic lives in on_turn_end and is untouched).
5
+ CLISurface forwards the unified outbound stream into renderer.on_stream_delta —
6
+ the same seam the legacy make_stream_callback used — so flag-ON routing through
7
+ the router produces the same ordered delta sequence (the CLI semantic golden).
8
+
9
+ Sub-agent filtering is NOT done here: the OutboundMessage carries no agent id, so
10
+ filtering is a PRODUCER concern (the stream mirror is attached only for the main
11
+ agent in _register_stream_callback). Finalize (partial=False stream) is a no-op
12
+ because on_turn_end owns the CLI's end-of-turn rendering — emitting here would
13
+ double-render. Fully fail-open: a renderer error never propagates into the loop.
14
+ """
15
+ import logging
16
+ from typing import Any, Callable, Optional
17
+
18
+ from core.surfaces.surface import Surface
19
+ from core.surfaces.envelopes import OutboundMessage, SendResult, SurfaceCapabilities
20
+
21
+ logger = logging.getLogger(__name__)
22
+
23
+
24
+ class CLISurface(Surface):
25
+ def __init__(self, renderer: Any, main_agent_id: Optional[Callable[[], str]] = None) -> None:
26
+ super().__init__()
27
+ self._renderer = renderer
28
+ # Retained for symmetry with make_stream_callback; producer-side filtering
29
+ # is preferred, so this is currently unused by the surface itself.
30
+ self._main_agent_id = main_agent_id
31
+
32
+ @property
33
+ def surface_id(self) -> str:
34
+ return "cli"
35
+
36
+ @property
37
+ def capabilities(self) -> SurfaceCapabilities:
38
+ return SurfaceCapabilities(
39
+ supports_streaming=True,
40
+ supports_edit=True,
41
+ supports_interactive_ask=True,
42
+ is_multi_tenant=False,
43
+ markdown_flavor="none",
44
+ )
45
+
46
+ async def send(self, msg: OutboundMessage) -> SendResult:
47
+ try:
48
+ self._renderer.on_stream_delta(msg.text)
49
+ except Exception as e: # fail-open: rendering must never break the loop
50
+ logger.debug("CLISurface.send render error (ignored): %s", e)
51
+ return SendResult(success=True)
52
+
53
+ async def stream(self, msg: OutboundMessage) -> None:
54
+ # CLI renders deltas LIVE (override the buffering default). Finalize
55
+ # (partial=False) is a no-op: on_turn_end owns end-of-turn rendering.
56
+ if not msg.partial:
57
+ return
58
+ try:
59
+ self._renderer.on_stream_delta(msg.text)
60
+ except Exception as e:
61
+ logger.debug("CLISurface.stream render error (ignored): %s", e)
62
+
63
+ async def start(self, container) -> None:
64
+ return None
65
+
66
+ async def stop(self) -> None:
67
+ return None
File without changes
@@ -0,0 +1,49 @@
1
+ """Shared CLI bootstrap helpers (Phase 5).
2
+
3
+ The single home for the *narrow* bootstrap-output suppression used by both the
4
+ REPL (``chat.py``) and the one-shot path (``run.py``). Proposal §9: the
5
+ whole-phase ``/dev/null`` redirect is gone — we suppress only the noisy MCP /
6
+ gRPC bootstrap prints that arrive on stderr during ``build_cli_container`` and
7
+ session creation. Once the renderer is live it owns stdout, and any error
8
+ raised inside the window surfaces (the restore is in ``finally``).
9
+ """
10
+
11
+ from __future__ import annotations
12
+
13
+ import contextlib
14
+ import os
15
+ import sys
16
+
17
+
18
+ @contextlib.contextmanager
19
+ def suppress_bootstrap_output():
20
+ """Silence Python-level stdout/stderr plus OS fd 2 for a bootstrap window.
21
+
22
+ ``sys.stdout``/``sys.stderr`` are rebound to ``/dev/null`` (the MCP config
23
+ loader prints on stdout) and fd 2 is dup'd over so C-extension/gRPC noise
24
+ is caught too. OS fd 1 is intentionally left alone: a live renderer's
25
+ ``Console`` holds the real file object captured before this window, so it
26
+ is never clobbered. Note: ``sys.stdout`` (the Python object) IS rebound
27
+ below; "left alone" refers only to OS-level fd 1, which C extensions write
28
+ to directly. Restoration lives in ``finally`` so an exception raised
29
+ inside the block — e.g. the per-user session-limit ``AgentError`` from
30
+ ``create_session`` — cannot leave output pointed at ``/dev/null`` (which
31
+ would make the error invisible to the user).
32
+ """
33
+ devnull = open(os.devnull, "w")
34
+ saved_stdout, saved_stderr = sys.stdout, sys.stderr
35
+ try:
36
+ saved_fd2 = os.dup(2)
37
+ except Exception:
38
+ devnull.close()
39
+ raise
40
+ sys.stdout = devnull
41
+ sys.stderr = devnull
42
+ os.dup2(devnull.fileno(), 2)
43
+ try:
44
+ yield
45
+ finally:
46
+ sys.stdout, sys.stderr = saved_stdout, saved_stderr
47
+ os.dup2(saved_fd2, 2)
48
+ os.close(saved_fd2)
49
+ devnull.close()