qodev-apollo-cli 1.0.0__tar.gz → 1.2.0__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 (58) hide show
  1. {qodev_apollo_cli-1.0.0 → qodev_apollo_cli-1.2.0}/CHANGELOG.md +24 -0
  2. {qodev_apollo_cli-1.0.0 → qodev_apollo_cli-1.2.0}/PKG-INFO +11 -5
  3. {qodev_apollo_cli-1.0.0 → qodev_apollo_cli-1.2.0}/README.md +9 -3
  4. {qodev_apollo_cli-1.0.0 → qodev_apollo_cli-1.2.0}/pyproject.toml +3 -3
  5. {qodev_apollo_cli-1.0.0 → qodev_apollo_cli-1.2.0}/src/apollo_cli/app.py +4 -0
  6. {qodev_apollo_cli-1.0.0 → qodev_apollo_cli-1.2.0}/src/apollo_cli/commands/contacts.py +12 -1
  7. qodev_apollo_cli-1.2.0/src/apollo_cli/commands/conversations.py +67 -0
  8. qodev_apollo_cli-1.2.0/src/apollo_cli/commands/custom_fields.py +48 -0
  9. qodev_apollo_cli-1.2.0/src/apollo_cli/commands/deals.py +161 -0
  10. qodev_apollo_cli-1.2.0/src/apollo_cli/commands/people.py +68 -0
  11. qodev_apollo_cli-1.2.0/src/apollo_cli/formatters/conversations.py +117 -0
  12. qodev_apollo_cli-1.2.0/src/apollo_cli/formatters/people.py +21 -0
  13. {qodev_apollo_cli-1.0.0 → qodev_apollo_cli-1.2.0}/src/apollo_cli/skills/SKILL.md +21 -3
  14. qodev_apollo_cli-1.2.0/src/apollo_cli/util.py +44 -0
  15. {qodev_apollo_cli-1.0.0 → qodev_apollo_cli-1.2.0}/tests/conftest.py +15 -0
  16. {qodev_apollo_cli-1.0.0 → qodev_apollo_cli-1.2.0}/tests/test_commands.py +220 -0
  17. qodev_apollo_cli-1.2.0/tests/test_conversations_formatter.py +70 -0
  18. {qodev_apollo_cli-1.0.0 → qodev_apollo_cli-1.2.0}/uv.lock +4 -4
  19. qodev_apollo_cli-1.0.0/src/apollo_cli/commands/deals.py +0 -51
  20. qodev_apollo_cli-1.0.0/src/apollo_cli/commands/people.py +0 -35
  21. qodev_apollo_cli-1.0.0/src/apollo_cli/util.py +0 -22
  22. {qodev_apollo_cli-1.0.0 → qodev_apollo_cli-1.2.0}/.github/workflows/ci.yml +0 -0
  23. {qodev_apollo_cli-1.0.0 → qodev_apollo_cli-1.2.0}/.github/workflows/publish.yml +0 -0
  24. {qodev_apollo_cli-1.0.0 → qodev_apollo_cli-1.2.0}/.gitignore +0 -0
  25. {qodev_apollo_cli-1.0.0 → qodev_apollo_cli-1.2.0}/LICENSE +0 -0
  26. {qodev_apollo_cli-1.0.0 → qodev_apollo_cli-1.2.0}/src/apollo_cli/__init__.py +0 -0
  27. {qodev_apollo_cli-1.0.0 → qodev_apollo_cli-1.2.0}/src/apollo_cli/__main__.py +0 -0
  28. {qodev_apollo_cli-1.0.0 → qodev_apollo_cli-1.2.0}/src/apollo_cli/commands/__init__.py +0 -0
  29. {qodev_apollo_cli-1.0.0 → qodev_apollo_cli-1.2.0}/src/apollo_cli/commands/accounts.py +0 -0
  30. {qodev_apollo_cli-1.0.0 → qodev_apollo_cli-1.2.0}/src/apollo_cli/commands/calls.py +0 -0
  31. {qodev_apollo_cli-1.0.0 → qodev_apollo_cli-1.2.0}/src/apollo_cli/commands/emails.py +0 -0
  32. {qodev_apollo_cli-1.0.0 → qodev_apollo_cli-1.2.0}/src/apollo_cli/commands/enrich.py +0 -0
  33. {qodev_apollo_cli-1.0.0 → qodev_apollo_cli-1.2.0}/src/apollo_cli/commands/install.py +0 -0
  34. {qodev_apollo_cli-1.0.0 → qodev_apollo_cli-1.2.0}/src/apollo_cli/commands/jobs.py +0 -0
  35. {qodev_apollo_cli-1.0.0 → qodev_apollo_cli-1.2.0}/src/apollo_cli/commands/news.py +0 -0
  36. {qodev_apollo_cli-1.0.0 → qodev_apollo_cli-1.2.0}/src/apollo_cli/commands/notes.py +0 -0
  37. {qodev_apollo_cli-1.0.0 → qodev_apollo_cli-1.2.0}/src/apollo_cli/commands/pipelines.py +0 -0
  38. {qodev_apollo_cli-1.0.0 → qodev_apollo_cli-1.2.0}/src/apollo_cli/commands/tasks.py +0 -0
  39. {qodev_apollo_cli-1.0.0 → qodev_apollo_cli-1.2.0}/src/apollo_cli/commands/usage.py +0 -0
  40. {qodev_apollo_cli-1.0.0 → qodev_apollo_cli-1.2.0}/src/apollo_cli/context.py +0 -0
  41. {qodev_apollo_cli-1.0.0 → qodev_apollo_cli-1.2.0}/src/apollo_cli/formatters/__init__.py +0 -0
  42. {qodev_apollo_cli-1.0.0 → qodev_apollo_cli-1.2.0}/src/apollo_cli/formatters/accounts.py +0 -0
  43. {qodev_apollo_cli-1.0.0 → qodev_apollo_cli-1.2.0}/src/apollo_cli/formatters/contacts.py +0 -0
  44. {qodev_apollo_cli-1.0.0 → qodev_apollo_cli-1.2.0}/src/apollo_cli/formatters/deals.py +0 -0
  45. {qodev_apollo_cli-1.0.0 → qodev_apollo_cli-1.2.0}/src/apollo_cli/formatters/generic.py +0 -0
  46. {qodev_apollo_cli-1.0.0 → qodev_apollo_cli-1.2.0}/src/apollo_cli/help_reference.py +0 -0
  47. {qodev_apollo_cli-1.0.0 → qodev_apollo_cli-1.2.0}/src/apollo_cli/linkedin.py +0 -0
  48. {qodev_apollo_cli-1.0.0 → qodev_apollo_cli-1.2.0}/src/apollo_cli/output.py +0 -0
  49. {qodev_apollo_cli-1.0.0 → qodev_apollo_cli-1.2.0}/src/apollo_cli/skills/__init__.py +0 -0
  50. {qodev_apollo_cli-1.0.0 → qodev_apollo_cli-1.2.0}/src/apollo_cli/skills/references/__init__.py +0 -0
  51. {qodev_apollo_cli-1.0.0 → qodev_apollo_cli-1.2.0}/src/apollo_cli/skills/references/account-workflows.md +0 -0
  52. {qodev_apollo_cli-1.0.0 → qodev_apollo_cli-1.2.0}/src/apollo_cli/skills/references/contact-workflows.md +0 -0
  53. {qodev_apollo_cli-1.0.0 → qodev_apollo_cli-1.2.0}/src/apollo_cli/skills/references/deal-workflows.md +0 -0
  54. {qodev_apollo_cli-1.0.0 → qodev_apollo_cli-1.2.0}/tests/test_context.py +0 -0
  55. {qodev_apollo_cli-1.0.0 → qodev_apollo_cli-1.2.0}/tests/test_install.py +0 -0
  56. {qodev_apollo_cli-1.0.0 → qodev_apollo_cli-1.2.0}/tests/test_linkedin.py +0 -0
  57. {qodev_apollo_cli-1.0.0 → qodev_apollo_cli-1.2.0}/tests/test_output.py +0 -0
  58. {qodev_apollo_cli-1.0.0 → qodev_apollo_cli-1.2.0}/tests/test_util.py +0 -0
