chattermate-cli 0.5.0__tar.gz → 0.6.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.5.0 → chattermate_cli-0.6.0}/PKG-INFO +1 -1
- {chattermate_cli-0.5.0 → chattermate_cli-0.6.0}/chattermate_cli/__init__.py +1 -1
- {chattermate_cli-0.5.0 → chattermate_cli-0.6.0}/chattermate_cli/client.py +79 -0
- chattermate_cli-0.6.0/chattermate_cli/commands/help_center.py +507 -0
- {chattermate_cli-0.5.0 → chattermate_cli-0.6.0}/chattermate_cli/main.py +2 -0
- {chattermate_cli-0.5.0 → chattermate_cli-0.6.0}/chattermate_cli/mcp_server.py +166 -0
- {chattermate_cli-0.5.0 → chattermate_cli-0.6.0}/chattermate_cli.egg-info/PKG-INFO +1 -1
- {chattermate_cli-0.5.0 → chattermate_cli-0.6.0}/chattermate_cli.egg-info/SOURCES.txt +2 -0
- {chattermate_cli-0.5.0 → chattermate_cli-0.6.0}/pyproject.toml +1 -1
- chattermate_cli-0.6.0/tests/test_help_center.py +163 -0
- {chattermate_cli-0.5.0 → chattermate_cli-0.6.0}/LICENSE +0 -0
- {chattermate_cli-0.5.0 → chattermate_cli-0.6.0}/README.md +0 -0
- {chattermate_cli-0.5.0 → chattermate_cli-0.6.0}/chattermate_cli/commands/__init__.py +0 -0
- {chattermate_cli-0.5.0 → chattermate_cli-0.6.0}/chattermate_cli/commands/agent.py +0 -0
- {chattermate_cli-0.5.0 → chattermate_cli-0.6.0}/chattermate_cli/commands/ai.py +0 -0
- {chattermate_cli-0.5.0 → chattermate_cli-0.6.0}/chattermate_cli/commands/auth.py +0 -0
- {chattermate_cli-0.5.0 → chattermate_cli-0.6.0}/chattermate_cli/commands/customization.py +0 -0
- {chattermate_cli-0.5.0 → chattermate_cli-0.6.0}/chattermate_cli/commands/knowledge.py +0 -0
- {chattermate_cli-0.5.0 → chattermate_cli-0.6.0}/chattermate_cli/commands/lead_capture.py +0 -0
- {chattermate_cli-0.5.0 → chattermate_cli-0.6.0}/chattermate_cli/commands/widget.py +0 -0
- {chattermate_cli-0.5.0 → chattermate_cli-0.6.0}/chattermate_cli/commands/workflow.py +0 -0
- {chattermate_cli-0.5.0 → chattermate_cli-0.6.0}/chattermate_cli/config.py +0 -0
- {chattermate_cli-0.5.0 → chattermate_cli-0.6.0}/chattermate_cli/context.py +0 -0
- {chattermate_cli-0.5.0 → chattermate_cli-0.6.0}/chattermate_cli.egg-info/dependency_links.txt +0 -0
- {chattermate_cli-0.5.0 → chattermate_cli-0.6.0}/chattermate_cli.egg-info/entry_points.txt +0 -0
- {chattermate_cli-0.5.0 → chattermate_cli-0.6.0}/chattermate_cli.egg-info/requires.txt +0 -0
- {chattermate_cli-0.5.0 → chattermate_cli-0.6.0}/chattermate_cli.egg-info/top_level.txt +0 -0
- {chattermate_cli-0.5.0 → chattermate_cli-0.6.0}/setup.cfg +0 -0
- {chattermate_cli-0.5.0 → chattermate_cli-0.6.0}/tests/test_ai.py +0 -0
- {chattermate_cli-0.5.0 → chattermate_cli-0.6.0}/tests/test_client.py +0 -0
- {chattermate_cli-0.5.0 → chattermate_cli-0.6.0}/tests/test_customization.py +0 -0
- {chattermate_cli-0.5.0 → chattermate_cli-0.6.0}/tests/test_knowledge.py +0 -0
- {chattermate_cli-0.5.0 → chattermate_cli-0.6.0}/tests/test_lead_capture.py +0 -0
- {chattermate_cli-0.5.0 → chattermate_cli-0.6.0}/tests/test_mcp.py +0 -0
- {chattermate_cli-0.5.0 → chattermate_cli-0.6.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.6.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
|
|
@@ -325,3 +325,82 @@ class Client:
|
|
|
325
325
|
|
|
326
326
|
def get_ai_config(self) -> Any:
|
|
327
327
|
return self.request("GET", "/ai/config")
|
|
328
|
+
|
|
329
|
+
# -- help center / FAQ -------------------------------------------------
|
|
330
|
+
# Org is taken from the authenticated user server-side, so no org_id here.
|
|
331
|
+
|
|
332
|
+
def list_faqs(self, params: Optional[Dict[str, Any]] = None) -> Any:
|
|
333
|
+
return self.request("GET", "/help-center/faqs", params=params)
|
|
334
|
+
|
|
335
|
+
def faq_categories(self) -> Any:
|
|
336
|
+
return self.request("GET", "/help-center/faqs/categories")
|
|
337
|
+
|
|
338
|
+
def create_faq(self, payload: Dict[str, Any]) -> Any:
|
|
339
|
+
return self.request("POST", "/help-center/faqs", json=payload)
|
|
340
|
+
|
|
341
|
+
def update_faq(self, faq_id: str, payload: Dict[str, Any]) -> Any:
|
|
342
|
+
return self.request("PUT", f"/help-center/faqs/{faq_id}", json=payload)
|
|
343
|
+
|
|
344
|
+
def delete_faq(self, faq_id: str) -> Any:
|
|
345
|
+
return self.request("DELETE", f"/help-center/faqs/{faq_id}")
|
|
346
|
+
|
|
347
|
+
def bulk_faq_status(self, faq_ids: List[str], status: str) -> Any:
|
|
348
|
+
return self.request(
|
|
349
|
+
"POST", "/help-center/faqs/bulk-status",
|
|
350
|
+
json={"faq_ids": faq_ids, "status": status},
|
|
351
|
+
)
|
|
352
|
+
|
|
353
|
+
def bulk_delete_faqs(self, faq_ids: List[str]) -> Any:
|
|
354
|
+
return self.request("POST", "/help-center/faqs/bulk-delete", json={"faq_ids": faq_ids})
|
|
355
|
+
|
|
356
|
+
def upload_faq_image(self, name: str, content: bytes, content_type: str) -> Any:
|
|
357
|
+
return self.request(
|
|
358
|
+
"POST", "/help-center/faqs/image",
|
|
359
|
+
files={"file": (name, content, content_type)},
|
|
360
|
+
)
|
|
361
|
+
|
|
362
|
+
# settings / branding
|
|
363
|
+
def get_help_center_settings(self) -> Any:
|
|
364
|
+
return self.request("GET", "/help-center/settings")
|
|
365
|
+
|
|
366
|
+
def update_help_center_settings(self, payload: Dict[str, Any]) -> Any:
|
|
367
|
+
return self.request("PUT", "/help-center/settings", json=payload)
|
|
368
|
+
|
|
369
|
+
def upload_help_center_logo(self, name: str, content: bytes, content_type: str) -> Any:
|
|
370
|
+
return self.request(
|
|
371
|
+
"POST", "/help-center/logo",
|
|
372
|
+
files={"file": (name, content, content_type)},
|
|
373
|
+
)
|
|
374
|
+
|
|
375
|
+
def remove_help_center_logo(self) -> Any:
|
|
376
|
+
return self.request("DELETE", "/help-center/logo")
|
|
377
|
+
|
|
378
|
+
# import (URL / PDF) — async, returns a job
|
|
379
|
+
def import_help_center_url(self, url: str, mode: str = "qa") -> Any:
|
|
380
|
+
return self.request("POST", "/help-center/import", json={"url": url, "mode": mode})
|
|
381
|
+
|
|
382
|
+
def import_help_center_pdf(self, name: str, content: bytes) -> Any:
|
|
383
|
+
return self.request(
|
|
384
|
+
"POST", "/help-center/import/pdf",
|
|
385
|
+
files={"file": (name, content, "application/pdf")},
|
|
386
|
+
)
|
|
387
|
+
|
|
388
|
+
# custom domain
|
|
389
|
+
def set_help_center_domain(self, domain: str) -> Any:
|
|
390
|
+
return self.request("POST", "/help-center/domain", json={"domain": domain})
|
|
391
|
+
|
|
392
|
+
def clear_help_center_domain(self) -> Any:
|
|
393
|
+
return self.request("DELETE", "/help-center/domain")
|
|
394
|
+
|
|
395
|
+
def verify_help_center_domain(self) -> Any:
|
|
396
|
+
return self.request("POST", "/help-center/domain/verify")
|
|
397
|
+
|
|
398
|
+
def help_center_domain_status(self) -> Any:
|
|
399
|
+
return self.request("GET", "/help-center/domain/status")
|
|
400
|
+
|
|
401
|
+
# jobs (import/generate status polling)
|
|
402
|
+
def help_center_job(self, active: bool = True) -> Any:
|
|
403
|
+
return self.request("GET", "/help-center/jobs", params={"active": active})
|
|
404
|
+
|
|
405
|
+
def help_center_job_by_id(self, job_id: int) -> Any:
|
|
406
|
+
return self.request("GET", f"/help-center/jobs/{job_id}")
|
|
@@ -0,0 +1,507 @@
|
|
|
1
|
+
"""
|
|
2
|
+
ChatterMate - CLI Help-Center / FAQ 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
|
+
Manage the public help center: FAQs (create/edit/publish/import), site
|
|
20
|
+
customization, logo, and the custom domain. Generating FAQs from the knowledge
|
|
21
|
+
base is intentionally NOT exposed here — do that from the dashboard.
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
from pathlib import Path
|
|
25
|
+
from typing import Any, List, Optional
|
|
26
|
+
|
|
27
|
+
import typer
|
|
28
|
+
from rich.table import Table
|
|
29
|
+
|
|
30
|
+
from ..context import console, get_client, output, print_error, run
|
|
31
|
+
|
|
32
|
+
help_center_app = typer.Typer(
|
|
33
|
+
no_args_is_help=True,
|
|
34
|
+
help="Manage the public help center — FAQs, customization, logo and custom domain.",
|
|
35
|
+
)
|
|
36
|
+
faq_app = typer.Typer(no_args_is_help=True, help="Create, edit, publish and import FAQs.")
|
|
37
|
+
import_app = typer.Typer(no_args_is_help=True, help="Import FAQs from a URL or a PDF.")
|
|
38
|
+
logo_app = typer.Typer(no_args_is_help=True, help="Set or remove the help-center logo.")
|
|
39
|
+
domain_app = typer.Typer(no_args_is_help=True, help="Manage the help center's custom domain.")
|
|
40
|
+
jobs_app = typer.Typer(no_args_is_help=True, help="Inspect import/generation jobs.")
|
|
41
|
+
|
|
42
|
+
FAQ_STATUSES = ["draft", "published"]
|
|
43
|
+
IMPORT_MODES = ["qa", "articles"]
|
|
44
|
+
_IMAGE_TYPES = {
|
|
45
|
+
".png": "image/png", ".jpg": "image/jpeg", ".jpeg": "image/jpeg",
|
|
46
|
+
".webp": "image/webp", ".gif": "image/gif",
|
|
47
|
+
}
|
|
48
|
+
_JSON_OPT = typer.Option(False, "--json", help="Output raw JSON.")
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def _read_file(path: Path) -> bytes:
|
|
52
|
+
if not path.is_file():
|
|
53
|
+
print_error(f"Not a file: {path}")
|
|
54
|
+
raise typer.Exit(code=1)
|
|
55
|
+
try:
|
|
56
|
+
return path.read_bytes()
|
|
57
|
+
except OSError as exc:
|
|
58
|
+
print_error(f"Cannot read {path}: {exc}")
|
|
59
|
+
raise typer.Exit(code=1)
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
# ---------- settings / customization ----------
|
|
63
|
+
|
|
64
|
+
def _render_settings(data: Any) -> None:
|
|
65
|
+
if not isinstance(data, dict):
|
|
66
|
+
console.print("No settings.")
|
|
67
|
+
return
|
|
68
|
+
console.print(f" enabled: {data.get('enabled')}")
|
|
69
|
+
console.print(f" slug: {data.get('slug') or '-'}")
|
|
70
|
+
console.print(f" live url: {data.get('live_url') or '-'}")
|
|
71
|
+
console.print(f" title: {data.get('title') or '-'}")
|
|
72
|
+
console.print(f" description: {data.get('description') or '-'}")
|
|
73
|
+
console.print(f" brand color: {data.get('brand_color')}")
|
|
74
|
+
console.print(f" ai search: {data.get('ai_search_enabled')}")
|
|
75
|
+
console.print(f" chat widget: {data.get('chat_widget_enabled')}")
|
|
76
|
+
console.print(f" auto-generate:{data.get('auto_generate')}")
|
|
77
|
+
console.print(f" agent id: {data.get('agent_id') or '-'}")
|
|
78
|
+
console.print(f" published: {data.get('published_count')}")
|
|
79
|
+
links = data.get("header_links") or []
|
|
80
|
+
console.print(f" header links: {', '.join(l.get('label', '') for l in links) or '-'}")
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
@help_center_app.command("settings")
|
|
84
|
+
def settings(as_json: bool = _JSON_OPT):
|
|
85
|
+
"""Show the current help-center settings and customization."""
|
|
86
|
+
client = get_client()
|
|
87
|
+
data = run(client.get_help_center_settings)
|
|
88
|
+
output(data, as_json, _render_settings)
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
@help_center_app.command("configure")
|
|
92
|
+
def configure(
|
|
93
|
+
title: Optional[str] = typer.Option(None, "--title", help="Help-center title."),
|
|
94
|
+
description: Optional[str] = typer.Option(None, "--description", help="Meta description."),
|
|
95
|
+
brand_color: Optional[str] = typer.Option(None, "--brand-color", help="Brand color (hex, e.g. #4338CA)."),
|
|
96
|
+
cta_text: Optional[str] = typer.Option(None, "--cta-text", help="Header CTA button text."),
|
|
97
|
+
cta_url: Optional[str] = typer.Option(None, "--cta-url", help="Header CTA URL (blank string clears)."),
|
|
98
|
+
agent_id: Optional[str] = typer.Option(None, "--agent-id", help="Agent powering AI search / chat widget."),
|
|
99
|
+
header_link: List[str] = typer.Option(
|
|
100
|
+
[], "--header-link", help='Header nav link as "Label|https://url" (repeatable; replaces the list).'),
|
|
101
|
+
enabled: Optional[bool] = typer.Option(None, "--enable/--disable", help="Publish or unpublish the site."),
|
|
102
|
+
ai_search: Optional[bool] = typer.Option(None, "--ai-search/--no-ai-search", help="AI answer above search."),
|
|
103
|
+
chat_widget: Optional[bool] = typer.Option(None, "--chat-widget/--no-chat-widget", help="Embed the chat widget."),
|
|
104
|
+
auto_generate: Optional[bool] = typer.Option(
|
|
105
|
+
None, "--auto-generate/--no-auto-generate", help="Auto-generate FAQs from new knowledge."),
|
|
106
|
+
as_json: bool = _JSON_OPT,
|
|
107
|
+
):
|
|
108
|
+
"""Update help-center settings. Only the options you pass change.
|
|
109
|
+
|
|
110
|
+
Examples:
|
|
111
|
+
|
|
112
|
+
chattermate help-center configure --title "Help" --brand-color "#4338CA"
|
|
113
|
+
chattermate help-center configure --enable --ai-search
|
|
114
|
+
chattermate help-center configure --header-link "Home|https://acme.com"
|
|
115
|
+
"""
|
|
116
|
+
payload: dict = {}
|
|
117
|
+
for key, value in {
|
|
118
|
+
"title": title, "description": description, "brand_color": brand_color,
|
|
119
|
+
"cta_text": cta_text, "cta_url": cta_url, "agent_id": agent_id,
|
|
120
|
+
"enabled": enabled, "ai_search_enabled": ai_search,
|
|
121
|
+
"chat_widget_enabled": chat_widget, "auto_generate": auto_generate,
|
|
122
|
+
}.items():
|
|
123
|
+
if value is not None:
|
|
124
|
+
payload[key] = value
|
|
125
|
+
if header_link:
|
|
126
|
+
links = []
|
|
127
|
+
for item in header_link:
|
|
128
|
+
if "|" not in item:
|
|
129
|
+
print_error(f'--header-link must be "Label|https://url", got: {item}')
|
|
130
|
+
raise typer.Exit(code=1)
|
|
131
|
+
label, url = item.split("|", 1)
|
|
132
|
+
links.append({"label": label.strip(), "url": url.strip()})
|
|
133
|
+
payload["header_links"] = links
|
|
134
|
+
|
|
135
|
+
if not payload:
|
|
136
|
+
print_error("Nothing to update. Pass at least one option (see --help).")
|
|
137
|
+
raise typer.Exit(code=1)
|
|
138
|
+
|
|
139
|
+
client = get_client()
|
|
140
|
+
data = run(lambda: client.update_help_center_settings(payload))
|
|
141
|
+
if not as_json:
|
|
142
|
+
console.print("[green]Help-center settings updated.[/green]")
|
|
143
|
+
output(data, as_json, _render_settings)
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
# ---------- logo ----------
|
|
147
|
+
|
|
148
|
+
@logo_app.command("set")
|
|
149
|
+
def logo_set(
|
|
150
|
+
file: Path = typer.Argument(..., help="Local image file (PNG, JPG or WebP)."),
|
|
151
|
+
as_json: bool = _JSON_OPT,
|
|
152
|
+
):
|
|
153
|
+
"""Upload/replace the help-center header logo."""
|
|
154
|
+
ctype = _IMAGE_TYPES.get(file.suffix.lower())
|
|
155
|
+
if not ctype:
|
|
156
|
+
print_error("Logo must be a PNG, JPG or WebP image.")
|
|
157
|
+
raise typer.Exit(code=1)
|
|
158
|
+
content = _read_file(file)
|
|
159
|
+
client = get_client()
|
|
160
|
+
data = run(lambda: client.upload_help_center_logo(file.name, content, ctype))
|
|
161
|
+
if not as_json:
|
|
162
|
+
console.print("[green]Logo updated.[/green]")
|
|
163
|
+
output(data, as_json, _render_settings)
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
@logo_app.command("remove")
|
|
167
|
+
def logo_remove(as_json: bool = _JSON_OPT):
|
|
168
|
+
"""Remove the help-center logo."""
|
|
169
|
+
client = get_client()
|
|
170
|
+
data = run(client.remove_help_center_logo)
|
|
171
|
+
if not as_json:
|
|
172
|
+
console.print("[green]Logo removed.[/green]")
|
|
173
|
+
output(data, as_json, _render_settings)
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
# ---------- FAQs ----------
|
|
177
|
+
|
|
178
|
+
@faq_app.command("list")
|
|
179
|
+
def faq_list(
|
|
180
|
+
status: Optional[str] = typer.Option(None, "--status", help=f"Filter by status: {', '.join(FAQ_STATUSES)}."),
|
|
181
|
+
category: Optional[str] = typer.Option(None, "--category", help="Filter by category."),
|
|
182
|
+
q: Optional[str] = typer.Option(None, "--q", help="Search question/answer text."),
|
|
183
|
+
page: int = typer.Option(1, "--page", help="Page number."),
|
|
184
|
+
page_size: int = typer.Option(100, "--page-size", help="Items per page (1-200)."),
|
|
185
|
+
as_json: bool = _JSON_OPT,
|
|
186
|
+
):
|
|
187
|
+
"""List FAQs (filter by status/category, search, paginate)."""
|
|
188
|
+
if status is not None and status not in FAQ_STATUSES:
|
|
189
|
+
print_error(f"--status must be one of: {', '.join(FAQ_STATUSES)}.")
|
|
190
|
+
raise typer.Exit(code=1)
|
|
191
|
+
params = {"page": page, "page_size": page_size}
|
|
192
|
+
if status:
|
|
193
|
+
params["status"] = status
|
|
194
|
+
if category:
|
|
195
|
+
params["category"] = category
|
|
196
|
+
if q:
|
|
197
|
+
params["q"] = q
|
|
198
|
+
client = get_client()
|
|
199
|
+
data = run(lambda: client.list_faqs(params))
|
|
200
|
+
|
|
201
|
+
def render(payload):
|
|
202
|
+
rows = payload.get("faqs", []) if isinstance(payload, dict) else (payload or [])
|
|
203
|
+
table = Table(title="FAQs")
|
|
204
|
+
for col in ("id", "status", "category", "question"):
|
|
205
|
+
table.add_column(col, overflow="fold")
|
|
206
|
+
for r in rows:
|
|
207
|
+
table.add_row(
|
|
208
|
+
str(r.get("id")), str(r.get("status")), str(r.get("category", "")),
|
|
209
|
+
str(r.get("question", ""))[:80],
|
|
210
|
+
)
|
|
211
|
+
console.print(table)
|
|
212
|
+
pg = payload.get("pagination") if isinstance(payload, dict) else None
|
|
213
|
+
if isinstance(pg, dict):
|
|
214
|
+
console.print(
|
|
215
|
+
f"[dim]page {pg.get('page')}/{pg.get('total_pages')} · {pg.get('total')} total[/dim]")
|
|
216
|
+
|
|
217
|
+
output(data, as_json, render)
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
@faq_app.command("categories")
|
|
221
|
+
def faq_categories(as_json: bool = _JSON_OPT):
|
|
222
|
+
"""List the distinct FAQ categories."""
|
|
223
|
+
client = get_client()
|
|
224
|
+
data = run(client.faq_categories)
|
|
225
|
+
|
|
226
|
+
def render(payload):
|
|
227
|
+
for name in payload or []:
|
|
228
|
+
console.print(f" {name}")
|
|
229
|
+
|
|
230
|
+
output(data, as_json, render)
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
@faq_app.command("create")
|
|
234
|
+
def faq_create(
|
|
235
|
+
question: str = typer.Option(..., "--question", help="The question."),
|
|
236
|
+
answer: str = typer.Option(..., "--answer", help="The answer (Markdown allowed)."),
|
|
237
|
+
category: Optional[str] = typer.Option(None, "--category", help="Category (defaults server-side)."),
|
|
238
|
+
status: str = typer.Option("draft", "--status", help=f"One of: {', '.join(FAQ_STATUSES)}."),
|
|
239
|
+
as_json: bool = _JSON_OPT,
|
|
240
|
+
):
|
|
241
|
+
"""Create a FAQ manually."""
|
|
242
|
+
if status not in FAQ_STATUSES:
|
|
243
|
+
print_error(f"--status must be one of: {', '.join(FAQ_STATUSES)}.")
|
|
244
|
+
raise typer.Exit(code=1)
|
|
245
|
+
payload = {"question": question, "answer": answer, "status": status}
|
|
246
|
+
if category:
|
|
247
|
+
payload["category"] = category
|
|
248
|
+
client = get_client()
|
|
249
|
+
data = run(lambda: client.create_faq(payload))
|
|
250
|
+
if not as_json:
|
|
251
|
+
console.print(f"[green]Created FAQ[/green] {data.get('id') if isinstance(data, dict) else ''}")
|
|
252
|
+
output(data, as_json)
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
@faq_app.command("update")
|
|
256
|
+
def faq_update(
|
|
257
|
+
faq_id: str = typer.Argument(..., help="FAQ id."),
|
|
258
|
+
question: Optional[str] = typer.Option(None, "--question", help="New question."),
|
|
259
|
+
answer: Optional[str] = typer.Option(None, "--answer", help="New answer (Markdown allowed)."),
|
|
260
|
+
category: Optional[str] = typer.Option(None, "--category", help="New category."),
|
|
261
|
+
publish: Optional[bool] = typer.Option(
|
|
262
|
+
None, "--publish/--unpublish", help="Publish or unpublish this FAQ."),
|
|
263
|
+
as_json: bool = _JSON_OPT,
|
|
264
|
+
):
|
|
265
|
+
"""Edit a single FAQ."""
|
|
266
|
+
payload: dict = {}
|
|
267
|
+
if question is not None:
|
|
268
|
+
payload["question"] = question
|
|
269
|
+
if answer is not None:
|
|
270
|
+
payload["answer"] = answer
|
|
271
|
+
if category is not None:
|
|
272
|
+
payload["category"] = category
|
|
273
|
+
if publish is not None:
|
|
274
|
+
payload["status"] = "published" if publish else "draft"
|
|
275
|
+
if not payload:
|
|
276
|
+
print_error("Nothing to update. Pass at least one option (see --help).")
|
|
277
|
+
raise typer.Exit(code=1)
|
|
278
|
+
client = get_client()
|
|
279
|
+
data = run(lambda: client.update_faq(faq_id, payload))
|
|
280
|
+
if not as_json:
|
|
281
|
+
console.print(f"[green]Updated FAQ[/green] {faq_id}")
|
|
282
|
+
output(data, as_json)
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
@faq_app.command("delete")
|
|
286
|
+
def faq_delete(
|
|
287
|
+
faq_id: str = typer.Argument(..., help="FAQ id."),
|
|
288
|
+
as_json: bool = _JSON_OPT,
|
|
289
|
+
):
|
|
290
|
+
"""Delete a single FAQ."""
|
|
291
|
+
client = get_client()
|
|
292
|
+
run(lambda: client.delete_faq(faq_id))
|
|
293
|
+
if as_json:
|
|
294
|
+
output({"deleted": faq_id}, True)
|
|
295
|
+
else:
|
|
296
|
+
console.print(f"[green]Deleted FAQ[/green] {faq_id}")
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
@faq_app.command("publish")
|
|
300
|
+
def faq_publish(
|
|
301
|
+
faq_ids: List[str] = typer.Argument(..., help="One or more FAQ ids."),
|
|
302
|
+
as_json: bool = _JSON_OPT,
|
|
303
|
+
):
|
|
304
|
+
"""Publish one or more FAQs."""
|
|
305
|
+
client = get_client()
|
|
306
|
+
data = run(lambda: client.bulk_faq_status(faq_ids, "published"))
|
|
307
|
+
if not as_json:
|
|
308
|
+
console.print(f"[green]Published[/green] {data.get('updated') if isinstance(data, dict) else len(faq_ids)} FAQ(s).")
|
|
309
|
+
output(data, as_json)
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
@faq_app.command("unpublish")
|
|
313
|
+
def faq_unpublish(
|
|
314
|
+
faq_ids: List[str] = typer.Argument(..., help="One or more FAQ ids."),
|
|
315
|
+
as_json: bool = _JSON_OPT,
|
|
316
|
+
):
|
|
317
|
+
"""Unpublish (set to draft) one or more FAQs."""
|
|
318
|
+
client = get_client()
|
|
319
|
+
data = run(lambda: client.bulk_faq_status(faq_ids, "draft"))
|
|
320
|
+
if not as_json:
|
|
321
|
+
console.print(f"[green]Unpublished[/green] {data.get('updated') if isinstance(data, dict) else len(faq_ids)} FAQ(s).")
|
|
322
|
+
output(data, as_json)
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
@faq_app.command("delete-many")
|
|
326
|
+
def faq_delete_many(
|
|
327
|
+
faq_ids: List[str] = typer.Argument(..., help="One or more FAQ ids."),
|
|
328
|
+
as_json: bool = _JSON_OPT,
|
|
329
|
+
):
|
|
330
|
+
"""Delete multiple FAQs at once."""
|
|
331
|
+
client = get_client()
|
|
332
|
+
data = run(lambda: client.bulk_delete_faqs(faq_ids))
|
|
333
|
+
if not as_json:
|
|
334
|
+
console.print(f"[green]Deleted[/green] {data.get('deleted') if isinstance(data, dict) else len(faq_ids)} FAQ(s).")
|
|
335
|
+
output(data, as_json)
|
|
336
|
+
|
|
337
|
+
|
|
338
|
+
@faq_app.command("image")
|
|
339
|
+
def faq_image(
|
|
340
|
+
file: Path = typer.Argument(..., help="Local image (PNG, JPG, WebP or GIF) to host for an article."),
|
|
341
|
+
as_json: bool = _JSON_OPT,
|
|
342
|
+
):
|
|
343
|
+
"""Upload an image for embedding in an article's Markdown; prints the hosted URL."""
|
|
344
|
+
ctype = _IMAGE_TYPES.get(file.suffix.lower())
|
|
345
|
+
if not ctype:
|
|
346
|
+
print_error("Image must be a PNG, JPG, WebP or GIF file.")
|
|
347
|
+
raise typer.Exit(code=1)
|
|
348
|
+
content = _read_file(file)
|
|
349
|
+
client = get_client()
|
|
350
|
+
data = run(lambda: client.upload_faq_image(file.name, content, ctype))
|
|
351
|
+
if as_json:
|
|
352
|
+
output(data, True)
|
|
353
|
+
else:
|
|
354
|
+
console.print(data.get("url") if isinstance(data, dict) else str(data))
|
|
355
|
+
|
|
356
|
+
|
|
357
|
+
# ---------- import ----------
|
|
358
|
+
|
|
359
|
+
@import_app.command("url")
|
|
360
|
+
def import_url(
|
|
361
|
+
url: str = typer.Argument(..., help="Page/help-center URL to import from."),
|
|
362
|
+
mode: str = typer.Option(
|
|
363
|
+
"qa", "--mode",
|
|
364
|
+
help="qa = AI extracts Q&A (uses credits); articles = crawl linked articles as-is (no AI)."),
|
|
365
|
+
as_json: bool = _JSON_OPT,
|
|
366
|
+
):
|
|
367
|
+
"""Import FAQs from a URL (queues a job — poll with `help-center jobs`)."""
|
|
368
|
+
if mode not in IMPORT_MODES:
|
|
369
|
+
print_error(f"--mode must be one of: {', '.join(IMPORT_MODES)}.")
|
|
370
|
+
raise typer.Exit(code=1)
|
|
371
|
+
client = get_client()
|
|
372
|
+
data = run(lambda: client.import_help_center_url(url, mode))
|
|
373
|
+
if not as_json:
|
|
374
|
+
console.print(
|
|
375
|
+
f"[green]Import queued[/green] (job {data.get('id') if isinstance(data, dict) else '?'}). "
|
|
376
|
+
"Track it with: chattermate help-center jobs")
|
|
377
|
+
output(data, as_json)
|
|
378
|
+
|
|
379
|
+
|
|
380
|
+
@import_app.command("pdf")
|
|
381
|
+
def import_pdf(
|
|
382
|
+
file: Path = typer.Argument(..., help="Local PDF file to import."),
|
|
383
|
+
as_json: bool = _JSON_OPT,
|
|
384
|
+
):
|
|
385
|
+
"""Import FAQs from a PDF (queues a job — poll with `help-center jobs`)."""
|
|
386
|
+
if file.suffix.lower() != ".pdf":
|
|
387
|
+
print_error(f"Not a .pdf file: {file}")
|
|
388
|
+
raise typer.Exit(code=1)
|
|
389
|
+
content = _read_file(file)
|
|
390
|
+
if not content.startswith(b"%PDF-"):
|
|
391
|
+
print_error(f"Not a valid PDF (missing %PDF- header): {file}")
|
|
392
|
+
raise typer.Exit(code=1)
|
|
393
|
+
client = get_client()
|
|
394
|
+
data = run(lambda: client.import_help_center_pdf(file.name, content))
|
|
395
|
+
if not as_json:
|
|
396
|
+
console.print(
|
|
397
|
+
f"[green]PDF import queued[/green] (job {data.get('id') if isinstance(data, dict) else '?'}). "
|
|
398
|
+
"Track it with: chattermate help-center jobs")
|
|
399
|
+
output(data, as_json)
|
|
400
|
+
|
|
401
|
+
|
|
402
|
+
# ---------- custom domain ----------
|
|
403
|
+
|
|
404
|
+
def _render_domain(data: Any) -> None:
|
|
405
|
+
if not isinstance(data, dict):
|
|
406
|
+
console.print("No custom domain.")
|
|
407
|
+
return
|
|
408
|
+
console.print(f" domain: {data.get('custom_domain') or '-'}")
|
|
409
|
+
console.print(f" status: {data.get('domain_status')}")
|
|
410
|
+
console.print(f" ssl: {data.get('ssl_status')}")
|
|
411
|
+
records = data.get("records") or []
|
|
412
|
+
if records:
|
|
413
|
+
table = Table(title="DNS records to add")
|
|
414
|
+
for col in ("type", "host", "value", "verified"):
|
|
415
|
+
table.add_column(col, overflow="fold")
|
|
416
|
+
for r in records:
|
|
417
|
+
table.add_row(
|
|
418
|
+
str(r.get("type")), str(r.get("host")), str(r.get("value")),
|
|
419
|
+
"✓" if r.get("verified") else "✗",
|
|
420
|
+
)
|
|
421
|
+
console.print(table)
|
|
422
|
+
|
|
423
|
+
|
|
424
|
+
@domain_app.command("set")
|
|
425
|
+
def domain_set(
|
|
426
|
+
domain: str = typer.Argument(..., help="Custom domain, e.g. help.acme.com."),
|
|
427
|
+
as_json: bool = _JSON_OPT,
|
|
428
|
+
):
|
|
429
|
+
"""Claim a custom domain; prints the DNS records to add."""
|
|
430
|
+
client = get_client()
|
|
431
|
+
data = run(lambda: client.set_help_center_domain(domain))
|
|
432
|
+
output(data, as_json, _render_domain)
|
|
433
|
+
|
|
434
|
+
|
|
435
|
+
@domain_app.command("status")
|
|
436
|
+
def domain_status(as_json: bool = _JSON_OPT):
|
|
437
|
+
"""Show the custom domain's DNS/SSL status and required records."""
|
|
438
|
+
client = get_client()
|
|
439
|
+
data = run(client.help_center_domain_status)
|
|
440
|
+
output(data, as_json, _render_domain)
|
|
441
|
+
|
|
442
|
+
|
|
443
|
+
@domain_app.command("verify")
|
|
444
|
+
def domain_verify(as_json: bool = _JSON_OPT):
|
|
445
|
+
"""Run live DNS + SSL verification for the custom domain."""
|
|
446
|
+
client = get_client()
|
|
447
|
+
data = run(client.verify_help_center_domain)
|
|
448
|
+
output(data, as_json, _render_domain)
|
|
449
|
+
|
|
450
|
+
|
|
451
|
+
@domain_app.command("clear")
|
|
452
|
+
def domain_clear(as_json: bool = _JSON_OPT):
|
|
453
|
+
"""Remove the custom domain."""
|
|
454
|
+
client = get_client()
|
|
455
|
+
data = run(client.clear_help_center_domain)
|
|
456
|
+
if not as_json:
|
|
457
|
+
console.print("[green]Custom domain cleared.[/green]")
|
|
458
|
+
output(data, as_json, _render_domain)
|
|
459
|
+
|
|
460
|
+
|
|
461
|
+
# ---------- jobs ----------
|
|
462
|
+
|
|
463
|
+
def _render_job(data: Any) -> None:
|
|
464
|
+
if not isinstance(data, dict):
|
|
465
|
+
console.print("No job.")
|
|
466
|
+
return
|
|
467
|
+
console.print(f" id: {data.get('id')}")
|
|
468
|
+
console.print(f" type: {data.get('job_type')}")
|
|
469
|
+
console.print(f" status: {data.get('status')} ({data.get('stage')})")
|
|
470
|
+
console.print(f" progress: {data.get('progress_percentage')}%")
|
|
471
|
+
console.print(f" created: {data.get('faqs_created')} FAQ(s)")
|
|
472
|
+
if data.get("source_url"):
|
|
473
|
+
console.print(f" source: {data.get('source_url')}")
|
|
474
|
+
if data.get("error"):
|
|
475
|
+
console.print(f" [red]error: {data.get('error')}[/red]")
|
|
476
|
+
|
|
477
|
+
|
|
478
|
+
@jobs_app.command("list")
|
|
479
|
+
def jobs_list(
|
|
480
|
+
latest: bool = typer.Option(False, "--latest", help="Show the most recent job (any status) instead of the active one."),
|
|
481
|
+
as_json: bool = _JSON_OPT,
|
|
482
|
+
):
|
|
483
|
+
"""Show the running import/generation job (or the most recent with --latest)."""
|
|
484
|
+
client = get_client()
|
|
485
|
+
data = run(lambda: client.help_center_job(active=not latest))
|
|
486
|
+
if data is None and not as_json:
|
|
487
|
+
console.print("No job." if latest else "No active job.")
|
|
488
|
+
return
|
|
489
|
+
output(data, as_json, _render_job)
|
|
490
|
+
|
|
491
|
+
|
|
492
|
+
@jobs_app.command("get")
|
|
493
|
+
def jobs_get(
|
|
494
|
+
job_id: int = typer.Argument(..., help="Job id."),
|
|
495
|
+
as_json: bool = _JSON_OPT,
|
|
496
|
+
):
|
|
497
|
+
"""Fetch one import/generation job by id."""
|
|
498
|
+
client = get_client()
|
|
499
|
+
data = run(lambda: client.help_center_job_by_id(job_id))
|
|
500
|
+
output(data, as_json, _render_job)
|
|
501
|
+
|
|
502
|
+
|
|
503
|
+
help_center_app.add_typer(faq_app, name="faq")
|
|
504
|
+
help_center_app.add_typer(import_app, name="import")
|
|
505
|
+
help_center_app.add_typer(logo_app, name="logo")
|
|
506
|
+
help_center_app.add_typer(domain_app, name="domain")
|
|
507
|
+
help_center_app.add_typer(jobs_app, name="jobs")
|
|
@@ -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.customization import customization_app
|
|
28
|
+
from .commands.help_center import help_center_app
|
|
28
29
|
from .commands.knowledge import knowledge_app
|
|
29
30
|
from .commands.lead_capture import lead_app
|
|
30
31
|
from .commands.widget import widget_app
|
|
@@ -72,6 +73,7 @@ app.add_typer(workflow_app, name="workflow")
|
|
|
72
73
|
app.add_typer(knowledge_app, name="knowledge")
|
|
73
74
|
app.add_typer(lead_app, name="lead-capture")
|
|
74
75
|
app.add_typer(customization_app, name="customization")
|
|
76
|
+
app.add_typer(help_center_app, name="help-center")
|
|
75
77
|
|
|
76
78
|
|
|
77
79
|
def main():
|
|
@@ -245,6 +245,172 @@ def unlink_knowledge(knowledge_id: int, agent_id: str) -> Any:
|
|
|
245
245
|
return result if result is not None else {"ok": True}
|
|
246
246
|
|
|
247
247
|
|
|
248
|
+
# -- help center / FAQ tools ----------------------------------------------
|
|
249
|
+
|
|
250
|
+
_HC_IMAGE_TYPES = {
|
|
251
|
+
".png": "image/png", ".jpg": "image/jpeg", ".jpeg": "image/jpeg",
|
|
252
|
+
".webp": "image/webp", ".gif": "image/gif",
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
def _read_path(path: str) -> Any:
|
|
257
|
+
import os
|
|
258
|
+
if not os.path.isfile(path):
|
|
259
|
+
return {"error": f"Not a file: {path}"}
|
|
260
|
+
with open(path, "rb") as fh:
|
|
261
|
+
return fh.read()
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
@mcp.tool()
|
|
265
|
+
def help_center_settings() -> Any:
|
|
266
|
+
"""Get the help center's settings and customization."""
|
|
267
|
+
return _call(_client().get_help_center_settings)
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
@mcp.tool()
|
|
271
|
+
def list_faqs(
|
|
272
|
+
status: Optional[str] = None, category: Optional[str] = None,
|
|
273
|
+
q: Optional[str] = None, page: int = 1, page_size: int = 100,
|
|
274
|
+
) -> Any:
|
|
275
|
+
"""List help-center FAQs. status is draft or published (optional)."""
|
|
276
|
+
params: Dict[str, Any] = {"page": page, "page_size": page_size}
|
|
277
|
+
if status:
|
|
278
|
+
params["status"] = status
|
|
279
|
+
if category:
|
|
280
|
+
params["category"] = category
|
|
281
|
+
if q:
|
|
282
|
+
params["q"] = q
|
|
283
|
+
return _call(lambda: _client().list_faqs(params))
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
@mcp.tool()
|
|
287
|
+
def faq_categories() -> Any:
|
|
288
|
+
"""List the distinct FAQ categories."""
|
|
289
|
+
return _call(_client().faq_categories)
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
@mcp.tool()
|
|
293
|
+
def create_faq(
|
|
294
|
+
question: str, answer: str, category: Optional[str] = None, status: str = "draft",
|
|
295
|
+
) -> Any:
|
|
296
|
+
"""Create a help-center FAQ. status is draft or published. answer may be Markdown."""
|
|
297
|
+
payload: Dict[str, Any] = {"question": question, "answer": answer, "status": status}
|
|
298
|
+
if category:
|
|
299
|
+
payload["category"] = category
|
|
300
|
+
return _call(lambda: _client().create_faq(payload))
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
@mcp.tool()
|
|
304
|
+
def update_faq(
|
|
305
|
+
faq_id: str, question: Optional[str] = None, answer: Optional[str] = None,
|
|
306
|
+
category: Optional[str] = None, status: Optional[str] = None,
|
|
307
|
+
) -> Any:
|
|
308
|
+
"""Update a FAQ (question/answer/category/status). status is draft or published."""
|
|
309
|
+
payload: Dict[str, Any] = {}
|
|
310
|
+
for k, v in {"question": question, "answer": answer, "category": category, "status": status}.items():
|
|
311
|
+
if v is not None:
|
|
312
|
+
payload[k] = v
|
|
313
|
+
if not payload:
|
|
314
|
+
return {"error": "Nothing to update."}
|
|
315
|
+
return _call(lambda: _client().update_faq(faq_id, payload))
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
@mcp.tool()
|
|
319
|
+
def delete_faq(faq_id: str) -> Any:
|
|
320
|
+
"""Delete a single FAQ."""
|
|
321
|
+
result = _call(lambda: _client().delete_faq(faq_id))
|
|
322
|
+
return result if result is not None else {"ok": True}
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
@mcp.tool()
|
|
326
|
+
def set_faq_status(faq_ids: List[str], status: str) -> Any:
|
|
327
|
+
"""Publish or unpublish many FAQs at once. status is published or draft."""
|
|
328
|
+
return _call(lambda: _client().bulk_faq_status(faq_ids, status))
|
|
329
|
+
|
|
330
|
+
|
|
331
|
+
@mcp.tool()
|
|
332
|
+
def delete_faqs(faq_ids: List[str]) -> Any:
|
|
333
|
+
"""Delete multiple FAQs at once."""
|
|
334
|
+
return _call(lambda: _client().bulk_delete_faqs(faq_ids))
|
|
335
|
+
|
|
336
|
+
|
|
337
|
+
@mcp.tool()
|
|
338
|
+
def configure_help_center(settings: Dict[str, Any]) -> Any:
|
|
339
|
+
"""Update help-center settings with a JSON object of the fields to change
|
|
340
|
+
(title, description, brand_color, header_links, cta_text, cta_url, agent_id,
|
|
341
|
+
enabled, ai_search_enabled, chat_widget_enabled, auto_generate)."""
|
|
342
|
+
if not settings:
|
|
343
|
+
return {"error": "Provide at least one setting to update."}
|
|
344
|
+
return _call(lambda: _client().update_help_center_settings(settings))
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
@mcp.tool()
|
|
348
|
+
def import_faqs_from_url(url: str, mode: str = "qa") -> Any:
|
|
349
|
+
"""Import FAQs from a URL. mode=qa uses AI extraction (credits); mode=articles
|
|
350
|
+
crawls linked articles as-is (no AI). Returns a job; poll with help_center_job."""
|
|
351
|
+
return _call(lambda: _client().import_help_center_url(url, mode))
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
@mcp.tool()
|
|
355
|
+
def import_faqs_from_pdf(path: str) -> Any:
|
|
356
|
+
"""Import FAQs from a local PDF file path. Returns a job; poll with help_center_job."""
|
|
357
|
+
content = _read_path(path)
|
|
358
|
+
if isinstance(content, dict):
|
|
359
|
+
return content
|
|
360
|
+
import os
|
|
361
|
+
return _call(lambda: _client().import_help_center_pdf(os.path.basename(path), content))
|
|
362
|
+
|
|
363
|
+
|
|
364
|
+
@mcp.tool()
|
|
365
|
+
def upload_faq_image(path: str) -> Any:
|
|
366
|
+
"""Upload a local image (PNG/JPG/WebP/GIF) for embedding in an article; returns its URL."""
|
|
367
|
+
import os
|
|
368
|
+
ctype = _HC_IMAGE_TYPES.get(os.path.splitext(path)[1].lower())
|
|
369
|
+
if not ctype:
|
|
370
|
+
return {"error": "Image must be PNG, JPG, WebP or GIF."}
|
|
371
|
+
content = _read_path(path)
|
|
372
|
+
if isinstance(content, dict):
|
|
373
|
+
return content
|
|
374
|
+
return _call(lambda: _client().upload_faq_image(os.path.basename(path), content, ctype))
|
|
375
|
+
|
|
376
|
+
|
|
377
|
+
@mcp.tool()
|
|
378
|
+
def set_help_center_logo(path: str) -> Any:
|
|
379
|
+
"""Upload/replace the help-center logo from a local image path (PNG/JPG/WebP)."""
|
|
380
|
+
import os
|
|
381
|
+
ctype = _HC_IMAGE_TYPES.get(os.path.splitext(path)[1].lower())
|
|
382
|
+
if not ctype:
|
|
383
|
+
return {"error": "Logo must be PNG, JPG or WebP."}
|
|
384
|
+
content = _read_path(path)
|
|
385
|
+
if isinstance(content, dict):
|
|
386
|
+
return content
|
|
387
|
+
return _call(lambda: _client().upload_help_center_logo(os.path.basename(path), content, ctype))
|
|
388
|
+
|
|
389
|
+
|
|
390
|
+
@mcp.tool()
|
|
391
|
+
def help_center_domain_status() -> Any:
|
|
392
|
+
"""Get the custom domain's DNS/SSL status and the DNS records to add."""
|
|
393
|
+
return _call(_client().help_center_domain_status)
|
|
394
|
+
|
|
395
|
+
|
|
396
|
+
@mcp.tool()
|
|
397
|
+
def set_help_center_domain(domain: str) -> Any:
|
|
398
|
+
"""Claim a custom domain for the help center; returns the DNS records to add."""
|
|
399
|
+
return _call(lambda: _client().set_help_center_domain(domain))
|
|
400
|
+
|
|
401
|
+
|
|
402
|
+
@mcp.tool()
|
|
403
|
+
def verify_help_center_domain() -> Any:
|
|
404
|
+
"""Run live DNS + SSL verification for the custom domain."""
|
|
405
|
+
return _call(_client().verify_help_center_domain)
|
|
406
|
+
|
|
407
|
+
|
|
408
|
+
@mcp.tool()
|
|
409
|
+
def help_center_job(latest: bool = False) -> Any:
|
|
410
|
+
"""Get the active help-center import/generation job (or the most recent with latest=true)."""
|
|
411
|
+
return _call(lambda: _client().help_center_job(active=not latest))
|
|
412
|
+
|
|
413
|
+
|
|
248
414
|
def main():
|
|
249
415
|
mcp.run(transport="stdio")
|
|
250
416
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: chattermate-cli
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.6.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,6 +18,7 @@ chattermate_cli/commands/agent.py
|
|
|
18
18
|
chattermate_cli/commands/ai.py
|
|
19
19
|
chattermate_cli/commands/auth.py
|
|
20
20
|
chattermate_cli/commands/customization.py
|
|
21
|
+
chattermate_cli/commands/help_center.py
|
|
21
22
|
chattermate_cli/commands/knowledge.py
|
|
22
23
|
chattermate_cli/commands/lead_capture.py
|
|
23
24
|
chattermate_cli/commands/widget.py
|
|
@@ -25,6 +26,7 @@ chattermate_cli/commands/workflow.py
|
|
|
25
26
|
tests/test_ai.py
|
|
26
27
|
tests/test_client.py
|
|
27
28
|
tests/test_customization.py
|
|
29
|
+
tests/test_help_center.py
|
|
28
30
|
tests/test_knowledge.py
|
|
29
31
|
tests/test_lead_capture.py
|
|
30
32
|
tests/test_mcp.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.6.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,163 @@
|
|
|
1
|
+
"""
|
|
2
|
+
ChatterMate - CLI Help-Center 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 httpx
|
|
12
|
+
from typer.testing import CliRunner
|
|
13
|
+
|
|
14
|
+
from chattermate_cli.client import Client
|
|
15
|
+
from chattermate_cli.commands import help_center as hc
|
|
16
|
+
from chattermate_cli.commands.help_center import faq_app, import_app, logo_app, help_center_app
|
|
17
|
+
|
|
18
|
+
runner = CliRunner()
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def make_client(handler, token="cmat_x"):
|
|
22
|
+
client = Client(api_url="http://test", token=token)
|
|
23
|
+
client._http = httpx.Client(transport=httpx.MockTransport(handler))
|
|
24
|
+
return client
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
# ---------- client methods (path / body) ----------
|
|
28
|
+
|
|
29
|
+
def test_list_faqs_sends_params():
|
|
30
|
+
seen = {}
|
|
31
|
+
|
|
32
|
+
def handler(request):
|
|
33
|
+
seen["path"] = request.url.path
|
|
34
|
+
seen["query"] = dict(request.url.params)
|
|
35
|
+
return httpx.Response(200, json={"faqs": [], "pagination": {"page": 1, "total_pages": 1, "total": 0}})
|
|
36
|
+
|
|
37
|
+
client = make_client(handler)
|
|
38
|
+
client.list_faqs({"page": 1, "page_size": 50, "status": "published", "q": "billing"})
|
|
39
|
+
assert seen["path"] == "/api/v1/help-center/faqs"
|
|
40
|
+
assert seen["query"]["status"] == "published"
|
|
41
|
+
assert seen["query"]["q"] == "billing"
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def test_create_faq_body():
|
|
45
|
+
seen = {}
|
|
46
|
+
|
|
47
|
+
def handler(request):
|
|
48
|
+
seen["path"] = request.url.path
|
|
49
|
+
seen["body"] = request.content
|
|
50
|
+
return httpx.Response(201, json={"id": "f1", "question": "Q", "answer": "A"})
|
|
51
|
+
|
|
52
|
+
client = make_client(handler)
|
|
53
|
+
data = client.create_faq({"question": "Q", "answer": "A", "status": "draft"})
|
|
54
|
+
assert seen["path"] == "/api/v1/help-center/faqs"
|
|
55
|
+
assert b'"question"' in seen["body"] and b"Q" in seen["body"]
|
|
56
|
+
assert data["id"] == "f1"
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def test_bulk_status_body():
|
|
60
|
+
seen = {}
|
|
61
|
+
|
|
62
|
+
def handler(request):
|
|
63
|
+
seen["path"] = request.url.path
|
|
64
|
+
seen["body"] = request.content
|
|
65
|
+
return httpx.Response(200, json={"updated": 2})
|
|
66
|
+
|
|
67
|
+
client = make_client(handler)
|
|
68
|
+
data = client.bulk_faq_status(["a", "b"], "published")
|
|
69
|
+
assert seen["path"] == "/api/v1/help-center/faqs/bulk-status"
|
|
70
|
+
assert b'"faq_ids"' in seen["body"] and b"published" in seen["body"]
|
|
71
|
+
assert data["updated"] == 2
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def test_import_url_mode_passthrough():
|
|
75
|
+
seen = {}
|
|
76
|
+
|
|
77
|
+
def handler(request):
|
|
78
|
+
seen["path"] = request.url.path
|
|
79
|
+
seen["body"] = request.content
|
|
80
|
+
return httpx.Response(202, json={"id": 9, "status": "pending"})
|
|
81
|
+
|
|
82
|
+
client = make_client(handler)
|
|
83
|
+
client.import_help_center_url("https://x.com/help", "articles")
|
|
84
|
+
assert seen["path"] == "/api/v1/help-center/import"
|
|
85
|
+
assert b"articles" in seen["body"] and b"https://x.com/help" in seen["body"]
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def test_upload_logo_multipart():
|
|
89
|
+
seen = {}
|
|
90
|
+
|
|
91
|
+
def handler(request):
|
|
92
|
+
seen["path"] = request.url.path
|
|
93
|
+
seen["ctype"] = request.headers.get("content-type", "")
|
|
94
|
+
seen["body"] = request.content
|
|
95
|
+
return httpx.Response(200, json={"logo_url": "http://x/l.png"})
|
|
96
|
+
|
|
97
|
+
client = make_client(handler)
|
|
98
|
+
client.upload_help_center_logo("l.png", b"\x89PNG\r\n", "image/png")
|
|
99
|
+
assert seen["path"] == "/api/v1/help-center/logo"
|
|
100
|
+
assert "multipart/form-data" in seen["ctype"]
|
|
101
|
+
assert b'name="file"' in seen["body"] and b"l.png" in seen["body"]
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
# ---------- command validation (no API call) ----------
|
|
105
|
+
|
|
106
|
+
def test_configure_requires_an_option():
|
|
107
|
+
result = runner.invoke(help_center_app, ["configure"])
|
|
108
|
+
assert result.exit_code == 1
|
|
109
|
+
assert "Nothing to update" in result.output
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
def test_faq_create_rejects_bad_status():
|
|
113
|
+
result = runner.invoke(faq_app, ["create", "--question", "Q", "--answer", "A", "--status", "weird"])
|
|
114
|
+
assert result.exit_code == 1
|
|
115
|
+
assert "status" in result.output
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
def test_import_url_rejects_bad_mode():
|
|
119
|
+
result = runner.invoke(import_app, ["url", "https://x.com", "--mode", "nope"])
|
|
120
|
+
assert result.exit_code == 1
|
|
121
|
+
assert "mode" in result.output
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
def test_import_pdf_rejects_non_pdf(tmp_path):
|
|
125
|
+
p = tmp_path / "a.txt"
|
|
126
|
+
p.write_text("hi")
|
|
127
|
+
result = runner.invoke(import_app, ["pdf", str(p)])
|
|
128
|
+
assert result.exit_code == 1
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
def test_logo_set_rejects_unsupported_extension(tmp_path):
|
|
132
|
+
p = tmp_path / "a.txt"
|
|
133
|
+
p.write_text("hi")
|
|
134
|
+
result = runner.invoke(logo_app, ["set", str(p)])
|
|
135
|
+
assert result.exit_code == 1
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
# ---------- command wiring (patched client) ----------
|
|
139
|
+
|
|
140
|
+
def test_faq_list_command_renders(monkeypatch):
|
|
141
|
+
def handler(request):
|
|
142
|
+
return httpx.Response(200, json={
|
|
143
|
+
"faqs": [{"id": "f1", "status": "published", "category": "Billing", "question": "How much?"}],
|
|
144
|
+
"pagination": {"page": 1, "total_pages": 1, "total": 1},
|
|
145
|
+
})
|
|
146
|
+
|
|
147
|
+
client = make_client(handler)
|
|
148
|
+
monkeypatch.setattr(hc, "get_client", lambda *a, **k: client)
|
|
149
|
+
result = runner.invoke(faq_app, ["list", "--json"])
|
|
150
|
+
assert result.exit_code == 0
|
|
151
|
+
assert "f1" in result.output
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
def test_faq_publish_command(monkeypatch):
|
|
155
|
+
def handler(request):
|
|
156
|
+
assert request.url.path == "/api/v1/help-center/faqs/bulk-status"
|
|
157
|
+
return httpx.Response(200, json={"updated": 2})
|
|
158
|
+
|
|
159
|
+
client = make_client(handler)
|
|
160
|
+
monkeypatch.setattr(hc, "get_client", lambda *a, **k: client)
|
|
161
|
+
result = runner.invoke(faq_app, ["publish", "a", "b"])
|
|
162
|
+
assert result.exit_code == 0
|
|
163
|
+
assert "Published" in result.output
|
|
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
|
|
File without changes
|
{chattermate_cli-0.5.0 → chattermate_cli-0.6.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
|
|
File without changes
|
|
File without changes
|