autotouch-cli 0.2.113__tar.gz → 0.2.115__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 (62) hide show
  1. {autotouch_cli-0.2.113 → autotouch_cli-0.2.115}/PKG-INFO +8 -6
  2. {autotouch_cli-0.2.113 → autotouch_cli-0.2.115}/README.md +7 -5
  3. {autotouch_cli-0.2.113 → autotouch_cli-0.2.115}/autotouch_cli/cli.py +19 -0
  4. autotouch_cli-0.2.115/autotouch_cli/commands/capacity.py +308 -0
  5. {autotouch_cli-0.2.113 → autotouch_cli-0.2.115}/autotouch_cli/commands/sender_accounts.py +6 -5
  6. {autotouch_cli-0.2.113 → autotouch_cli-0.2.115}/autotouch_cli/commands/sequences.py +32 -7
  7. {autotouch_cli-0.2.113 → autotouch_cli-0.2.115}/autotouch_cli/data/CLI_REFERENCE.md +134 -8
  8. {autotouch_cli-0.2.113 → autotouch_cli-0.2.115}/autotouch_cli/data/cli-manifest.json +805 -8
  9. {autotouch_cli-0.2.113 → autotouch_cli-0.2.115}/autotouch_cli/parser.py +12 -0
  10. {autotouch_cli-0.2.113 → autotouch_cli-0.2.115}/autotouch_cli/templates.py +19 -8
  11. {autotouch_cli-0.2.113 → autotouch_cli-0.2.115}/autotouch_cli.egg-info/PKG-INFO +8 -6
  12. {autotouch_cli-0.2.113 → autotouch_cli-0.2.115}/autotouch_cli.egg-info/SOURCES.txt +1 -0
  13. {autotouch_cli-0.2.113 → autotouch_cli-0.2.115}/pyproject.toml +1 -1
  14. {autotouch_cli-0.2.113 → autotouch_cli-0.2.115}/MANIFEST.in +0 -0
  15. {autotouch_cli-0.2.113 → autotouch_cli-0.2.115}/autotouch_cli/__init__.py +0 -0
  16. {autotouch_cli-0.2.113 → autotouch_cli-0.2.115}/autotouch_cli/cli_contracts.py +0 -0
  17. {autotouch_cli-0.2.113 → autotouch_cli-0.2.115}/autotouch_cli/commands/__init__.py +0 -0
  18. {autotouch_cli-0.2.113 → autotouch_cli-0.2.115}/autotouch_cli/commands/agents.py +0 -0
  19. {autotouch_cli-0.2.113 → autotouch_cli-0.2.115}/autotouch_cli/commands/auth.py +0 -0
  20. {autotouch_cli-0.2.113 → autotouch_cli-0.2.115}/autotouch_cli/commands/cells.py +0 -0
  21. {autotouch_cli-0.2.113 → autotouch_cli-0.2.115}/autotouch_cli/commands/columns.py +0 -0
  22. {autotouch_cli-0.2.113 → autotouch_cli-0.2.115}/autotouch_cli/commands/integrations.py +0 -0
  23. {autotouch_cli-0.2.113 → autotouch_cli-0.2.115}/autotouch_cli/commands/jobs.py +0 -0
  24. {autotouch_cli-0.2.113 → autotouch_cli-0.2.115}/autotouch_cli/commands/leads.py +0 -0
  25. {autotouch_cli-0.2.113 → autotouch_cli-0.2.115}/autotouch_cli/commands/linkedin.py +0 -0
  26. {autotouch_cli-0.2.113 → autotouch_cli-0.2.115}/autotouch_cli/commands/list_build.py +0 -0
  27. {autotouch_cli-0.2.113 → autotouch_cli-0.2.115}/autotouch_cli/commands/outreach.py +0 -0
  28. {autotouch_cli-0.2.113 → autotouch_cli-0.2.115}/autotouch_cli/commands/prompts.py +0 -0
  29. {autotouch_cli-0.2.113 → autotouch_cli-0.2.115}/autotouch_cli/commands/rows.py +0 -0
  30. {autotouch_cli-0.2.113 → autotouch_cli-0.2.115}/autotouch_cli/commands/search.py +0 -0
  31. {autotouch_cli-0.2.113 → autotouch_cli-0.2.115}/autotouch_cli/commands/tables.py +0 -0
  32. {autotouch_cli-0.2.113 → autotouch_cli-0.2.115}/autotouch_cli/commands/tasks.py +0 -0
  33. {autotouch_cli-0.2.113 → autotouch_cli-0.2.115}/autotouch_cli/commands/webhooks.py +0 -0
  34. {autotouch_cli-0.2.113 → autotouch_cli-0.2.115}/autotouch_cli/commands/workspace_secrets.py +0 -0
  35. {autotouch_cli-0.2.113 → autotouch_cli-0.2.115}/autotouch_cli/core/__init__.py +0 -0
  36. {autotouch_cli-0.2.113 → autotouch_cli-0.2.115}/autotouch_cli/core/auth.py +0 -0
  37. {autotouch_cli-0.2.113 → autotouch_cli-0.2.115}/autotouch_cli/core/config.py +0 -0
  38. {autotouch_cli-0.2.113 → autotouch_cli-0.2.115}/autotouch_cli/core/csv_import.py +0 -0
  39. {autotouch_cli-0.2.113 → autotouch_cli-0.2.115}/autotouch_cli/core/http.py +0 -0
  40. {autotouch_cli-0.2.113 → autotouch_cli-0.2.115}/autotouch_cli/core/io.py +0 -0
  41. {autotouch_cli-0.2.113 → autotouch_cli-0.2.115}/autotouch_cli/core/output.py +0 -0
  42. {autotouch_cli-0.2.113 → autotouch_cli-0.2.115}/autotouch_cli/core/polling.py +0 -0
  43. {autotouch_cli-0.2.113 → autotouch_cli-0.2.115}/autotouch_cli/core/run.py +0 -0
  44. {autotouch_cli-0.2.113 → autotouch_cli-0.2.115}/autotouch_cli/core/validation.py +0 -0
  45. {autotouch_cli-0.2.113 → autotouch_cli-0.2.115}/autotouch_cli/exceptions.py +0 -0
  46. {autotouch_cli-0.2.113 → autotouch_cli-0.2.115}/autotouch_cli/mongo_status.py +0 -0
  47. {autotouch_cli-0.2.113 → autotouch_cli-0.2.115}/autotouch_cli/parser_groups.py +0 -0
  48. {autotouch_cli-0.2.113 → autotouch_cli-0.2.115}/autotouch_cli/sequence_support.py +0 -0
  49. {autotouch_cli-0.2.113 → autotouch_cli-0.2.115}/autotouch_cli/workflows/__init__.py +0 -0
  50. {autotouch_cli-0.2.113 → autotouch_cli-0.2.115}/autotouch_cli/workflows/registry.py +0 -0
  51. {autotouch_cli-0.2.113 → autotouch_cli-0.2.115}/autotouch_cli.egg-info/dependency_links.txt +0 -0
  52. {autotouch_cli-0.2.113 → autotouch_cli-0.2.115}/autotouch_cli.egg-info/entry_points.txt +0 -0
  53. {autotouch_cli-0.2.113 → autotouch_cli-0.2.115}/autotouch_cli.egg-info/requires.txt +0 -0
  54. {autotouch_cli-0.2.113 → autotouch_cli-0.2.115}/autotouch_cli.egg-info/top_level.txt +0 -0
  55. {autotouch_cli-0.2.113 → autotouch_cli-0.2.115}/autotouch_shared/__init__.py +0 -0
  56. {autotouch_cli-0.2.113 → autotouch_cli-0.2.115}/autotouch_shared/linkedin_contract.py +0 -0
  57. {autotouch_cli-0.2.113 → autotouch_cli-0.2.115}/autotouch_shared/linkedin_filters.py +0 -0
  58. {autotouch_cli-0.2.113 → autotouch_cli-0.2.115}/autotouch_shared/list_build_contract.py +0 -0
  59. {autotouch_cli-0.2.113 → autotouch_cli-0.2.115}/autotouch_shared/product_lifecycle.py +0 -0
  60. {autotouch_cli-0.2.113 → autotouch_cli-0.2.115}/autotouch_shared/provider_registry.py +0 -0
  61. {autotouch_cli-0.2.113 → autotouch_cli-0.2.115}/autotouch_shared/search_contract.py +0 -0
  62. {autotouch_cli-0.2.113 → autotouch_cli-0.2.115}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: autotouch-cli