@@ -4,6 +4,30 @@ All notable changes to this project will be documented in this file.
4
4
 
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
6
6
 
7
+ ## [Unreleased]
8
+
9
+ ## [1.2.0] - 2026-07-08
10
+
11
+ Usage-driven UX improvements — every item here closes a gap where users had been dropping to raw curl or doing extra lookups.
12
+
13
+ ### Added
14
+
15
+ - **people search — company-domain filter.** `people search --organization-domains acme.com,globex.com` (alias `--domains`) finds people at specific companies — the single most common raw-curl workaround (`q_organization_domains_list`). Also adds `--seniorities`, and `people search` now respects the global `--limit`/`--page` (it previously ignored them). Results render as a table instead of a raw dict.
16
+ - **Filter deals/contacts by stage name.** `deals search --stage-name "Negotiation"` and `contacts search --stage-name "Customer"` resolve the name to an ID internally, removing the round-trip through `pipelines stages` / `contacts stages`. An unknown name fails loudly and lists the valid names.
17
+ - **`conversations transcript ID`** — prints just the transcript (no metadata/summary), for when you only want the words.
18
+ - **Deal contact roles.** `deals role-types` lists the available role types; `deals set-role DEAL_ID --contact-id C [--role-type "Decision Maker"] [--primary]` sets/updates a contact's role on a deal (read-modify-write; `--primary` makes them the sole primary contact). Previously only reachable via curl.
19
+ - **`custom-fields list [--modality]`** — lists custom field definitions across contacts/accounts/opportunities.
20
+
21
+ ### Changed
22
+
23
+ - Requires `qodev-apollo-api>=0.3.0` (for `update_opportunity_roles` and `list_custom_fields`).
24
+
25
+ ## [1.1.0] - 2026-07-08
26
+
27
+ ### Added
28
+
29
+ - **conversations**: new command group exposing the recorded-conversation endpoints (Zoom/Teams/Meet). `conversations search [--query]` lists conversations; `conversations get ID` returns the full detail including transcript and AI call summary (outcome, pain points, objections, next steps). The underlying `qodev-apollo-api` client already supported `search_conversations`/`get_conversation` — only the CLI surface was missing. Note this is distinct from `calls`, which covers dialer/phone-call activity, not recorded meetings.
30
+
7
31
  ## [1.0.0] - 2026-07-01
