saleslumen 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.
Files changed (78) hide show
  1. saleslumen-0.1.0/.github/workflows/ci.yml +21 -0
  2. saleslumen-0.1.0/.github/workflows/publish.yml +41 -0
  3. saleslumen-0.1.0/.gitignore +6 -0
  4. saleslumen-0.1.0/.python-version +1 -0
  5. saleslumen-0.1.0/AGENTS.md +29 -0
  6. saleslumen-0.1.0/CONTRIBUTING.md +21 -0
  7. saleslumen-0.1.0/LICENSE +21 -0
  8. saleslumen-0.1.0/PKG-INFO +45 -0
  9. saleslumen-0.1.0/README.md +31 -0
  10. saleslumen-0.1.0/examples/appointment_reschedule/__init__.py +0 -0
  11. saleslumen-0.1.0/examples/appointment_reschedule/flow.py +50 -0
  12. saleslumen-0.1.0/examples/appointment_reschedule/tools.py +25 -0
  13. saleslumen-0.1.0/pyproject.toml +42 -0
  14. saleslumen-0.1.0/src/saleslumen/cx/__init__.py +42 -0
  15. saleslumen-0.1.0/src/saleslumen/cx/cli.py +106 -0
  16. saleslumen-0.1.0/src/saleslumen/cx/events/__init__.py +9 -0
  17. saleslumen-0.1.0/src/saleslumen/cx/events/events.py +60 -0
  18. saleslumen-0.1.0/src/saleslumen/cx/flow/__init__.py +23 -0
  19. saleslumen-0.1.0/src/saleslumen/cx/flow/compile.py +327 -0
  20. saleslumen-0.1.0/src/saleslumen/cx/flow/context.py +38 -0
  21. saleslumen-0.1.0/src/saleslumen/cx/flow/errors.py +2 -0
  22. saleslumen-0.1.0/src/saleslumen/cx/flow/models.py +221 -0
  23. saleslumen-0.1.0/src/saleslumen/cx/live/__init__.py +0 -0
  24. saleslumen-0.1.0/src/saleslumen/cx/live/feed.py +68 -0
  25. saleslumen-0.1.0/src/saleslumen/cx/live/pipecat_graph.py +106 -0
  26. saleslumen-0.1.0/src/saleslumen/cx/live/publish.py +23 -0
  27. saleslumen-0.1.0/src/saleslumen/cx/live/routes.py +52 -0
  28. saleslumen-0.1.0/src/saleslumen/cx/live/static/draw.js +366 -0
  29. saleslumen-0.1.0/src/saleslumen/cx/live/static/live.css +370 -0
  30. saleslumen-0.1.0/src/saleslumen/cx/live/static/live.html +40 -0
  31. saleslumen-0.1.0/src/saleslumen/cx/live/static/page.js +229 -0
  32. saleslumen-0.1.0/src/saleslumen/cx/live/static/project.js +183 -0
  33. saleslumen-0.1.0/src/saleslumen/cx/ports/__init__.py +4 -0
  34. saleslumen-0.1.0/src/saleslumen/cx/ports/transfer.py +29 -0
  35. saleslumen-0.1.0/src/saleslumen/cx/ports/workflow.py +144 -0
  36. saleslumen-0.1.0/src/saleslumen/cx/py.typed +0 -0
  37. saleslumen-0.1.0/src/saleslumen/cx/runtime/call.py +89 -0
  38. saleslumen-0.1.0/src/saleslumen/cx/runtime/compiler.py +551 -0
  39. saleslumen-0.1.0/src/saleslumen/cx/runtime/tool_bridge.py +42 -0
  40. saleslumen-0.1.0/src/saleslumen/cx/testing/harness.py +138 -0
  41. saleslumen-0.1.0/src/saleslumen/cx/voice/__init__.py +0 -0
  42. saleslumen-0.1.0/src/saleslumen/cx/voice/config.py +45 -0
  43. saleslumen-0.1.0/src/saleslumen/cx/voice/connectors.py +88 -0
  44. saleslumen-0.1.0/src/saleslumen/cx/voice/pipeline.py +226 -0
  45. saleslumen-0.1.0/src/saleslumen/cx/voice/runner.py +44 -0
  46. saleslumen-0.1.0/src/saleslumen/cx/workflows/__init__.py +1 -0
  47. saleslumen-0.1.0/src/saleslumen/cx/workflows/adapter.py +95 -0
  48. saleslumen-0.1.0/src/saleslumen/cx/workflows/client.py +299 -0
  49. saleslumen-0.1.0/src/saleslumen/cx/workflows/grants.py +61 -0
  50. saleslumen-0.1.0/src/saleslumen/cx/workflows/models.py +157 -0
  51. saleslumen-0.1.0/src/saleslumen/cx/workflows/run.py +342 -0
  52. saleslumen-0.1.0/src/saleslumen/cx/workflows/steps.py +224 -0
  53. saleslumen-0.1.0/tests/__init__.py +1 -0
  54. saleslumen-0.1.0/tests/flow/__init__.py +0 -0
  55. saleslumen-0.1.0/tests/flow/test_compile.py +205 -0
  56. saleslumen-0.1.0/tests/live/__init__.py +0 -0
  57. saleslumen-0.1.0/tests/live/draw.test.js +48 -0
  58. saleslumen-0.1.0/tests/live/fixtures/refund/revision.json +226 -0
  59. saleslumen-0.1.0/tests/live/project.test.js +104 -0
  60. saleslumen-0.1.0/tests/live/test_feed.py +49 -0
  61. saleslumen-0.1.0/tests/live/test_pipecat_graph.py +33 -0
  62. saleslumen-0.1.0/tests/live/test_publish.py +26 -0
  63. saleslumen-0.1.0/tests/live/test_routes.py +38 -0
  64. saleslumen-0.1.0/tests/runtime/__init__.py +0 -0
  65. saleslumen-0.1.0/tests/runtime/test_harness.py +132 -0
  66. saleslumen-0.1.0/tests/runtime/test_tool_schema.py +36 -0
  67. saleslumen-0.1.0/tests/test_cli.py +79 -0
  68. saleslumen-0.1.0/tests/test_config.py +52 -0
  69. saleslumen-0.1.0/tests/test_import_rules.py +171 -0
  70. saleslumen-0.1.0/tests/voice/__init__.py +0 -0
  71. saleslumen-0.1.0/tests/voice/test_pipeline.py +82 -0
  72. saleslumen-0.1.0/tests/workflows/__init__.py +6 -0
  73. saleslumen-0.1.0/tests/workflows/test_adapter.py +34 -0
  74. saleslumen-0.1.0/tests/workflows/test_client.py +367 -0
  75. saleslumen-0.1.0/tests/workflows/test_models.py +61 -0
  76. saleslumen-0.1.0/tests/workflows/test_run.py +396 -0
  77. saleslumen-0.1.0/tests/workflows/test_steps.py +106 -0
  78. saleslumen-0.1.0/uv.lock +4973 -0