3
- Version: 0.2.113
3
+ Version: 0.2.115
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
@@ -52,11 +52,11 @@ Smart Table is the operating layer. Most workflows should land records there bef
52
52
  Released package:
53
53
 
54
54
  ```bash
55
- pipx install autotouch-cli
55
+ pipx install --force autotouch-cli
56
56
  # or
57
- pip install autotouch-cli
57
+ python -m pip install autotouch-cli
58
58
  # upgrade
59
- pip install -U autotouch-cli
59
+ python -m pip install -U autotouch-cli
60
60
  ```
61
61
 
62
62
  Unreleased branch or pre-publish build:
@@ -185,13 +185,15 @@ When a user asks to create a campaign sequence, distinguish these separate decis
185
185
 
186
186
  If the user says "automate the sequence" without asking for AI-written sends, choose the template-based automated path. Offer manual AI-draft review as the higher-personalization path, but call out that it creates upfront manual tasks while the system learns.
187
187
 
188
+ Do not mix `aiDraft=true` with non-empty `subjectTemplate`, `bodyTemplate`, or `scriptTemplate`. Template fields send exact variable-filled copy when `aiDraft=false`; AI-draft steps should leave template fields empty and use sequence/source-table context. The CLI and developer-key API reject the mixed shape.
189
+
188
190
  For bulk Instantly/Smartlead sequences, email sender accounts live on the provider campaign, not on each enrollment. Use `autotouch sequences sync-accounts --sequence-id <SEQUENCE_ID> --account-selection all_eligible` for the org's eligible provider-account group, or `--account-selection selected --selected-account sender@example.com` for specific provider mailboxes. For personal mailbox or LinkedIn steps, use enrollment sender routing only when the user asks for explicit sender pinning or team routing.