8
32
 
9
33
  ### Added
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: qodev-apollo-cli
3
- Version: 1.0.0
3
+ Version: 1.2.0
4
4
  Summary: Agent-friendly CLI for the Apollo API
5
5
  Project-URL: Homepage, https://github.com/qodevai/apollo-cli
6
6
  Project-URL: Repository, https://github.com/qodevai/apollo-cli
@@ -19,7 +19,7 @@ Classifier: Programming Language :: Python :: 3.13
19
19
  Classifier: Typing :: Typed
20
20
  Requires-Python: >=3.11
21
21
  Requires-Dist: cyclopts>=3.0
22
- Requires-Dist: qodev-apollo-api>=0.1.0
22
+ Requires-Dist: qodev-apollo-api>=0.3.0
23
23
  Requires-Dist: rich>=13.0
24
24
  Provides-Extra: dev
25
25
  Requires-Dist: mypy>=1.13.0; extra == 'dev'
@@ -88,7 +88,7 @@ $ qodev-apollo-cli usage
88
88
 
89
89
  | Group | Subcommand | Description |
90
90
  |---|---|---|
91
- | **contacts** | `search` | Search contacts (`--query`, `--stage-id`, `--linkedin-url`) |
91
+ | **contacts** | `search` | Search contacts (`--query`, `--stage-id`, `--stage-name`, `--linkedin-url`) |
92
92
  | | `get` | Get contact details by ID |
93
93
  | | `create` | Create a new contact (`--first-name`, `--last-name`, `--email`, etc.) |
94
94
  | | `update` | Update contact (`--title`, `--label-ids`) |
@@ -96,8 +96,10 @@ $ qodev-apollo-cli usage
96
96
  | | `stages` | List all contact stages |
97
97
  | **accounts** | `search` | Search companies/accounts (`--query`, `--domain`) |
98
98
  | | `get` | Get account details by ID |
99
- | **deals** | `search` | Search opportunities/deals (`--query`, `--stage-id`) |
99
+ | **deals** | `search` | Search opportunities/deals (`--query`, `--stage-id`, `--stage-name`) |
100
100
  | | `get` | Get deal details by ID |
101
+ | | `role-types` | List opportunity contact role types |
102
+ | | `set-role` | Set/update a contact's role on a deal (`--contact-id`, `--role-type`, `--primary`) |
101
103
  | **pipelines** | `list` | List all deal pipelines |
102
104
  | | `get` | Get pipeline details |
103
105
  | | `stages` | List stages in a pipeline |
@@ -105,12 +107,16 @@ $ qodev-apollo-cli usage
105
107
  | | `get` | Get stage details |
106
108
  | **enrich** | `org` | Enrich organization by domain (FREE - no credits) |
107
109
  | | `person` | Enrich person by email (1 credit per lookup) |
108
- | **people** | `search` | Search people database (`--person-titles`, `--q-organization-domains`) |
110
+ | **people** | `search` | Search people database (`--titles`, `--seniorities`, `--locations`, `--organization-domains`) |
109
111
  | **notes** | `search` | Search notes (`--contact-id`, `--account-id`, `--opportunity-id`) |
110
112
  | | `create` | Create a note (`--contact-ids`, `--account-ids`, `--opportunity-ids`, `--content`) |
111
113
  | **tasks** | `search` | Search tasks (`--type`, `--status`) |
112
114
  | | `create` | Create a task (`--contact-ids`, `--note`, `--due-at`) |
113
115
  | **calls** | `search` | Search call activities |
116
+ | **conversations** | `search` | Search recorded conversations (`--query`) |
117
+ | | `get` | Get a conversation with transcript and AI summary |
118
+ | | `transcript` | Print just the transcript of a conversation |
119
+ | **custom-fields** | `list` | List custom field definitions (`--modality`) |
114
120
  | **emails** | `search` | Search email activities |
115
121
  | **news** | `search` | Search news (`--categories`) |
116
122
  | **jobs** | `search` | Search job postings (`--job-titles`, `--company-domains`) |
@@ -57,7 +57,7 @@ $ qodev-apollo-cli usage
57
57
 
58
58
  | Group | Subcommand | Description |
59
59
  |---|---|---|
60
- | **contacts** | `search` | Search contacts (`--query`, `--stage-id`, `--linkedin-url`) |
60
+ | **contacts** | `search` | Search contacts (`--query`, `--stage-id`, `--stage-name`, `--linkedin-url`) |
61
61
  | | `get` | Get contact details by ID |
