autotouch-cli 0.2.107__tar.gz → 0.2.109__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 (61) hide show
  1. {autotouch_cli-0.2.107 → autotouch_cli-0.2.109}/PKG-INFO +3 -3
  2. {autotouch_cli-0.2.107 → autotouch_cli-0.2.109}/README.md +2 -2
  3. {autotouch_cli-0.2.107 → autotouch_cli-0.2.109}/autotouch_cli/cli.py +30 -0
  4. {autotouch_cli-0.2.107 → autotouch_cli-0.2.109}/autotouch_cli/cli_contracts.py +1 -0
  5. autotouch_cli-0.2.109/autotouch_cli/commands/outreach.py +308 -0
  6. {autotouch_cli-0.2.107 → autotouch_cli-0.2.109}/autotouch_cli/data/CLI_REFERENCE.md +330 -1
  7. {autotouch_cli-0.2.107 → autotouch_cli-0.2.109}/autotouch_cli/data/cli-manifest.json +1866 -1
  8. {autotouch_cli-0.2.107 → autotouch_cli-0.2.109}/autotouch_cli/parser.py +17 -0
  9. {autotouch_cli-0.2.107 → autotouch_cli-0.2.109}/autotouch_cli/templates.py +36 -6
  10. {autotouch_cli-0.2.107 → autotouch_cli-0.2.109}/autotouch_cli/workflows/registry.py +38 -4
  11. {autotouch_cli-0.2.107 → autotouch_cli-0.2.109}/autotouch_cli.egg-info/PKG-INFO +3 -3
  12. {autotouch_cli-0.2.107 → autotouch_cli-0.2.109}/autotouch_cli.egg-info/SOURCES.txt +1 -0
  13. {autotouch_cli-0.2.107 → autotouch_cli-0.2.109}/autotouch_shared/provider_registry.py +7 -3
  14. {autotouch_cli-0.2.107 → autotouch_cli-0.2.109}/pyproject.toml +1 -1
  15. {autotouch_cli-0.2.107 → autotouch_cli-0.2.109}/MANIFEST.in +0 -0
  16. {autotouch_cli-0.2.107 → autotouch_cli-0.2.109}/autotouch_cli/__init__.py +0 -0
  17. {autotouch_cli-0.2.107 → autotouch_cli-0.2.109}/autotouch_cli/commands/__init__.py +0 -0
  18. {autotouch_cli-0.2.107 → autotouch_cli-0.2.109}/autotouch_cli/commands/agents.py +0 -0
  19. {autotouch_cli-0.2.107 → autotouch_cli-0.2.109}/autotouch_cli/commands/auth.py +0 -0
  20. {autotouch_cli-0.2.107 → autotouch_cli-0.2.109}/autotouch_cli/commands/cells.py +0 -0
  21. {autotouch_cli-0.2.107 → autotouch_cli-0.2.109}/autotouch_cli/commands/columns.py +0 -0
  22. {autotouch_cli-0.2.107 → autotouch_cli-0.2.109}/autotouch_cli/commands/integrations.py +0 -0
  23. {autotouch_cli-0.2.107 → autotouch_cli-0.2.109}/autotouch_cli/commands/jobs.py +0 -0
  24. {autotouch_cli-0.2.107 → autotouch_cli-0.2.109}/autotouch_cli/commands/leads.py +0 -0
  25. {autotouch_cli-0.2.107 → autotouch_cli-0.2.109}/autotouch_cli/commands/linkedin.py +0 -0
  26. {autotouch_cli-0.2.107 → autotouch_cli-0.2.109}/autotouch_cli/commands/list_build.py +0 -0
  27. {autotouch_cli-0.2.107 → autotouch_cli-0.2.109}/autotouch_cli/commands/prompts.py +0 -0
  28. {autotouch_cli-0.2.107 → autotouch_cli-0.2.109}/autotouch_cli/commands/rows.py +0 -0
  29. {autotouch_cli-0.2.107 → autotouch_cli-0.2.109}/autotouch_cli/commands/search.py +0 -0
  30. {autotouch_cli-0.2.107 → autotouch_cli-0.2.109}/autotouch_cli/commands/sender_accounts.py +0 -0
  31. {autotouch_cli-0.2.107 → autotouch_cli-0.2.109}/autotouch_cli/commands/sequences.py +0 -0
  32. {autotouch_cli-0.2.107 → autotouch_cli-0.2.109}/autotouch_cli/commands/tables.py +0 -0
  33. {autotouch_cli-0.2.107 → autotouch_cli-0.2.109}/autotouch_cli/commands/tasks.py +0 -0
  34. {autotouch_cli-0.2.107 → autotouch_cli-0.2.109}/autotouch_cli/commands/webhooks.py +0 -0
  35. {autotouch_cli-0.2.107 → autotouch_cli-0.2.109}/autotouch_cli/commands/workspace_secrets.py +0 -0
  36. {autotouch_cli-0.2.107 → autotouch_cli-0.2.109}/autotouch_cli/core/__init__.py +0 -0
  37. {autotouch_cli-0.2.107 → autotouch_cli-0.2.109}/autotouch_cli/core/auth.py +0 -0
  38. {autotouch_cli-0.2.107 → autotouch_cli-0.2.109}/autotouch_cli/core/config.py +0 -0
  39. {autotouch_cli-0.2.107 → autotouch_cli-0.2.109}/autotouch_cli/core/csv_import.py +0 -0
  40. {autotouch_cli-0.2.107 → autotouch_cli-0.2.109}/autotouch_cli/core/http.py +0 -0
  41. {autotouch_cli-0.2.107 → autotouch_cli-0.2.109}/autotouch_cli/core/io.py +0 -0
  42. {autotouch_cli-0.2.107 → autotouch_cli-0.2.109}/autotouch_cli/core/output.py +0 -0
  43. {autotouch_cli-0.2.107 → autotouch_cli-0.2.109}/autotouch_cli/core/polling.py +0 -0
  44. {autotouch_cli-0.2.107 → autotouch_cli-0.2.109}/autotouch_cli/core/run.py +0 -0
  45. {autotouch_cli-0.2.107 → autotouch_cli-0.2.109}/autotouch_cli/core/validation.py +0 -0
  46. {autotouch_cli-0.2.107 → autotouch_cli-0.2.109}/autotouch_cli/exceptions.py +0 -0
  47. {autotouch_cli-0.2.107 → autotouch_cli-0.2.109}/autotouch_cli/mongo_status.py +0 -0
  48. {autotouch_cli-0.2.107 → autotouch_cli-0.2.109}/autotouch_cli/parser_groups.py +0 -0
  49. {autotouch_cli-0.2.107 → autotouch_cli-0.2.109}/autotouch_cli/sequence_support.py +0 -0
  50. {autotouch_cli-0.2.107 → autotouch_cli-0.2.109}/autotouch_cli/workflows/__init__.py +0 -0
  51. {autotouch_cli-0.2.107 → autotouch_cli-0.2.109}/autotouch_cli.egg-info/dependency_links.txt +0 -0
  52. {autotouch_cli-0.2.107 → autotouch_cli-0.2.109}/autotouch_cli.egg-info/entry_points.txt +0 -0
  53. {autotouch_cli-0.2.107 → autotouch_cli-0.2.109}/autotouch_cli.egg-info/requires.txt +0 -0
  54. {autotouch_cli-0.2.107 → autotouch_cli-0.2.109}/autotouch_cli.egg-info/top_level.txt +0 -0
  55. {autotouch_cli-0.2.107 → autotouch_cli-0.2.109}/autotouch_shared/__init__.py +0 -0
  56. {autotouch_cli-0.2.107 → autotouch_cli-0.2.109}/autotouch_shared/linkedin_contract.py +0 -0
  57. {autotouch_cli-0.2.107 → autotouch_cli-0.2.109}/autotouch_shared/linkedin_filters.py +0 -0
  58. {autotouch_cli-0.2.107 → autotouch_cli-0.2.109}/autotouch_shared/list_build_contract.py +0 -0
  59. {autotouch_cli-0.2.107 → autotouch_cli-0.2.109}/autotouch_shared/product_lifecycle.py +0 -0
  60. {autotouch_cli-0.2.107 → autotouch_cli-0.2.109}/autotouch_shared/search_contract.py +0 -0
  61. {autotouch_cli-0.2.107 → autotouch_cli-0.2.109}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: autotouch-cli
