socialcli 0.3.12__tar.gz → 0.3.14__tar.gz

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 (201) hide show
  1. {socialcli-0.3.12 → socialcli-0.3.14}/PKG-INFO +2 -2
  2. {socialcli-0.3.12 → socialcli-0.3.14}/pyproject.toml +2 -2
  3. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/agent_errors.py +22 -1
  4. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/agent_guide.py +1 -1
  5. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/agent_journey.py +3 -3
  6. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/capabilities.yml +51 -0
  7. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/cli.py +1 -1
  8. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/connections/account_cli.py +165 -10
  9. socialcli-0.3.14/socialctl/connections/brand_binding.py +208 -0
  10. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/connections/cli.py +12 -1
  11. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/connections/client.py +6 -0
  12. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/connections/file_store.py +4 -1
  13. socialcli-0.3.14/socialctl/connections/rotation_cli.py +185 -0
  14. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/connections/saas_client.py +17 -2
  15. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/context.py +3 -1
  16. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/context_cli.py +1 -1
  17. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/entrypoint.py +2 -2
  18. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/ui/assets/agent-actions.json +223 -0
  19. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/ui/assets/agent-journey.json +95 -1
  20. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/ui/assets/agent-manual.md +42 -0
  21. socialcli-0.3.14/socialctl/ui/assets/agents.md +33 -0
  22. socialcli-0.3.12/socialctl/connections/rotation_cli.py +0 -116
  23. socialcli-0.3.12/socialctl/ui/assets/agents.md +0 -37
  24. {socialcli-0.3.12 → socialcli-0.3.14}/.gitignore +0 -0
  25. {socialcli-0.3.12 → socialcli-0.3.14}/LICENSE +0 -0
  26. {socialcli-0.3.12 → socialcli-0.3.14}/LICENSE-MIT-LEGACY +0 -0
  27. {socialcli-0.3.12 → socialcli-0.3.14}/README.md +0 -0
  28. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/__init__.py +0 -0
  29. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/__main__.py +0 -0
  30. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/adapters/__init__.py +0 -0
  31. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/adapters/base.py +0 -0
  32. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/adapters/errores.py +0 -0
  33. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/adapters/facebook.py +0 -0
  34. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/adapters/instagram.py +0 -0
  35. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/adapters/tiktok.py +0 -0
  36. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/adapters/youtube.py +0 -0
  37. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/agent_recovery.py +0 -0
  38. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/approval_cli.py +0 -0
  39. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/auth.py +0 -0
  40. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/authflow.py +0 -0
  41. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/brands.py +0 -0
  42. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/capabilities.py +0 -0
  43. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/cli_result.py +0 -0
  44. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/connections/__init__.py +0 -0
  45. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/connections/credential_cli.py +0 -0
  46. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/connections/credential_store.py +0 -0
  47. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/connections/http_transport.py +0 -0
  48. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/connections/keychain.py +0 -0
  49. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/connections/meta_user.py +0 -0
  50. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/connections/temporary_media.py +0 -0
  51. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/connections/token_requests.py +0 -0
  52. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/delivery_options.py +0 -0
  53. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/engagement.py +0 -0
  54. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/engagement_cli.py +0 -0
  55. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/executor.py +0 -0
  56. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/formatter.py +0 -0
  57. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/hosted_media.py +0 -0
  58. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/identity.py +0 -0
  59. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/inbox.py +0 -0
  60. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/inbox_cli.py +0 -0
  61. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/inventory.py +0 -0
  62. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/inventory_cli.py +0 -0
  63. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/inventory_sources.py +0 -0
  64. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/management/__init__.py +0 -0
  65. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/management/batch_cli.py +0 -0
  66. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/management/batches.py +0 -0
  67. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/management/changes.py +0 -0
  68. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/management/cli.py +0 -0
  69. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/management/comments_cli.py +0 -0
  70. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/management/community_batch_cli.py +0 -0
  71. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/management/community_batches.py +0 -0
  72. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/management/community_changes.py +0 -0
  73. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/management/community_cli.py +0 -0
  74. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/management/community_schema.py +0 -0
  75. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/management/facebook_groups.py +0 -0
  76. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/management/groups_cli.py +0 -0
  77. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/management/inbox_readers.py +0 -0
  78. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/management/meta_changes.py +0 -0
  79. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/management/meta_cli.py +0 -0
  80. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/management/meta_client.py +0 -0
  81. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/management/meta_comment_inbox.py +0 -0
  82. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/management/meta_comments.py +0 -0
  83. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/management/meta_errors.py +0 -0
  84. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/management/meta_pagination.py +0 -0
  85. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/management/meta_schema.py +0 -0
  86. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/management/meta_webhooks.py +0 -0
  87. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/management/metadata_parts.py +0 -0
  88. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/management/owned_assets.py +0 -0
  89. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/management/owned_changes.py +0 -0
  90. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/management/owned_cli.py +0 -0
  91. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/management/owned_reorder.py +0 -0
  92. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/management/owned_schema.py +0 -0
  93. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/management/proposal_routes.py +0 -0
  94. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/management/reply_context.py +0 -0
  95. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/management/reply_evidence.py +0 -0
  96. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/management/resource_changes.py +0 -0
  97. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/management/resource_cli.py +0 -0
  98. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/management/snapshot_diagnostics.py +0 -0
  99. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/management/snippet_readback.py +0 -0
  100. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/management/stories.py +0 -0
  101. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/management/stories_cli.py +0 -0
  102. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/management/youtube.py +0 -0
  103. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/management/youtube_community.py +0 -0
  104. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/management/youtube_metadata.py +0 -0
  105. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/management/youtube_owned.py +0 -0
  106. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/management/youtube_resources.py +0 -0
  107. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/media.py +0 -0
  108. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/media_cli.py +0 -0
  109. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/media_ingress.py +0 -0
  110. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/media_preflight.py +0 -0
  111. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/media_registry.py +0 -0
  112. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/media_requirements.py +0 -0
  113. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/metricas/__init__.py +0 -0
  114. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/metricas/almacen.py +0 -0
  115. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/metricas/analytics_changes.py +0 -0
  116. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/metricas/analytics_cli.py +0 -0
  117. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/metricas/analytics_client.py +0 -0
  118. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/metricas/analytics_ingest.py +0 -0
  119. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/metricas/analytics_schema.py +0 -0
  120. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/metricas/base.py +0 -0
  121. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/metricas/facebook.py +0 -0
  122. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/metricas/insights.py +0 -0
  123. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/metricas/instagram.py +0 -0
  124. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/metricas/modelos.py +0 -0
  125. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/metricas/piezas.py +0 -0
  126. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/metricas/reach.py +0 -0
  127. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/metricas/reporting_client.py +0 -0
  128. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/metricas/resumen.py +0 -0
  129. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/metricas/slugs.py +0 -0
  130. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/metricas/tiktok.py +0 -0
  131. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/metricas/youtube.py +0 -0
  132. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/migration_cli.py +0 -0
  133. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/migration_files.py +0 -0
  134. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/models.py +0 -0
  135. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/native_schedule/__init__.py +0 -0
  136. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/native_schedule/api_delivery.py +0 -0
  137. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/native_schedule/api_reconcile.py +0 -0
  138. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/native_schedule/approval.py +0 -0
  139. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/native_schedule/attestations.py +0 -0
  140. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/native_schedule/cadence.py +0 -0
  141. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/native_schedule/cli.py +0 -0
  142. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/native_schedule/dispatcher.py +0 -0
  143. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/native_schedule/facebook.py +0 -0
  144. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/native_schedule/facebook_reels.py +0 -0
  145. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/native_schedule/first_comment.py +0 -0
  146. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/native_schedule/handoff.py +0 -0
  147. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/native_schedule/instagram_delivery.py +0 -0
  148. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/native_schedule/instagram_runtime.py +0 -0
  149. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/native_schedule/inventory.py +0 -0
  150. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/native_schedule/migration.py +0 -0
  151. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/native_schedule/models.py +0 -0
  152. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/native_schedule/planner.py +0 -0
  153. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/native_schedule/preflight.py +0 -0
  154. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/native_schedule/preparation.py +0 -0
  155. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/native_schedule/reconcile.py +0 -0
  156. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/native_schedule/remote_data.py +0 -0
  157. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/native_schedule/report.py +0 -0
  158. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/native_schedule/store.py +0 -0
  159. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/native_schedule/verification.py +0 -0
  160. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/native_schedule/youtube.py +0 -0
  161. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/operation_output.py +0 -0
  162. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/plantillas/accounts.yml +0 -0
  163. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/plantillas/brand.md +0 -0
  164. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/plantillas/estrategia.md +0 -0
  165. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/post_cli.py +0 -0
  166. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/postfile.py +0 -0
  167. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/preflight.py +0 -0
  168. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/preview_exports.py +0 -0
  169. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/public_availability.py +0 -0
  170. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/publication_approval.py +0 -0
  171. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/publication_policy.py +0 -0
  172. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/publication_status.py +0 -0
  173. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/publication_steps.py +0 -0
  174. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/publish_output.py +0 -0
  175. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/publisher.py +0 -0
  176. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/qa/__init__.py +0 -0
  177. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/qa/backend.py +0 -0
  178. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/qa/cli.py +0 -0
  179. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/qa/guard.py +0 -0
  180. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/qa/models.py +0 -0
  181. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/qa/runner.py +0 -0
  182. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/qa/store.py +0 -0
  183. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/qa/transport.py +0 -0
  184. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/queue_migration.py +0 -0
  185. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/read_budget.py +0 -0
  186. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/read_checkpoints.py +0 -0
  187. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/read_reports.py +0 -0
  188. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/rutas.py +0 -0
  189. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/schedule_remote.py +0 -0
  190. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/schedule_sqlite.py +0 -0
  191. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/scheduler.py +0 -0
  192. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/scheduler_launchd.py +0 -0
  193. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/scheduler_systemd.py +0 -0
  194. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/source_links.py +0 -0
  195. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/stats_recovery.py +0 -0
  196. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/ui/__init__.py +0 -0
  197. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/ui/assets/cli-result.schema.json +0 -0
  198. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/upload_consent.py +0 -0
  199. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/workspace.py +0 -0
  200. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/youtube_data.py +0 -0
  201. {socialcli-0.3.12 → socialcli-0.3.14}/socialctl/youtube_data_service.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: socialcli
