superdialog 0.2.0a0__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 (178) hide show
  1. superdialog-0.2.0a0/.gitignore +25 -0
  2. superdialog-0.2.0a0/LICENSE +202 -0
  3. superdialog-0.2.0a0/PKG-INFO +40 -0
  4. superdialog-0.2.0a0/README.md +5 -0
  5. superdialog-0.2.0a0/chat.py +246 -0
  6. superdialog-0.2.0a0/docs/00-overview.md +95 -0
  7. superdialog-0.2.0a0/docs/01-architecture.md +303 -0
  8. superdialog-0.2.0a0/docs/02-api-reference.md +416 -0
  9. superdialog-0.2.0a0/docs/03-embedding-guides.md +259 -0
  10. superdialog-0.2.0a0/docs/README.md +61 -0
  11. superdialog-0.2.0a0/docs/decisions.md +100 -0
  12. superdialog-0.2.0a0/examples/fastapi_app.py +25 -0
  13. superdialog-0.2.0a0/examples/livekit.py +37 -0
  14. superdialog-0.2.0a0/examples/pipecat.py +27 -0
  15. superdialog-0.2.0a0/examples/ws.py +51 -0
  16. superdialog-0.2.0a0/generated_system_prompt.txt +79 -0
  17. superdialog-0.2.0a0/pyproject.toml +49 -0
  18. superdialog-0.2.0a0/src/superdialog/__init__.py +55 -0
  19. superdialog-0.2.0a0/src/superdialog/adapters/__init__.py +13 -0
  20. superdialog-0.2.0a0/src/superdialog/adapters/fastapi.py +120 -0
  21. superdialog-0.2.0a0/src/superdialog/adapters/livekit.py +197 -0
  22. superdialog-0.2.0a0/src/superdialog/adapters/pipecat.py +84 -0
  23. superdialog-0.2.0a0/src/superdialog/adapters/websocket.py +200 -0
  24. superdialog-0.2.0a0/src/superdialog/agent.py +55 -0
  25. superdialog-0.2.0a0/src/superdialog/agents/__init__.py +5 -0
  26. superdialog-0.2.0a0/src/superdialog/agents/langchain_agent.py +90 -0
  27. superdialog-0.2.0a0/src/superdialog/agents/llm_agent.py +101 -0
  28. superdialog-0.2.0a0/src/superdialog/chat_context.py +33 -0
  29. superdialog-0.2.0a0/src/superdialog/cli/__init__.py +9 -0
  30. superdialog-0.2.0a0/src/superdialog/cli/main.py +256 -0
  31. superdialog-0.2.0a0/src/superdialog/dialog_machine.py +410 -0
  32. superdialog-0.2.0a0/src/superdialog/flow/__init__.py +17 -0
  33. superdialog-0.2.0a0/src/superdialog/flow/_loaders.py +100 -0
  34. superdialog-0.2.0a0/src/superdialog/flow/bootstrap.py +456 -0
  35. superdialog-0.2.0a0/src/superdialog/flow/enums.py +14 -0
  36. superdialog-0.2.0a0/src/superdialog/flow/loader.py +39 -0
  37. superdialog-0.2.0a0/src/superdialog/flow/models.py +545 -0
  38. superdialog-0.2.0a0/src/superdialog/flow_state.py +55 -0
  39. superdialog-0.2.0a0/src/superdialog/llm/__init__.py +17 -0
  40. superdialog-0.2.0a0/src/superdialog/llm/litellm_provider.py +78 -0
  41. superdialog-0.2.0a0/src/superdialog/llm/provider.py +36 -0
  42. superdialog-0.2.0a0/src/superdialog/llm/registry.py +27 -0
  43. superdialog-0.2.0a0/src/superdialog/llm/resolver.py +36 -0
  44. superdialog-0.2.0a0/src/superdialog/machine/__init__.py +41 -0
  45. superdialog-0.2.0a0/src/superdialog/machine/_lang_util.py +49 -0
  46. superdialog-0.2.0a0/src/superdialog/machine/_prompts.py +115 -0
  47. superdialog-0.2.0a0/src/superdialog/machine/actions.py +139 -0
  48. superdialog-0.2.0a0/src/superdialog/machine/adapters/__init__.py +6 -0
  49. superdialog-0.2.0a0/src/superdialog/machine/adapters/base.py +83 -0
  50. superdialog-0.2.0a0/src/superdialog/machine/adapters/llm_adapter.py +311 -0
  51. superdialog-0.2.0a0/src/superdialog/machine/adapters/text_adapter.py +120 -0
  52. superdialog-0.2.0a0/src/superdialog/machine/adapters/toolcall_adapter.py +541 -0
  53. superdialog-0.2.0a0/src/superdialog/machine/composer.py +505 -0
  54. superdialog-0.2.0a0/src/superdialog/machine/criteria.py +406 -0
  55. superdialog-0.2.0a0/src/superdialog/machine/extractor.py +138 -0
  56. superdialog-0.2.0a0/src/superdialog/machine/gate.py +336 -0
  57. superdialog-0.2.0a0/src/superdialog/machine/hooks.py +86 -0
  58. superdialog-0.2.0a0/src/superdialog/machine/machine.py +2162 -0
  59. superdialog-0.2.0a0/src/superdialog/machine/models.py +531 -0
  60. superdialog-0.2.0a0/src/superdialog/machine/runner.py +343 -0
  61. superdialog-0.2.0a0/src/superdialog/machine/store.py +34 -0
  62. superdialog-0.2.0a0/src/superdialog/machine/testing/__init__.py +16 -0
  63. superdialog-0.2.0a0/src/superdialog/machine/testing/flow_smoke.py +161 -0
  64. superdialog-0.2.0a0/src/superdialog/machine/testing/mock_adapter.py +136 -0
  65. superdialog-0.2.0a0/src/superdialog/machine/testing/sample_appointment_flow.json +107 -0
  66. superdialog-0.2.0a0/src/superdialog/machine/testing/test_self_loop_protection.py +509 -0
  67. superdialog-0.2.0a0/src/superdialog/machine/tools/__init__.py +27 -0
  68. superdialog-0.2.0a0/src/superdialog/machine/tools/base.py +47 -0
  69. superdialog-0.2.0a0/src/superdialog/machine/tools/builtins.py +135 -0
  70. superdialog-0.2.0a0/src/superdialog/machine/tools/registry.py +60 -0
  71. superdialog-0.2.0a0/src/superdialog/machine/transitions.py +94 -0
  72. superdialog-0.2.0a0/src/superdialog/py.typed +0 -0
  73. superdialog-0.2.0a0/src/superdialog/session/__init__.py +19 -0
  74. superdialog-0.2.0a0/src/superdialog/session/lock.py +52 -0
  75. superdialog-0.2.0a0/src/superdialog/session/record.py +29 -0
  76. superdialog-0.2.0a0/src/superdialog/session/session.py +82 -0
  77. superdialog-0.2.0a0/src/superdialog/session/store.py +61 -0
  78. superdialog-0.2.0a0/src/superdialog/session/worker.py +137 -0
  79. superdialog-0.2.0a0/src/superdialog/stream.py +44 -0
  80. superdialog-0.2.0a0/src/superdialog/tools/__init__.py +9 -0
  81. superdialog-0.2.0a0/src/superdialog/tools/base.py +78 -0
  82. superdialog-0.2.0a0/src/superdialog/tools/decorator.py +51 -0
  83. superdialog-0.2.0a0/src/superdialog/tools/http_tool.py +37 -0
  84. superdialog-0.2.0a0/src/superdialog/tools/mcp_tool.py +53 -0
  85. superdialog-0.2.0a0/src/superdialog/tools/python_tool.py +67 -0
  86. superdialog-0.2.0a0/src/superdialog/traversal/.gitkeep +0 -0
  87. superdialog-0.2.0a0/src/superdialog/traversal/__init__.py +5 -0
  88. superdialog-0.2.0a0/src/superdialog/traversal/history/.gitignore +4 -0
  89. superdialog-0.2.0a0/src/superdialog/traversal/history/.gitkeep +0 -0
  90. superdialog-0.2.0a0/src/superdialog/traversal/traversal.py +195 -0
  91. superdialog-0.2.0a0/tests/__init__.py +0 -0
  92. superdialog-0.2.0a0/tests/adapters/__init__.py +0 -0
  93. superdialog-0.2.0a0/tests/adapters/conftest.py +62 -0
  94. superdialog-0.2.0a0/tests/adapters/test_fastapi.py +72 -0
  95. superdialog-0.2.0a0/tests/adapters/test_imports.py +25 -0
  96. superdialog-0.2.0a0/tests/adapters/test_livekit.py +66 -0
  97. superdialog-0.2.0a0/tests/adapters/test_pipecat.py +54 -0
  98. superdialog-0.2.0a0/tests/adapters/test_websocket.py +188 -0
  99. superdialog-0.2.0a0/tests/cli/__init__.py +0 -0
  100. superdialog-0.2.0a0/tests/cli/test_chat.py +396 -0
  101. superdialog-0.2.0a0/tests/conftest.py +54 -0
  102. superdialog-0.2.0a0/tests/dialog_machine/__init__.py +0 -0
  103. superdialog-0.2.0a0/tests/dialog_machine/conftest.py +41 -0
  104. superdialog-0.2.0a0/tests/dialog_machine/test_adapter_protocol.py +29 -0
  105. superdialog-0.2.0a0/tests/dialog_machine/test_bob_card_e2e.py +452 -0
  106. superdialog-0.2.0a0/tests/dialog_machine/test_conversation_engine.py +833 -0
  107. superdialog-0.2.0a0/tests/dialog_machine/test_corpus_generator.py +478 -0
  108. superdialog-0.2.0a0/tests/dialog_machine/test_criteria.py +222 -0
  109. superdialog-0.2.0a0/tests/dialog_machine/test_criteria_judge.py +182 -0
  110. superdialog-0.2.0a0/tests/dialog_machine/test_custom_tool_e2e.py +850 -0
  111. superdialog-0.2.0a0/tests/dialog_machine/test_custom_tools.py +439 -0
  112. superdialog-0.2.0a0/tests/dialog_machine/test_dialog_machine_e2e.py +586 -0
  113. superdialog-0.2.0a0/tests/dialog_machine/test_edge_accuracy.py +335 -0
  114. superdialog-0.2.0a0/tests/dialog_machine/test_engine_advisor.py +315 -0
  115. superdialog-0.2.0a0/tests/dialog_machine/test_engine_resolver.py +79 -0
  116. superdialog-0.2.0a0/tests/dialog_machine/test_evaluator_surface.py +392 -0
  117. superdialog-0.2.0a0/tests/dialog_machine/test_failure_classifier.py +646 -0
  118. superdialog-0.2.0a0/tests/dialog_machine/test_flow_meta_and_create_machine.py +346 -0
  119. superdialog-0.2.0a0/tests/dialog_machine/test_flow_optimizer.py +374 -0
  120. superdialog-0.2.0a0/tests/dialog_machine/test_gated_traversal.py +826 -0
  121. superdialog-0.2.0a0/tests/dialog_machine/test_gated_traversal_e2e.py +577 -0
  122. superdialog-0.2.0a0/tests/dialog_machine/test_graph_analysis.py +537 -0
  123. superdialog-0.2.0a0/tests/dialog_machine/test_kairali_e2e.py +584 -0
  124. superdialog-0.2.0a0/tests/dialog_machine/test_language_tracking.py +365 -0
  125. superdialog-0.2.0a0/tests/dialog_machine/test_livekit_bridge.py +268 -0
  126. superdialog-0.2.0a0/tests/dialog_machine/test_machine.py +432 -0
  127. superdialog-0.2.0a0/tests/dialog_machine/test_mock_adapter.py +157 -0
  128. superdialog-0.2.0a0/tests/dialog_machine/test_models.py +138 -0
  129. superdialog-0.2.0a0/tests/dialog_machine/test_multi_flow_e2e.py +224 -0
  130. superdialog-0.2.0a0/tests/dialog_machine/test_multi_model.py +254 -0
  131. superdialog-0.2.0a0/tests/dialog_machine/test_path_traversal.py +262 -0
  132. superdialog-0.2.0a0/tests/dialog_machine/test_rl_loop.py +491 -0
  133. superdialog-0.2.0a0/tests/dialog_machine/test_robustness.py +710 -0
  134. superdialog-0.2.0a0/tests/dialog_machine/test_runner.py +163 -0
  135. superdialog-0.2.0a0/tests/dialog_machine/test_runner_positioning.py +190 -0
  136. superdialog-0.2.0a0/tests/dialog_machine/test_sample_flow.py +304 -0
  137. superdialog-0.2.0a0/tests/dialog_machine/test_scope_build_invariant.py +275 -0
  138. superdialog-0.2.0a0/tests/dialog_machine/test_sdk_e2e.py +141 -0
  139. superdialog-0.2.0a0/tests/dialog_machine/test_simple_flow_agent.py +627 -0
  140. superdialog-0.2.0a0/tests/dialog_machine/test_text_adapter.py +110 -0
  141. superdialog-0.2.0a0/tests/dialog_machine/test_user_simulator.py +224 -0
  142. superdialog-0.2.0a0/tests/fixtures/flow/appointment.json +68 -0
  143. superdialog-0.2.0a0/tests/fixtures/flow/escalation.json +61 -0
  144. superdialog-0.2.0a0/tests/fixtures/flow/kyc.json +96 -0
  145. superdialog-0.2.0a0/tests/flow/__init__.py +0 -0
  146. superdialog-0.2.0a0/tests/flow/test_loader.py +72 -0
  147. superdialog-0.2.0a0/tests/flow/test_models.py +65 -0
  148. superdialog-0.2.0a0/tests/llm/__init__.py +0 -0
  149. superdialog-0.2.0a0/tests/llm/test_resolver.py +45 -0
  150. superdialog-0.2.0a0/tests/machine/__init__.py +0 -0
  151. superdialog-0.2.0a0/tests/machine/test_composer_language.py +99 -0
  152. superdialog-0.2.0a0/tests/machine/test_imports.py +43 -0
  153. superdialog-0.2.0a0/tests/personas/__init__.py +0 -0
  154. superdialog-0.2.0a0/tests/personas/test_api_developer.py +279 -0
  155. superdialog-0.2.0a0/tests/personas/test_kyc_chatbot_developer.py +211 -0
  156. superdialog-0.2.0a0/tests/personas/test_support_team_lead.py +198 -0
  157. superdialog-0.2.0a0/tests/session/__init__.py +0 -0
  158. superdialog-0.2.0a0/tests/session/test_chat_context.py +37 -0
  159. superdialog-0.2.0a0/tests/session/test_dialog_machine_methods.py +91 -0
  160. superdialog-0.2.0a0/tests/session/test_flow_state.py +45 -0
  161. superdialog-0.2.0a0/tests/session/test_integration.py +147 -0
  162. superdialog-0.2.0a0/tests/session/test_langchain_agent.py +46 -0
  163. superdialog-0.2.0a0/tests/session/test_llm_agent.py +71 -0
  164. superdialog-0.2.0a0/tests/session/test_lock.py +43 -0
  165. superdialog-0.2.0a0/tests/session/test_session.py +60 -0
  166. superdialog-0.2.0a0/tests/session/test_store.py +50 -0
  167. superdialog-0.2.0a0/tests/session/test_worker.py +144 -0
  168. superdialog-0.2.0a0/tests/test_dialog_machine.py +204 -0
  169. superdialog-0.2.0a0/tests/test_dialog_machine_stream.py +93 -0
  170. superdialog-0.2.0a0/tests/tools/__init__.py +0 -0
  171. superdialog-0.2.0a0/tests/tools/test_base.py +63 -0
  172. superdialog-0.2.0a0/tests/tools/test_http_tool.py +78 -0
  173. superdialog-0.2.0a0/tests/tools/test_python_tool.py +64 -0
  174. superdialog-0.2.0a0/tests/tools/test_tool_decorator.py +322 -0
  175. superdialog-0.2.0a0/tests/traversal/__init__.py +0 -0
  176. superdialog-0.2.0a0/tests/traversal/test_traversal.py +317 -0
  177. superdialog-0.2.0a0/uv.lock +3477 -0
  178. superdialog-0.2.0a0/view_traversal.py +145 -0