62
62
  | | `create` | Create a new contact (`--first-name`, `--last-name`, `--email`, etc.) |
63
63
  | | `update` | Update contact (`--title`, `--label-ids`) |
@@ -65,8 +65,10 @@ $ qodev-apollo-cli usage
65
65
  | | `stages` | List all contact stages |
66
66
  | **accounts** | `search` | Search companies/accounts (`--query`, `--domain`) |
67
67
  | | `get` | Get account details by ID |
68
- | **deals** | `search` | Search opportunities/deals (`--query`, `--stage-id`) |
68
+ | **deals** | `search` | Search opportunities/deals (`--query`, `--stage-id`, `--stage-name`) |
69
69
  | | `get` | Get deal details by ID |
70
+ | | `role-types` | List opportunity contact role types |
71
+ | | `set-role` | Set/update a contact's role on a deal (`--contact-id`, `--role-type`, `--primary`) |
70
72
  | **pipelines** | `list` | List all deal pipelines |
71
73
  | | `get` | Get pipeline details |
72
74
  | | `stages` | List stages in a pipeline |
@@ -74,12 +76,16 @@ $ qodev-apollo-cli usage
74
76
  | | `get` | Get stage details |
75
77
  | **enrich** | `org` | Enrich organization by domain (FREE - no credits) |
76
78
  | | `person` | Enrich person by email (1 credit per lookup) |
77
- | **people** | `search` | Search people database (`--person-titles`, `--q-organization-domains`) |
79
+ | **people** | `search` | Search people database (`--titles`, `--seniorities`, `--locations`, `--organization-domains`) |
78
80
  | **notes** | `search` | Search notes (`--contact-id`, `--account-id`, `--opportunity-id`) |
79
81
  | | `create` | Create a note (`--contact-ids`, `--account-ids`, `--opportunity-ids`, `--content`) |
80
82
  | **tasks** | `search` | Search tasks (`--type`, `--status`) |
81
83
  | | `create` | Create a task (`--contact-ids`, `--note`, `--due-at`) |
82
84
  | **calls** | `search` | Search call activities |
85
+ | **conversations** | `search` | Search recorded conversations (`--query`) |
86
+ | | `get` | Get a conversation with transcript and AI summary |
87
+ | | `transcript` | Print just the transcript of a conversation |
88
+ | **custom-fields** | `list` | List custom field definitions (`--modality`) |
83
89
  | **emails** | `search` | Search email activities |
84
90
  | **news** | `search` | Search news (`--categories`) |
85
91
  | **jobs** | `search` | Search job postings (`--job-titles`, `--company-domains`) |
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "qodev-apollo-cli"
3
- version = "1.0.0"
3
+ version = "1.2.0"
4
4
  description = "Agent-friendly CLI for the Apollo API"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.11"
