pineai-cli 0.1.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.
@@ -0,0 +1,42 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+ workflow_call:
9
+
10
+ jobs:
11
+ build:
12
+ runs-on: ubuntu-latest
13
+
14
+ strategy:
15
+ matrix:
16
+ python-version: ["3.10", "3.11", "3.12", "3.13"]
17
+
18
+ steps:
19
+ - uses: actions/checkout@v4
20
+
21
+ - name: Set up Python ${{ matrix.python-version }}
22
+ uses: actions/setup-python@v5
23
+ with:
24
+ python-version: ${{ matrix.python-version }}
25
+
26
+ - name: Install build tools
27
+ run: pip install build twine
28
+
29
+ - name: Install package
30
+ run: pip install .
31
+
32
+ - name: Verify import
33
+ run: python -c "from pine_cli import __version__; print(f'pineai-cli {__version__} OK')"
34
+
35
+ - name: Verify CLI entry point
36
+ run: pine --version
37
+
38
+ - name: Build distribution
39
+ run: python -m build
40
+
41
+ - name: Check distribution
42
+ run: twine check dist/*
@@ -0,0 +1,33 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ push:
5
+ tags: ["v*"]
6
+
7
+ jobs:
8
+ ci:
9
+ uses: ./.github/workflows/ci.yml
10
+
11
+ publish:
12
+ needs: ci
13
+ runs-on: ubuntu-latest
14
+ permissions:
15
+ contents: read
16
+ id-token: write
17
+ steps:
18
+ - uses: actions/checkout@v4
19
+
20
+ - uses: actions/setup-python@v5
21
+ with:
22
+ python-version: "3.12"
23
+
24
+ - name: Install build tools
25
+ run: pip install build
26
+
27
+ - name: Build distribution
28
+ run: python -m build
29
+
30
+ - name: Publish to PyPI
31
+ uses: pypa/gh-action-pypi-publish@release/v1
32
+ with:
33
+ attestations: true
@@ -0,0 +1,15 @@
1
+ __pycache__/
2
+ *.pyc
3
+ *.pyo
4
+ dist/
5
+ build/
6
+ *.egg-info/
7
+ *.egg
8
+ .eggs/
9
+ *.whl
10
+ .venv/
11
+ venv/
12
+ .env
13
+ .pytest_cache/
14
+ .ruff_cache/
15
+ .mypy_cache/
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Pine AI
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,138 @@
1
+ Metadata-Version: 2.4
2
+ Name: pineai-cli
3
+ Version: 0.1.0
4
+ Summary: Unified CLI for Pine AI — voice calls & assistant tasks from your terminal
5
+ Project-URL: Homepage, https://github.com/19PINE-AI/pineai-cli
6
+ Project-URL: Repository, https://github.com/19PINE-AI/pineai-cli
7
+ Project-URL: Issues, https://github.com/19PINE-AI/pineai-cli/issues
8
+ Project-URL: Documentation, https://pineclaw.com
9
+ Author: Pine AI
10
+ License-Expression: MIT
11
+ License-File: LICENSE
12
+ Keywords: assistant,cli,customer-service,phone,pine,pine-ai,voice
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Environment :: Console
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Intended Audience :: End Users/Desktop
17
+ Classifier: License :: OSI Approved :: MIT License
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Programming Language :: Python :: 3.13
23
+ Classifier: Topic :: Communications :: Telephony
24
+ Classifier: Topic :: Office/Business
25
+ Requires-Python: >=3.10
26
+ Requires-Dist: click>=8.1.0
27
+ Requires-Dist: pine-assistant>=0.2.0
28
+ Requires-Dist: pine-voice>=0.1.5
29
+ Requires-Dist: rich>=13.0.0
30
+ Description-Content-Type: text/markdown
31
+
32
+ # Pine CLI
33
+
34
+ Unified command-line interface for [Pine AI](https://www.19pine.ai) — voice calls and assistant tasks from your terminal.
35
+
36
+ ## Install
37
+
38
+ ```bash
39
+ pip install pineai-cli
40
+ ```
41
+
42
+ Or install from source:
43
+
44
+ ```bash
45
+ cd pine-cli
46
+ pip install -e .
47
+ ```
48
+
49
+ ## Quick Start
50
+
51
+ ```bash
52
+ # Authenticate (shared credentials for voice & assistant)
53
+ pine auth login
54
+
55
+ # Make a voice call
56
+ pine voice call \
57
+ --to "+14155551234" \
58
+ --name "Dr. Smith Office" \
59
+ --context "I'm a patient needing a follow-up" \
60
+ --objective "Schedule an appointment for next week"
61
+
62
+ # Check call status
63
+ pine voice status <call-id>
64
+
65
+ # Start an assistant chat
66
+ pine chat
67
+
68
+ # Send a one-shot message
69
+ pine send "Negotiate my Comcast bill down"
70
+
71
+ # List sessions
72
+ pine sessions list
73
+
74
+ # Start a task
75
+ pine task start <session-id>
76
+ ```
77
+
78
+ ## Commands
79
+
80
+ ### Authentication
81
+
82
+ | Command | Description |
83
+ |---------|-------------|
84
+ | `pine auth login` | Log in with email verification |
85
+ | `pine auth status` | Show current auth status |
86
+ | `pine auth logout` | Clear saved credentials |
87
+
88
+ ### Voice Calls
89
+
90
+ | Command | Description |
91
+ |---------|-------------|
92
+ | `pine voice call` | Make a phone call via Pine AI voice agent |
93
+ | `pine voice status <id>` | Check call status / get result |
94
+
95
+ **Voice call options:**
96
+
97
+ ```
98
+ --to Phone number (E.164 format, required)
99
+ --name Callee name (required)
100
+ --context Background context (required)
101
+ --objective Call goal (required)
102
+ --instructions Detailed strategy
103
+ --caller negotiator | communicator
104
+ --voice male | female
105
+ --max-duration 1-120 minutes
106
+ --summary Enable LLM summary
107
+ --wait Wait for completion (default: yes)
108
+ --no-wait Fire and forget
109
+ --json JSON output
110
+ ```
111
+
112
+ ### Assistant
113
+
114
+ | Command | Description |
115
+ |---------|-------------|
116
+ | `pine chat [session-id]` | Interactive REPL chat |
117
+ | `pine send <message>` | One-shot message |
118
+ | `pine sessions list` | List sessions |
119
+ | `pine sessions get <id>` | Get session details |
120
+ | `pine sessions create` | Create new session |
121
+ | `pine sessions delete <id>` | Delete session |
122
+ | `pine task start <id>` | Start task execution |
123
+ | `pine task stop <id>` | Stop a running task |
124
+
125
+ ## Configuration
126
+
127
+ Credentials are stored at `~/.pine/config.json` after `pine auth login`. Both voice and assistant commands share the same authentication.
128
+
129
+ ## Dependencies
130
+
131
+ - [pine-voice](https://pypi.org/project/pine-voice/) — Pine AI Voice SDK
132
+ - [pine-assistant](https://pypi.org/project/pine-assistant/) — Pine AI Assistant SDK
133
+ - [click](https://click.palletsprojects.com/) — CLI framework
134
+ - [rich](https://rich.readthedocs.io/) — Terminal formatting
135
+
136
+ ## License
137
+
138
+ MIT — see [LICENSE](LICENSE).
@@ -0,0 +1,107 @@
1
+ # Pine CLI
2
+
3
+ Unified command-line interface for [Pine AI](https://www.19pine.ai) — voice calls and assistant tasks from your terminal.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ pip install pineai-cli
9
+ ```
10
+
11
+ Or install from source:
12
+
13
+ ```bash
14
+ cd pine-cli
15
+ pip install -e .
16
+ ```
17
+
18
+ ## Quick Start
19
+
20
+ ```bash
21
+ # Authenticate (shared credentials for voice & assistant)
22
+ pine auth login
23
+
24
+ # Make a voice call
25
+ pine voice call \
26
+ --to "+14155551234" \
27
+ --name "Dr. Smith Office" \
28
+ --context "I'm a patient needing a follow-up" \
29
+ --objective "Schedule an appointment for next week"
30
+
31
+ # Check call status
32
+ pine voice status <call-id>
33
+
34
+ # Start an assistant chat
35
+ pine chat
36
+
37
+ # Send a one-shot message
38
+ pine send "Negotiate my Comcast bill down"
39
+
40
+ # List sessions
41
+ pine sessions list
42
+
43
+ # Start a task
44
+ pine task start <session-id>
45
+ ```
46
+
47
+ ## Commands
48
+
49
+ ### Authentication
50
+
51
+ | Command | Description |
52
+ |---------|-------------|
53
+ | `pine auth login` | Log in with email verification |
54
+ | `pine auth status` | Show current auth status |
55
+ | `pine auth logout` | Clear saved credentials |
56
+
57
+ ### Voice Calls
58
+
59
+ | Command | Description |
60
+ |---------|-------------|
61
+ | `pine voice call` | Make a phone call via Pine AI voice agent |
62
+ | `pine voice status <id>` | Check call status / get result |
63
+
64
+ **Voice call options:**
65
+
66
+ ```
67
+ --to Phone number (E.164 format, required)
68
+ --name Callee name (required)
69
+ --context Background context (required)
70
+ --objective Call goal (required)
71
+ --instructions Detailed strategy
72
+ --caller negotiator | communicator
73
+ --voice male | female
74
+ --max-duration 1-120 minutes
75
+ --summary Enable LLM summary
76
+ --wait Wait for completion (default: yes)
77
+ --no-wait Fire and forget
78
+ --json JSON output
79
+ ```
80
+
81
+ ### Assistant
82
+
83
+ | Command | Description |
84
+ |---------|-------------|
85
+ | `pine chat [session-id]` | Interactive REPL chat |
86
+ | `pine send <message>` | One-shot message |
87
+ | `pine sessions list` | List sessions |
88
+ | `pine sessions get <id>` | Get session details |
89
+ | `pine sessions create` | Create new session |
90
+ | `pine sessions delete <id>` | Delete session |
91
+ | `pine task start <id>` | Start task execution |
92
+ | `pine task stop <id>` | Stop a running task |
93
+
94
+ ## Configuration
95
+
96
+ Credentials are stored at `~/.pine/config.json` after `pine auth login`. Both voice and assistant commands share the same authentication.
97
+
98
+ ## Dependencies
99
+
100
+ - [pine-voice](https://pypi.org/project/pine-voice/) — Pine AI Voice SDK
101
+ - [pine-assistant](https://pypi.org/project/pine-assistant/) — Pine AI Assistant SDK
102
+ - [click](https://click.palletsprojects.com/) — CLI framework
103
+ - [rich](https://rich.readthedocs.io/) — Terminal formatting
104
+
105
+ ## License
106
+
107
+ MIT — see [LICENSE](LICENSE).
@@ -0,0 +1,56 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "pineai-cli"
7
+ version = "0.1.0"
8
+ description = "Unified CLI for Pine AI — voice calls & assistant tasks from your terminal"
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ requires-python = ">=3.10"
12
+ authors = [{ name = "Pine AI" }]
13
+ keywords = ["pine", "pine-ai", "cli", "voice", "assistant", "customer-service", "phone"]
14
+ classifiers = [
15
+ "Development Status :: 3 - Alpha",
16
+ "Intended Audience :: Developers",
17
+ "Intended Audience :: End Users/Desktop",
18
+ "License :: OSI Approved :: MIT License",
19
+ "Programming Language :: Python :: 3",
20
+ "Programming Language :: Python :: 3.10",
21
+ "Programming Language :: Python :: 3.11",
22
+ "Programming Language :: Python :: 3.12",
23
+ "Programming Language :: Python :: 3.13",
24
+ "Environment :: Console",
25
+ "Topic :: Communications :: Telephony",
26
+ "Topic :: Office/Business",
27
+ ]
28
+ dependencies = [
29
+ "pine-voice>=0.1.5",
30
+ "pine-assistant>=0.2.0",
31
+ "click>=8.1.0",
32
+ "rich>=13.0.0",
33
+ ]
34
+
35
+ [project.urls]
36
+ Homepage = "https://github.com/19PINE-AI/pineai-cli"
37
+ Repository = "https://github.com/19PINE-AI/pineai-cli"
38
+ Issues = "https://github.com/19PINE-AI/pineai-cli/issues"
39
+ Documentation = "https://pineclaw.com"
40
+
41
+ [project.scripts]
42
+ pine = "pine_cli.main:main"
43
+
44
+ [tool.hatch.build.targets.wheel]
45
+ packages = ["src/pine_cli"]
46
+
47
+ [tool.ruff]
48
+ target-version = "py310"
49
+ line-length = 120
50
+
51
+ [tool.ruff.lint]
52
+ select = ["E", "F", "I", "W", "UP", "B", "SIM"]
53
+ ignore = ["E501"]
54
+
55
+ [tool.ruff.lint.isort]
56
+ known-first-party = ["pine_cli"]
@@ -0,0 +1,3 @@
1
+ """Pine CLI — unified command-line interface for Pine AI."""
2
+
3
+ __version__ = "0.1.0"
@@ -0,0 +1,67 @@
1
+ """pine auth login|status|logout — shared authentication for Voice & Assistant."""
2
+
3
+ from typing import Optional
4
+
5
+ import click
6
+ from rich.console import Console
7
+
8
+ from pine_cli.config import load_config, save_config, run_async, handle_api_errors
9
+
10
+ console = Console()
11
+
12
+
13
+ @click.group()
14
+ def auth():
15
+ """Authentication commands."""
16
+
17
+
18
+ @auth.command("login")
19
+ @click.option("--base-url", default=None, help="Pine AI base URL override")
20
+ @handle_api_errors
21
+ def login(base_url: Optional[str]):
22
+ """Log in with email verification."""
23
+ from pine_assistant.client import AsyncPineAI
24
+
25
+ async def _login():
26
+ cfg = load_config()
27
+ url = base_url or cfg.get("base_url", "https://www.19pine.ai")
28
+ client = AsyncPineAI(base_url=url)
29
+
30
+ email = click.prompt("Email")
31
+ with console.status("Sending verification code…"):
32
+ result = await client.auth.request_code(email)
33
+ console.print("[green]✓ Code sent — check your email.[/green]")
34
+
35
+ code = click.prompt("Verification code")
36
+ with console.status("Verifying…"):
37
+ verify = await client.auth.verify_code(email, code, result["request_token"])
38
+
39
+ save_config({
40
+ **cfg,
41
+ "access_token": verify["access_token"],
42
+ "user_id": verify["id"],
43
+ "email": verify["email"],
44
+ "base_url": url,
45
+ })
46
+ console.print(f"[green]✓ Logged in as {verify['email']}[/green] (user {verify['id']})")
47
+ console.print("[dim]Credentials saved to ~/.pine/config.json[/dim]")
48
+
49
+ run_async(_login())
50
+
51
+
52
+ @auth.command("status")
53
+ def status():
54
+ """Show current authentication status."""
55
+ cfg = load_config()
56
+ if cfg.get("access_token"):
57
+ console.print(f"[green]● Logged in[/green] {cfg.get('email', '?')} (user {cfg.get('user_id', '?')})")
58
+ console.print(f"[dim]Base URL: {cfg.get('base_url', 'https://www.19pine.ai')}[/dim]")
59
+ else:
60
+ console.print("[yellow]○ Not logged in.[/yellow] Run [bold]pine auth login[/bold].")
61
+
62
+
63
+ @auth.command("logout")
64
+ def logout():
65
+ """Clear saved credentials."""
66
+ save_config({})
67
+ console.print("[green]✓ Logged out. Credentials removed.[/green]")
@@ -0,0 +1,107 @@
1
+ """pine chat / pine send — interactive and one-shot messaging."""
2
+
3
+ import json
4
+ from typing import Optional
5
+
6
+ import click
7
+ from rich.console import Console
8
+ from rich.panel import Panel
9
+
10
+ from pine_assistant.models.events import S2CEvent
11
+ from pine_cli.config import get_assistant_client, run_async, handle_api_errors
12
+
13
+ console = Console()
14
+
15
+
16
+ @click.command("chat")
17
+ @click.argument("session_id", required=False)
18
+ @handle_api_errors
19
+ def chat_cmd(session_id: Optional[str]):
20
+ """Interactive chat with Pine AI (REPL)."""
21
+ async def _chat():
22
+ client = get_assistant_client()
23
+ await client.connect()
24
+
25
+ sid = session_id
26
+ if not sid:
27
+ with console.status("Creating session…"):
28
+ s = await client.sessions.create()
29
+ sid = s["id"]
30
+ console.print(f"[dim]Session: {sid}[/dim]")
31
+
32
+ await client.join_session(sid)
33
+ console.print("[cyan]Type your message (Ctrl+C or /quit to exit)[/cyan]\n")
34
+
35
+ try:
36
+ while True:
37
+ msg = click.prompt("You", prompt_suffix=": ")
38
+ if msg.strip().lower() in ("/quit", "/exit"):
39
+ break
40
+ async for event in client.chat(sid, msg):
41
+ _print_event(event)
42
+ except (KeyboardInterrupt, EOFError):
43
+ console.print()
44
+ finally:
45
+ client.leave_session(sid)
46
+ await client.disconnect()
47
+
48
+ run_async(_chat())
49
+
50
+
51
+ @click.command("send")
52
+ @click.argument("message")
53
+ @click.option("-s", "--session", "session_id", default=None, help="Existing session ID")
54
+ @click.option("--json-output", "--json", is_flag=True, help="Output as JSON")
55
+ @handle_api_errors
56
+ def send_cmd(message: str, session_id: Optional[str], json_output: bool):
57
+ """Send a one-shot message to Pine AI."""
58
+ async def _send():
59
+ client = get_assistant_client()
60
+ await client.connect()
61
+
62
+ sid = session_id
63
+ try:
64
+ if not sid:
65
+ s = await client.sessions.create()
66
+ sid = s["id"]
67
+ if not json_output:
68
+ console.print(f"[dim]Session: {sid}[/dim]")
69
+
70
+ await client.join_session(sid)
71
+ async for event in client.chat(sid, message):
72
+ if json_output:
73
+ click.echo(json.dumps({"type": event.type, "data": event.data}))
74
+ else:
75
+ _print_event(event)
76
+
77
+ client.leave_session(sid)
78
+ finally:
79
+ await client.disconnect()
80
+
81
+ run_async(_send())
82
+
83
+
84
+ def _print_event(event):
85
+ """Render a chat event to the console."""
86
+ if event.type == S2CEvent.SESSION_TEXT:
87
+ data = event.data if isinstance(event.data, dict) else {}
88
+ content = data.get("content", "")
89
+ if content:
90
+ console.print(f"[green]Pine AI:[/green] {content}")
91
+ elif event.type == S2CEvent.SESSION_FORM_TO_USER:
92
+ data = event.data if isinstance(event.data, dict) else {}
93
+ msg = data.get("message_to_user", "")
94
+ console.print(Panel(f"[yellow]{msg}[/yellow]\n{json.dumps(data, indent=2)}",
95
+ title="Form Required", border_style="yellow"))
96
+ elif event.type == S2CEvent.SESSION_STATE:
97
+ data = event.data if isinstance(event.data, dict) else {}
98
+ state = data.get("content", "")
99
+ if state:
100
+ console.print(f"[dim] ● state → {state}[/dim]")
101
+ elif event.type == S2CEvent.SESSION_THINKING:
102
+ console.print("[dim] ● thinking…[/dim]")
103
+ elif event.type == S2CEvent.SESSION_WORK_LOG:
104
+ data = event.data if isinstance(event.data, dict) else {}
105
+ steps = data.get("steps", [])
106
+ for step in steps:
107
+ console.print(f"[dim] ● {step.get('step_title', '')} [{step.get('status', '')}][/dim]")
@@ -0,0 +1,92 @@
1
+ """Shared configuration and client helpers."""
2
+
3
+ import asyncio
4
+ import json
5
+ from pathlib import Path
6
+ from typing import Any
7
+
8
+ from rich.console import Console
9
+
10
+ CONFIG_DIR = Path.home() / ".pine"
11
+ CONFIG_FILE = CONFIG_DIR / "config.json"
12
+
13
+ console = Console()
14
+
15
+
16
+ def load_config() -> dict[str, Any]:
17
+ try:
18
+ return json.loads(CONFIG_FILE.read_text())
19
+ except (FileNotFoundError, json.JSONDecodeError):
20
+ return {}
21
+
22
+
23
+ def save_config(cfg: dict[str, Any]) -> None:
24
+ CONFIG_DIR.mkdir(parents=True, exist_ok=True)
25
+ CONFIG_FILE.write_text(json.dumps(cfg, indent=2) + "\n")
26
+
27
+
28
+ def require_auth() -> dict[str, Any]:
29
+ """Return config or exit if not logged in."""
30
+ cfg = load_config()
31
+ if not cfg.get("access_token") or not cfg.get("user_id"):
32
+ console.print("[red]Not logged in. Run [bold]pine auth login[/bold] first.[/red]")
33
+ raise SystemExit(1)
34
+ return cfg
35
+
36
+
37
+ def get_voice_client():
38
+ """Build an authenticated PineVoice (sync) client."""
39
+ from pine_voice import PineVoice
40
+
41
+ cfg = require_auth()
42
+ return PineVoice(access_token=cfg["access_token"], user_id=cfg["user_id"])
43
+
44
+
45
+ def get_assistant_client():
46
+ """Build an authenticated AsyncPineAI client."""
47
+ from pine_assistant.client import AsyncPineAI
48
+
49
+ cfg = require_auth()
50
+ return AsyncPineAI(
51
+ access_token=cfg["access_token"],
52
+ user_id=cfg["user_id"],
53
+ base_url=cfg.get("base_url", "https://www.19pine.ai"),
54
+ )
55
+
56
+
57
+ def run_async(coro):
58
+ """Run an async coroutine from sync context."""
59
+ loop = asyncio.new_event_loop()
60
+ try:
61
+ return loop.run_until_complete(coro)
62
+ finally:
63
+ loop.close()
64
+
65
+
66
+ def handle_api_errors(fn):
67
+ """Decorator that catches SDK exceptions and prints user-friendly messages."""
68
+ import functools
69
+
70
+ @functools.wraps(fn)
71
+ def wrapper(*args, **kwargs):
72
+ try:
73
+ return fn(*args, **kwargs)
74
+ except SystemExit:
75
+ raise
76
+ except KeyboardInterrupt:
77
+ console.print("\n[dim]Interrupted.[/dim]")
78
+ raise SystemExit(130)
79
+ except Exception as exc:
80
+ _print_api_error(exc)
81
+ raise SystemExit(1)
82
+
83
+ return wrapper
84
+
85
+
86
+ def _print_api_error(exc: Exception) -> None:
87
+ code = getattr(exc, "code", None)
88
+ message = str(exc)
89
+ if code:
90
+ console.print(f"[red]Error ({code}):[/red] {message}")
91
+ else:
92
+ console.print(f"[red]Error:[/red] {message}")
@@ -0,0 +1,39 @@
1
+ """
2
+ Pine CLI — unified command-line interface for Pine AI.
3
+
4
+ Commands:
5
+ pine auth login|status|logout Authentication
6
+ pine voice call|status Voice calls
7
+ pine chat [session-id] Interactive assistant chat
8
+ pine send <message> One-shot assistant message
9
+ pine sessions list|get|create|delete Session management
10
+ pine task start|stop Task lifecycle
11
+ """
12
+
13
+ import click
14
+
15
+ from pine_cli import __version__
16
+
17
+
18
+ @click.group()
19
+ @click.version_option(__version__, prog_name="pine")
20
+ def main():
21
+ """Pine AI CLI — voice calls & assistant tasks from your terminal."""
22
+
23
+
24
+ from pine_cli.auth import auth
25
+ from pine_cli.voice import voice
26
+ from pine_cli.chat import chat_cmd, send_cmd
27
+ from pine_cli.sessions import sessions
28
+ from pine_cli.tasks import task
29
+
30
+ main.add_command(auth)
31
+ main.add_command(voice)
32
+ main.add_command(chat_cmd)
33
+ main.add_command(send_cmd)
34
+ main.add_command(sessions)
35
+ main.add_command(task)
36
+
37
+
38
+ if __name__ == "__main__":
39
+ main()
@@ -0,0 +1,101 @@
1
+ """pine sessions list|get|create|delete — session management."""
2
+
3
+ import json
4
+
5
+ import click
6
+ from rich.console import Console
7
+ from rich.table import Table
8
+
9
+ from pine_cli.config import get_assistant_client, run_async, handle_api_errors
10
+
11
+ console = Console()
12
+
13
+
14
+ @click.group()
15
+ def sessions():
16
+ """Session management commands."""
17
+
18
+
19
+ @sessions.command("list")
20
+ @click.option("--state", default=None, help="Filter by state (e.g. init, active, task_finished)")
21
+ @click.option("--limit", default=10, type=int, help="Max results (default: 10)")
22
+ @click.option("--json-output", "--json", is_flag=True, help="Output as JSON")
23
+ @handle_api_errors
24
+ def sessions_list(state, limit, json_output):
25
+ """List sessions."""
26
+ async def _list():
27
+ client = get_assistant_client()
28
+ result = await client.sessions.list(state=state, limit=limit)
29
+ if json_output:
30
+ click.echo(json.dumps(result, indent=2))
31
+ return
32
+ table = Table(title=f"Sessions ({result['total']} total)")
33
+ table.add_column("ID", style="bold", no_wrap=True)
34
+ table.add_column("State")
35
+ table.add_column("Title", max_width=50)
36
+ table.add_column("Updated")
37
+ for s in result["sessions"]:
38
+ state_color = {
39
+ "chat": "green", "task_processing": "blue", "task_finished": "cyan",
40
+ "init": "yellow", "active": "green",
41
+ }.get(s.get("state", ""), "white")
42
+ table.add_row(s["id"], f"[{state_color}]{s.get('state', '')}[/{state_color}]",
43
+ s.get("title", ""), s.get("updated_at", ""))
44
+ console.print(table)
45
+
46
+ run_async(_list())
47
+
48
+
49
+ @sessions.command("get")
50
+ @click.argument("session_id")
51
+ @click.option("--json-output", "--json", is_flag=True, help="Output as JSON")
52
+ @handle_api_errors
53
+ def sessions_get(session_id, json_output):
54
+ """Get session details."""
55
+ async def _get():
56
+ client = get_assistant_client()
57
+ result = await client.sessions.get(session_id)
58
+ if json_output:
59
+ click.echo(json.dumps(result, indent=2))
60
+ return
61
+ console.print(f"[bold]Session {result['id']}[/bold]")
62
+ console.print(f" State: {result.get('state', '?')}")
63
+ console.print(f" Title: {result.get('title', '—')}")
64
+ console.print(f" Created: {result.get('created_at', '?')}")
65
+ console.print(f" Updated: {result.get('updated_at', '?')}")
66
+ console.print(f" URL: https://www.19pine.ai/app/chat/{result['id']}")
67
+
68
+ run_async(_get())
69
+
70
+
71
+ @sessions.command("create")
72
+ @click.option("--json-output", "--json", is_flag=True, help="Output as JSON")
73
+ @handle_api_errors
74
+ def sessions_create(json_output):
75
+ """Create a new session."""
76
+ async def _create():
77
+ client = get_assistant_client()
78
+ with console.status("Creating session…"):
79
+ session = await client.sessions.create()
80
+ if json_output:
81
+ click.echo(json.dumps(session, indent=2))
82
+ else:
83
+ console.print(f"[green]✓ Session created:[/green] [bold]{session['id']}[/bold]")
84
+ console.print(f"[dim]URL: https://www.19pine.ai/app/chat/{session['id']}[/dim]")
85
+
86
+ run_async(_create())
87
+
88
+
89
+ @sessions.command("delete")
90
+ @click.argument("session_id")
91
+ @click.option("-f", "--force", is_flag=True, help="Force delete")
92
+ @handle_api_errors
93
+ def sessions_delete(session_id, force):
94
+ """Delete a session."""
95
+ async def _delete():
96
+ client = get_assistant_client()
97
+ with console.status("Deleting session…"):
98
+ await client.sessions.delete(session_id, force_delete=force)
99
+ console.print(f"[green]✓ Session {session_id} deleted.[/green]")
100
+
101
+ run_async(_delete())
@@ -0,0 +1,41 @@
1
+ """pine task start|stop — task lifecycle commands."""
2
+
3
+ import click
4
+ from rich.console import Console
5
+
6
+ from pine_cli.config import get_assistant_client, run_async, handle_api_errors
7
+
8
+ console = Console()
9
+
10
+
11
+ @click.group()
12
+ def task():
13
+ """Task lifecycle commands."""
14
+
15
+
16
+ @task.command("start")
17
+ @click.argument("session_id")
18
+ @handle_api_errors
19
+ def task_start(session_id):
20
+ """Start task execution for a session."""
21
+ async def _start():
22
+ client = get_assistant_client()
23
+ with console.status("Starting task…"):
24
+ result = await client.sessions.start_task(session_id)
25
+ console.print(f"[green]✓ Task started[/green] {result.get('message', 'OK')}")
26
+
27
+ run_async(_start())
28
+
29
+
30
+ @task.command("stop")
31
+ @click.argument("session_id")
32
+ @handle_api_errors
33
+ def task_stop(session_id):
34
+ """Stop a running task."""
35
+ async def _stop():
36
+ client = get_assistant_client()
37
+ with console.status("Stopping task…"):
38
+ result = await client.sessions.stop_task(session_id)
39
+ console.print(f"[green]✓ Task stopped[/green] {result.get('message', 'OK')}")
40
+
41
+ run_async(_stop())
@@ -0,0 +1,130 @@
1
+ """pine voice call|status — Pine AI voice calls."""
2
+
3
+ import json
4
+ from contextlib import nullcontext
5
+ from typing import Optional
6
+
7
+ import click
8
+ from rich.console import Console
9
+ from rich.panel import Panel
10
+ from rich.table import Table
11
+
12
+ from pine_cli.config import get_voice_client, handle_api_errors
13
+
14
+ console = Console()
15
+
16
+
17
+ @click.group()
18
+ def voice():
19
+ """Voice call commands."""
20
+
21
+
22
+ @voice.command("call")
23
+ @click.option("--to", "phone", required=True, help="Phone number in E.164 format (e.g. +14155551234)")
24
+ @click.option("--name", required=True, help="Name of the person/business being called")
25
+ @click.option("--context", required=True, help="Background context for the call")
26
+ @click.option("--objective", required=True, help="What the call should achieve")
27
+ @click.option("--instructions", default=None, help="Detailed strategy or instructions")
28
+ @click.option("--caller", type=click.Choice(["negotiator", "communicator"]), default=None,
29
+ help="Caller persona (default: negotiator)")
30
+ @click.option("--voice", "voice_gender", type=click.Choice(["male", "female"]), default=None,
31
+ help="Voice gender (default: female)")
32
+ @click.option("--max-duration", type=click.IntRange(1, 120), default=None,
33
+ help="Max call duration in minutes (1-120)")
34
+ @click.option("--summary/--no-summary", default=False, help="Enable LLM summary of the call")
35
+ @click.option("--wait/--no-wait", default=True, help="Wait for call to complete (default: wait)")
36
+ @click.option("--json-output", "--json", is_flag=True, help="Output as JSON")
37
+ @handle_api_errors
38
+ def call_cmd(phone, name, context, objective, instructions, caller, voice_gender,
39
+ max_duration, summary, wait, json_output):
40
+ """Make a phone call via Pine AI voice agent."""
41
+ client = get_voice_client()
42
+
43
+ call_kwargs = dict(
44
+ to=phone, name=name, context=context, objective=objective,
45
+ instructions=instructions, caller=caller, voice=voice_gender,
46
+ max_duration_minutes=max_duration, enable_summary=summary,
47
+ )
48
+ call_kwargs = {k: v for k, v in call_kwargs.items() if v is not None}
49
+
50
+ if not wait:
51
+ with console.status("Initiating call…"):
52
+ initiated = client.calls.create(**call_kwargs)
53
+ if json_output:
54
+ click.echo(json.dumps({"call_id": initiated.call_id, "status": initiated.status}))
55
+ else:
56
+ console.print(f"[green]✓ Call initiated[/green] ID: [bold]{initiated.call_id}[/bold]")
57
+ console.print(f"[dim]Check status: pine voice status {initiated.call_id}[/dim]")
58
+ return
59
+
60
+ def _on_progress(progress):
61
+ if not json_output:
62
+ dur = f" ({progress.duration_seconds}s)" if progress.duration_seconds else ""
63
+ console.print(f"[dim] ● {progress.status}{dur}[/dim]")
64
+
65
+ if not json_output:
66
+ console.print(f"[cyan]Calling {name} at {phone}…[/cyan]")
67
+ with console.status("Call in progress…") if not json_output else nullcontext():
68
+ result = client.calls.create_and_wait(**call_kwargs, on_progress=_on_progress)
69
+
70
+ if json_output:
71
+ click.echo(json.dumps({
72
+ "call_id": result.call_id, "status": result.status,
73
+ "duration_seconds": result.duration_seconds,
74
+ "summary": result.summary, "credits_charged": result.credits_charged,
75
+ "transcript": [{"speaker": t.speaker, "text": t.text} for t in result.transcript],
76
+ }, indent=2))
77
+ return
78
+
79
+ _render_result(result)
80
+
81
+
82
+ @voice.command("status")
83
+ @click.argument("call_id")
84
+ @click.option("--json-output", "--json", is_flag=True, help="Output as JSON")
85
+ @handle_api_errors
86
+ def status_cmd(call_id, json_output):
87
+ """Check the status of a voice call."""
88
+ client = get_voice_client()
89
+
90
+ with console.status("Fetching call status…"):
91
+ result = client.calls.get(call_id)
92
+
93
+ if json_output:
94
+ data = {"call_id": result.call_id, "status": result.status}
95
+ if hasattr(result, "summary"):
96
+ data.update(
97
+ duration_seconds=result.duration_seconds,
98
+ summary=result.summary,
99
+ credits_charged=result.credits_charged,
100
+ transcript=[{"speaker": t.speaker, "text": t.text} for t in result.transcript],
101
+ )
102
+ click.echo(json.dumps(data, indent=2))
103
+ return
104
+
105
+ if hasattr(result, "summary"):
106
+ _render_result(result)
107
+ else:
108
+ console.print(f"Call [bold]{result.call_id}[/bold] Status: [yellow]{result.status}[/yellow]")
109
+ if result.duration_seconds:
110
+ console.print(f"Duration: {result.duration_seconds}s")
111
+
112
+
113
+ def _render_result(result):
114
+ """Pretty-print a completed CallResult."""
115
+ color = {"completed": "green", "failed": "red", "cancelled": "yellow"}.get(result.status, "white")
116
+ console.print(f"\n[{color} bold]{result.status.upper()}[/{color} bold] "
117
+ f"Call [bold]{result.call_id}[/bold]")
118
+ console.print(f"Duration: {result.duration_seconds}s | Credits: {result.credits_charged}")
119
+
120
+ if result.summary:
121
+ console.print(Panel(result.summary, title="Summary", border_style="cyan"))
122
+
123
+ if result.transcript:
124
+ table = Table(title="Transcript", show_lines=True, expand=True)
125
+ table.add_column("Speaker", style="bold", width=8)
126
+ table.add_column("Text")
127
+ for entry in result.transcript:
128
+ style = "green" if entry.speaker == "agent" else "white"
129
+ table.add_row(entry.speaker, entry.text, style=style)
130
+ console.print(table)