@@ -0,0 +1,25 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *.egg-info/
5
+ .eggs/
6
+ build/
7
+ dist/
8
+
9
+ # Virtualenv / tooling caches
10
+ .venv/
11
+ .ruff_cache/
12
+ .pytest_cache/
13
+ .mypy_cache/
14
+
15
+ # Environment
16
+ .env
17
+ .env.*
18
+ !.env.example
19
+
20
+ # Editor / OS
21
+ .DS_Store
22
+
23
+ # Local-only planning docs (kept out of the deploy repo)
24
+ docs/plans/
25
+ docs/superpowers/
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,40 @@
1
+ Metadata-Version: 2.4
2
+ Name: superdialog
3
+ Version: 0.2.0a0
4
+ Summary: Standalone dialog state machine framework — text in, text out.
5
+ Author-email: Unpod <parvinder@unpod.ai>
6
+ License: Apache-2.0
7
+ License-File: LICENSE
8
+ Requires-Python: >=3.10
9
+ Requires-Dist: httpx>=0.27
10
+ Requires-Dist: litellm>=1.50
11
+ Requires-Dist: pydantic>=2.5
12
+ Requires-Dist: python-dotenv>=1.0
13
+ Requires-Dist: transitions>=0.9
14
+ Requires-Dist: typing-extensions>=4.10
15
+ Provides-Extra: dev
16
+ Requires-Dist: anyio>=4; extra == 'dev'
17
+ Requires-Dist: pyrefly>=0.1; extra == 'dev'
18
+ Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
19
+ Requires-Dist: pytest>=8; extra == 'dev'
20
+ Requires-Dist: ruff>=0.4; extra == 'dev'
21
+ Provides-Extra: fastapi
22
+ Requires-Dist: fastapi>=0.110; extra == 'fastapi'
23
+ Requires-Dist: uvicorn>=0.27; extra == 'fastapi'
24
+ Provides-Extra: langchain
25
+ Requires-Dist: langchain-core>=0.3; extra == 'langchain'
26
+ Provides-Extra: livekit
27
+ Requires-Dist: livekit-agents>=0.12; extra == 'livekit'
28
+ Provides-Extra: mcp
29
+ Requires-Dist: mcp>=0.9; extra == 'mcp'
30
+ Provides-Extra: pipecat
31
+ Requires-Dist: pipecat-ai>=0.0.50; extra == 'pipecat'
32
+ Provides-Extra: ws
33
+ Requires-Dist: websockets>=12; extra == 'ws'
34
+ Description-Content-Type: text/markdown
35
+
36
+ # superdialog
37
+
38
+ Standalone dialog state machine framework. Text in, text out.
39
+
40
+ See `docs/` for product spec; see `docs/plans/` for implementation plans.
@@ -0,0 +1,5 @@
1
+ # superdialog
2
+
3
+ Standalone dialog state machine framework. Text in, text out.
4
+
5
+ See `docs/` for product spec; see `docs/plans/` for implementation plans.
@@ -0,0 +1,246 @@
1
+ """
2
+ superdialog tester.
3
+
4
+ python chat.py → chat with last generated flow
5
+ python chat.py --generate → generate new flow from GENERATE_PROMPT,
6
+ save to FLOW_PATH, then chat with it
7
+
8
+ Workflow:
9
+ 1. Edit GENERATE_PROMPT below
10
+ 2. Run: python chat.py --generate
11
+ → new flow JSON saved to FLOW_PATH (overwrites)
12
+ → chat starts immediately
13
+ 3. Next time, just: python chat.py (reuses saved flow, no LLM generate call)
14
+ """
15
+
16
+ from __future__ import annotations
17
+ import asyncio, os, sys, textwrap, argparse, json
18
+ from datetime import datetime, timezone
19
+ from pathlib import Path
20
+ from dotenv import load_dotenv
21
+
22
+ load_dotenv("/home/ankit/Unpod/super-sanyam/.env")
23
+
24
+ from superdialog.traversal import build_traversal, save_traversal
25
+
26
+ # ── CONFIGURE HERE ─────────────────────────────────────────────────────────────
27
+ MODEL = "openai/gpt-4.1-mini"
28
+
29
+ # --- generated flow always saved/loaded here ---
30
+ FLOW_PATH = "/home/ankit/Downloads/flow_golf_ai_updated.json"
31
+ SYSTEM_PROMPT_PATH = "/home/ankit/Unpod/super-sanyam/super/superdialog/generated_system_prompt.txt"
32
+ TRAVERSAL_DIR = Path(__file__).parent / "src/superdialog/traversal"
33
+
34
+ # --- describe the agent you want to build ---
35
+ GENERATE_PROMPT = """
36
+ A voice tee-time booking agent for GolfAI TeeTime named Arjun (male).
37
+
38
+ On start: greet the caller with time-of-day salutation (Good morning / Good afternoon /
39
+ Good evening). Returning callers (with booking history) get a personalised greeting
40
+ mentioning their last course and are offered to rebook or go somewhere new.
41
+ New callers get a standard welcome.
42
+
43
+ Core booking flow:
44
+ 1. Collect: city or specific course name.
45
+ 2. If multiple courses in city, list them and ask caller to choose.
46
+ 3. Collect: booking date, preferred tee time (range 6 AM – 5:45 PM), number of players (max 4).
47
+ 4. Check availability for the selected course, date, and time window.
48
+ 5. Present nearest available slot and price. Confirm full summary (course, date, time, players, total price).
49
+ 6. Inform caller that payment link has been sent to their registered email and they have 7 minutes to pay.
50
+ 7. End call after payment instruction — do not wait for payment.
51
+
52
+ Additional paths:
53
+ - Caller wants to rebook the same course as last time → skip city/course collection, ask only for date, time, players.
54
+ - Caller wants to check an existing booking → ask for booking reference, read back details.
55
+ - Caller wants to cancel a booking → ask for reference, confirm cancellation.
56
+ - Caller asks about course details (pricing, facilities, policy) → provide details, then offer to book.
57
+ - Caller asks which cities have courses → list available cities.
58
+ - Caller is silent after greeting → ask "Hello, can you hear me?"; if still silent → end call.
59
+ - Caller says call back later → collect preferred callback time, confirm, end call.
60
+ - Caller says goodbye → immediately end call politely without asking further questions.
61
+
62
+ Language: detect caller's language and respond in the same language throughout.
63
+ Support Hinglish (Hindi-English mix). Agent (Arjun) uses masculine Hindi verb forms for himself
64
+ but gender-neutral forms when addressing the caller.
65
+ Numbers are always spoken as words (e.g. four thousand eight hundred, not 4800).
66
+ Never reveal internal IDs (course_id, booking_id) to the caller.
67
+ Never re-greet after the greeting node.
68
+ """
69
+ # ───────────────────────────────────────────────────────────────────────────────
70
+
71
+ R="\033[0m"; B="\033[1m"; DIM="\033[2m"
72
+ GRN="\033[92m"; CYN="\033[96m"; YLW="\033[93m"
73
+ GRY="\033[90m"; RED="\033[91m"; WHT="\033[97m"
74
+
75
+ W = min(os.get_terminal_size().columns if sys.stdout.isatty() else 88, 100)
76
+
77
+ def hr(c="─"): print(GRY + c*W + R)
78
+ def wrap(text, pad=6):
79
+ p = " " * pad
80
+ return textwrap.fill(text.strip(), width=W-pad, initial_indent=p, subsequent_indent=p)
81
+
82
+
83
+ def print_msg(msg: dict):
84
+ role, content, n = msg.get("role"), msg.get("content","").strip(), msg.get("_node","")
85
+ if not content or role == "system":
86
+ return
87
+ if role == "user":
88
+ print(f" {B}{GRN}You{R}")
89
+ print(wrap(content)); print()
90
+ elif role == "assistant":
91
+ print(f" {B}{CYN}Bot{R} {GRY}[{n}]{R}")
92
+ for line in content.split("\n"):
93
+ if line.strip(): print(wrap(line))
94
+ print()
95
+
96
+
97
+ def print_node_status(node: str):
98
+ hr()
99
+ print(f" {DIM}node: {B}{WHT}{node}{R} {GRY}│ quit = exit{R}")
100
+ hr()
101
+
102
+
103
+
104
+
105
+ async def generate_and_save():
106
+ """Generate flow from GENERATE_PROMPT, save to FLOW_PATH."""
107
+ from superdialog import create_dialog_flow
108
+
109
+ hr("═")
110
+ print(f"{B}{WHT} Generating flow...{R} {DIM}{MODEL}{R}"); hr("═"); print()
111
+ print(f"{YLW} Prompt:{R}")
112
+ for line in GENERATE_PROMPT.strip().split("\n"):
113
+ if line.strip(): print(f" {DIM}{line.strip()}{R}")
114
+ print(f"\n {DIM}Calling LLM...{R}", flush=True)
115
+
116
+ flow = await create_dialog_flow(prompt=GENERATE_PROMPT.strip(), llm=MODEL)
117
+
118
+ flow.save(FLOW_PATH)
119
+ with open(SYSTEM_PROMPT_PATH, "w") as f:
120
+ f.write(flow.system_prompt)
121
+ print(f" {GRN}✓ System prompt saved:{R} {B}{SYSTEM_PROMPT_PATH}{R}")
122
+
123
+ node_count = len(flow.nodes)
124
+ edge_count = sum(len(n.edges) for n in flow.nodes)
125
+ print(f"\n {GRN}✓ Flow generated + saved:{R} {B}{FLOW_PATH}{R}")
126
+ print(f" {B}{node_count} nodes{R} {GRY}│{R} {B}{edge_count} edges{R}\n")
127
+ print(f" {DIM}Nodes:{R}")
128
+ for n in flow.nodes:
129
+ star = f"{GRN}★{R}" if n.id == flow.initial_node else " "
130
+ edges_preview = ", ".join(e.id for e in n.edges[:3])
131
+ if len(n.edges) > 3: edges_preview += "..."
132
+ print(f" {star} {B}{n.id}{R} {GRY}→ [{edges_preview}]{R}")
133
+ print()
134
+ input(f" {DIM}Press Enter to start chat...{R} ")
135
+
136
+
137
+ async def chat(flow_path: str):
138
+ from superdialog import DialogMachine, Flow
139
+
140
+ if not os.path.exists(flow_path):
141
+ print(f"{RED}Flow not found: {flow_path}{R}"); sys.exit(1)
142
+
143
+ flow = Flow.load(flow_path)
144
+ machine = DialogMachine(flow=flow, llm=MODEL)
145
+ source = os.path.basename(flow_path)
146
+ chat_turns: list[dict] = []
147
+ started_at = datetime.now(timezone.utc)
148
+
149
+ hr("═")
150
+ print(f"{B}{WHT} superdialog tester{R} {GRY}│{R} {CYN}{source}{R} {GRY}│{R} {DIM}model: {MODEL}{R}")
151
+ hr("═"); print()
152
+
153
+ try:
154
+ first = await machine.start()
155
+ except Exception as e:
156
+ print(f"{RED}Failed to start: {e}{R}"); sys.exit(1)
157
+
158
+ node = machine.state["node_id"]
159
+ if first.text:
160
+ msg = {"role": "assistant", "content": first.text, "_node": node}
161
+ print_msg(msg)
162
+ chat_turns.append({
163
+ "step": 1,
164
+ "bot": first.text or "",
165
+ "user": None,
166
+ "node": node,
167
+ "ts": datetime.now(timezone.utc).isoformat(),
168
+ })
169
+
170
+ while True:
171
+ print_node_status(node)
172
+
173
+ if machine._machine and machine._machine.is_complete:
174
+ print(f"\n {B}{GRN}✓ Conversation complete.{R}\n"); break
175
+
176
+ try:
177
+ raw = input(f"\n {B}{GRN}You ›{R} ").strip()
178
+ except (EOFError, KeyboardInterrupt):
179
+ print(f"\n\n {DIM}[exited]{R}\n"); break
180
+
181
+ if raw.lower() in {"quit","exit","q","/quit"}:
182
+ print(f"\n {DIM}[exited]{R}\n"); break
183
+ if not raw:
184
+ continue
185
+
186
+ print()
187
+ print_msg({"role": "user", "content": raw})
188
+
189
+ try:
190
+ turn = await machine.turn(raw)
191
+ except Exception as e:
192
+ print_msg({"role": "assistant", "content": f"[ERROR: {e}]", "_node": node})
193
+ continue
194
+
195
+ node = machine.state["node_id"]
196
+ if turn.text:
197
+ print_msg({"role": "assistant", "content": turn.text, "_node": node})
198
+ chat_turns.append({
199
+ "step": len(chat_turns) + 1,
200
+ "bot": turn.text or "",
201
+ "user": raw,
202
+ "node": node,
203
+ "ts": datetime.now(timezone.utc).isoformat(),
204
+ })
205
+
206
+ # Save traversal after loop exits
207
+ if chat_turns:
208
+ try:
209
+ traversal = build_traversal(
210
+ machine, chat_turns, flow, source, MODEL, started_at
211
+ )
212
+ saved_path = save_traversal(traversal, TRAVERSAL_DIR)
213
+ print(f"\n {GRN}✓ Traversal saved:{R} {B}{saved_path}{R}")
214
+ print(f" {DIM} {len(traversal['traversal'])} steps │ "
215
+ f"{sum(1 for n in traversal['graph']['nodes'] if n['visited'])} nodes visited{R}\n")
216
+ except Exception as e:
217
+ print(f"\n {YLW}Warning: traversal save failed: {e}{R}\n")
218
+
219
+
220
+ async def main_async(generate: bool):
221
+ import asyncio as _aio
222
+ if generate:
223
+ await generate_and_save()
224
+ elif not os.path.exists(FLOW_PATH):
225
+ print(f"{YLW}No flow found at:{R} {FLOW_PATH}")
226
+ print(f"{DIM}Run with --generate first to create one.{R}")
227
+ sys.exit(1)
228
+ await chat(FLOW_PATH)
229
+ await _aio.sleep(0.15) # let SSL connections flush before loop closes
230
+
231
+
232
+ def main():
233
+ p = argparse.ArgumentParser(description=__doc__,
234
+ formatter_class=argparse.RawDescriptionHelpFormatter)
235
+ p.add_argument("--generate", action="store_true",
236
+ help="Generate new flow from GENERATE_PROMPT, save, then chat")
237
+ args = p.parse_args()
238
+
239
+ if not os.environ.get("OPENAI_API_KEY") and MODEL.startswith("openai/"):
240
+ print(f"{YLW}Warning: OPENAI_API_KEY not set{R}")
241
+
242
+ asyncio.run(main_async(args.generate))
243
+
244
+
245
+ if __name__ == "__main__":
246
+ main()
@@ -0,0 +1,95 @@
1
+ # SuperDialog — Overview
2
+
3
+ **Status:** Canonical
4
+ **Parent:** [README.md](README.md)
5
+
6
+ ---
7
+
8
+ ## 1. What it is
9
+
10
+ A Python library that turns a prompt or a flow graph into an executable dialog state machine. Pure text in, pure text out. Plays the role of the "brain" in conversational systems.
11
+
12
+ ## 2. Why standalone
13
+
14
+ Two reasons:
15
+
16
+ **(a) The brain has natural reuse beyond voice.** A dialog state machine that runs a customer-onboarding flow works the same whether the user is on a phone, a WhatsApp thread, an Intercom widget, or a CLI test harness. Coupling it to telephony forecloses every non-voice use case.
17
+
18
+ **(b) The dependency direction matters.** Voice Infrastructure should depend on SuperDialog (as one brain option), not the other way around. Putting SuperDialog inside the platform makes the platform non-modular and the framework non-portable.
19
+
20
+ > *"उस machine को release करने का more less idea यह है... इस architecture से इन इस infrastructure से उसका कोई लेना देना नहीं है."*
21
+
22
+ ## 3. Why OSS
23
+
24
+ - **Community pull.** LiveKit and PipeCat owe their adoption to OSS. Releasing a strong dialog framework — with good docs, working LiveKit/PipeCat adapters, and a CLI chatbot mode for evaluation — creates a top-of-funnel that no closed product can match.
25
+ - **Lower support burden.** Developers who build complex flows will keep modifying them. If the framework is theirs to fork, our team is not in the loop for every prompt change.
26
+ - **Trust.** Buyers who don't want vendor lock-in see an open core and engage further. The closed parts (telephony, voice profiles) are the parts they don't care about owning.
27
+
28
+ ## 4. Why it ships first
29
+
30
+ Three reasons:
31
+
32
+ **(a) It already exists.** The dialog state machine code is the most mature part of the Unpod stack. Polishing it for OSS release is faster than building new telephony infrastructure.
33
+
34
+ **(b) Independent shippability.** It needs no telephony, no speech, no media server, no Room — none of the platform pieces. Therefore nothing on the platform side gates it.
35
+
36
+ **(c) Validation channel.** Public release is the cheapest way to learn whether the framework actually solves the *"developer wants to own their flow"* problem we hypothesize. If the OSS adoption signal is weak, the Voice Infra GTM (which depends on the same hypothesis) needs rethinking before we burn cycles on it.
37
+
38
+ ## 5. Positioning
39
+
40
+ SuperDialog is to **conversation flow** what n8n is to **integration workflow** — a simple, composable, eval-able runtime for orchestrating turn-by-turn logic. Where LangChain and LangGraph expose agent primitives, SuperDialog focuses narrowly on the conversational state machine: who speaks next, what flow to switch to, when to call a tool, when to escalate.
41
+
42
+ It is intentionally smaller than LangChain in surface area. The pitch is: *"if your problem is conversation state, this is the right size."*
43
+
44
+ ## 6. Audiences
45
+
46
+ | Audience | Why they care |
47
+ |---|---|
48
+ | **Voice developer using LiveKit / PipeCat today** | Drop SuperDialog in as the brain; stop hand-writing turn logic |
49
+ | **Chatbot developer (text-only)** | Use SuperDialog directly with FastAPI; test as a CLI chat |
50
+ | **Enterprise dev with their own LLM** | Plug their custom LLM URI (`custom/internal/...`) and get the rest of the framework for free |
51
+ | **Unpod Voice Infra customer** | SuperDialog is the default brain Unpod offers; same code runs locally and inside Unpod cloud |
52
+
53
+ ## 7. What it does well
54
+
55
+ | Capability | Status |
56
+ |---|---|
57
+ | Prompt → flow: `await create_dialog_flow(prompt=..., llm=...)` | shipped (v0.1) |
58
+ | Turn execution: `await dialog_machine.turn(text)` | shipped (v0.1) |
59
+ | LLM provider abstraction (model URIs) | shipped (v0.1) |
60
+ | Tools: Python callables, HTTP endpoints, MCP servers | shipped (v0.1) |
61
+ | Mid-conversation flow switching (`FlowSet`, `switch_flow`) | shipped (v0.1) |
62
+ | CLI: `chat`, `flow lint / draw / generate` | shipped (v0.1) |
63
+ | Adapters: LiveKit `DialogMachineLLM`, PipeCat `make_processor`, FastAPI, WebSocket | shipped (v0.1) |
64
+ | `Agent` Protocol + `Session` + `SessionWorker` (multi-conversation lifecycle, in-process persistence, per-session locking) | shipped (v0.2) |
65
+ | `LLMAgent`, `LangChainAgent` (non-DM brains usable in SessionWorker) | shipped (v0.2) |
66
+ | `assist(text)` (renamed from `inject_system`) | shipped (v0.2) |
67
+ | Distributed stores (`RedisSessionStore`, `FileSessionStore`, `SQLiteSessionStore`) + `RedisLockBackend` | planned (v0.3) |
68
+ | Pluggable HTTP auth (`BearerAuth`, `BasicAuth`, callable) | planned (v0.3) |
69
+ | `Eval` harness + `superdialog eval` CLI | planned (v0.3) |
70
+ | True provider-level streaming inference | planned (v0.4) |
71
+ | Streaming-interruption (`UserChunk`/`AgentChunk` protocol) | planned (v0.4) |
72
+
73
+ ## 8. What it explicitly is not
74
+
75
+ - **Not a UI flow designer.** That belongs to a downstream tool (future, n8n-style).
76
+ - **Not a voice framework.** Audio/STT/TTS are out of scope.
77
+ - **Not multi-modal.** Text only at the interface. (Vision/audio inputs through tools, if needed.)
78
+ - **Not a hosted service.** A library. Hosting is offered by Voice Infra for those who want it.
79
+
80
+ ## 9. Success criteria
81
+
82
+ - **GitHub stars and forks.** Baseline target TBD, but real numbers — not vanity metrics.
83
+ - **Adapter usage.** Are developers actually plugging SuperDialog into LiveKit and PipeCat? Telemetry from optional usage pings if they opt in.
84
+ - **Eval adoption.** Are developers running the eval harness, or just using the runtime? The eval is part of what differentiates this from "yet another agent framework."
85
+ - **Issue and PR volume.** OSS health.
86
+ - **Unpod Voice Infra trial conversion.** Of the OSS users who try Voice Infra, what fraction stick? This is the funnel justification for releasing the framework freely.
87
+
88
+ ## 10. Anti-goals
89
+
90
+ We will refuse to:
91
+ - Add features that only matter on a phone call (audio handling, RTP, SIP, etc.).
92
+ - Tie OSS releases to Unpod account creation.
93
+ - Use the OSS as a freemium ladder where critical features are paid. The framework is fully usable without ever paying Unpod.
94
+
95
+ The paid product is the Speech Pipe. The framework is the loss leader.