@@ -20,7 +20,7 @@ classifiers = [
20
20
  dependencies = [
21
21
  "cyclopts>=3.0",
22
22
  "rich>=13.0",
23
- "qodev-apollo-api>=0.1.0",
23
+ "qodev-apollo-api>=0.3.0",
24
24
  ]
25
25
 
26
26
  [project.optional-dependencies]
@@ -48,7 +48,7 @@ build-backend = "hatchling.build"
48
48
  packages = ["src/apollo_cli"]
49
49
 
50
50
  [tool.uv.sources]
51
- qodev-apollo-api = { path = "../../libs/apollo" }
51
+ qodev-apollo-api = { path = "../apollo-api" }
52
52
 
53
53
  [tool.ruff]
54
54
  target-version = "py311"
@@ -26,6 +26,8 @@ app.meta.group_parameters = Group("Global Options", sort_key=0)
26
26
  from apollo_cli.commands.accounts import accounts_app # noqa: E402
27
27
  from apollo_cli.commands.calls import calls_app # noqa: E402
28
28
  from apollo_cli.commands.contacts import contacts_app # noqa: E402
29
+ from apollo_cli.commands.conversations import conversations_app # noqa: E402
30
+ from apollo_cli.commands.custom_fields import custom_fields_app # noqa: E402
29
31
  from apollo_cli.commands.deals import deals_app # noqa: E402
30
32
  from apollo_cli.commands.emails import emails_app # noqa: E402
31
33
  from apollo_cli.commands.enrich import enrich_app # noqa: E402
@@ -50,6 +52,8 @@ _sub_apps = [
50
52
  notes_app,
51
53
  tasks_app,
52
54
  calls_app,
55
+ conversations_app,
56
+ custom_fields_app,
53
57
  emails_app,
54
58
  news_app,
55
59
  jobs_app,
@@ -14,7 +14,7 @@ from apollo_cli.formatters.contacts import (
14
14
  )
15
15
  from apollo_cli.linkedin import apollo_canonical_linkedin_url
16
16
  from apollo_cli.output import error, output, output_list
17
- from apollo_cli.util import parse_comma_list
17
+ from apollo_cli.util import parse_comma_list, resolve_stage_id
18
18
 
19
19
  contacts_app = App(name="contacts", help="Manage contacts.")
20
20
 
@@ -24,6 +24,12 @@ async def search(
24
24
  *,
25
25
  query: Annotated[str, Parameter(name=["--query", "-q"], help="Search keyword")] = "",
26
26
  stage_id: Annotated[str | None, Parameter(name="--stage-id", help="Filter by stage ID")] = None,
27
+ stage_name: Annotated[
28
+ str | None,
29
+ Parameter(
30
+ name="--stage-name", help="Filter by stage name (resolved to an ID; avoids a `contacts stages` lookup)"
31
+ ),
32
+ ] = None,
27
33
  linkedin_url: Annotated[str | None, Parameter(name="--linkedin-url", help="Filter by LinkedIn URL")] = None,
28
34
  ) -> None:
29
35
  """Search contacts by keyword or filter."""
@@ -38,6 +44,11 @@ async def search(
38
44
  filters["linkedin_url"] = apollo_canonical_linkedin_url(linkedin_url)
39
45
 
40
46
  async with ctx.client() as client:
47
+ if stage_name:
48
+ stages_ = await client.get_contact_stages()
49
+ filters.setdefault("contact_stage_ids", []).append(
50
+ resolve_stage_id(stage_name, stages_, kind="contact stage")
51
+ )
41
52
  result = await client.search_contacts(page=ctx.page, limit=ctx.limit, **filters)
42
53
 
43
54
  output_list(
@@ -0,0 +1,67 @@
1
+ """Conversations command group."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Annotated
6
+
7
+ from cyclopts import App, Parameter
8
+
9
+ from apollo_cli.context import ctx
10
+ from apollo_cli.formatters.conversations import (
11
+ format_conversation_detail,
12
+ format_conversation_list,
13
+ format_transcript,
14
+ )
15
+ from apollo_cli.output import output, output_json, output_list, output_markdown
16
+
17
+ conversations_app = App(name="conversations", help="Recorded conversations (Zoom/Teams/Meet).")
18
+
19
+
20
+ @conversations_app.command
21
+ async def search(
22
+ *,
23
+ query: Annotated[str, Parameter(name=["--query", "-q"], help="Search keyword (topic/title)")] = "",
24
+ ) -> None:
25
+ """Search recorded conversations."""
26
+ filters: dict = {}
27
+ if query:
28
+ filters["q_keywords"] = query
29
+
30
+ async with ctx.client() as client:
31
+ result = await client.search_conversations(page=ctx.page, limit=ctx.limit, **filters)
32
+
33
+ output_list(
34
+ items=result.items,
35
+ total=result.total,
36
+ page=result.page,
37
+ limit=ctx.limit,
38
+ ctx=ctx,
39
+ format_fn=format_conversation_list,
40
+ resource_name="Conversations",
41
+ )
42
+
43
+
44
+ @conversations_app.command
45
+ async def get(
46
+ id: Annotated[str, Parameter(help="Conversation ID")],
47
+ ) -> None:
48
+ """Get conversation details by ID (includes transcript and AI summary)."""
49
+ async with ctx.client() as client:
50
+ conversation = await client.get_conversation(id)
51
+
52
+ output(conversation, ctx=ctx, format_fn=format_conversation_detail)
53
+
54
+
55
+ @conversations_app.command
56
+ async def transcript(
57
+ id: Annotated[str, Parameter(help="Conversation ID")],
58
+ ) -> None:
59
+ """Print just the transcript of a conversation (no metadata or summary)."""
60
+ async with ctx.client() as client:
61
+ conversation = await client.get_conversation(id)
62
+
63
+ segments = getattr(conversation, "transcript", None) or []
64
+ if ctx.json_mode:
65
+ output_json(segments)
66
+ else:
67
+ output_markdown(format_transcript(conversation))
@@ -0,0 +1,48 @@
1
+ """Custom fields command group."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Annotated
6
+
7
+ from cyclopts import App, Parameter
8
+
9
+ from apollo_cli.context import ctx
10
+ from apollo_cli.formatters.generic import list_table
11
+ from apollo_cli.output import output_list
12
+
13
+ custom_fields_app = App(name="custom-fields", help="Custom field definitions.")
14
+
15
+ CUSTOM_FIELD_COLUMNS = [
16
+ ("ID", "id"),
17
+ ("Modality", "modality"),
18
+ ("Name", "name"),
19
+ ("Type", "type"),
20
+ ("CRM Field", "mapped_crm_field"),
21
+ ]
22
+
23
+
24
+ @custom_fields_app.command(name="list")
25
+ async def list_fields(
26
+ *,
27
+ modality: Annotated[
28
+ str | None,
29
+ Parameter(name="--modality", help="Filter by modality: contact, account, or opportunity"),
30
+ ] = None,
31
+ ) -> None:
32
+ """List custom field definitions across contacts, accounts, and opportunities."""
33
+ async with ctx.client() as client:
34
+ fields = await client.list_custom_fields()
35
+
36
+ if modality:
37
+ target = modality.strip().lower()
38
+ fields = [f for f in fields if (f.modality or "").lower() == target]
39
+
40
+ output_list(
41
+ items=fields,
42
+ total=len(fields),
43
+ page=1,
44
+ limit=len(fields) or 1,
45
+ ctx=ctx,
46
+ format_fn=lambda items, **kw: list_table(items, CUSTOM_FIELD_COLUMNS, title="Custom Fields", **kw),
47
+ resource_name="Custom Fields",
48
+ )
@@ -0,0 +1,161 @@
1
+ """Deals command group."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Annotated, Any
6
+
7
+ from cyclopts import App, Parameter
8
+
9
+ from apollo_cli.context import ctx
10
+ from apollo_cli.formatters.deals import format_deal_detail, format_deal_list
11
+ from apollo_cli.formatters.generic import list_table
12
+ from apollo_cli.output import error, output, output_list
13
+ from apollo_cli.util import resolve_stage_id
14
+
15
+ deals_app = App(name="deals", help="Manage deals/opportunities.")
16
+
17
+
18
+ @deals_app.command
19
+ async def search(
20
+ *,
21
+ query: Annotated[str, Parameter(name=["--query", "-q"], help="Search keyword")] = "",
22
+ stage_id: Annotated[str | None, Parameter(name="--stage-id", help="Filter by deal stage ID")] = None,
23
+ stage_name: Annotated[
24
+ str | None,
25
+ Parameter(
26
+ name="--stage-name", help="Filter by stage name (resolved to an ID; avoids a `pipelines stages` lookup)"
27
+ ),
28
+ ] = None,
29
+ ) -> None:
30
+ """Search deals by keyword or filter."""
31
+ filters: dict = {}
32
+ if query:
33
+ filters["q_keywords"] = query
34
+ stage_ids: list[str] = []
35
+ if stage_id:
36
+ stage_ids.append(stage_id)
37
+
38
+ async with ctx.client() as client:
39
+ if stage_name:
40
+ all_stages = await client.list_all_stages()
41
+ stage_ids.append(resolve_stage_id(stage_name, all_stages.items, kind="deal stage"))
42
+ if stage_ids:
43
+ filters["opportunity_stage_ids"] = stage_ids
44
+ result = await client.search_deals(page=ctx.page, limit=ctx.limit, **filters)
45
+
46
+ output_list(
47
+ items=result.items,
48
+ total=result.total,
49
+ page=result.page,
50
+ limit=ctx.limit,
51
+ ctx=ctx,
52
+ format_fn=format_deal_list,
53
+ resource_name="Deals",
54
+ )
55
+
56
+
57
+ @deals_app.command
58
+ async def get(
59
+ id: Annotated[str, Parameter(help="Deal ID")],
60
+ ) -> None:
61
+ """Get deal details by ID."""
62
+ async with ctx.client() as client:
63
+ deal = await client.get_deal(id)
64
+
65
+ output(deal, ctx=ctx, format_fn=format_deal_detail)
66
+
67
+
68
+ ROLE_TYPE_COLUMNS = [("ID", "id"), ("Name", "name"), ("Display Order", "display_order")]
69
+
70
+
71
+ @deals_app.command(name="role-types")
72
+ async def role_types() -> None:
73
+ """List the available opportunity contact role types (e.g. Decision Maker, Champion)."""
74
+ async with ctx.client() as client:
75
+ result = await client.list_opportunity_contact_role_types()
76
+
77
+ output_list(
78
+ items=result.items,
79
+ total=result.total,
80
+ page=1,
81
+ limit=len(result.items) or 1,
82
+ ctx=ctx,
83
+ format_fn=lambda items, **kw: list_table(items, ROLE_TYPE_COLUMNS, title="Role Types", **kw),
84
+ resource_name="Role Types",
85
+ )
86
+
87
+
88
+ def _existing_roles(deal: Any) -> list[dict]:
89
+ """Flatten a deal's current opportunity_contact_roles into update_roles entries."""
90
+ roles: list[dict] = []
91
+ for r in getattr(deal, "opportunity_contact_roles", []) or []:
92
+ role_type_id = None
93
+ if r.role:
94
+ role_type_id = r.role[0].opportunity_contact_role_type_id
95
+ roles.append(
96
+ {
97
+ "contact_id": r.contact_id,
98
+ "opportunity_contact_role_type_id": role_type_id,
99
+ "is_primary": bool(r.is_primary),
100
+ }
101
+ )
102
+ return roles
103
+
104
+
105
+ @deals_app.command(name="set-role")
106
+ async def set_role(
107
+ id: Annotated[str, Parameter(help="Deal ID")],
108
+ *,
109
+ contact_id: Annotated[str, Parameter(name="--contact-id", help="Contact ID to add/update on the deal")],
110
+ role_type: Annotated[
111
+ str | None,
112
+ Parameter(name="--role-type", help="Role type ID or name (e.g. 'Decision Maker'); resolved to an ID"),
113
+ ] = None,
114
+ primary: Annotated[
115
+ bool,
116
+ Parameter(name="--primary", help="Mark this contact as the primary contact (unsets any other primary)"),
117
+ ] = False,
118
+ ) -> None:
119
+ """Set or update a contact's role on a deal.
120
+
121
+ Reads the deal's current contact roles, applies the change, and writes the full
122
+ set back (Apollo's update_roles replaces all roles). Add ``--primary`` to make
123
+ this contact the single primary contact.
124
+ """
125
+ async with ctx.client() as client:
126
+ deal = await client.get_deal(id)
127
+ roles = _existing_roles(deal)
128
+
129
+ role_type_id: str | None = None
130
+ if role_type:
131
+ role_type_id = role_type
132
+ # Resolve a human name to an ID when it isn't already an ID.
133
+ rt_result = await client.list_opportunity_contact_role_types()
134
+ names = {rt.name.lower(): rt.id for rt in rt_result.items if rt.name}
135
+ ids = {rt.id for rt in rt_result.items}
136
+ if role_type not in ids:
137
+ resolved = names.get(role_type.lower())
138
+ if resolved is None:
139
+ error(
140
+ f"No role type {role_type!r}. Available: "
141
+ + ", ".join(sorted(rt.name for rt in rt_result.items if rt.name)),
142
+ ctx=ctx,
143
+ code="unknown_role_type",
144
+ exit_code=2,
145
+ )
146
+ return
147
+ role_type_id = resolved
148
+
149
+ entry = next((r for r in roles if r["contact_id"] == contact_id), None)
150
+ if entry is None:
151
+ entry = {"contact_id": contact_id, "opportunity_contact_role_type_id": None, "is_primary": False}
152
+ roles.append(entry)
153
+ if role_type_id is not None:
154
+ entry["opportunity_contact_role_type_id"] = role_type_id
155
+ if primary:
156
+ for r in roles:
157
+ r["is_primary"] = r["contact_id"] == contact_id
158
+
159
+ updated = await client.update_opportunity_roles(id, roles)
160
+
161
+ output(updated, ctx=ctx, format_fn=format_deal_detail)
@@ -0,0 +1,68 @@
1
+ """People database search command group."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Annotated
6
+
7
+ from cyclopts import App, Parameter
8
+
9
+ from apollo_cli.context import ctx
10
+ from apollo_cli.formatters.people import format_people_list
11
+ from apollo_cli.output import output_list
12
+ from apollo_cli.util import parse_comma_list
13
+
14
+ people_app = App(name="people", help="People database search.")
15
+
16
+
17
+ @people_app.command
18
+ async def search(
19
+ *,
20
+ keywords: Annotated[str | None, Parameter(name="--keywords", help="Search keywords")] = None,
21
+ titles: Annotated[str | None, Parameter(name="--titles", help="Comma-separated job titles")] = None,
22
+ seniorities: Annotated[
23
+ str | None,
24
+ Parameter(name="--seniorities", help="Comma-separated seniorities (e.g. owner,vp,director,manager)"),
25
+ ] = None,
26
+ locations: Annotated[str | None, Parameter(name="--locations", help="Comma-separated person locations")] = None,
27
+ organization_domains: Annotated[
28
+ str | None,
29
+ Parameter(
30
+ name=["--organization-domains", "--domains"],
31
+ help="Comma-separated company domains — find people at these companies (e.g. acme.com,globex.com)",
32
+ ),
33
+ ] = None,
34
+ ) -> None:
35
+ """Search Apollo's global people database.
36
+
37
+ Respects the global ``--limit`` / ``--page`` options for pagination.
38
+ """
39
+ filters: dict = {"page": ctx.page, "per_page": ctx.limit}
40
+ if keywords:
41
+ filters["q_keywords"] = keywords
42
+ if titles:
43
+ filters["person_titles"] = parse_comma_list(titles)
44
+ if seniorities:
45
+ filters["person_seniorities"] = parse_comma_list(seniorities)
46
+ if locations:
47
+ filters["person_locations"] = parse_comma_list(locations)
48
+ if organization_domains:
49
+ filters["q_organization_domains_list"] = parse_comma_list(organization_domains)
50
+
51
+ async with ctx.client() as client:
52
+ result = await client.search_people(**filters)
53
+
54
+ # search_people returns the raw Apollo dict; people live under "people" (and
55
+ # sometimes "contacts" for matched CRM records).
56
+ items = result.get("people") or result.get("contacts") or []
57
+ pagination = result.get("pagination", {})
58
+ total = pagination.get("total_entries", len(items))
59
+
60
+ output_list(
61
+ items=items,
62
+ total=total,
63
+ page=ctx.page,
64
+ limit=ctx.limit,
65
+ ctx=ctx,
66
+ format_fn=format_people_list,
67
+ resource_name="People",
68
+ )
@@ -0,0 +1,117 @@
1
+ """Conversation-specific formatters."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Any
6
+
7
+ from apollo_cli.formatters.generic import detail_table, list_table
8
+
9
+ CONVERSATION_LIST_COLUMNS = [
10
+ ("ID", "id"),
11
+ ("Topic", "topic"),
12
+ ("Type", "conversation_type"),
13
+ ("Start", "start_time"),
14
+ ("Duration", "duration"),
15
+ ("Host", "host"),
16
+ ("State", "state"),
17
+ ]
18
+
19
+ CONVERSATION_DETAIL_FIELDS = [
20
+ ("ID", "id"),
21
+ ("Topic", "topic"),
22
+ ("Type", "conversation_type"),
23
+ ("Start", "start_time"),
24
+ ("Duration (s)", "duration"),
25
+ ("Host", "host"),
26
+ ("Host ID", "host_id"),
27
+ ("State", "state"),
28
+ ("Internal", "is_internal"),
29
+ ("Private", "is_private"),
30
+ ("Comments", "comment_count"),
31
+ ("Participants", "participant_names"),
32
+ ("Accounts", "account_names"),
33
+ ("Recording", "video_recording.url"),
34
+ ("Pushed to CRM", "pushed_to_crm"),
35
+ ]
36
+
37
+
38
+ def format_conversation_list(items: list[Any], *, total: int = 0, page: int = 1) -> str:
39
+ """Format a list of conversations as a markdown table."""
40
+ return list_table(items, CONVERSATION_LIST_COLUMNS, title="Conversations", total=total, page=page)
41
+
42
+
43
+ def format_conversation_detail(data: Any) -> str:
44
+ """Format a single conversation (with transcript & summary) as a markdown detail view."""
45
+ topic = getattr(data, "topic", None) or "Conversation"
46
+ md = detail_table(data, CONVERSATION_DETAIL_FIELDS, title=f"Conversation: {topic}")
47
+
48
+ # Participants (richer than the participant_names list in the metadata table)
49
+ participants = getattr(data, "participants_info", None) or []
50
+ if participants:
51
+ md += "\n\n## Participants\n"
52
+ for p in participants:
53
+ name = getattr(p, "name", None) or "Unknown"
54
+ title = getattr(p, "title", None)
55
+ account = getattr(p, "account_name", None)
56
+ internal = getattr(p, "is_internal_participant", None)
57
+ suffix = ", ".join(x for x in [title, account] if x)
58
+ tag = " (internal)" if internal else ""
59
+ md += f"\n- **{name}**{tag}" + (f" — {suffix}" if suffix else "")
60
+
61
+ # Associated deals
62
+ deals = getattr(data, "deals", None) or []
63
+ if deals:
64
+ md += "\n\n## Deals\n"
65
+ for d in deals:
66
+ name = getattr(d, "name", None) or getattr(d, "id", "Unknown")
67
+ account = getattr(d, "account_name", None)
68
+ md += f"\n- {name}" + (f" ({account})" if account else "")
69
+
70
+ # AI-generated call summary (detail endpoint only)
71
+ summary = getattr(data, "call_summary", None)
72
+ if summary:
73
+ md += _format_summary(summary)
74
+
75
+ # Transcript (detail endpoint only)
76
+ if getattr(data, "transcript", None):
77
+ md += "\n\n" + format_transcript(data)
78
+
79
+ return md
80
+
81
+
82
+ def format_transcript(data: Any) -> str:
83
+ """Render just the transcript of a conversation as `**Speaker:** sentence` lines."""
84
+ segments = getattr(data, "transcript", None) or []
85
+ if not segments:
86
+ return "## Transcript\n\n_No transcript available._"
87
+ lines = ["## Transcript", ""]
88
+ for seg in segments:
89
+ speaker = getattr(seg, "participant_name", None) or "Unknown"
90
+ sentence = getattr(seg, "spoken_sentence", None) or ""
91
+ lines.append(f"- **{speaker}:** {sentence}")
92
+ return "\n".join(lines)
93
+
94
+
95
+ def _format_summary(summary: Any) -> str:
96
+ """Render the AI call summary (outcome, pain points, objections, next steps)."""
97
+ md = "\n\n## Call Summary\n"
98
+ outcome = getattr(summary, "outcome", None)
99
+ if outcome:
100
+ md += f"\n**Outcome:** {outcome}\n"
101
+ pricing = getattr(summary, "pricing_discussion", None)
102
+ if pricing:
103
+ md += f"\n**Pricing discussion:** {pricing}\n"
104
+
105
+ for label, attr, field in (
106
+ ("Pain Points", "pain_points", "text"),
107
+ ("Objections", "objections", "text"),
108
+ ("Next Steps", "next_steps", "step"),
109
+ ):
110
+ items = getattr(summary, attr, None) or []
111
+ if items:
112
+ md += f"\n### {label}\n"
113
+ for item in items:
114
+ text = getattr(item, field, None) or ""
115
+ who = getattr(item, "participant_name", None)
116
+ md += f"\n- {text}" + (f" — _{who}_" if who else "")
117
+ return md