189
191
 
190
192
  Keep `requiredVariables` limited to variables that the sequence actually needs. If a variable is listed there, every provider enrollment must hydrate it from lead context, research-table mappings, or explicit overrides; unused required variables can block an otherwise valid bulk campaign.
191
193
 
192
194
  Version guard:
193
195
 
194
- - Use `autotouch --version` before relying on recipe defaults. This repo expects `autotouch-cli` `0.2.112` or newer.
196
+ - Use `autotouch --version` before relying on recipe defaults. This repo expects `autotouch-cli` `0.2.115` or newer.
195
197
  - 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.
196
198
  - Before authoring a LinkedIn sequence, inspect the live recipe:
197
199
 
@@ -320,7 +322,7 @@ For automation or agent-driven setup, use:
320
322
  - `autotouch cli-manifest --output json` for the local machine-readable command contract
321
323
  - `autotouch cli-reference` for the shipped parser-generated reference
322
324
  - `autotouch capabilities --output json` for provider/workflow contracts
323
- - `autotouch --version` should be `0.2.112` 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, mixed parent-row/child-list Sync to Table and Sync to Leads recipe configs, and company variable guidance for `company_name_clean` versus internal match keys
325
+ - `autotouch --version` should be `0.2.115` 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, `LINKEDIN_MESSAGE` best-available delivery versus `LINKEDIN_CHAT_MESSAGE` chat-only guidance, 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, mixed parent-row/child-list Sync to Table and Sync to Leads recipe configs, and company variable guidance for `company_name_clean` versus internal match keys
324
326
  - `autotouch capabilities --output json --select list_builds` for documented list-build inputs such as geography IDs, company size buckets, profile language, and company IDs
325
327
  - `autotouch integrations list` and `autotouch integrations status --provider <provider>` before choosing source/destination workflows
326
328
  - `autotouch workflows plan --type bulk-outreach` and `autotouch workflows scaffold --type bulk-outreach --out-dir workflow` for goal-level workflow planning
@@ -27,11 +27,11 @@ Smart Table is the operating layer. Most workflows should land records there bef
27
27
  Released package:
28
28
 
29
29
  ```bash
30
- pipx install autotouch-cli
30
+ pipx install --force autotouch-cli
31
31
  # or
32
- pip install autotouch-cli
32
+ python -m pip install autotouch-cli
33
33
  # upgrade
34
- pip install -U autotouch-cli
34
+ python -m pip install -U autotouch-cli
35
35
  ```
36
36
 
37
37
  Unreleased branch or pre-publish build:
@@ -160,13 +160,15 @@ When a user asks to create a campaign sequence, distinguish these separate decis
160
160
 
161
161
  If the user says "automate the sequence" without asking for AI-written sends, choose the template-based automated path. Offer manual AI-draft review as the higher-personalization path, but call out that it creates upfront manual tasks while the system learns.
162
162
 
163
+ Do not mix `aiDraft=true` with non-empty `subjectTemplate`, `bodyTemplate`, or `scriptTemplate`. Template fields send exact variable-filled copy when `aiDraft=false`; AI-draft steps should leave template fields empty and use sequence/source-table context. The CLI and developer-key API reject the mixed shape.
164
+
163
165
  For bulk Instantly/Smartlead sequences, email sender accounts live on the provider campaign, not on each enrollment. Use `autotouch sequences sync-accounts --sequence-id <SEQUENCE_ID> --account-selection all_eligible` for the org's eligible provider-account group, or `--account-selection selected --selected-account sender@example.com` for specific provider mailboxes. For personal mailbox or LinkedIn steps, use enrollment sender routing only when the user asks for explicit sender pinning or team routing.
164
166
 
165
167
  Keep `requiredVariables` limited to variables that the sequence actually needs. If a variable is listed there, every provider enrollment must hydrate it from lead context, research-table mappings, or explicit overrides; unused required variables can block an otherwise valid bulk campaign.
166
168
 
167
169
  Version guard:
168
170
 
169
- - Use `autotouch --version` before relying on recipe defaults. This repo expects `autotouch-cli` `0.2.112` or newer.
171
+ - Use `autotouch --version` before relying on recipe defaults. This repo expects `autotouch-cli` `0.2.115` or newer.
170
172
  - 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.
171
173
  - Before authoring a LinkedIn sequence, inspect the live recipe:
172
174
 