3
- Version: 0.3.12
3
+ Version: 0.3.14
4
4
  Summary: SocialCli: publish and manage creator-owned social content from the terminal.
5
5
  Project-URL: Homepage, https://socialcli.app
6
6
  Project-URL: Documentation, https://socialcli.app/ai-agents.html
@@ -14,7 +14,7 @@ Requires-Dist: httpx>=0.28.1
14
14
  Requires-Dist: keyring>=25.0
15
15
  Requires-Dist: pydantic>=2.13.5
16
16
  Requires-Dist: pyyaml>=6.0.3
17
- Requires-Dist: typer>=0.27.2
17
+ Requires-Dist: typer<0.28,>=0.27.2
18
18
  Provides-Extra: headless-credentials
19
19
  Requires-Dist: cryptography>=43; extra == 'headless-credentials'
20
20
  Description-Content-Type: text/markdown
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "socialcli"
3
- version = "0.3.12"
3
+ version = "0.3.14"
4
4
  description = "SocialCli: publish and manage creator-owned social content from the terminal."
5
5
  readme = "README.md"
6
6
  license = "LicenseRef-SocialCli-Proprietary"
@@ -12,7 +12,7 @@ dependencies = [
12
12
  "keyring>=25.0",
13
13
  "pydantic>=2.13.5",
14
14
  "pyyaml>=6.0.3",
15
- "typer>=0.27.2",
15
+ "typer>=0.27.2,<0.28",
16
16
  ]
