chattermate-cli 0.3.1__tar.gz → 0.4.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.
- {chattermate_cli-0.3.1 → chattermate_cli-0.4.0}/PKG-INFO +1 -1
- {chattermate_cli-0.3.1 → chattermate_cli-0.4.0}/chattermate_cli/__init__.py +1 -1
- {chattermate_cli-0.3.1 → chattermate_cli-0.4.0}/chattermate_cli/client.py +10 -0
- chattermate_cli-0.4.0/chattermate_cli/commands/lead_capture.py +150 -0
- {chattermate_cli-0.3.1 → chattermate_cli-0.4.0}/chattermate_cli/main.py +2 -0
- {chattermate_cli-0.3.1 → chattermate_cli-0.4.0}/chattermate_cli.egg-info/PKG-INFO +1 -1
- {chattermate_cli-0.3.1 → chattermate_cli-0.4.0}/chattermate_cli.egg-info/SOURCES.txt +2 -0
- {chattermate_cli-0.3.1 → chattermate_cli-0.4.0}/pyproject.toml +1 -1
- chattermate_cli-0.4.0/tests/test_lead_capture.py +60 -0
- {chattermate_cli-0.3.1 → chattermate_cli-0.4.0}/LICENSE +0 -0
- {chattermate_cli-0.3.1 → chattermate_cli-0.4.0}/README.md +0 -0
- {chattermate_cli-0.3.1 → chattermate_cli-0.4.0}/chattermate_cli/commands/__init__.py +0 -0
- {chattermate_cli-0.3.1 → chattermate_cli-0.4.0}/chattermate_cli/commands/agent.py +0 -0
- {chattermate_cli-0.3.1 → chattermate_cli-0.4.0}/chattermate_cli/commands/ai.py +0 -0
- {chattermate_cli-0.3.1 → chattermate_cli-0.4.0}/chattermate_cli/commands/auth.py +0 -0
- {chattermate_cli-0.3.1 → chattermate_cli-0.4.0}/chattermate_cli/commands/knowledge.py +0 -0
- {chattermate_cli-0.3.1 → chattermate_cli-0.4.0}/chattermate_cli/commands/widget.py +0 -0
- {chattermate_cli-0.3.1 → chattermate_cli-0.4.0}/chattermate_cli/commands/workflow.py +0 -0
- {chattermate_cli-0.3.1 → chattermate_cli-0.4.0}/chattermate_cli/config.py +0 -0
- {chattermate_cli-0.3.1 → chattermate_cli-0.4.0}/chattermate_cli/context.py +0 -0
- {chattermate_cli-0.3.1 → chattermate_cli-0.4.0}/chattermate_cli/mcp_server.py +0 -0
- {chattermate_cli-0.3.1 → chattermate_cli-0.4.0}/chattermate_cli.egg-info/dependency_links.txt +0 -0
- {chattermate_cli-0.3.1 → chattermate_cli-0.4.0}/chattermate_cli.egg-info/entry_points.txt +0 -0
- {chattermate_cli-0.3.1 → chattermate_cli-0.4.0}/chattermate_cli.egg-info/requires.txt +0 -0
- {chattermate_cli-0.3.1 → chattermate_cli-0.4.0}/chattermate_cli.egg-info/top_level.txt +0 -0
- {chattermate_cli-0.3.1 → chattermate_cli-0.4.0}/setup.cfg +0 -0
- {chattermate_cli-0.3.1 → chattermate_cli-0.4.0}/tests/test_ai.py +0 -0
- {chattermate_cli-0.3.1 → chattermate_cli-0.4.0}/tests/test_client.py +0 -0
- {chattermate_cli-0.3.1 → chattermate_cli-0.4.0}/tests/test_knowledge.py +0 -0
- {chattermate_cli-0.3.1 → chattermate_cli-0.4.0}/tests/test_mcp.py +0 -0
- {chattermate_cli-0.3.1 → chattermate_cli-0.4.0}/tests/test_widget.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: chattermate-cli
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.0
|
|
4
4
|
Summary: ChatterMate CLI and MCP server — sign up, authenticate, and configure agents, workflows and knowledge from the terminal or an AI agent.
|
|
5
5
|
Author: ChatterMate
|
|
6
6
|
License: AGPL-3.0-or-later
|
|
@@ -227,6 +227,16 @@ class Client:
|
|
|
227
227
|
def update_agent(self, agent_id: str, payload: Dict[str, Any]) -> Any:
|
|
228
228
|
return self.request("PUT", f"/agent/{agent_id}", json=payload)
|
|
229
229
|
|
|
230
|
+
# -- lead capture ------------------------------------------------------
|
|
231
|
+
|
|
232
|
+
def get_lead_capture(self, agent_id: str) -> Any:
|
|
233
|
+
"""Fetch the agent's lead-capture config (lazily created OFF if none)."""
|
|
234
|
+
return self.request("GET", f"/agent/{agent_id}/lead-capture")
|
|
235
|
+
|
|
236
|
+
def update_lead_capture(self, agent_id: str, payload: Dict[str, Any]) -> Any:
|
|
237
|
+
"""Full-replace the agent's lead-capture config."""
|
|
238
|
+
return self.request("PUT", f"/agent/{agent_id}/lead-capture", json=payload)
|
|
239
|
+
|
|
230
240
|
# -- workflows ---------------------------------------------------------
|
|
231
241
|
|
|
232
242
|
def get_workflow_for_agent(self, agent_id: str) -> Any:
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"""
|
|
2
|
+
ChatterMate - CLI Lead Capture Commands
|
|
3
|
+
Copyright (C) 2024 ChatterMate
|
|
4
|
+
|
|
5
|
+
This program is free software: you can redistribute it and/or modify
|
|
6
|
+
it under the terms of the GNU Affero General Public License as
|
|
7
|
+
published by the Free Software Foundation, either version 3 of the
|
|
8
|
+
License, or (at your option) any later version.
|
|
9
|
+
|
|
10
|
+
This program is distributed in the hope that it will be useful,
|
|
11
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
GNU Affero General Public License for more details.
|
|
14
|
+
|
|
15
|
+
You should have received a copy of the GNU Affero General Public License
|
|
16
|
+
along with this program. If not, see <https://www.gnu.org/licenses/>
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
from typing import List, Optional
|
|
20
|
+
|
|
21
|
+
import typer
|
|
22
|
+
|
|
23
|
+
from ..context import console, get_client, output, print_error, run
|
|
24
|
+
|
|
25
|
+
lead_app = typer.Typer(
|
|
26
|
+
no_args_is_help=True,
|
|
27
|
+
help="Configure an agent's lead capture (collect visitor contact details in chat).",
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
# The standard contact fields the agent can collect. Custom fields configured in the
|
|
31
|
+
# dashboard are preserved untouched by `set`.
|
|
32
|
+
STANDARD_FIELDS = ["email", "name", "company", "phone"]
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def _split_csv(value: Optional[str]) -> List[str]:
|
|
36
|
+
if not value:
|
|
37
|
+
return []
|
|
38
|
+
return [v.strip().lower() for v in value.split(",") if v.strip()]
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
@lead_app.command("show")
|
|
42
|
+
def show(
|
|
43
|
+
agent_id: str = typer.Argument(..., help="The agent's ID."),
|
|
44
|
+
as_json: bool = typer.Option(False, "--json", help="Output raw JSON."),
|
|
45
|
+
):
|
|
46
|
+
"""Show an agent's lead-capture configuration."""
|
|
47
|
+
client = get_client()
|
|
48
|
+
data = run(lambda: client.get_lead_capture(agent_id))
|
|
49
|
+
|
|
50
|
+
def render(cfg):
|
|
51
|
+
if not isinstance(cfg, dict):
|
|
52
|
+
console.print(str(cfg))
|
|
53
|
+
return
|
|
54
|
+
console.print(f" enabled: {cfg.get('enabled')}")
|
|
55
|
+
console.print(f" require consent: {cfg.get('require_consent')}")
|
|
56
|
+
console.print(f" guidance: {cfg.get('guidance') or '-'}")
|
|
57
|
+
fields = cfg.get("fields") or []
|
|
58
|
+
collect = [f for f in fields if f.get("enabled")]
|
|
59
|
+
if collect:
|
|
60
|
+
console.print(" collect:")
|
|
61
|
+
for f in collect:
|
|
62
|
+
label = f.get("label") or f.get("key")
|
|
63
|
+
req = " [required]" if f.get("required") else ""
|
|
64
|
+
console.print(f" - {label}{req}")
|
|
65
|
+
|
|
66
|
+
output(data, as_json, render)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
@lead_app.command("set")
|
|
70
|
+
def set_config(
|
|
71
|
+
agent_id: str = typer.Argument(..., help="The agent's ID."),
|
|
72
|
+
enable: Optional[bool] = typer.Option(
|
|
73
|
+
None, "--enable/--disable", help="Turn lead capture on or off."),
|
|
74
|
+
fields: Optional[str] = typer.Option(
|
|
75
|
+
None, "--fields",
|
|
76
|
+
help="Comma-separated standard fields to collect: email,name,company,phone. "
|
|
77
|
+
"Email is always collected. Replaces the current standard-field selection."),
|
|
78
|
+
required: Optional[str] = typer.Option(
|
|
79
|
+
None, "--required",
|
|
80
|
+
help="Comma-separated fields to mark required (email is always required)."),
|
|
81
|
+
consent: Optional[bool] = typer.Option(
|
|
82
|
+
None, "--consent/--no-consent",
|
|
83
|
+
help="Require the visitor's explicit consent before recording a lead (GDPR)."),
|
|
84
|
+
guidance: Optional[str] = typer.Option(
|
|
85
|
+
None, "--guidance", help="Freeform guidance steering when/how the agent asks."),
|
|
86
|
+
as_json: bool = typer.Option(False, "--json", help="Output raw JSON."),
|
|
87
|
+
):
|
|
88
|
+
"""Update an agent's lead-capture config (Pro plan).
|
|
89
|
+
|
|
90
|
+
Full-replace under the hood: the current config is fetched, your flags are
|
|
91
|
+
applied, and the result is saved. Custom fields are preserved. Examples:
|
|
92
|
+
|
|
93
|
+
chattermate lead-capture set <agent> --enable --fields email,name,company
|
|
94
|
+
chattermate lead-capture set <agent> --required email,company --consent
|
|
95
|
+
chattermate lead-capture set <agent> --disable
|
|
96
|
+
"""
|
|
97
|
+
client = get_client()
|
|
98
|
+
cfg = run(lambda: client.get_lead_capture(agent_id))
|
|
99
|
+
if not isinstance(cfg, dict):
|
|
100
|
+
print_error("Unexpected response fetching current config.")
|
|
101
|
+
raise typer.Exit(code=1)
|
|
102
|
+
|
|
103
|
+
existing = cfg.get("fields") or []
|
|
104
|
+
custom_fields = [f for f in existing if not f.get("standard")]
|
|
105
|
+
# Preserve current standard-field state unless --fields overrides it.
|
|
106
|
+
std_state = {f["key"]: f for f in existing if f.get("standard") and f.get("key")}
|
|
107
|
+
|
|
108
|
+
req_keys = set(_split_csv(required))
|
|
109
|
+
req_keys.add("email") # email is always required to have a usable lead
|
|
110
|
+
|
|
111
|
+
if fields is not None:
|
|
112
|
+
wanted = set(_split_csv(fields))
|
|
113
|
+
wanted.add("email") # always collect email
|
|
114
|
+
std_fields = [
|
|
115
|
+
{"key": k, "standard": True, "enabled": k in wanted,
|
|
116
|
+
"required": k in req_keys}
|
|
117
|
+
for k in STANDARD_FIELDS
|
|
118
|
+
]
|
|
119
|
+
else:
|
|
120
|
+
# Keep the current standard fields; just refresh required flags if asked.
|
|
121
|
+
std_fields = []
|
|
122
|
+
for k in STANDARD_FIELDS:
|
|
123
|
+
f = std_state.get(k)
|
|
124
|
+
if not f:
|
|
125
|
+
continue
|
|
126
|
+
f = dict(f)
|
|
127
|
+
if required is not None or k == "email":
|
|
128
|
+
f["required"] = k in req_keys
|
|
129
|
+
std_fields.append(f)
|
|
130
|
+
if not std_fields: # nothing configured yet → at least collect email
|
|
131
|
+
std_fields = [{"key": "email", "standard": True, "enabled": True, "required": True}]
|
|
132
|
+
|
|
133
|
+
payload = {
|
|
134
|
+
"enabled": cfg.get("enabled", False) if enable is None else enable,
|
|
135
|
+
"require_consent": cfg.get("require_consent", True) if consent is None else consent,
|
|
136
|
+
"guidance": cfg.get("guidance") if guidance is None else (guidance or None),
|
|
137
|
+
"fields": std_fields + custom_fields,
|
|
138
|
+
"assignment_mode": cfg.get("assignment_mode", "none"),
|
|
139
|
+
"assignment_target_user_id": cfg.get("assignment_target_user_id"),
|
|
140
|
+
"crm_sync_target": cfg.get("crm_sync_target", "none"),
|
|
141
|
+
"slack_notify_enabled": cfg.get("slack_notify_enabled", False),
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
data = run(lambda: client.update_lead_capture(agent_id, payload))
|
|
145
|
+
if as_json:
|
|
146
|
+
output(data, True)
|
|
147
|
+
return
|
|
148
|
+
state = "on" if payload["enabled"] else "off"
|
|
149
|
+
collect = ", ".join(f["key"] for f in std_fields if f["enabled"]) or "-"
|
|
150
|
+
console.print(f"[green]Lead capture {state}[/green] — collecting: {collect}")
|
|
@@ -25,6 +25,7 @@ from .commands import auth as auth_cmd
|
|
|
25
25
|
from .commands.agent import agent_app
|
|
26
26
|
from .commands.ai import ai_app
|
|
27
27
|
from .commands.knowledge import knowledge_app
|
|
28
|
+
from .commands.lead_capture import lead_app
|
|
28
29
|
from .commands.widget import widget_app
|
|
29
30
|
from .commands.workflow import workflow_app
|
|
30
31
|
|
|
@@ -68,6 +69,7 @@ app.add_typer(ai_app, name="ai")
|
|
|
68
69
|
app.add_typer(widget_app, name="widget")
|
|
69
70
|
app.add_typer(workflow_app, name="workflow")
|
|
70
71
|
app.add_typer(knowledge_app, name="knowledge")
|
|
72
|
+
app.add_typer(lead_app, name="lead-capture")
|
|
71
73
|
|
|
72
74
|
|
|
73
75
|
def main():
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: chattermate-cli
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.0
|
|
4
4
|
Summary: ChatterMate CLI and MCP server — sign up, authenticate, and configure agents, workflows and knowledge from the terminal or an AI agent.
|
|
5
5
|
Author: ChatterMate
|
|
6
6
|
License: AGPL-3.0-or-later
|
|
@@ -18,10 +18,12 @@ chattermate_cli/commands/agent.py
|
|
|
18
18
|
chattermate_cli/commands/ai.py
|
|
19
19
|
chattermate_cli/commands/auth.py
|
|
20
20
|
chattermate_cli/commands/knowledge.py
|
|
21
|
+
chattermate_cli/commands/lead_capture.py
|
|
21
22
|
chattermate_cli/commands/widget.py
|
|
22
23
|
chattermate_cli/commands/workflow.py
|
|
23
24
|
tests/test_ai.py
|
|
24
25
|
tests/test_client.py
|
|
25
26
|
tests/test_knowledge.py
|
|
27
|
+
tests/test_lead_capture.py
|
|
26
28
|
tests/test_mcp.py
|
|
27
29
|
tests/test_widget.py
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "chattermate-cli"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.4.0"
|
|
8
8
|
description = "ChatterMate CLI and MCP server — sign up, authenticate, and configure agents, workflows and knowledge from the terminal or an AI agent."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.10"
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"""
|
|
2
|
+
ChatterMate - CLI Lead Capture Command Tests
|
|
3
|
+
Copyright (C) 2024 ChatterMate
|
|
4
|
+
|
|
5
|
+
This program is free software: you can redistribute it and/or modify
|
|
6
|
+
it under the terms of the GNU Affero General Public License as
|
|
7
|
+
published by the Free Software Foundation, either version 3 of the
|
|
8
|
+
License, or (at your option) any later version.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
import json
|
|
12
|
+
|
|
13
|
+
import httpx
|
|
14
|
+
|
|
15
|
+
from chattermate_cli.client import Client
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def make_client(handler, token="cmat_x"):
|
|
19
|
+
client = Client(api_url="http://test", token=token)
|
|
20
|
+
client._http = httpx.Client(transport=httpx.MockTransport(handler))
|
|
21
|
+
return client
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def test_get_lead_capture_path():
|
|
25
|
+
seen = {}
|
|
26
|
+
|
|
27
|
+
def handler(request):
|
|
28
|
+
seen["method"] = request.method
|
|
29
|
+
seen["path"] = request.url.path
|
|
30
|
+
return httpx.Response(200, json={"enabled": False, "fields": []})
|
|
31
|
+
|
|
32
|
+
client = make_client(handler)
|
|
33
|
+
data = client.get_lead_capture("ag-1")
|
|
34
|
+
|
|
35
|
+
assert seen["method"] == "GET"
|
|
36
|
+
assert seen["path"] == "/api/v1/agent/ag-1/lead-capture"
|
|
37
|
+
assert data["enabled"] is False
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def test_update_lead_capture_puts_payload():
|
|
41
|
+
seen = {}
|
|
42
|
+
|
|
43
|
+
def handler(request):
|
|
44
|
+
seen["method"] = request.method
|
|
45
|
+
seen["path"] = request.url.path
|
|
46
|
+
seen["json"] = json.loads(request.content)
|
|
47
|
+
return httpx.Response(200, json={"enabled": True})
|
|
48
|
+
|
|
49
|
+
client = make_client(handler)
|
|
50
|
+
payload = {
|
|
51
|
+
"enabled": True,
|
|
52
|
+
"require_consent": True,
|
|
53
|
+
"fields": [{"key": "email", "standard": True, "enabled": True, "required": True}],
|
|
54
|
+
}
|
|
55
|
+
data = client.update_lead_capture("ag-1", payload)
|
|
56
|
+
|
|
57
|
+
assert seen["method"] == "PUT"
|
|
58
|
+
assert seen["path"] == "/api/v1/agent/ag-1/lead-capture"
|
|
59
|
+
assert seen["json"]["enabled"] is True
|
|
60
|
+
assert data["enabled"] is True
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{chattermate_cli-0.3.1 → chattermate_cli-0.4.0}/chattermate_cli.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|