@@ -295,7 +297,7 @@ For automation or agent-driven setup, use:
295
297
  - `autotouch cli-manifest --output json` for the local machine-readable command contract
296
298
  - `autotouch cli-reference` for the shipped parser-generated reference
297
299
  - `autotouch capabilities --output json` for provider/workflow contracts
298
- - `autotouch --version` should be `0.2.112` 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, mixed parent-row/child-list Sync to Table and Sync to Leads recipe configs, and company variable guidance for `company_name_clean` versus internal match keys
300
+ - `autotouch --version` should be `0.2.115` 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, `LINKEDIN_MESSAGE` best-available delivery versus `LINKEDIN_CHAT_MESSAGE` chat-only guidance, 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, mixed parent-row/child-list Sync to Table and Sync to Leads recipe configs, and company variable guidance for `company_name_clean` versus internal match keys
299
301
  - `autotouch capabilities --output json --select list_builds` for documented list-build inputs such as geography IDs, company size buckets, profile language, and company IDs
300
302
  - `autotouch integrations list` and `autotouch integrations status --provider <provider>` before choosing source/destination workflows
301
303
  - `autotouch workflows plan --type bulk-outreach` and `autotouch workflows scaffold --type bulk-outreach --out-dir workflow` for goal-level workflow planning
@@ -71,6 +71,12 @@ from autotouch_cli.commands.auth import (
71
71
  cmd_auth_show as cmd_auth_show_impl,
72
72
  cmd_auth_whoami as cmd_auth_whoami_impl,
73
73
  )
74
+ from autotouch_cli.commands.capacity import (
75
+ CapacityCommandRuntime as CapacityCommandHandlerRuntime,
76
+ cmd_capacity_channels as cmd_capacity_channels_impl,
77
+ cmd_capacity_overview as cmd_capacity_overview_impl,
78
+ cmd_capacity_recommend as cmd_capacity_recommend_impl,
79
+ )
74
80
  from autotouch_cli.commands.jobs import (
75
81
  JobCommandRuntime as JobCommandHandlerRuntime,
76
82
  cmd_jobs_get as cmd_jobs_get_impl,
@@ -1349,6 +1355,14 @@ def _prompt_command_runtime() -> PromptCommandHandlerRuntime:
1349
1355
  )
1350
1356
 
1351
1357
 
1358
+ def _capacity_command_runtime() -> CapacityCommandHandlerRuntime:
1359
+ return CapacityCommandHandlerRuntime(
1360
+ resolve_token=_resolve_token,
1361
+ request_api=_request_api,
1362
+ print_json=lambda data, compact=False: _print_json(data, compact=compact),
1363
+ )
1364
+
1365
+
1352
1366
  def _workspace_secret_command_runtime() -> WorkspaceSecretCommandHandlerRuntime:
1353
1367
  return WorkspaceSecretCommandHandlerRuntime(
1354
1368
  resolve_token=_resolve_token,
@@ -1490,6 +1504,11 @@ _register("prompts_create", cmd_prompts_create_impl, _prompt_command_runtime)
1490
1504
  _register("prompts_update", cmd_prompts_update_impl, _prompt_command_runtime)
1491
1505
  _register("prompts_delete", cmd_prompts_delete_impl, _prompt_command_runtime)
1492
1506
 
1507
+ # -- Capacity commands --
1508
+ _register("capacity_overview", cmd_capacity_overview_impl, _capacity_command_runtime)
1509
+ _register("capacity_channels", cmd_capacity_channels_impl, _capacity_command_runtime)
1510
+ _register("capacity_recommend", cmd_capacity_recommend_impl, _capacity_command_runtime)
1511
+
1493
1512
  # -- Workspace secrets commands --
1494
1513
  _register("workspace_secrets_list", cmd_workspace_secrets_list_impl, _workspace_secret_command_runtime)
1495
1514
  _register("workspace_secrets_set", cmd_workspace_secrets_set_impl, _workspace_secret_command_runtime)
@@ -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, List, Optional
6
+
7
+ from autotouch_cli.exceptions import AutotouchInputError
8
+
9
+
10
+ @dataclass(frozen=True)
11
+ class CapacityCommandRuntime:
12
+ resolve_token: Callable[[Optional[str], bool], Optional[str]]
13
+ request_api: Callable[..., Any]
14
+ print_json: Callable[[Any, bool], None]
15
+
16
+
17
+ def _overview_params(args: argparse.Namespace) -> Dict[str, Any]:
18
+ scope = str(getattr(args, "scope", "org") or "org")
19
+ params: Dict[str, Any] = {
20
+ "surface": str(getattr(args, "surface", "admin_command_center") or "admin_command_center"),
21
+ "scope": scope,
22
+ }
23
+ user_id = str(getattr(args, "user_id", "") or "").strip()
24
+ user_email = str(getattr(args, "user_email", "") or "").strip()
25
+ if (user_id or user_email) and scope != "me":
26
+ raise AutotouchInputError("--user-id and --user-email require --scope me")
27
+ if user_id:
28
+ params["user_id"] = user_id
29
+ if user_email:
30
+ params["user_email"] = user_email
31
+ date = str(getattr(args, "date", "") or "").strip()
32
+ if date:
33
+ params["date"] = date
34
+ timezone = str(getattr(args, "timezone", "") or "").strip()
35
+ if timezone:
36
+ params["timezone"] = timezone
37
+ return params
38
+
39
+
40
+ def _fetch_overview(args: argparse.Namespace, *, runtime: CapacityCommandRuntime) -> Dict[str, Any]:
41
+ token = runtime.resolve_token(args.token, required=True)
42
+ data = runtime.request_api(
43
+ "GET",
44
+ "/api/command-center/overview",
45
+ base_url=args.base_url,
46
+ token=token,
47
+ use_x_api_key=args.use_x_api_key,
48
+ params=_overview_params(args),
49
+ timeout=args.timeout,
50
+ verbose=args.verbose,
51
+ )
52
+ if not isinstance(data, dict):
53
+ raise AutotouchInputError("command center overview response must be a JSON object")
54
+ if data.get("error"):
55
+ raise AutotouchInputError(f"command center overview unavailable: {data.get('error')}")
56
+ if not isinstance(data.get("capacity"), dict):
57
+ raise AutotouchInputError("command center overview response is missing capacity")
58
+ return data
59
+
60
+
61
+ def _capacity(data: Dict[str, Any]) -> Dict[str, Any]:
62
+ capacity = data.get("capacity")
63
+ return capacity if isinstance(capacity, dict) else {}
64
+
65
+
66
+ def _channels(data: Dict[str, Any]) -> List[Dict[str, Any]]:
67
+ channels = _capacity(data).get("channels")
68
+ return [channel for channel in channels if isinstance(channel, dict)] if isinstance(channels, list) else []
69
+
70
+
71
+ def _channel_summary(channel: Dict[str, Any]) -> Dict[str, Any]:
72
+ blockers = channel.get("blockers") if isinstance(channel.get("blockers"), list) else []
73
+ accounts = channel.get("accounts") if isinstance(channel.get("accounts"), list) else []
74
+ lanes = channel.get("lanes") if isinstance(channel.get("lanes"), list) else []
75
+ output = {
76
+ "id": channel.get("id"),
77
+ "label": channel.get("label"),
78
+ "model": channel.get("model"),
79
+ "visible": bool(channel.get("visible")),
80
+ "configured": bool(channel.get("configured")),
81
+ "status": channel.get("status"),
82
+ "used": channel.get("used"),
83
+ "planned": channel.get("planned"),
84
+ "limit": channel.get("limit"),
85
+ "remaining": channel.get("remaining"),
86
+ "utilizationPct": channel.get("utilizationPct"),
87
+ "blockerCount": sum(int(blocker.get("count") or 1) for blocker in blockers if isinstance(blocker, dict)),
88
+ "accountCount": len(accounts),
89
+ "laneCount": len(lanes),
90
+ }
91
+ if channel.get("estimated") is not None:
92
+ output["estimated"] = bool(channel.get("estimated"))
93
+ if blockers:
94
+ output["blockers"] = blockers
95
+ notes = channel.get("notes")
96
+ if isinstance(notes, list) and notes:
97
+ output["notes"] = notes
98
+ return output
99
+
100
+
101
+ def _priority_actions(data: Dict[str, Any]) -> Dict[str, Any]:
102
+ summary = _capacity(data).get("summary")
103
+ if not isinstance(summary, dict):
104
+ return {}
105
+ priority = summary.get("priorityActions")
106
+ return priority if isinstance(priority, dict) else {}
107
+
108
+
109
+ def _add_recommendation(
110
+ recommendations: List[Dict[str, Any]],
111
+ *,
112
+ action: str,
113
+ priority: str,
114
+ message: str,
115
+ evidence: Dict[str, Any],
116
+ next_commands: Optional[List[str]] = None,
117
+ ) -> None:
118
+ recommendations.append(
119
+ {
120
+ "action": action,
121
+ "priority": priority,
122
+ "message": message,
123
+ "evidence": evidence,
124
+ "nextCommands": next_commands or [],
125
+ }
126
+ )
127
+
128
+
129
+ def _recommendations(data: Dict[str, Any]) -> List[Dict[str, Any]]:
130
+ recommendations: List[Dict[str, Any]] = []
131
+ priority = _priority_actions(data)
132
+ review_tasks = int(priority.get("reviewTasks") or 0)
133
+ if review_tasks > 0:
134
+ _add_recommendation(
135
+ recommendations,
136
+ action="review_tasks",
137
+ priority="high",
138
+ message=f"Review {review_tasks} queued task(s) before adding more work.",
139
+ evidence={"priorityActions": priority},
140
+ next_commands=[
141
+ "autotouch tasks query --output json",
142
+ "autotouch tasks count --output json",
143
+ ],
144
+ )
145
+
146
+ for channel in _channels(data):
147
+ channel_id = str(channel.get("id") or "")
148
+ label = str(channel.get("label") or channel_id or "Channel")
149
+ status = str(channel.get("status") or "unknown")
150
+ remaining = int(channel.get("remaining") or 0)
151
+ planned = int(channel.get("planned") or 0)
152
+ limit = int(channel.get("limit") or 0)
153
+ used = int(channel.get("used") or 0)
154
+ blockers = channel.get("blockers") if isinstance(channel.get("blockers"), list) else []
155
+ configured = bool(channel.get("configured"))
156
+ visible = bool(channel.get("visible"))
157
+ evidence = {
158
+ "channel": channel_id,
159
+ "status": status,
160
+ "used": used,
161
+ "planned": planned,
162
+ "limit": limit,
163
+ "remaining": remaining,
164
+ "blockers": blockers,
165
+ }
166
+
167
+ if not configured and visible:
168
+ _add_recommendation(
169
+ recommendations,
170
+ action="connect_capacity",
171
+ priority="high",
172
+ message=f"{label} has demand but no configured capacity.",
173
+ evidence=evidence,
174
+ )
175
+ continue
176
+ if blockers:
177
+ _add_recommendation(
178
+ recommendations,
179
+ action="fix_blockers",
180
+ priority="high",
181
+ message=f"{label} has blocker(s) that should be resolved before scaling more work.",
182
+ evidence=evidence,
183
+ )
184
+ continue
185
+ if limit > 0 and remaining <= 0:
186
+ _add_recommendation(
187
+ recommendations,
188
+ action="wait_or_add_capacity",
189
+ priority="medium",
190
+ message=f"{label} is at capacity for the selected window.",
191
+ evidence=evidence,
192
+ )
193
+ continue
194
+ if limit > 0 and planned == 0 and remaining > 0 and configured:
195
+ _add_recommendation(
196
+ recommendations,
197
+ action="add_or_prioritize_work",
198
+ priority="medium",
199
+ message=f"{label} has unused capacity; add eligible leads/tasks or prioritize existing work.",
200
+ evidence=evidence,
201
+ )
202
+ continue
203
+
204
+ if not recommendations:
205
+ _add_recommendation(
206
+ recommendations,
207
+ action="monitor",
208
+ priority="low",
209
+ message="No immediate capacity blocker was found in the selected scope.",
210
+ evidence={"summary": _capacity(data).get("summary") or {}},
211
+ )
212
+ return recommendations
213
+
214
+
215
+ def _capacity_metadata(data: Dict[str, Any]) -> Dict[str, Any]:
216
+ capacity = _capacity(data)
217
+ return {
218
+ "organizationId": data.get("organizationId"),
219
+ "generatedAt": data.get("generatedAt"),
220
+ "surface": data.get("surface"),
221
+ "scope": data.get("scope"),
222
+ "date": data.get("date"),
223
+ "timezone": data.get("timezone"),
224
+ "window": capacity.get("window") if isinstance(capacity.get("window"), dict) else None,
225
+ }
226
+
227
+
228
+ def cmd_capacity_overview(args: argparse.Namespace, *, runtime: CapacityCommandRuntime) -> None:
229
+ runtime.print_json(_fetch_overview(args, runtime=runtime), args.compact)
230
+
231
+
232
+ def cmd_capacity_channels(args: argparse.Namespace, *, runtime: CapacityCommandRuntime) -> None:
233
+ data = _fetch_overview(args, runtime=runtime)
234
+ output = {
235
+ **_capacity_metadata(data),
236
+ "summary": _capacity(data).get("summary") or {},
237
+ "channels": [_channel_summary(channel) for channel in _channels(data)],
238
+ }
239
+ if getattr(args, "include_details", False):
240
+ output["details"] = {"channels": _channels(data)}
241
+ runtime.print_json(output, args.compact)
242
+
243
+
244
+ def cmd_capacity_recommend(args: argparse.Namespace, *, runtime: CapacityCommandRuntime) -> None:
245
+ data = _fetch_overview(args, runtime=runtime)
246
+ output = {
247
+ **_capacity_metadata(data),
248
+ "source": "command_center_overview",
249
+ "scopeNote": "Capacity-only recommendation. Pair with lead/table/task inspection when deciding exactly what to build next.",
250
+ "summary": _capacity(data).get("summary") or {},
251
+ "recommendations": _recommendations(data),
252
+ "channels": [_channel_summary(channel) for channel in _channels(data)],
253
+ }
254
+ runtime.print_json(output, args.compact)
255
+
256
+
257
+ def _add_capacity_common_arguments(parser: argparse.ArgumentParser) -> None:
258
+ parser.add_argument("--scope", choices=["org", "me"], default="org", help="Capacity scope (default: org)")
259
+ parser.add_argument("--user-id", help="Target org user id for --scope me")
260
+ parser.add_argument("--user-email", help="Target org user email for --scope me")
261
+ parser.add_argument(
262
+ "--surface",
263
+ choices=["admin_command_center", "sales_home"],
264
+ default="admin_command_center",
265
+ help="Command Center surface model to read",
266
+ )
267
+ parser.add_argument("--date", help="Capacity date in YYYY-MM-DD; default is today in the requested timezone")
268
+ parser.add_argument("--timezone", help="IANA timezone for the date window, for example America/New_York")
269
+
270
+
271
+ def register_capacity_subcommands(
272
+ subparsers: argparse._SubParsersAction[argparse.ArgumentParser],
273
+ *,
274
+ add_api_common_arguments: Callable[[argparse.ArgumentParser], None],
275
+ handlers: Dict[str, Callable[[argparse.Namespace], None]],
276
+ ) -> None:
277
+ parser = subparsers.add_parser(
278
+ "capacity",
279
+ help="Inspect sender and task capacity",
280
+ description=(
281
+ "Read the backend-owned Command Center capacity model for LinkedIn, provider email, "
282
+ "personal email, and calls. These commands are read-only and require the tasks:read "
283
+ "developer-key scope."
284
+ ),
285
+ )
286
+ parser._codex_examples = [
287
+ "autotouch capacity overview --scope org --output json",
288
+ "autotouch capacity channels --scope me --output json",
289
+ "autotouch capacity overview --scope me --user-email rep@example.com --output json",
290
+ "autotouch capacity recommend --scope org --output json",
291
+ ]
292
+ capacity_sub = parser.add_subparsers(dest="capacity_cmd", required=True)
293
+
294
+ overview = capacity_sub.add_parser("overview", help="Return the full Command Center overview payload")
295
+ _add_capacity_common_arguments(overview)
296
+ add_api_common_arguments(overview)
297
+ overview.set_defaults(func=handlers["overview"])
298
+
299
+ channels = capacity_sub.add_parser("channels", help="Summarize channel capacity and blockers")
300
+ _add_capacity_common_arguments(channels)
301
+ channels.add_argument("--include-details", action="store_true", help="Also include raw channel details")
302
+ add_api_common_arguments(channels)
303
+ channels.set_defaults(func=handlers["channels"])
304
+
305
+ recommend = capacity_sub.add_parser("recommend", help="Recommend the next capacity action from current usage")
306
+ _add_capacity_common_arguments(recommend)
307
+ add_api_common_arguments(recommend)
308
+ recommend.set_defaults(func=handlers["recommend"])
@@ -105,8 +105,9 @@ def register_sender_accounts_subcommands(
105
105
  help="List connected email and LinkedIn sender accounts",
106
106
  description=(
107
107
  "Read sender accounts available to the current actor. Most sequence enrollments only need "
108
- "an assignee and will use that user's default connected senders. Use these IDs for advanced "
109
- "team routing, explicit sender pinning, or sender-account delegation management."
108
+ "an assignee and will use that user's default connected senders. Use these IDs when the "
109
+ "task owner/reviewer differs from the email or LinkedIn sender, for round-robin routing, "
110
+ "or for sender-account delegation management."
110
111
  ),
111
112
  )
112
113
  sender_sub = parser.add_subparsers(dest="sender_accounts_cmd", required=True)
@@ -116,7 +117,7 @@ def register_sender_accounts_subcommands(
116
117
  list_parser.add_argument(
117
118
  "--include-all",
118
119
  action="store_true",
119
- help="Admin only: include all sender accounts in the organization",
120
+ help="Admin only: include all sender accounts in the organization, useful when resolving explicit team-managed senders",
120
121
  )
121
122
  add_api_common_arguments(list_parser)
122
123
  list_parser.set_defaults(func=handlers["list"])
@@ -142,8 +143,8 @@ def register_sender_accounts_subcommands(
142
143
  "grant-delegation",
143
144
  help="Allow another user to send from a sender account",
144
145
  description=(
145
- "Owner/admin user-session management command. Use when a manager owns a connected account "
146
- "but another workspace user should be allowed to send assigned sequence work from it."
146
+ "Owner/admin user-session management command. Use when one user's connected account "
147
+ "should be available for another workspace user to manage or execute assigned sequence work."
147
148
  ),
148
149
  )
149
150
  grant_parser.add_argument("--sender-account-id", required=True)
@@ -68,7 +68,10 @@ def _sequence_enroll_output_hints(payload: Dict[str, Any]) -> Dict[str, Any]:
68
68
  )
69
69
  elif sender_account_ids:
70
70
  channels = ", ".join(sorted(str(channel) for channel in sender_account_ids.keys()))
71
- sender_hint = f"Enrollment pins sender account IDs for: {channels}."
71
+ sender_hint = (
72
+ f"Enrollment pins sender account IDs for: {channels}. "
73
+ "The task owner/reviewer can differ from the sender identity."
74
+ )
72
75
  else:
73
76
  sender_hint = (
74
77
  "No sender account IDs are pinned; sequence execution will use the assignee/owner's default connected sender accounts."
@@ -218,6 +221,23 @@ def _attach_sequence_authoring_warnings(output: Dict[str, Any], payload: Optiona
218
221
  return enriched
219
222
 
220
223
 
224
+ def _raise_for_unsafe_sequence_authoring(payload: Dict[str, Any]) -> None:
225
+ mixed_mode_warnings = _sequence_template_ai_draft_warnings(payload)
226
+ if not mixed_mode_warnings:
227
+ return
228
+
229
+ step_labels = ", ".join(
230
+ str(warning.get("step_id") or f"step {int(warning.get('step_index') or 0) + 1}")
231
+ for warning in mixed_mode_warnings
232
+ )
233
+ raise AutotouchInputError(
234
+ "sequence payload mixes aiDraft=true with non-empty template fields "
235
+ f"on {step_labels}. Template fields are deterministic copy when aiDraft=false; "
236
+ "with aiDraft=true they become draft context and are not guaranteed to be sent exactly. "
237
+ "Set aiDraft=false for template sending, or leave template fields empty for AI-drafted tasks."
238
+ )
239
+
240
+
221
241
  def _split_account_values(values: Optional[List[str]]) -> List[str]:
222
242
  out: List[str] = []
223
243
  seen: set[str] = set()
@@ -428,6 +448,7 @@ def cmd_sequences_create(args: argparse.Namespace, *, runtime: SequenceCommandRu
428
448
  if not isinstance(payload, dict):
429
449
  raise AutotouchInputError("sequence create requires --data-json/--data-file with a JSON object")
430
450
  payload = _apply_provider_account_config(payload, args)
451
+ _raise_for_unsafe_sequence_authoring(payload)
431
452
 
432
453
  data = runtime.request_api(
433
454
  "POST",
@@ -456,6 +477,7 @@ def cmd_sequences_update(args: argparse.Namespace, *, runtime: SequenceCommandRu
456
477
  if not isinstance(payload, dict):
457
478
  raise AutotouchInputError("sequence update requires --data-json/--data-file with a JSON object")
458
479
  payload = _apply_provider_account_config(payload, args)
480
+ _raise_for_unsafe_sequence_authoring(payload)
459
481
 
460
482
  try:
461
483
  data = runtime.request_api(
@@ -767,7 +789,8 @@ def register_sequences_subcommands(
767
789
  description=(
768
790
  "For bulk sequences, sender accounts live on the provider campaign rather than per enrollment. "
769
791
  "Use --account-selection all_eligible for the org's eligible provider account group, or "
770
- "--account-selection selected with --selected-account for specific mailbox emails."
792
+ "--account-selection selected with --selected-account for specific mailbox emails. "
793
+ "This is separate from personal email/LinkedIn senderAccountIds used by sequence enrollments."
771
794
  ),
772
795
  )
773
796
  psqsa.add_argument("--sequence-id", required=True)
@@ -825,9 +848,11 @@ def register_sequences_subcommands(
825
848
  help="Enroll leads into a sequence (best for one-off/manual adds)",
826
849
  description=(
827
850
  "Direct enroll is best for one-off/manual adds. The simple path is lead IDs plus "
828
- "--assigned-to-user-id; when sender account flags are omitted, execution uses that "
829
- "user's default connected email/LinkedIn senders. Use add_to_sequence when rows "
830
- "should auto-enroll from a research table over time."
851
+ "--assigned-to-user-id, which is the task owner/reviewer. When sender account flags "
852
+ "are omitted, execution uses that user's default connected email/LinkedIn senders. "
853
+ "For team-managed work, keep --assigned-to-user-id as the manager/reviewer and pass "
854
+ "--email-sender-account-id / --linkedin-sender-account-id for the account that should "
855
+ "actually send. Use add_to_sequence when rows should auto-enroll from a research table over time."
831
856
  ),
832
857
  )
833
858
  psqe.add_argument("--sequence-id", required=True)
@@ -873,11 +898,11 @@ def register_sequences_subcommands(
873
898
  psqe.add_argument("--variable-overrides-file", help="variableOverrides JSON file")
874
899
  psqe.add_argument(
875
900
  "--assigned-to-user-id",
876
- help="Assign generated tasks to this user; default senders for that user are used unless sender routing flags are supplied",
901
+ help="Task owner/reviewer. Default senders for that user are used unless sender routing flags are supplied",
877
902
  )
878
903
  psqe.add_argument(
879
904
  "--email-sender-account-id",
880
- help="Advanced: pin email steps to this sender account instead of using the assignee's default",
905
+ help="Advanced: pin personal email steps to this sender account instead of using the assignee's default",
881
906
  )
882
907
  psqe.add_argument(
883
908
  "--linkedin-sender-account-id",