17
17
 
18
18
  [project.scripts]
@@ -18,6 +18,20 @@ _ACTIONS = {
18
18
  'activation_required': 'recover',
19
19
  'subscription_required': 'user_action',
20
20
  'brand_limit': 'user_action',
21
+ 'brand_consent_required': 'user_action',
22
+ 'brand_selection_required': 'correct_input',
23
+ 'brand_unavailable': 'correct_input',
24
+ 'brand_archived': 'user_action',
25
+ 'brand_name_exists': 'correct_input',
26
+ 'brand_removal_requires_disconnect': 'user_action',
27
+ 'account_already_connected': 'correct_input',
28
+ 'brand_capacity_required': 'user_action',
29
+ 'brand_changed': 'inspect',
30
+ 'provider_wide_revocation_requires_review': 'user_action',
31
+ 'rotation_inventory_changed': 'reconcile',
32
+ 'rotation_changed': 'reconcile',
33
+ 'rotation_unavailable': 'inspect',
34
+
21
35
  'connection_inactive': 'user_action',
22
36
  'connection_unavailable': 'user_action',
23
37
  'connection_replaced': 'user_action',
@@ -32,6 +46,7 @@ _ACTIONS = {
32
46
  # Only fixed internal codes acquire action semantics. Provider text is diagnostic,
33
47
  # never a command, an expiry signal or evidence that a write was not accepted.
34
48
  _CATALOG = {
49
+ 'account_bind_required': ('correct_input', 'Existing SaaS connection metadata requires verified local brand binding.'),
35
50
  'proposal_route_mismatch': ('correct_input', 'Use the validated proposal owner route; inspect operation state and use read-only recovery for an existing attempt. No write was started.'),
36
51
  'proposal_observation_unknown': ('inspect', 'The original observation age is unknown for this saved proposal; preserve it. Export cannot assign a new age or certify freshness.'),
37
52
  'proposal_missing': ('inspect', 'No saved proposal with this ID exists in the selected brand storage. No provider request was sent.'),
@@ -142,6 +157,7 @@ def error_document(exc: BaseException, *, read_only: bool) -> dict:
142
157
  from socialctl.identity import ReadError
143
158
  from socialctl.read_checkpoints import CheckpointError
144
159
  from socialctl.metricas.almacen import ProjectionBusyError
160
+ from socialctl.connections.brand_binding import AccountBindRequired
145
161
 
146
162
  # A read flow may refresh a token via POST. A lost response to that operation
147
163
  # cannot be classified as a harmless GET retry merely from the CLI command.
@@ -152,7 +168,9 @@ def error_document(exc: BaseException, *, read_only: bool) -> dict:
152
168
  except RuntimeError: request = None
153
169
  if request is not None and request.method not in {'GET','HEAD','OPTIONS'}:
154
170
  read_only = False
155
- if isinstance(exc, ServiceRejected):
171
+ if isinstance(exc, AccountBindRequired):
172
+ code = 'account_bind_required'
173
+ elif isinstance(exc, ServiceRejected):
156
174
  code = exc.code if exc.code in MESSAGES else {
157
175
  401:'installation_access_required',402:'subscription_required',
158
176
  429:'rate_limited',503:'provider_unavailable'}.get(exc.status,'service_rejected')
@@ -223,6 +241,9 @@ def error_document(exc: BaseException, *, read_only: bool) -> dict:
223
241
  options = proposal_options(exc.recovery)
224
242
  if options:
225
243
  result['next_steps'] = options
244
+ if isinstance(exc,AccountBindRequired):
245
+ result.update(brand_id=exc.brand_id,next_steps=exc.options(),stage='input_validation',
246
+ write_state='not_started',diagnostic={'source':'local','stage':'input_validation','write_state':'not_started'})
226
247
  return result
227
248
 
228
249
 
@@ -49,4 +49,4 @@ def guide(topic):
49
49
  if topic == 'qa':
50
50
  sections = re.split(r'(?=^## )', full, flags=re.MULTILINE)
51
51
  result += ''.join(s for s in sections if s.startswith('## Isolated YouTube QA sequences'))
52
- return result + '\nNext: socialcli agent-guide actions; socialcli agent-guide interaction; socialcli agent-guide publish; socialcli agent-guide schedule; socialcli agent-guide inbox; socialcli agent-guide errors; socialcli agent-guide permissions; socialcli agent-guide all.\n'
52
+ return result + '\nNext: socialcli agent-guide actions; socialcli agent-guide interaction; socialcli agent-guide publish; socialcli agent-guide schedule; socialcli agent-guide inbox; socialcli agent-guide errors; socialcli agent-guide permissions; socialcli agent-guide brands; socialcli agent-guide all.\n'
@@ -6,11 +6,11 @@ import re
6
6
 
7
7
  START = '<!-- socialcli-journey:start -->'
8
8
  END = '<!-- socialcli-journey:end -->'
9
- TOPICS = frozenset(('setup', 'interaction', 'publish', 'schedule', 'inbox', 'errors', 'permissions', 'capabilities', 'qa'))
9
+ TOPICS = frozenset(('setup', 'interaction', 'publish', 'schedule', 'inbox', 'errors', 'permissions', 'capabilities', 'qa', 'brands'))
10
10
  SECTION_IDS = frozenset(('public-availability', 'capability-decision', 'workspace-context',
11
11
  'setup-installation', 'agent-interaction', 'user-friendly-handoffs', 'installation-permissions',
12
12
  'exact-approval', 'publish-recipe', 'youtube-scheduling', 'reads-and-errors',
13
- 'inbox-replies', 'persist-recover'))
13
+ 'inbox-replies', 'persist-recover', 'multibrand'))
14
14
 
15
15
 
16
16
  def version_key(value):
@@ -116,7 +116,7 @@ def document(*, version, html=False, topic=None, data=None):
116
116
  raise ValueError('Unknown journey topic')
117
117
  data = load() if data is None else validate(data)
118
118
  renderer = render_html if html else render_markdown
119
- return ''.join(renderer(section, version=version) for section in data['sections'] if topic is None or topic in section['topics'])
119
+ return ''.join(renderer(section, version=version) for section in data['sections'] if (topic is None or topic in section['topics']) and any(applicable(b,version) for b in section['blocks']))
120
120
 
121
121
 
122
122
  def recipes(*, version):
@@ -7818,6 +7818,57 @@
7818
7818
  "youtube"
7819
7819
  ],