3
- Version: 0.2.107
3
+ Version: 0.2.109
4
4
  Summary: Autotouch Smart Table CLI
5
5
  Project-URL: Homepage, https://app.autotouch.ai
6
6
  Project-URL: Documentation, https://github.com/nicolonic/autotouch_main/tree/main/docs/research-table/reference
@@ -185,7 +185,7 @@ If the user says "automate the sequence" without asking for AI-written sends, ch
185
185
 
186
186
  Version guard:
187
187
 
188
- - Use `autotouch --version` before relying on recipe defaults. This repo expects `autotouch-cli` `0.2.107` or newer.
188
+ - Use `autotouch --version` before relying on recipe defaults. This repo expects `autotouch-cli` `0.2.109` or newer.
189
189
  - If `python3 -m pip install -U autotouch-cli` upgrades the package but `which autotouch` still points at an older shim, run the upgraded binary directly or fix PATH before creating production sequences.
190
190
  - Before authoring a LinkedIn sequence, inspect the live recipe:
191
191
 
@@ -306,7 +306,7 @@ For automation or agent-driven setup, use:
306
306
  - `autotouch cli-manifest --output json` for the local machine-readable command contract
307
307
  - `autotouch cli-reference` for the shipped parser-generated reference
308
308
  - `autotouch capabilities --output json` for provider/workflow contracts