@@ -0,0 +1,21 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+
8
+ jobs:
9
+ test:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v4
13
+ - uses: astral-sh/setup-uv@v5
14
+ - run: uv sync --frozen
15
+ - run: uv run python -m unittest discover -s tests -t .
16
+ - run: uv run saleslumen cx validate examples.appointment_reschedule.flow:flow
17
+ - uses: actions/setup-node@v4
18
+ with:
19
+ node-version: "22"
20
+ - run: node --test tests/live/draw.test.js tests/live/project.test.js
21
+ - run: uv build
@@ -0,0 +1,41 @@
1
+ name: Publish
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ workflow_dispatch:
7
+
8
+ permissions:
9
+ contents: read
10
+
11
+ jobs:
12
+ build:
13
+ runs-on: ubuntu-latest
14
+ steps:
15
+ - uses: actions/checkout@v4
16
+ - uses: astral-sh/setup-uv@v5
17
+ - run: uv sync --frozen
18
+ - run: uv run python -m unittest discover -s tests -t .
19
+ - uses: actions/setup-node@v4
20
+ with:
21
+ node-version: "22"
22
+ - run: node --test tests/live/draw.test.js tests/live/project.test.js
23
+ - run: uv build
24
+ - uses: actions/upload-artifact@v4
25
+ with:
26
+ name: dist
27
+ path: dist/
28
+
29
+ publish:
30
+ needs: build
31
+ runs-on: ubuntu-latest
32
+ permissions:
33
+ id-token: write
34
+ steps:
35
+ - uses: actions/download-artifact@v4
36
+ with:
37
+ name: dist
38
+ path: dist/
39
+ - uses: pypa/gh-action-pypi-publish@release/v1
40
+ with:
41
+ skip-existing: true
@@ -0,0 +1,6 @@
1
+ .venv/
2
+ __pycache__/
3
+ *.pyc
4
+ .env
5
+ dist/
6
+ *.egg-info/
@@ -0,0 +1 @@
1
+ 3.13
@@ -0,0 +1,29 @@
1
+ # saleslumen Agent
2
+
3
+ ## Identity
4
+
5
+ Distribution `saleslumen` ships PEP 420 import package `saleslumen.cx` under `src/saleslumen/cx/` (no `src/saleslumen/__init__.py`). Voice runtime needs `saleslumen[cx]` (Pipecat 1.17.0, runner/webrtc/mcp only — no vendor STT/TTS/LLM extras). Author flows as Python `Flow` objects; `flow.validate()` / `flow.compile()` are the static contract.
6
+
7
+ ## Commands
8
+
9
+ ```bash
10
+ uv sync
11
+ uv run saleslumen cx validate examples.appointment_reschedule.flow:flow
12
+ uv run saleslumen cx run examples.appointment_reschedule.flow:flow --providers <module:factory> -t webrtc
13
+ uv run python -m unittest discover -s tests -t .
14
+ node --test tests/live/draw.test.js tests/live/project.test.js
15
+ ```
16
+
17
+ `config.load()` in `saleslumen.cx.voice.config` reads Saleslumen Workflows env only. Consumer apps inject `stt`/`tts`/`llm` into `serve_flow` and supply a `--providers` factory for `cx run`; this repo has no `bot.py` or vendor modules under `voice/`.
18
+
19
+ ## Boundaries
20
+
21
+ - `flow/` — stdlib + pydantic
22
+ - `workflows/` — httpx client; no pipecat, runtime, voice
23
+ - `runtime/` — pipecat compiler; no workflows client/run imports
24
+ - `live/` — graph from `CompiledFlow`; no pipecat
25
+ - Import rules: `tests/test_import_rules.py`
26
+
27
+ ## Example
28
+
29
+ - `examples/appointment_reschedule/` — lookup tool, warm transfer, dual idle prompts
@@ -0,0 +1,21 @@
1
+ # Contributing
2
+
3
+ Work in import package `saleslumen.cx` under `src/saleslumen/cx/`. Add or change behavior in the owning layer (`flow`, `ports`, `workflows`, `runtime`, `voice`, `live`, `testing`).
4
+
5
+ ## New example
6
+
7
+ 1. Add `examples/<name>/flow.py` with a `Flow` instance and `tools.py` with `CallContext` tools.
8
+ 2. Route every `ToolOutput[SomeEnum]` outcome on the owning `Agent.routes`.
9
+ 3. Run `uv run saleslumen cx validate examples.<name>.flow:flow`. For `cx run`, pass a consumer `--providers` factory (SDK examples do not ship vendor builders).
10
+
11
+ ## Tests
12
+
13
+ ```bash
14
+ uv run python -m unittest discover -s tests -t .
15
+ ```
16
+
17
+ Import-boundary tests: `tests/test_import_rules.py`.
18
+
19
+ ## Config
20
+
21
+ Do not commit `.env`. `config.load()` must stay env-only; callers load dotenv if needed.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 SalesLumen
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,45 @@
1
+ Metadata-Version: 2.5
2
+ Name: saleslumen
3
+ Version: 0.1.0
4
+ Summary: Python-first voice flow SDK for Saleslumen workflows on Pipecat.
5
+ License-File: LICENSE
6
+ Requires-Python: >=3.11
7
+ Requires-Dist: httpx<1,>=0.28
8
+ Requires-Dist: pydantic-settings<3,>=2.16.3
9
+ Requires-Dist: pydantic<3,>=2.14.4
10
+ Requires-Dist: python-dotenv<2,>=1.1
11
+ Provides-Extra: cx
12
+ Requires-Dist: pipecat-ai[mcp,runner,webrtc]==1.17.0; extra == 'cx'
13
+ Description-Content-Type: text/markdown
14
+
15
+ # saleslumen
16
+
17
+ Python-first voice flow SDK for Saleslumen workflows on Pipecat (`saleslumen.cx`). Install voice runtime extras with `saleslumen[cx]` (runner, WebRTC, MCP — no Deepgram or OpenRouter).
18
+
19
+ ## Layout
20
+
21
+ - `src/saleslumen/cx/` — PEP 420 package under namespace `saleslumen` (no `src/saleslumen/__init__.py`)
22
+ - `examples/appointment_reschedule/` — transfer + idle sample flow
23
+
24
+ ## Install
25
+
26
+ ```bash
27
+ uv sync
28
+ # consumer apps: depend on saleslumen[cx]
29
+ ```
30
+
31
+ ## CLI
32
+
33
+ ```bash
34
+ uv run saleslumen cx validate examples.appointment_reschedule.flow:flow
35
+ uv run saleslumen cx run examples.appointment_reschedule.flow:flow --providers <module:factory> -t webrtc
36
+ ```
37
+
38
+ Consumer apps own STT/TTS/LLM builders and pass them via `--providers` (for example `providers:build_services` in the billing demo).
39
+
40
+ ## Test
41
+
42
+ ```bash
43
+ uv run python -m unittest discover -s tests -t .
44
+ node --test tests/live/draw.test.js tests/live/project.test.js
45
+ ```
@@ -0,0 +1,31 @@
1
+ # saleslumen
2
+
3
+ Python-first voice flow SDK for Saleslumen workflows on Pipecat (`saleslumen.cx`). Install voice runtime extras with `saleslumen[cx]` (runner, WebRTC, MCP — no Deepgram or OpenRouter).
4
+
5
+ ## Layout
6
+
7
+ - `src/saleslumen/cx/` — PEP 420 package under namespace `saleslumen` (no `src/saleslumen/__init__.py`)
8
+ - `examples/appointment_reschedule/` — transfer + idle sample flow
9
+
10
+ ## Install
11
+
12
+ ```bash
13
+ uv sync
14
+ # consumer apps: depend on saleslumen[cx]
15
+ ```
16
+
17
+ ## CLI
18
+
19
+ ```bash
20
+ uv run saleslumen cx validate examples.appointment_reschedule.flow:flow
21
+ uv run saleslumen cx run examples.appointment_reschedule.flow:flow --providers <module:factory> -t webrtc
22
+ ```
23
+
24
+ Consumer apps own STT/TTS/LLM builders and pass them via `--providers` (for example `providers:build_services` in the billing demo).
25
+
26
+ ## Test
27
+
28
+ ```bash
29
+ uv run python -m unittest discover -s tests -t .
30
+ node --test tests/live/draw.test.js tests/live/project.test.js
31
+ ```
@@ -0,0 +1,50 @@
1
+ from examples.appointment_reschedule.tools import AppointmentState, LookupOutcome, lookup_appointment
2
+ from saleslumen.cx import Agent, End, Flow, Handoff, HandoffArg, Idle, Transfer
3
+
4
+ ROLE = "You are the scheduling voice for MedSchedule appointments."
5
+ GREET_PROMPT = (
6
+ "You help callers reschedule appointments. When they give a confirmation number, call lookup_appointment before "
7
+ "replying. If the tool says missing, ask once more, then call hang_up if they cannot provide a number. "
8
+ "When they want a new time and the appointment is found, call reschedule with what they said. "
9
+ "When they are finished, call hang_up in the same reply as your goodbye."
10
+ )
11
+ end_invalid = End(name="end_invalid", say="I could not complete that request. Goodbye.")
12
+ end_voicemail = End(name="end_voicemail", say="No one is available. Please call back during business hours.")
13
+ end_quiet = End(name="end_quiet")
14
+ transfer_desk = Transfer(
15
+ name="transfer_desk",
16
+ mode="warm",
17
+ target="+15550101999",
18
+ say="Please hold while I connect you to scheduling.",
19
+ whisper="Transferring to scheduling.",
20
+ on_failed=end_invalid,
21
+ on_no_answer=end_voicemail,
22
+ )
23
+ greet = Agent(
24
+ name="greet",
25
+ prompt=GREET_PROMPT,
26
+ say="Hello, MedSchedule appointments. What is your confirmation number?",
27
+ first_speaker="caller",
28
+ tools=(lookup_appointment,),
29
+ handoffs=(
30
+ Handoff(
31
+ name="reschedule",
32
+ to=transfer_desk,
33
+ when="Caller wants a new time and appointment is found.",
34
+ args=(HandoffArg(name="detail", type="string"),),
35
+ ),
36
+ ),
37
+ routes={},
38
+ )
39
+ greet.routes = {LookupOutcome.missing: end_invalid, LookupOutcome.found: greet}
40
+ flow = Flow(
41
+ entry=greet,
42
+ system_prompt=ROLE,
43
+ state_type=AppointmentState,
44
+ global_handoffs=(Handoff(name="hang_up", to=end_quiet, when="Caller is done."),),
45
+ idle=Idle(
46
+ timeout_secs=15,
47
+ prompts=("Are you still on the line?", "I have not heard from you."),
48
+ then=end_invalid,
49
+ ),
50
+ )
@@ -0,0 +1,25 @@
1
+ from enum import StrEnum
2
+
3
+ from pydantic import BaseModel
4
+
5
+ from saleslumen.cx import CallContext, ToolOutput
6
+
7
+ KNOWN = {"CONF-4401", "CONF-8820"}
8
+
9
+
10
+ class AppointmentState(BaseModel):
11
+ appointment: str = ""
12
+
13
+
14
+ class LookupOutcome(StrEnum):
15
+ found = "found"
16
+ missing = "missing"
17
+
18
+
19
+ async def lookup_appointment(ctx: CallContext[AppointmentState], confirmation: str) -> ToolOutput[LookupOutcome]:
20
+ """Look up an appointment by confirmation code."""
21
+ code = confirmation.strip().upper()
22
+ if code in KNOWN:
23
+ ctx.state.appointment = code
24
+ return ToolOutput(data={"status": "found", "code": code}, outcome=LookupOutcome.found)
25
+ return ToolOutput(data={"status": "missing"}, outcome=LookupOutcome.missing)
@@ -0,0 +1,42 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "saleslumen"
7
+ version = "0.1.0"
8
+ description = "Python-first voice flow SDK for Saleslumen workflows on Pipecat."
9
+ requires-python = ">=3.11"
10
+ dependencies = [
11
+ "httpx>=0.28,<1",
12
+ "pydantic>=2.14.4,<3",
13
+ "pydantic-settings>=2.16.3,<3",
14
+ "python-dotenv>=1.1,<2",
15
+ ]
16
+ readme = "README.md"
17
+
18
+ [project.optional-dependencies]
19
+ cx = ["pipecat-ai[runner,webrtc,mcp]==1.17.0"]
20
+
21
+ [project.scripts]
22
+ saleslumen = "saleslumen.cx.cli:main"
23
+
24
+ [tool.hatch.build.targets.wheel]
25
+ packages = ["src/saleslumen"]
26
+ exclude = [
27
+ "src/saleslumen/cx/live/static",
28
+ "src/saleslumen/cx/py.typed",
29
+ ]
30
+
31
+ [tool.hatch.build.targets.wheel.force-include]
32
+ "src/saleslumen/cx/live/static" = "saleslumen/cx/live/static"
33
+ "src/saleslumen/cx/py.typed" = "saleslumen/cx/py.typed"
34
+
35
+ [tool.uv]
36
+ package = true
37
+
38
+ [dependency-groups]
39
+ dev = [
40
+ "pipecat-ai[runner,webrtc,mcp,cli]==1.17.0",
41
+ "pyyaml>=6,<7",
42
+ ]
@@ -0,0 +1,42 @@
1
+ """Saleslumen voice flow SDK.
2
+
3
+ Public authoring types for Python-first Pipecat flows. Import from this package
4
+ in examples and host apps; avoid importing ``saleslumen.cx.runtime`` at
5
+ authoring time unless extending the runtime.
6
+ """
7
+
8
+ from saleslumen.cx.flow.context import CallContext, ToolOutput
9
+ from saleslumen.cx.flow.errors import FlowValidationError
10
+ from saleslumen.cx.flow.models import (
11
+ Agent,
12
+ Connector,
13
+ End,
14
+ Flow,
15
+ Handoff,
16
+ HandoffArg,
17
+ Idle,
18
+ MaxDuration,
19
+ Skill,
20
+ Transfer,
21
+ Workflow,
22
+ )
23
+
24
+ __version__ = "0.1.0"
25
+
26
+ __all__ = [
27
+ "__version__",
28
+ "Agent",
29
+ "CallContext",
30
+ "Connector",
31
+ "End",
32
+ "Flow",
33
+ "FlowValidationError",
34
+ "Handoff",
35
+ "HandoffArg",
36
+ "Idle",
37
+ "MaxDuration",
38
+ "Skill",
39
+ "ToolOutput",
40
+ "Transfer",
41
+ "Workflow",
42
+ ]
@@ -0,0 +1,106 @@
1
+ import argparse
2
+ import importlib
3
+ import sys
4
+ from pathlib import Path
5
+ from typing import Any
6
+
7
+ from saleslumen.cx.flow.errors import FlowValidationError
8
+ from saleslumen.cx.flow.models import Flow
9
+
10
+
11
+ def _ensure_cwd_on_path() -> None:
12
+ cwd = str(Path.cwd())
13
+ if cwd not in sys.path:
14
+ sys.path.insert(0, cwd)
15
+
16
+
17
+ def _load_symbol(module_attr: str, label: str) -> Any:
18
+ _ensure_cwd_on_path()
19
+ module_name, _, attr = module_attr.partition(":")
20
+ if not module_name or not attr:
21
+ raise SystemExit(f"usage: saleslumen cx <command> <module:attr>")
22
+ module = importlib.import_module(module_name)
23
+ value = getattr(module, attr)
24
+ if value is None:
25
+ raise SystemExit(f"{module_attr} is not defined")
26
+ return value
27
+
28
+
29
+ def _load_flow(module_attr: str) -> Flow:
30
+ value = _load_symbol(module_attr, "flow")
31
+ if not isinstance(value, Flow):
32
+ raise SystemExit(f"{module_attr} is not a Flow")
33
+ return value
34
+
35
+
36
+ def _load_providers(module_attr: str) -> tuple[Any, Any, Any]:
37
+ factory = _load_symbol(module_attr, "providers")
38
+ if not callable(factory):
39
+ raise SystemExit(f"{module_attr} is not callable")
40
+ result = factory()
41
+ if isinstance(result, dict):
42
+ try:
43
+ return result["stt"], result["tts"], result["llm"]
44
+ except KeyError as exc:
45
+ raise SystemExit("providers factory dict must include stt, tts, and llm keys") from exc
46
+ if isinstance(result, (tuple, list)) and len(result) == 3:
47
+ return result[0], result[1], result[2]
48
+ raise SystemExit("providers factory must return (stt, tts, llm) or a dict with those keys")
49
+
50
+
51
+ def cmd_validate(module_attr: str) -> int:
52
+ flow = _load_flow(module_attr)
53
+ try:
54
+ flow.validate()
55
+ flow.compile()
56
+ except FlowValidationError as exc:
57
+ print(str(exc), file=sys.stderr)
58
+ return 1
59
+ return 0
60
+
61
+
62
+ def cmd_run(module_attr: str, providers_attr: str) -> None:
63
+ from dotenv import load_dotenv
64
+ from pipecat.runner.run import app, main
65
+ from pipecat.runner.types import RunnerArguments
66
+ from saleslumen.cx.live.routes import register
67
+ from saleslumen.cx.voice.config import load
68
+ from saleslumen.cx.voice.runner import serve_flow
69
+ load_dotenv()
70
+ flow = _load_flow(module_attr)
71
+ flow.validate()
72
+ stt, tts, llm = _load_providers(providers_attr)
73
+ settings = load()
74
+ global_names = tuple(item.name for item in flow.global_handoffs)
75
+ register(app, flow=flow, global_names=global_names)
76
+ async def bot(runner_args: RunnerArguments) -> None:
77
+ await serve_flow(runner_args, flow, settings, stt=stt, tts=tts, llm=llm)
78
+ import pipecat.runner.run as runner_module
79
+ runner_module.bot = bot
80
+ main()
81
+
82
+
83
+ def _build_parser() -> argparse.ArgumentParser:
84
+ parser = argparse.ArgumentParser(prog="saleslumen")
85
+ sub = parser.add_subparsers(dest="domain", required=True)
86
+ cx = sub.add_parser("cx")
87
+ cx_sub = cx.add_subparsers(dest="command", required=True)
88
+ val = cx_sub.add_parser("validate")
89
+ val.add_argument("target")
90
+ run = cx_sub.add_parser("run")
91
+ run.add_argument("target")
92
+ run.add_argument("--providers", required=True)
93
+ return parser
94
+
95
+
96
+ def main() -> None:
97
+ args, unknown = _build_parser().parse_known_args()
98
+ if args.domain != "cx":
99
+ raise SystemExit(2)
100
+ if args.command == "validate":
101
+ raise SystemExit(cmd_validate(args.target))
102
+ if args.command == "run":
103
+ sys.argv = [sys.argv[0], *unknown]
104
+ cmd_run(args.target, args.providers)
105
+ return
106
+ raise SystemExit(2)
@@ -0,0 +1,9 @@
1
+ from saleslumen.cx.events.events import CallEnded, CallStarted, FlowNodeEvent, TranscriptEvent, WorkflowStepEvent
2
+
3
+ __all__ = [
4
+ "CallStarted",
5
+ "CallEnded",
6
+ "FlowNodeEvent",
7
+ "WorkflowStepEvent",
8
+ "TranscriptEvent",
9
+ ]
@@ -0,0 +1,60 @@
1
+ """Typed live-call events for the localhost call view."""
2
+
3
+ from typing import Literal, Self
4
+
5
+ from pydantic import BaseModel, ConfigDict, model_validator
6
+
7
+ StepState = Literal["running", "awaiting", "succeeded", "failed"]
8
+ TranscriptRole = Literal["user", "assistant"]
9
+
10
+
11
+ class CallStarted(BaseModel):
12
+ model_config = ConfigDict(extra="forbid", frozen=True)
13
+ kind: Literal["call_started"] = "call_started"
14
+ call_id: str
15
+
16
+
17
+ class CallEnded(BaseModel):
18
+ model_config = ConfigDict(extra="forbid", frozen=True)
19
+ kind: Literal["call_ended"] = "call_ended"
20
+ call_id: str
21
+
22
+
23
+ class TranscriptEvent(BaseModel):
24
+ model_config = ConfigDict(extra="forbid", frozen=True)
25
+ kind: Literal["transcript"] = "transcript"
26
+ call_id: str
27
+ role: TranscriptRole
28
+ text: str
29
+
30
+
31
+ class FlowNodeEvent(BaseModel):
32
+ model_config = ConfigDict(extra="forbid", frozen=True)
33
+ kind: Literal["flow_node"] = "flow_node"
34
+ call_id: str
35
+ node: str
36
+ graph_node: str
37
+ function: str | None = None
38
+
39
+
40
+ class WorkflowStepEvent(BaseModel):
41
+ model_config = ConfigDict(extra="forbid", frozen=True)
42
+ kind: Literal["workflow_step"] = "workflow_step"
43
+ call_id: str
44
+ execution_id: str
45
+ version: int
46
+ state: StepState
47
+ workflow: str
48
+ step_path: str = ""
49
+ sequence: int | None = None
50
+ @model_validator(mode="after")
51
+ def awaiting_fields(self) -> Self:
52
+ if self.state == "awaiting":
53
+ if self.step_path == "":
54
+ raise ValueError("step_path required when state is awaiting")
55
+ if self.sequence is None:
56
+ raise ValueError("sequence required when state is awaiting")
57
+ return self
58
+
59
+
60
+ LiveEvent = CallStarted | CallEnded | TranscriptEvent | FlowNodeEvent | WorkflowStepEvent
@@ -0,0 +1,23 @@
1
+ from saleslumen.cx.flow.compile import CompiledFlow, compile_flow, validate_flow
2
+ from saleslumen.cx.flow.context import CallContext, ToolOutput
3
+ from saleslumen.cx.flow.errors import FlowValidationError
4
+ from saleslumen.cx.flow.models import Agent, Connector, End, Flow, Handoff, Idle, MaxDuration, Skill, Transfer, Workflow
5
+
6
+ __all__ = [
7
+ "Flow",
8
+ "Agent",
9
+ "Workflow",
10
+ "Transfer",
11
+ "End",
12
+ "Handoff",
13
+ "Idle",
14
+ "MaxDuration",
15
+ "Skill",
16
+ "Connector",
17
+ "CallContext",
18
+ "ToolOutput",
19
+ "FlowValidationError",
20
+ "CompiledFlow",
21
+ "validate_flow",
22
+ "compile_flow",
23
+ ]