7820
7820
  "live_verification": "unknown"
7821
+ },
7822
+ {
7823
+ "id": "account.brands",
7824
+ "task": "Discover only installation-authorized brand IDs and effective limits",
7825
+ "command": "socialcli account brands --brand Example --root /path/to/workspace --json --json-version 2",
7826
+ "approval": "none_read_only",
7827
+ "prerequisites": [
7828
+ "Installed candidate client 0.3.13; service brand protocol 2 with authorized discovery; exact named workspace/service/owner and approved brand ID.",
7829
+ "Only YouTube public; Solo one / Studio five requires independent access and verified capacity."
7830
+ ],
7831
+ "verification_limits": [
7832
+ "No unapproved brand enumeration or first-ID selection. Local binding and credential reuse grant no publication, billing or provider approval.",
7833
+ "Uncertain writes require reconciliation; no sign-out or reconnection to add a brand. Candidate is not claimed released or Live."
7834
+ ],
7835
+ "minimum_version": "0.3.13",
7836
+ "release_status": "not_inferred_from_installation",
7837
+ "live_verification": "unknown"
7838
+ },
7839
+ {
7840
+ "id": "account.bind",
7841
+ "task": "Bind one local folder to an exact approved stable brand ID",
7842
+ "command": "socialcli account bind --brand Example --root /path/to/workspace --brand-id fictional-brand-123456789 --json --json-version 2",
7843
+ "approval": "explicit_brand_selection",
7844
+ "prerequisites": [
7845
+ "Installed candidate client 0.3.13; service brand protocol 2 with authorized discovery; exact named workspace/service/owner and approved brand ID.",
7846
+ "Only YouTube public; Solo one / Studio five requires independent access and verified capacity."
7847
+ ],
7848
+ "verification_limits": [
7849
+ "No unapproved brand enumeration or first-ID selection. Local binding and credential reuse grant no publication, billing or provider approval.",
7850
+ "Uncertain writes require reconciliation; no sign-out or reconnection to add a brand. Candidate is not claimed released or Live."
7851
+ ],
7852
+ "minimum_version": "0.3.13",
7853
+ "release_status": "not_inferred_from_installation",
7854
+ "live_verification": "unknown"
7855
+ },
7856
+ {
7857
+ "id": "account.reuse",
7858
+ "task": "Explicitly reuse a named local installation after additive owner consent",
7859
+ "command": "socialcli account reuse --from-brand First --brand Second --root /path/to/workspace --service https://social.example --brand-id fictional-brand-123456789 --json --json-version 2",
7860
+ "approval": "owner_approved_brand_membership",
7861
+ "prerequisites": [
7862
+ "Installed candidate client 0.3.13; service brand protocol 2 with authorized discovery; exact named workspace/service/owner and approved brand ID.",
7863
+ "Only YouTube public; Solo one / Studio five requires independent access and verified capacity."
7864
+ ],
7865
+ "verification_limits": [
7866
+ "No unapproved brand enumeration or first-ID selection. Local binding and credential reuse grant no publication, billing or provider approval.",
7867
+ "Uncertain writes require reconciliation; no sign-out or reconnection to add a brand. Candidate is not claimed released or Live."
7868
+ ],
7869
+ "minimum_version": "0.3.13",
7870
+ "release_status": "not_inferred_from_installation",
7871
+ "live_verification": "unknown"
7821
7872
  }
7822
7873
  ],