309
- - `autotouch --version` should be `0.2.107` or newer for structured company list builds without user-supplied keywords, stored list-build input lookup, research-workspace list-build guidance, the cleaned single LinkedIn-sourced list-build path, Exa Company Search up to 100 results, scheduled agent `--target ACCOUNTS|LEADS`, `agents signals --target`, the `agent-to-sequence` and `agent-to-leads` workflow scaffolds, paced HTTP Request column contracts, branch-aware LinkedIn sequence recipes, real agent soft-delete with associated-table handling, research-table sequence handoff assignee and active-sequence-conflict guard config, backend-owned directional source/destination helpers, goal-level workflow plans, website visitor/external intent webhook workflow guidance, create-time agent assignment defaults, company-page signal configuration guidance, sequence authoring warnings when AI draft is mixed with fixed templates, sender-account discovery/management for explicit sequence routing, and mixed parent-row/child-list Sync to Table and Sync to Leads recipe configs
309
+ - `autotouch --version` should be `0.2.109` or newer for structured company list builds without user-supplied keywords, stored list-build input lookup, research-workspace list-build guidance, the cleaned single LinkedIn-sourced list-build path, Exa Company Search up to 100 results, scheduled agent `--target ACCOUNTS|LEADS`, `agents signals --target`, the `agent-to-sequence` and `agent-to-leads` workflow scaffolds, paced HTTP Request column contracts, branch-aware LinkedIn sequence recipes, sequence campaign intake guards before mutating objects, real agent soft-delete with associated-table handling, research-table sequence handoff assignee and active-sequence-conflict guard config, backend-owned directional source/destination helpers, goal-level workflow plans, website visitor/external intent webhook workflow guidance, create-time agent assignment defaults, company-page signal configuration guidance, sequence authoring warnings when AI draft is mixed with fixed templates, sender-account discovery/management for explicit sequence routing, and mixed parent-row/child-list Sync to Table and Sync to Leads recipe configs
310
310
  - `autotouch capabilities --output json --select list_builds` for documented list-build inputs such as geography IDs, company size buckets, profile language, and company IDs
311
311
  - `autotouch integrations list` and `autotouch integrations status --provider <provider>` before choosing source/destination workflows
312
312
  - `autotouch workflows plan --type bulk-outreach` and `autotouch workflows scaffold --type bulk-outreach --out-dir workflow` for goal-level workflow planning
@@ -160,7 +160,7 @@ If the user says "automate the sequence" without asking for AI-written sends, ch
160
160
 
161
161
  Version guard:
162
162
 
163
- - Use `autotouch --version` before relying on recipe defaults. This repo expects `autotouch-cli` `0.2.107` or newer.
163
+ - Use `autotouch --version` before relying on recipe defaults. This repo expects `autotouch-cli` `0.2.109` or newer.
164
164
  - If `python3 -m pip install -U autotouch-cli` upgrades the package but `which autotouch` still points at an older shim, run the upgraded binary directly or fix PATH before creating production sequences.
165
165
  - Before authoring a LinkedIn sequence, inspect the live recipe:
166
166
 
@@ -281,7 +281,7 @@ For automation or agent-driven setup, use:
281
281
  - `autotouch cli-manifest --output json` for the local machine-readable command contract
282
282
  - `autotouch cli-reference` for the shipped parser-generated reference
283
283
  - `autotouch capabilities --output json` for provider/workflow contracts