7823
7874
  "input_schemas": {
@@ -98,7 +98,7 @@ def approval_hash(post, brand, platform):
98
98
 
99
99
 
100
100
  @app.command('agent-guide')
101
- def agent_guide(topic: str = typer.Argument('setup', help='setup, capabilities, actions (JSON), interaction, publish, schedule, inbox, errors, permissions or all')):
101
+ def agent_guide(topic: str = typer.Argument('setup', help='setup, capabilities, actions (JSON), interaction, publish, schedule, inbox, errors, permissions, brands or all')):
102
102
  """Read a focused agent guide offline, without an account or workspace."""
103
103
  from socialctl.agent_guide import guide
104
104
  try:
@@ -35,23 +35,27 @@ def http_client():
35
35
 
36
36
  def metadata(brand):
37
37
  path=brand.dir_secretos/'socialcli-account.json'
38
+ if brand.dir_secretos.is_symlink() or path.is_symlink() or path.exists() and not path.is_file():
39
+ raise ValueError('Unsafe local brand binding metadata path.')
38
40
  data=json.loads(path.read_text()) if path.exists() else {}
39
41
  if data and (data.get('version')!=1 or data.get('auth_mode')!='saas-installation'):
40
42
  raise ValueError('Invalid SocialCli installation metadata.')
41
43
  if data:
42
44
  from socialctl.context import validate_service_origin
43
45
  validate_service_origin(data.get('service_url'))
46
+ from socialctl.connections.brand_binding import validate_local
47
+ validate_local(brand,data)
44
48
  return data
45
49
 
46
50
 
47
- def handoff(url,*,no_browser,seconds):
51
+ def handoff(url,*,no_browser,seconds,context=None):
48
52
  if seconds is not None and (type(seconds) not in {int,float} or not math.isfinite(seconds) or not 0<seconds<=1800):
49
53
  raise ValueError('Invalid SocialCli authorization timing.')
50
54
  # Progress is factual data. The agent's workflow belongs in its guide, not
51
55
  # in service/tool output. The duration is relative to creation, not resume.
52
56
  typer.echo(json.dumps({'version':1,'event':'authorization_pending','status':'pending',
53
57
  'browser_url':url,'expires_after_seconds':seconds,
54
- 'expiry_reference':'authorization_creation' if seconds is not None else None},allow_nan=False),err=True)
58
+ 'expiry_reference':'authorization_creation' if seconds is not None else None,**(context or {})},allow_nan=False),err=True)
55
59
  if not no_browser: webbrowser.open(url)
56
60
 
57
61
 
@@ -174,7 +178,12 @@ def status(brand_name:str=typer.Option(...,'--brand'),root:Path=typer.Option(def
174
178
  with http_client() as transport:
175
179
  client=SaaSClient(saved['service_url'],transport,allow_http_local=saved.get('development_local') is True)
176
180
  result=client.request('GET','/api/saas/v1/installations/'+opaque(saved['connection_id']),secret=keychain.get(brand,Slot.ACCOUNT,saved))
177
- output({**result,'status':'signed_in'},json_output)
181
+ from socialctl.connections.brand_binding import discovery,exact
182
+ with http_client() as transport:
183
+ client=SaaSClient(saved['service_url'],transport,allow_http_local=saved.get('development_local') is True)
184
+ found=discovery(client,brand,saved)
185
+ selected=exact(found,saved['brand_id']) if found and saved.get('brand_id') else None
186
+ output({**result,'status':'signed_in','brand':selected},json_output)
178
187
  except Exception as exc:
179
188
  if json_output:
180
189
  from socialctl.agent_errors import emit_error
@@ -215,6 +224,8 @@ def logout(brand_name:str=typer.Option(...,'--brand'),root:Path=typer.Option(def
215
224
  try:
216
225
  brand=cargar_brand(root,brand_name);lock=acquire_brand_lock(brand);saved=metadata(brand)
217
226
  if not saved: raise ValueError('Not signed in.')
227
+ if len(saved.get('local_siblings',[]))>1:
228
+ raise ValueError('This installation is shared by registered local brands. Installation-wide sign-out requires owner browser review; no credential was removed.')
218
229
  with http_client() as transport:
219
230
  client=SaaSClient(saved['service_url'],transport,allow_http_local=saved.get('development_local') is True)
220
231
  try:client.request('DELETE','/api/saas/v1/installations/'+opaque(saved['connection_id']),secret=keychain.get(brand,Slot.ACCOUNT,saved))
@@ -245,9 +256,17 @@ def finalize_local(brand,platform,client,result):
245
256
  if result.get('platform')!=platform.value:raise ValueError('Connection platform mismatch.')
246
257
  secret=result.get('connection_secret')
247
258
  if not isinstance(secret,str) or not 16<=len(secret)<=512:raise ValueError('Invalid connection credential.')
259
+ from socialctl.connections.brand_binding import discovery,exact,persist
260
+ installation=metadata(brand)
261
+ found=discovery(client,brand,installation)
262
+ if found is not None:
263
+ row=exact(found,result.get('brand_id'))
264
+ installation=persist(brand,installation,found,row)
248
265
  validate_binding(brand,platform,account)
249
- saved={'version':1,'auth_mode':'broker','protocol':'saas-v1','service_url':client.origin,
266
+ saved={'version':1,'auth_mode':'broker','protocol':'saas-v1','platform':platform.value,'service_url':client.origin,
250
267
  'connection_id':connection_id,'account_id':account['id'],'account':account,'granted_scopes':result.get('granted_scopes',[])}
268
+ if installation.get('brand_id'):
269
+ saved.update({k:installation[k] for k in ('brand_id','owner_id','local_path')})
251
270
  if client.origin.startswith('http://'):saved['development_local']=True
252
271
  path=brand.dir_secretos/(platform.value+'.json');config=brand.raiz/'accounts.yml'
253
272
  old=brand.leer_secreto(platform)
@@ -304,7 +323,13 @@ def recover(platform:Platform,brand_name:str=typer.Option(...,'--brand'),root:Pa
304
323
  try:
305
324
  brand=cargar_brand(root,brand_name);lock=acquire_brand_lock(brand,allow_recovery=True)
306
325
  saved=json.loads(recovery_path(brand,platform).read_text())
326
+ if saved.get('platform',platform.value)!=platform.value:
327
+ raise ValueError('Recovery platform binding mismatch.')
307
328
  journal=json.loads(keychain.get(brand,recovery_slot(platform),saved));secret=keychain.get(brand,platform,saved)
329
+ from socialctl.connections.brand_binding import validate_connection
330
+ validate_connection(brand,saved,saved)
331
+ if saved.get('platform',platform.value)!=platform.value or journal.get('metadata')!=saved:
332
+ raise ValueError('Recovery platform or journal binding mismatch.')
308
333
  with http_client() as transport:
309
334
  client=SaaSClient(saved['service_url'],transport,allow_http_local=saved.get('development_local') is True)
310
335
  try:client.request('POST','/api/saas/v1/connections/'+opaque(saved['connection_id'])+'/activate',secret=secret)
@@ -330,13 +355,15 @@ def connect_saas(brand,platform,*,no_browser,account_id=None,replace_independent
330
355
  with http_client() as transport:
331
356
  client=SaaSClient(saved['service_url'],transport,allow_http_local=saved.get('development_local') is True)
332
357
  secret=keychain.get(brand,Slot.ACCOUNT,saved);installation_id=opaque(saved['connection_id'])
358
+ from socialctl.connections.brand_binding import select
359
+ selection=select(client,brand,saved,allow_initial=True)
333
360
  poll_secret=secrets.token_urlsafe(32)
334
361
  start=client.request('POST','/api/saas/v1/installations/'+installation_id+'/authorizations',secret=secret,
335
- body={'platform':platform.value,'brand':brand.nombre,'poll_challenge':hashlib.sha256(poll_secret.encode()).hexdigest(),
362
+ body={'platform':platform.value,**selection,'poll_challenge':hashlib.sha256(poll_secret.encode()).hexdigest(),
336
363
  'management':management,'analytics':analytics})
337
364
  auth_id=opaque(start.get('authorization_id'));expected=client.origin+'/connect/'+auth_id
338
365
  if start.get('browser_url')!=expected:raise ValueError('Invalid account authorization URL.')
339
- handoff(expected,no_browser=no_browser,seconds=start['expires_in'])
366
+ handoff(expected,no_browser=no_browser,seconds=start['expires_in'],context={'brand':selection,'platform':platform.value,'requested_account_id':account_id})
340
367
  result=wait(client,'/api/saas/v1/authorizations/'+auth_id+'/poll',poll_secret,min(timeout,start['expires_in']),start['poll_interval'],{'selected'})
341
368
  if account_id is not None and result.get('account',{}).get('id')!=account_id:raise ValueError('Browser-selected account differs from the explicitly requested ID. No connection was installed.')
342
369
  installed=finalize_local(brand,platform,client,result)
@@ -344,10 +371,13 @@ def connect_saas(brand,platform,*,no_browser,account_id=None,replace_independent
344
371
  # replay OAuth/activation; return the known identity and inspect guidance.
345
372
  account=installed['account']
346
373
  payload={'version':1,'status':'connected','verified':False,'platform':platform.value,
374
+ 'brand':{'id':installed.get('brand_id'),'label':metadata(brand).get('brand_label',brand.nombre)},
347
375
  'account':{'id':account['id'],'name':visible(account.get('name',account['id']))},'errors':[]}
348
376
  try:
349
377
  status=client.request('GET','/api/saas/v1/connections/'+opaque(installed['connection_id']),
350
378
  secret=keychain.get(brand,platform,installed))
379
+ from socialctl.connections.brand_binding import validate_connection
380
+ validate_connection(brand,installed,status)
351
381
  if (status.get('platform')!=platform.value or status.get('account',{}).get('id')!=account['id']
352
382
  or status.get('needs_reconnect') is not False):
353
383
  raise ValueError('Connection status did not confirm the selected account.')
@@ -382,7 +412,7 @@ def attach(platform:Platform,brand_name:str=typer.Option(...,'--brand'),root:Pat
382
412
  client=SaaSClient(saved['service_url'],transport,allow_http_local=saved.get('development_local') is True)
383
413
  if previous:
384
414
  try:
385
- client.request('GET','/api/saas/v1/connections/'+opaque(previous['connection_id']),
415
+ status=client.request('GET','/api/saas/v1/connections/'+opaque(previous['connection_id']),
386
416
  secret=keychain.get(brand,platform,previous))
387
417
  except ServiceRejected as exc:
388
418
  # Browser revocation removes capabilities (404); a new
@@ -393,14 +423,23 @@ def attach(platform:Platform,brand_name:str=typer.Option(...,'--brand'),root:Pat
393
423
  (401,'installation_revoked'),(401,'installation_expired'),
394
424
  (404,'connection_unavailable'),(409,'connection_replaced')}:
395
425
  raise
396
- else:raise ValueError('A local connection already exists. Review it before replacing it.')
426
+ else:
427
+ from socialctl.connections.brand_binding import validate_connection
428
+ validate_connection(brand,previous,status)
429
+ raise ValueError('A local connection already exists. Review it before replacing it.')
430
+ from socialctl.connections.brand_binding import select
431
+ selection=select(client,brand,saved)
397
432
  result=client.request('POST','/api/saas/v1/installations/'+opaque(saved['connection_id'])+'/attach',
398
- secret=keychain.get(brand,Slot.ACCOUNT,saved),body={'platform':platform.value,'brand':brand.nombre})
433
+ secret=keychain.get(brand,Slot.ACCOUNT,saved),body={'platform':platform.value,**selection})
399
434
  if previous and result.get('account',{}).get('id')!=previous.get('account_id'):
400
435
  raise ValueError('The approved account changed. Review it before replacing this local connection.')
401
436
  finalize_local(brand,platform,client,result)
402
437
  typer.echo(platform.value+' attached for '+visible(brand.nombre)+'. No OAuth or publication was repeated.')
403
438
  except Exception as exc:
439
+ from socialctl.connections.brand_binding import AccountBindRequired
440
+ if isinstance(exc,AccountBindRequired):
441
+ from socialctl.agent_errors import emit_error
442
+ emit_error(exc,read_only=False)
404
443
  typer.echo(str(exc) if isinstance(exc,ValueError) else 'Could not attach safely. Check your SocialCli account.',err=True);raise typer.Exit(1)
405
444
  finally:
406
445
  if lock is not None:os.close(lock)
@@ -431,6 +470,9 @@ def migrate(platform:Platform,brand_name:str=typer.Option(...,'--brand'),root:Pa
431
470
  client=SaaSClient(saved['service_url'],transport,allow_http_local=saved.get('development_local') is True)
432
471
  if not migration_origin_allowed(old['service_url'],client.origin,allow_http_local=saved.get('development_local') is True and old.get('development_local') is True):
433
472
  raise ValueError('Legacy connection belongs to another service. Its credential cannot be transferred to this destination.')
473
+ if any(brand.leer_secreto(p).get('protocol')=='saas-v1' for p in Platform):
474
+ from socialctl.connections.brand_binding import select
475
+ select(client,brand,saved)
434
476
  poll_secret=secrets.token_urlsafe(32)
435
477
  start=client.request('POST','/api/saas/v1/installations/'+opaque(saved['connection_id'])+'/migrations',
436
478
  secret=keychain.get(brand,Slot.ACCOUNT,saved),legacy_secret=keychain.get(brand,platform,old),
@@ -446,6 +488,10 @@ def migrate(platform:Platform,brand_name:str=typer.Option(...,'--brand'),root:Pa
446
488
  finalize_local(brand,platform,client,result)
447
489
  typer.echo(platform.value+' migrated for '+visible(brand.nombre)+'. No OAuth or publication was repeated.')
448
490
  except Exception as exc:
491
+ from socialctl.connections.brand_binding import AccountBindRequired
492
+ if isinstance(exc,AccountBindRequired):
493
+ from socialctl.agent_errors import emit_error
494
+ emit_error(exc,read_only=False)
449
495
  typer.echo(str(exc) if isinstance(exc,ValueError) else 'Could not confirm migration. Keep local credentials and check account recovery.',err=True);raise typer.Exit(1)
450
496
  finally:
451
497
  if lock is not None:os.close(lock)
@@ -457,7 +503,7 @@ def rotate(brand_name:str=typer.Option(...,'--brand'),root:Path=typer.Option(def
457
503
  """Renew this installation before expiry; rerun to recover an interruption."""
458
504
  lock=None
459
505
  try:
460
- brand=cargar_brand(root,brand_name);lock=acquire_brand_lock(brand,allow_rotation=True)
506
+ brand=cargar_brand(root,brand_name)
461
507
  from socialctl.connections.rotation_cli import rotate_local
462
508
  typer.echo(rotate_local(brand,cancel=cancel))
463
509
  except Exception as exc:
@@ -466,3 +512,112 @@ def rotate(brand_name:str=typer.Option(...,'--brand'),root:Path=typer.Option(def
466
512
  raise typer.Exit(1)
467
513
  finally:
468
514
  if lock is not None:os.close(lock)
515
+
516
+
517
+ @account_app.command('brands')
518
+ def authorized_brands(brand_name:str=typer.Option(...,'--brand'),root:Path=typer.Option(default_root(),'--root'),
519
+ permissions:bool=typer.Option(False,'--permissions'),no_browser:bool=typer.Option(False,'--no-browser'),
520
+ json_output:bool=typer.Option(False,'--json')):
521
+ """List only authorized brand IDs or hand off additive owner permissions."""
522
+ try:
523
+ from socialctl.connections.brand_binding import discovery
524
+ brand=cargar_brand(root,brand_name);saved=metadata(brand)
525
+ if not saved:raise ValueError('Not signed in.')
526
+ with http_client() as transport:
527
+ client=SaaSClient(saved['service_url'],transport,allow_http_local=saved.get('development_local') is True)
528
+ value=discovery(client,brand,saved,required=True)
529
+ if permissions:handoff(value['browser_url'],no_browser=no_browser,seconds=None)
530
+ output({**value,'status':'owner_action_required' if permissions else 'ok'},True)
531
+ except Exception as exc:
532
+ if json_output:
533
+ from socialctl.agent_errors import emit_error
534
+ emit_error(exc,read_only=True)
535
+ typer.echo(str(exc) if isinstance(exc,ValueError) else 'Authorized brand discovery unavailable.',err=True);raise typer.Exit(1)
536
+
537
+
538
+ @account_app.command('bind')
539
+ def bind_brand(brand_id:str=typer.Option(...,'--brand-id'),brand_name:str=typer.Option(...,'--brand'),
540
+ root:Path=typer.Option(default_root(),'--root')):
541
+ """Bind this local folder to one exact already owner-approved brand ID."""
542
+ lock=None
543
+ try:
544
+ from socialctl.connections.brand_binding import discovery,exact,pending_binding,bind_verified_metadata,local_path,validate_local
545
+ brand=cargar_brand(root,brand_name);lock=acquire_brand_lock(brand,allow_binding=True);saved=metadata(brand)
546
+ if not saved:raise ValueError('Not signed in.')
547
+ pending_binding(brand,saved,brand_id)
548
+ with http_client() as transport:
549
+ client=SaaSClient(saved['service_url'],transport,allow_http_local=saved.get('development_local') is True)
550
+ value=discovery(client,brand,saved,required=True);row=exact(value,brand_id)
551
+ verified=[]
552
+ for platform in Platform:
553
+ old=brand.leer_secreto(platform)
554
+ # Binding verifies only this installation's SaaS capabilities.
555
+ # Independent and legacy-broker records retain their own owner
556
+ # and service boundaries; their metadata and stores are untouched.
557
+ if old.get('auth_mode')!='broker' or old.get('protocol')!='saas-v1':continue
558
+ validate_local(brand,old)
559
+ if (old.get('service_url')!=client.origin
560
+ or old.get('brand_id',brand_id)!=brand_id or old.get('owner_id',value['owner_id'])!=value['owner_id']
561
+ or old.get('platform',platform.value)!=platform.value):
562
+ raise ValueError('Existing local credentials require review before binding.')
563
+ status=client.request('GET','/api/saas/v1/connections/'+opaque(old['connection_id']),secret=keychain.get(brand,platform,old))
564
+ if status.get('brand_id')!=brand_id or status.get('platform')!=platform.value or status.get('account',{}).get('id')!=old.get('account_id'):
565
+ raise ValueError('Existing local account does not match the selected brand ID.')
566
+ verified.append((brand.dir_secretos/(platform.value+'.json'),{**old,'brand_id':brand_id,'owner_id':value['owner_id'],
567
+ 'local_path':local_path(brand),'platform':platform.value}))
568
+ bind_verified_metadata(brand,saved,value,row,verified,atomic_bytes)
569
+ binding_result('bound',metadata(brand))
570
+ except Exception as exc:
571
+ typer.echo(str(exc) if isinstance(exc,ValueError) else 'Could not bind the selected brand safely.',err=True);raise typer.Exit(1)
572
+ finally:
573
+ if lock is not None:os.close(lock)
574
+
575
+
576
+ @account_app.command('reuse')
577
+ def reuse_installation(from_brand:str=typer.Option(...,'--from-brand'),brand_id:str=typer.Option(...,'--brand-id'),
578
+ brand_name:str=typer.Option(...,'--brand'),root:Path=typer.Option(default_root(),'--root')):
579
+ """Reuse an explicitly named local installation after exact owner brand approval."""
580
+ locks=[]
581
+ try:
582
+ from socialctl.connections.brand_binding import discovery,exact,persist,siblings,local_path
583
+ source=cargar_brand(root,from_brand);target=cargar_brand(root,brand_name)
584
+ if local_path(source)==local_path(target):raise ValueError('Source and destination brands must differ.')
585
+ saved=metadata(source)
586
+ if not saved:raise ValueError('The explicit source brand is not signed in.')
587
+ peers=siblings(source,saved,require_registry=False,empty_destination=local_path(target))
588
+ paths=sorted(set(local_path(p) for p in peers)|{local_path(target)})
589
+ for path in paths:
590
+ p=Path(path);locks.append(acquire_brand_lock(cargar_brand(p.parent,p.name)))
591
+ if metadata(source)!=saved:raise ValueError('Source installation changed. Preserve local credentials.')
592
+ if metadata(target) or any(target.leer_secreto(p) for p in Platform):
593
+ raise ValueError('Destination already has credentials. Preserve its existing binding.')
594
+ keychain.ensure_available(target)
595
+ with http_client() as transport:
596
+ client=SaaSClient(saved['service_url'],transport,allow_http_local=saved.get('development_local') is True)
597
+ value=discovery(client,source,saved,required=True);row=exact(value,brand_id)
598
+ if any(metadata(p).get('brand_id')==brand_id for p in peers):
599
+ raise ValueError('That stable brand ID already has a local sibling folder.')
600
+ if saved.get('owner_id')!=value['owner_id']:raise ValueError('Source owner binding requires account bind first.')
601
+ secret=keychain.get(source,Slot.ACCOUNT,saved)
602
+ next_saved={k:v for k,v in saved.items() if k not in {'brand_id','brand_label','local_path','local_siblings'}}
603
+ next_saved['local_siblings']=paths
604
+ keychain.save(target,Slot.ACCOUNT,next_saved,secret)
605
+ # Register destination first on every existing peer. An interrupted
606
+ # write fails closed at rotation until this explicit reuse resumes.
607
+ for peer in peers:
608
+ current=metadata(peer)
609
+ atomic_bytes(peer.dir_secretos/'socialcli-account.json',json.dumps({**current,'local_siblings':paths}).encode())
610
+ persist(target,next_saved,value,row)
611
+ binding_result('installation_reused',metadata(target))
612
+ except Exception as exc:
613
+ typer.echo(str(exc) if isinstance(exc,ValueError) else 'Could not reuse installation safely. Preserve local records.',err=True);raise typer.Exit(1)
614
+ finally:
615
+ for lock in reversed(locks):os.close(lock)
616
+
617
+
618
+ def binding_result(status,saved):
619
+ from socialctl.cli_result import active_result,emit_legacy
620
+ if active_result.get() is not None:
621
+ emit_legacy({'version':1,'status':status,'installation_id':saved['connection_id'],'owner_id':saved['owner_id'],
622
+ 'brand':{'id':saved['brand_id'],'label':saved['brand_label']},'registered_local_brands':len(saved['local_siblings'])})
623
+ else:typer.echo(status.replace('_',' ').capitalize()+'.')