284
- - `autotouch --version` should be `0.2.107` or newer for structured company list builds without user-supplied keywords, stored list-build input lookup, research-workspace list-build guidance, the cleaned single LinkedIn-sourced list-build path, Exa Company Search up to 100 results, scheduled agent `--target ACCOUNTS|LEADS`, `agents signals --target`, the `agent-to-sequence` and `agent-to-leads` workflow scaffolds, paced HTTP Request column contracts, branch-aware LinkedIn sequence recipes, real agent soft-delete with associated-table handling, research-table sequence handoff assignee and active-sequence-conflict guard config, backend-owned directional source/destination helpers, goal-level workflow plans, website visitor/external intent webhook workflow guidance, create-time agent assignment defaults, company-page signal configuration guidance, sequence authoring warnings when AI draft is mixed with fixed templates, sender-account discovery/management for explicit sequence routing, and mixed parent-row/child-list Sync to Table and Sync to Leads recipe configs
284
+ - `autotouch --version` should be `0.2.109` or newer for structured company list builds without user-supplied keywords, stored list-build input lookup, research-workspace list-build guidance, the cleaned single LinkedIn-sourced list-build path, Exa Company Search up to 100 results, scheduled agent `--target ACCOUNTS|LEADS`, `agents signals --target`, the `agent-to-sequence` and `agent-to-leads` workflow scaffolds, paced HTTP Request column contracts, branch-aware LinkedIn sequence recipes, sequence campaign intake guards before mutating objects, real agent soft-delete with associated-table handling, research-table sequence handoff assignee and active-sequence-conflict guard config, backend-owned directional source/destination helpers, goal-level workflow plans, website visitor/external intent webhook workflow guidance, create-time agent assignment defaults, company-page signal configuration guidance, sequence authoring warnings when AI draft is mixed with fixed templates, sender-account discovery/management for explicit sequence routing, and mixed parent-row/child-list Sync to Table and Sync to Leads recipe configs
285
285
  - `autotouch capabilities --output json --select list_builds` for documented list-build inputs such as geography IDs, company size buckets, profile language, and company IDs
286
286
  - `autotouch integrations list` and `autotouch integrations status --provider <provider>` before choosing source/destination workflows
287
287
  - `autotouch workflows plan --type bulk-outreach` and `autotouch workflows scaffold --type bulk-outreach --out-dir workflow` for goal-level workflow planning
@@ -121,6 +121,17 @@ from autotouch_cli.commands.list_build import (
121
121
  cmd_list_build_status as cmd_list_build_status_impl,
122
122
  cmd_list_build_sync_to_table as cmd_list_build_sync_to_table_impl,
123
123
  )
124
+ from autotouch_cli.commands.outreach import (
125
+ OutreachCommandRuntime as OutreachCommandHandlerRuntime,
126
+ cmd_outreach_accounts_list as cmd_outreach_accounts_list_impl,
127
+ cmd_outreach_campaigns_activate as cmd_outreach_campaigns_activate_impl,
128
+ cmd_outreach_campaigns_create as cmd_outreach_campaigns_create_impl,
129
+ cmd_outreach_campaigns_get as cmd_outreach_campaigns_get_impl,
130
+ cmd_outreach_campaigns_list as cmd_outreach_campaigns_list_impl,
131
+ cmd_outreach_campaigns_pause as cmd_outreach_campaigns_pause_impl,
132
+ cmd_outreach_campaigns_sync_accounts as cmd_outreach_campaigns_sync_accounts_impl,
133
+ cmd_outreach_campaigns_sync_templates as cmd_outreach_campaigns_sync_templates_impl,
134
+ )
124
135
  from autotouch_cli.commands.rows import (
125
136
  RowCommandRuntime as RowCommandHandlerRuntime,
126
137
  cmd_rows_add as cmd_rows_add_impl,
@@ -1406,6 +1417,15 @@ def _integration_command_runtime() -> IntegrationCommandHandlerRuntime:
1406
1417
  )
1407
1418
 
1408
1419
 
1420
+ def _outreach_command_runtime() -> OutreachCommandHandlerRuntime:
1421
+ return OutreachCommandHandlerRuntime(
1422
+ resolve_token=_resolve_token,
1423
+ request_api=_request_api,
1424
+ print_json=lambda data, compact=False: _print_json(data, compact=compact),
1425
+ load_json_input=_load_json_input,
1426
+ )
1427
+
1428
+
1409
1429
  def _sender_account_command_runtime() -> SenderAccountCommandHandlerRuntime:
1410
1430
  return SenderAccountCommandHandlerRuntime(
1411
1431
  resolve_token=_resolve_token,
@@ -1549,6 +1569,16 @@ _register("integrations_recipe", cmd_integrations_recipe_impl, _integration_comm
1549
1569
  _register("integrations_from_crm_status", cmd_integrations_from_crm_status_impl, _integration_command_runtime)
1550
1570
  _register("integrations_to_crm_status", cmd_integrations_to_crm_status_impl, _integration_command_runtime)
1551
1571
 
1572
+ # -- Outreach commands --
1573
+ _register("outreach_accounts_list", cmd_outreach_accounts_list_impl, _outreach_command_runtime)
1574
+ _register("outreach_campaigns_list", cmd_outreach_campaigns_list_impl, _outreach_command_runtime)
1575
+ _register("outreach_campaigns_get", cmd_outreach_campaigns_get_impl, _outreach_command_runtime)
1576
+ _register("outreach_campaigns_create", cmd_outreach_campaigns_create_impl, _outreach_command_runtime)
1577
+ _register("outreach_campaigns_sync_accounts", cmd_outreach_campaigns_sync_accounts_impl, _outreach_command_runtime)
1578
+ _register("outreach_campaigns_sync_templates", cmd_outreach_campaigns_sync_templates_impl, _outreach_command_runtime)
1579
+ _register("outreach_campaigns_activate", cmd_outreach_campaigns_activate_impl, _outreach_command_runtime)
1580
+ _register("outreach_campaigns_pause", cmd_outreach_campaigns_pause_impl, _outreach_command_runtime)
1581
+
1552
1582
  # -- Sender account commands --
1553
1583
  _register("sender_accounts_list", cmd_sender_accounts_list_impl, _sender_account_command_runtime)
1554
1584
  _register("sender_accounts_get", cmd_sender_accounts_get_impl, _sender_account_command_runtime)
@@ -54,6 +54,7 @@ _AUTH_MODE_PREFIXES: Tuple[Tuple[str, str], ...] = (
54
54
  ("webhooks.", "developer_key_or_user_session"),
55
55
  ("search.", "developer_key_or_user_session"),
56
56
  ("linkedin.", "developer_key_or_user_session"),
57
+ ("outreach.", "developer_key_or_user_session"),
57
58
  ("workflows.", "none"),
58
59
  )
59
60
 
@@ -0,0 +1,308 @@
1
+ from __future__ import annotations
2
+
3
+ import argparse
4
+ from dataclasses import dataclass
5
+ from typing import Any, Callable, Dict, Optional, Sequence
6
+ from urllib.parse import urlencode
7
+
8
+ from autotouch_cli.exceptions import AutotouchInputError
9
+
10
+
11
+ OUTREACH_PROVIDERS = ("instantly", "smartlead")
12
+
13
+
14
+ @dataclass(frozen=True)
15
+ class OutreachCommandRuntime:
16
+ resolve_token: Callable[[Optional[str], bool], Optional[str]]
17
+ request_api: Callable[..., Any]
18
+ print_json: Callable[[Any, bool], None]
19
+ load_json_input: Callable[..., Any]
20
+
21
+
22
+ def _provider(args: argparse.Namespace) -> str:
23
+ provider = str(getattr(args, "provider", "") or "").strip().lower()
24
+ if provider not in OUTREACH_PROVIDERS:
25
+ raise AutotouchInputError("--provider must be instantly or smartlead")
26
+ return provider
27
+
28
+
29
+ def _base_payload(args: argparse.Namespace, *, runtime: OutreachCommandRuntime) -> Dict[str, Any]:
30
+ explicit = runtime.load_json_input(
31
+ inline_json=getattr(args, "data_json", None),
32
+ file_path=getattr(args, "data_file", None),
33
+ context="data",
34
+ default=None,
35
+ )
36
+ if explicit is not None:
37
+ if not isinstance(explicit, dict):
38
+ raise AutotouchInputError("outreach payload must be a JSON object")
39
+ return explicit
40
+ return {}
41
+
42
+
43
+ def _account_payload(args: argparse.Namespace, *, runtime: OutreachCommandRuntime) -> Dict[str, Any]:
44
+ payload = _base_payload(args, runtime=runtime)
45
+ if "accountSelection" not in payload and getattr(args, "account_selection", None):
46
+ payload["accountSelection"] = args.account_selection
47
+ selected = getattr(args, "selected_account", None) or []
48
+ if selected and "selectedAccounts" not in payload:
49
+ payload["selectedAccounts"] = selected
50
+ if getattr(args, "min_health_score", None) is not None and "minHealthScore" not in payload:
51
+ payload["minHealthScore"] = int(args.min_health_score)
52
+ if getattr(args, "no_refresh", False) and "refresh" not in payload:
53
+ payload["refresh"] = False
54
+ return payload
55
+
56
+
57
+ def cmd_outreach_campaigns_list(args: argparse.Namespace, *, runtime: OutreachCommandRuntime) -> None:
58
+ token = runtime.resolve_token(args.token, required=True)
59
+ provider = _provider(args)
60
+ data = runtime.request_api(
61
+ "GET",
62
+ f"/api/integrations/{provider}/campaigns",
63
+ base_url=args.base_url,
64
+ token=token,
65
+ use_x_api_key=args.use_x_api_key,
66
+ timeout=args.timeout,
67
+ verbose=args.verbose,
68
+ )
69
+ runtime.print_json(data, args.compact)
70
+
71
+
72
+ def cmd_outreach_campaigns_get(args: argparse.Namespace, *, runtime: OutreachCommandRuntime) -> None:
73
+ token = runtime.resolve_token(args.token, required=True)
74
+ provider = _provider(args)
75
+ data = runtime.request_api(
76
+ "GET",
77
+ f"/api/integrations/{provider}/campaigns/{args.campaign_id}",
78
+ base_url=args.base_url,
79
+ token=token,
80
+ use_x_api_key=args.use_x_api_key,
81
+ timeout=args.timeout,
82
+ verbose=args.verbose,
83
+ )
84
+ runtime.print_json(data, args.compact)
85
+
86
+
87
+ def cmd_outreach_campaigns_create(args: argparse.Namespace, *, runtime: OutreachCommandRuntime) -> None:
88
+ token = runtime.resolve_token(args.token, required=True)
89
+ provider = _provider(args)
90
+ payload = _account_payload(args, runtime=runtime)
91
+ if "name" not in payload:
92
+ name = str(getattr(args, "name", "") or "").strip()
93
+ if not name:
94
+ raise AutotouchInputError("--name is required unless --data-json/--data-file provides name")
95
+ payload["name"] = name
96
+ if getattr(args, "activate", False):
97
+ payload["activate"] = True
98
+ data = runtime.request_api(
99
+ "POST",
100
+ f"/api/integrations/{provider}/campaigns",
101
+ base_url=args.base_url,
102
+ token=token,
103
+ use_x_api_key=args.use_x_api_key,
104
+ payload=payload,
105
+ timeout=args.timeout,
106
+ verbose=args.verbose,
107
+ )
108
+ runtime.print_json(data, args.compact)
109
+
110
+
111
+ def cmd_outreach_campaigns_sync_accounts(args: argparse.Namespace, *, runtime: OutreachCommandRuntime) -> None:
112
+ token = runtime.resolve_token(args.token, required=True)
113
+ provider = _provider(args)
114
+ payload = _account_payload(args, runtime=runtime)
115
+ data = runtime.request_api(
116
+ "POST",
117
+ f"/api/integrations/{provider}/campaigns/{args.campaign_id}/sync-account-pool",
118
+ base_url=args.base_url,
119
+ token=token,
120
+ use_x_api_key=args.use_x_api_key,
121
+ payload=payload,
122
+ timeout=args.timeout,
123
+ verbose=args.verbose,
124
+ )
125
+ runtime.print_json(data, args.compact)
126
+
127
+
128
+ def cmd_outreach_campaigns_sync_templates(args: argparse.Namespace, *, runtime: OutreachCommandRuntime) -> None:
129
+ token = runtime.resolve_token(args.token, required=True)
130
+ provider = _provider(args)
131
+ payload = _base_payload(args, runtime=runtime)
132
+ if "steps" not in payload:
133
+ raise AutotouchInputError("sync-templates requires --data-json/--data-file with steps[]")
134
+ data = runtime.request_api(
135
+ "POST",
136
+ f"/api/integrations/{provider}/campaigns/{args.campaign_id}/sync-templates",
137
+ base_url=args.base_url,
138
+ token=token,
139
+ use_x_api_key=args.use_x_api_key,
140
+ payload=payload,
141
+ timeout=args.timeout,
142
+ verbose=args.verbose,
143
+ )
144
+ runtime.print_json(data, args.compact)
145
+
146
+
147
+ def _campaign_state(args: argparse.Namespace, *, runtime: OutreachCommandRuntime, action: str) -> None:
148
+ token = runtime.resolve_token(args.token, required=True)
149
+ provider = _provider(args)
150
+ data = runtime.request_api(
151
+ "POST",
152
+ f"/api/integrations/{provider}/campaigns/{args.campaign_id}/{action}",
153
+ base_url=args.base_url,
154
+ token=token,
155
+ use_x_api_key=args.use_x_api_key,
156
+ payload={},
157
+ timeout=args.timeout,
158
+ verbose=args.verbose,
159
+ )
160
+ runtime.print_json(data, args.compact)
161
+
162
+
163
+ def cmd_outreach_campaigns_activate(args: argparse.Namespace, *, runtime: OutreachCommandRuntime) -> None:
164
+ _campaign_state(args, runtime=runtime, action="activate")
165
+
166
+
167
+ def cmd_outreach_campaigns_pause(args: argparse.Namespace, *, runtime: OutreachCommandRuntime) -> None:
168
+ _campaign_state(args, runtime=runtime, action="pause")
169
+
170
+
171
+ def cmd_outreach_accounts_list(args: argparse.Namespace, *, runtime: OutreachCommandRuntime) -> None:
172
+ token = runtime.resolve_token(args.token, required=True)
173
+ provider = str(getattr(args, "provider", "") or "").strip().lower()
174
+ if provider and provider not in OUTREACH_PROVIDERS:
175
+ raise AutotouchInputError("--provider must be instantly or smartlead")
176
+ query = f"?{urlencode({'provider': provider})}" if provider else ""
177
+ data = runtime.request_api(
178
+ "GET",
179
+ f"/api/email-accounts/external-accounts{query}",
180
+ base_url=args.base_url,
181
+ token=token,
182
+ use_x_api_key=args.use_x_api_key,
183
+ timeout=args.timeout,
184
+ verbose=args.verbose,
185
+ )
186
+ runtime.print_json(data, args.compact)
187
+
188
+
189
+ def _add_provider_argument(parser: argparse.ArgumentParser) -> None:
190
+ parser.add_argument("--provider", required=True, choices=list(OUTREACH_PROVIDERS))
191
+
192
+
193
+ def _add_account_policy_arguments(parser: argparse.ArgumentParser) -> None:
194
+ parser.add_argument(
195
+ "--account-selection",
196
+ choices=["all_eligible", "selected"],
197
+ default="all_eligible",
198
+ help="Sending account pool selection (default: all_eligible)",
199
+ )
200
+ parser.add_argument(
201
+ "--selected-account",
202
+ action="append",
203
+ default=None,
204
+ help="Sending account email when --account-selection selected; repeatable",
205
+ )
206
+ parser.add_argument(
207
+ "--min-health-score",
208
+ type=int,
209
+ help="One-off mailbox health threshold 0-100; does not update org settings",
210
+ )
211
+
212
+
213
+ def _add_json_payload_arguments(parser: argparse.ArgumentParser) -> None:
214
+ parser.add_argument("--data-json", help="Explicit JSON payload")
215
+ parser.add_argument("--data-file", help="Path to JSON payload file")
216
+
217
+
218
+ def register_outreach_subcommands(
219
+ subparsers: argparse._SubParsersAction[argparse.ArgumentParser],
220
+ *,
221
+ add_api_common_arguments: Callable[[argparse.ArgumentParser], None],
222
+ handlers: Dict[str, Callable[[argparse.Namespace], None]],
223
+ ) -> None:
224
+ parser = subparsers.add_parser(
225
+ "outreach",
226
+ help="Manage Instantly/Smartlead campaign handoff from Autotouch",
227
+ description=(
228
+ "Manage external outreach-provider campaigns used by research-table to_outreach. "
229
+ "Autotouch can create/configure campaigns, map healthy sender accounts, upload rows, "
230
+ "and explicitly activate/pause campaigns; the provider runs the campaign after activation."
231
+ ),
232
+ )
233
+ parser._codex_examples = [
234
+ "autotouch outreach accounts list --provider instantly",
235
+ "autotouch outreach campaigns list --provider instantly",
236
+ "autotouch outreach campaigns create --provider instantly --name 'June Buyers' --min-health-score 100",
237
+ "autotouch columns recipe --type to_outreach --out-file push-to-outreach.json",
238
+ ]
239
+ outreach_sub = parser.add_subparsers(dest="outreach_cmd", required=True)
240
+
241
+ accounts = outreach_sub.add_parser("accounts", help="Inspect eligible provider sending accounts")
242
+ accounts_sub = accounts.add_subparsers(dest="outreach_accounts_cmd", required=True)
243
+ accounts_list = accounts_sub.add_parser(
244
+ "list",
245
+ help="List Instantly/Smartlead sending accounts with Autotouch eligibility applied",
246
+ )
247
+ accounts_list.add_argument("--provider", choices=list(OUTREACH_PROVIDERS), help="Filter provider")
248
+ add_api_common_arguments(accounts_list)
249
+ accounts_list.set_defaults(func=handlers["accounts_list"])
250
+
251
+ campaigns = outreach_sub.add_parser("campaigns", help="List, create, and manage provider campaigns")
252
+ campaigns_sub = campaigns.add_subparsers(dest="outreach_campaigns_cmd", required=True)
253
+
254
+ plist = campaigns_sub.add_parser("list", help="List provider campaigns")
255
+ _add_provider_argument(plist)
256
+ add_api_common_arguments(plist)
257
+ plist.set_defaults(func=handlers["campaigns_list"])
258
+
259
+ pget = campaigns_sub.add_parser("get", help="Get one provider campaign")
260
+ _add_provider_argument(pget)
261
+ pget.add_argument("--campaign-id", required=True)
262
+ add_api_common_arguments(pget)
263
+ pget.set_defaults(func=handlers["campaigns_get"])
264
+
265
+ pcreate = campaigns_sub.add_parser(
266
+ "create",
267
+ help="Create a draft provider campaign",
268
+ description=(
269
+ "Create an Instantly/Smartlead campaign and attach eligible sending accounts. "
270
+ "The campaign is draft/inactive by default; use activate explicitly when ready. "
271
+ "Use --data-file for optional schedule or deterministic template steps."
272
+ ),
273
+ )
274
+ _add_provider_argument(pcreate)
275
+ pcreate.add_argument("--name", help="Campaign name; required unless provided in --data-json/--data-file")
276
+ _add_account_policy_arguments(pcreate)
277
+ pcreate.add_argument("--activate", action="store_true", help="Activate immediately after create")
278
+ _add_json_payload_arguments(pcreate)
279
+ add_api_common_arguments(pcreate)
280
+ pcreate.set_defaults(func=handlers["campaigns_create"])
281
+
282
+ psync_accounts = campaigns_sub.add_parser("sync-accounts", help="Sync campaign sender account pool")
283
+ _add_provider_argument(psync_accounts)
284
+ psync_accounts.add_argument("--campaign-id", required=True)
285
+ _add_account_policy_arguments(psync_accounts)
286
+ psync_accounts.add_argument("--no-refresh", action="store_true", help="Use cached provider account snapshot")
287
+ _add_json_payload_arguments(psync_accounts)
288
+ add_api_common_arguments(psync_accounts)
289
+ psync_accounts.set_defaults(func=handlers["campaigns_sync_accounts"])
290
+
291
+ psync_templates = campaigns_sub.add_parser("sync-templates", help="Sync deterministic provider template steps")
292
+ _add_provider_argument(psync_templates)
293
+ psync_templates.add_argument("--campaign-id", required=True)
294
+ _add_json_payload_arguments(psync_templates)
295
+ add_api_common_arguments(psync_templates)
296
+ psync_templates.set_defaults(func=handlers["campaigns_sync_templates"])
297
+
298
+ pactivate = campaigns_sub.add_parser("activate", help="Activate a provider campaign")
299
+ _add_provider_argument(pactivate)
300
+ pactivate.add_argument("--campaign-id", required=True)
301
+ add_api_common_arguments(pactivate)
302
+ pactivate.set_defaults(func=handlers["campaigns_activate"])
303
+
304
+ ppause = campaigns_sub.add_parser("pause", help="Pause a provider campaign")
305
+ _add_provider_argument(ppause)
306
+ ppause.add_argument("--campaign-id", required=True)
307
+ add_api_common_arguments(ppause)
308
+ ppause.set_defaults(func=handlers["campaigns_pause"])