agentbuildkit-templates 0.2.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 (50) hide show
  1. agentbuildkit_templates-0.2.0/.gitignore +32 -0
  2. agentbuildkit_templates-0.2.0/LICENSE +202 -0
  3. agentbuildkit_templates-0.2.0/PKG-INFO +27 -0
  4. agentbuildkit_templates-0.2.0/README.md +15 -0
  5. agentbuildkit_templates-0.2.0/agentbuildkit_templates/__init__.py +12 -0
  6. agentbuildkit_templates-0.2.0/agentbuildkit_templates/compat.py +64 -0
  7. agentbuildkit_templates-0.2.0/agentbuildkit_templates/customer_service/README.md +73 -0
  8. agentbuildkit_templates-0.2.0/agentbuildkit_templates/customer_service/__init__.py +37 -0
  9. agentbuildkit_templates-0.2.0/agentbuildkit_templates/customer_service/__main__.py +6 -0
  10. agentbuildkit_templates-0.2.0/agentbuildkit_templates/customer_service/business.py +185 -0
  11. agentbuildkit_templates-0.2.0/agentbuildkit_templates/customer_service/cli.py +308 -0
  12. agentbuildkit_templates-0.2.0/agentbuildkit_templates/customer_service/connections.py +598 -0
  13. agentbuildkit_templates-0.2.0/agentbuildkit_templates/customer_service/dashboard.py +1042 -0
  14. agentbuildkit_templates-0.2.0/agentbuildkit_templates/customer_service/dashboard_model.py +340 -0
  15. agentbuildkit_templates-0.2.0/agentbuildkit_templates/customer_service/dashboard_view.py +1710 -0
  16. agentbuildkit_templates-0.2.0/agentbuildkit_templates/customer_service/draft_pages.py +440 -0
  17. agentbuildkit_templates-0.2.0/agentbuildkit_templates/customer_service/evaluation.py +575 -0
  18. agentbuildkit_templates-0.2.0/agentbuildkit_templates/customer_service/health.py +37 -0
  19. agentbuildkit_templates-0.2.0/agentbuildkit_templates/customer_service/models.py +113 -0
  20. agentbuildkit_templates-0.2.0/agentbuildkit_templates/customer_service/recovery.py +290 -0
  21. agentbuildkit_templates-0.2.0/agentbuildkit_templates/customer_service/service.py +245 -0
  22. agentbuildkit_templates-0.2.0/agentbuildkit_templates/customer_service/sheets.py +460 -0
  23. agentbuildkit_templates-0.2.0/agentbuildkit_templates/customer_service/static/dashboard.css +283 -0
  24. agentbuildkit_templates-0.2.0/agentbuildkit_templates/customer_service/static/dashboard.js +87 -0
  25. agentbuildkit_templates-0.2.0/agentbuildkit_templates/customer_service/static/fonts/OFL-GeistMono.txt +93 -0
  26. agentbuildkit_templates-0.2.0/agentbuildkit_templates/customer_service/static/fonts/OFL-InstrumentSans.txt +93 -0
  27. agentbuildkit_templates-0.2.0/agentbuildkit_templates/customer_service/static/fonts/geist-mono-latin-400-normal.woff2 +0 -0
  28. agentbuildkit_templates-0.2.0/agentbuildkit_templates/customer_service/static/fonts/geist-mono-latin-500-normal.woff2 +0 -0
  29. agentbuildkit_templates-0.2.0/agentbuildkit_templates/customer_service/static/fonts/instrument-sans-latin-400-normal.woff2 +0 -0
  30. agentbuildkit_templates-0.2.0/agentbuildkit_templates/customer_service/static/fonts/instrument-sans-latin-500-normal.woff2 +0 -0
  31. agentbuildkit_templates-0.2.0/agentbuildkit_templates/customer_service/static/fonts/instrument-sans-latin-600-normal.woff2 +0 -0
  32. agentbuildkit_templates-0.2.0/agentbuildkit_templates/customer_service/team.json +52 -0
  33. agentbuildkit_templates-0.2.0/agentbuildkit_templates/customer_service/team.py +233 -0
  34. agentbuildkit_templates-0.2.0/agentbuildkit_templates/office/__init__.py +1 -0
  35. agentbuildkit_templates-0.2.0/agentbuildkit_templates/office/clients.py +126 -0
  36. agentbuildkit_templates-0.2.0/agentbuildkit_templates/office/installation.py +360 -0
  37. agentbuildkit_templates-0.2.0/agentbuildkit_templates/office/mcp.py +58 -0
  38. agentbuildkit_templates-0.2.0/agentbuildkit_templates/office/reporting.py +279 -0
  39. agentbuildkit_templates-0.2.0/agentbuildkit_templates/office/server.py +697 -0
  40. agentbuildkit_templates-0.2.0/agentbuildkit_templates/office/templates.py +100 -0
  41. agentbuildkit_templates-0.2.0/agentbuildkit_templates/operations_reporting/README.md +20 -0
  42. agentbuildkit_templates-0.2.0/agentbuildkit_templates/operations_reporting/__init__.py +5 -0
  43. agentbuildkit_templates-0.2.0/agentbuildkit_templates/operations_reporting/evaluation.py +147 -0
  44. agentbuildkit_templates-0.2.0/agentbuildkit_templates/operations_reporting/jobs.py +106 -0
  45. agentbuildkit_templates-0.2.0/agentbuildkit_templates/operations_reporting/models.py +34 -0
  46. agentbuildkit_templates-0.2.0/agentbuildkit_templates/operations_reporting/service.py +84 -0
  47. agentbuildkit_templates-0.2.0/agentbuildkit_templates/operations_reporting/sheets.py +77 -0
  48. agentbuildkit_templates-0.2.0/agentbuildkit_templates/operations_reporting/team.json +28 -0
  49. agentbuildkit_templates-0.2.0/agentbuildkit_templates/operations_reporting/team.py +88 -0
  50. agentbuildkit_templates-0.2.0/pyproject.toml +28 -0
@@ -0,0 +1,32 @@
1
+ # Python
2
+ .venv/
3
+ __pycache__/
4
+ *.py[cod]
5
+ *.egg-info/
6
+ .pytest_cache/
7
+ .ruff_cache/
8
+ .pyright/
9
+ .mypy_cache/
10
+ .coverage
11
+ htmlcov/
12
+ dist/
13
+ build/
14
+
15
+ # Secrets and local telemetry
16
+ .env
17
+ .env.*
18
+ !.env.example
19
+ traces/
20
+ .data/
21
+ *.sqlite
22
+ *.sqlite3
23
+ *.sqlite-journal
24
+ *.sqlite-wal
25
+ *.sqlite-shm
26
+ *.db
27
+
28
+ # Local design-tool state. It is not part of the release.
29
+ .impeccable/
30
+
31
+ # OS and editors
32
+ .DS_Store
@@ -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,27 @@
1
+ Metadata-Version: 2.5
2
+ Name: agentbuildkit-templates
3
+ Version: 0.2.0
4
+ Summary: First-party Customer Service and Operations Reporting templates for AgentBuildKit.
5
+ Author: AgentBuildKit
6
+ Maintainer: AgentBuildKit
7
+ License-Expression: Apache-2.0
8
+ License-File: LICENSE
9
+ Requires-Python: >=3.12
10
+ Requires-Dist: agentbuildkit<0.3.0,>=0.2.0
11
+ Description-Content-Type: text/markdown
12
+
13
+ # AgentBuildKit templates
14
+
15
+ This directory is the `agentbuildkit-templates` package. The installed import
16
+ name is `agentbuildkit_templates`. It contains the Customer Service and
17
+ Operations Reporting applications and the local office that registers those
18
+ two templates.
19
+
20
+ The harness imports `agentbuildkit_templates` by that module name. It does
21
+ not scan installed packages for other templates. The directories
22
+ `customer_service/` and `office/` at this level are checkout wrappers for
23
+ `python -m`. They are not installed.
24
+
25
+ See [docs/install.md](../docs/install.md) for the local wheel install. The
26
+ checkout commands in each example README remain available while developing
27
+ inside this repository.
@@ -0,0 +1,15 @@
1
+ # AgentBuildKit templates
2
+
3
+ This directory is the `agentbuildkit-templates` package. The installed import
4
+ name is `agentbuildkit_templates`. It contains the Customer Service and
5
+ Operations Reporting applications and the local office that registers those
6
+ two templates.
7
+
8
+ The harness imports `agentbuildkit_templates` by that module name. It does
9
+ not scan installed packages for other templates. The directories
10
+ `customer_service/` and `office/` at this level are checkout wrappers for
11
+ `python -m`. They are not installed.
12
+
13
+ See [docs/install.md](../docs/install.md) for the local wheel install. The
14
+ checkout commands in each example README remain available while developing
15
+ inside this repository.
@@ -0,0 +1,12 @@
1
+ """First-party Customer Service and Operations Reporting templates.
2
+
3
+ The harness imports this package by name. It does not search for other
4
+ template packages. Importing this package checks that the installed harness
5
+ provides the capabilities these templates call.
6
+ """
7
+
8
+ from agentbuildkit_templates.compat import HARNESS_RELEASE_BOUND, require_harness
9
+
10
+ require_harness()
11
+
12
+ __all__ = ["HARNESS_RELEASE_BOUND", "require_harness"]
@@ -0,0 +1,64 @@
1
+ """Reject a harness that does not provide the capabilities these templates call.
2
+
3
+ The published ``agentbuildkit`` 0.1.0 package does not provide these
4
+ capabilities. ``HARNESS_RELEASE_BOUND`` is the templates dependency for the
5
+ 0.2.0 release. The check still runs so a forced install of an older harness
6
+ fails before the templates import missing modules.
7
+ """
8
+
9
+ import importlib
10
+ from importlib.metadata import PackageNotFoundError, version
11
+
12
+ REQUIRED_CAPABILITIES = (
13
+ ("agentbuildkit.applications", "RenderedPage"),
14
+ ("agentbuildkit.teams", "load_bundle_json"),
15
+ ("agentbuildkit.revisions", "RevisionService"),
16
+ ("agentbuildkit.revisions.store", "StartupLockError"),
17
+ ("agentbuildkit.drafting", "build_server"),
18
+ )
19
+
20
+ HARNESS_RELEASE_BOUND = "agentbuildkit>=0.2.0,<0.3.0"
21
+
22
+
23
+ class HarnessIncompatible(RuntimeError):
24
+ """The installed harness cannot run these templates."""
25
+
26
+
27
+ def require_harness() -> None:
28
+ """Raise when the installed harness is missing a required capability."""
29
+ missing = tuple(
30
+ f"{module_name}.{attribute}"
31
+ for module_name, attribute in REQUIRED_CAPABILITIES
32
+ if not _provides(module_name, attribute)
33
+ )
34
+ if missing:
35
+ raise HarnessIncompatible(_message(missing))
36
+
37
+
38
+ def _provides(module_name: str, attribute: str) -> bool:
39
+ try:
40
+ module = importlib.import_module(module_name)
41
+ except ImportError:
42
+ return False
43
+ return hasattr(module, attribute)
44
+
45
+
46
+ def _installed_version() -> str:
47
+ try:
48
+ return version("agentbuildkit")
49
+ except PackageNotFoundError:
50
+ return "unknown"
51
+
52
+
53
+ def _message(missing: tuple[str, ...]) -> str:
54
+ installed = _installed_version()
55
+ needed = ", ".join(missing)
56
+ return (
57
+ "agentbuildkit-templates cannot use this harness. "
58
+ f"The installed agentbuildkit package is {installed}. "
59
+ f"These templates need {needed}. "
60
+ f"These templates require {HARNESS_RELEASE_BOUND}. "
61
+ "The published agentbuildkit 0.1.0 package does not provide them. "
62
+ "Install the 0.2.0 harness and templates together. Until that release is "
63
+ "published, install the harness and templates built from the same revision."
64
+ )
@@ -0,0 +1,73 @@
1
+ # Customer-service example
2
+
3
+ This package demonstrates an agent team built with AgentBuildKit. It is fixture data, not a connection to a CRM or a live customer-service backend.
4
+
5
+ - Alex classifies a typed request.
6
+ - Python routes that decision to Sam or Taylor, and rejects any other name.
7
+ - Sam reads account data. Taylor reads service data and may propose one action.
8
+ - Jordan approves, rejects, or escalates the draft.
9
+ - An informational answer is returned immediately.
10
+ - A service change pauses for a person and is stored. Approval runs it at most once.
11
+
12
+ The business system is an in-process HTTP mock at `http://business.test`. It does not call a network. `LOCAL_MOCK_TOKEN` is a fixture marker. The only customer reference is `A-100`, with fixture account name Northwind.
13
+
14
+ Each role declares its own provider and model. The runnable default uses `openai` and `gpt-4.1-mini` for every role, so a live run needs `OPENAI_API_KEY` only. `production_clients()` asks the provider registry for one client per role. Offline tests pass a `ScriptedChatClient` per role to `build_team(clients=...)` and do not construct a live client.
15
+
16
+ The default team asks the registry for an OpenAI client per role:
17
+
18
+ ```python
19
+ from agentbuildkit_templates.customer_service import build_team, handle_request, production_clients
20
+
21
+ team = build_team(clients=production_clients(), api_token=token)
22
+ ```
23
+
24
+ Switch Taylor to Anthropic without changing the workflow. Sam stays on OpenAI. That live client also needs `ANTHROPIC_API_KEY`.
25
+
26
+ ```python
27
+ from agentbuildkit.providers import ProviderConfiguration
28
+ from agentbuildkit_templates.customer_service import build_team, production_clients
29
+
30
+ roles = {"taylor": ProviderConfiguration(provider="anthropic", model="claude-sonnet-4-5")}
31
+ team = build_team(clients=production_clients(roles=roles), api_token=token)
32
+ ```
33
+
34
+ A local live run:
35
+
36
+ ```bash
37
+ PYTHONPATH=examples uv run python -m customer_service
38
+ ```
39
+
40
+ The same team can be opened in a local dashboard beside Operations Reporting. The selector chooses which team is on screen. The server still checks that a run or approval belongs to that team. SQLite files are opened on the dashboard's owner thread; browser requests only dispatch work to that thread. Set `APP_STATE_DIRECTORY` so a restarted process can recover pending approvals and the audit ledger. Opening an older database writes a backup copy, then keeps the existing customer-service rows under that team id. It does not delete the database. The customer reference, action arguments, and shown outcome text are stored beside that directory. They are not written to the audit ledger and are not exported telemetry. If those arguments were not recovered, approval does not run the action. If the process stops after the action is reserved and before completion is recorded, it stays unresolved and is not sent again. This is not exactly-once delivery to the business system.
41
+
42
+ ```bash
43
+ PYTHONPATH=examples uv run python -m customer_service.dashboard
44
+ ```
45
+
46
+ That module command is the checkout wrapper. After `agentbuildkit-templates` is installed from a local wheel, the same dashboard is `agentkit dashboard`. See [Install](../../docs/install.md). The published 0.1.0 package does not include it. The upcoming 0.2.0 install is documented there and is not published yet.
47
+
48
+ `APP_STATE_DIRECTORY` in `.env` overrides the same variable in the shell. `--state-directory` selects the directory for one process and leaves `.env` unchanged. Provider settings still come from `.env` and the process environment. A check with a fake `.env` pointed at a sentinel directory wrote the workflow, revision, recovery, and connection databases, and a revision migration backup, only in the directory named by the flag. The sentinel was unchanged. A shell assignment alone was not shown to select a temporary directory when `.env` already sets `APP_STATE_DIRECTORY`. Earlier preview processes started that way do not have an established storage location.
49
+
50
+ ```bash
51
+ mkdir -p /tmp/agentbuildkit-try
52
+ PYTHONPATH=src:examples uv run python -m customer_service.dashboard --state-directory /tmp/agentbuildkit-try
53
+ ```
54
+
55
+ Create team, at `/teams/new`, adds an inactive instance of one of the two registered templates, Customer Service or Operations Reporting. It does not generate a workflow or accept another template. The instance can take a request only after you validate the draft, run the offline evaluation, and activate that revision. The evaluation uses scripted clients. It does not measure a live model or show that a provider account or a spreadsheet connection is ready. Repeating the same creation request returns that team. A different name, description, template, or team id for the same request conflicts and does not change the original. Editing a draft versions that instance. Edit active version copies the revision in use. Reset from shipped template is a separate action. Editing one team does not create another team. A new instance has no spreadsheet assignment until one is saved for it. With `APP_STATE_DIRECTORY` or `--state-directory` set, drafts and published revisions stay in `revisions.sqlite` in that directory. Without it they last only until the process stops. Saving, validating, and the scripted suite do not activate a revision. The overview lists what needs attention (approvals waiting, and actions that failed or whose outcome is unknown), recent runs, the team, and the offline evaluation. A run page shows the route recorded for that request, its status history, the approval decision, and its audit events. The page shows only what the service, workflow store, recovery file, and audit ledger record: outcomes have no timestamps, and the customer's message is not stored. The styles, script, and fonts are served from `static/`; the fonts are Instrument Sans and Geist Mono under the SIL Open Font Licence.
56
+
57
+ A live run of the default team needs `OPENAI_API_KEY`. The model for each role is the model on that agent's definition.
58
+
59
+ Google Sheets is an optional connected read for Sam. Demo mode still answers account questions from fixture account A-100 and the name Northwind. Connected mode answers those questions from one spreadsheet id and one sheet range that you save on Sam's page. A missing connection, a failed read, or a result larger than the saved window stays an error. The server does not return a clipped sheet, and it does not return the fixture.
60
+
61
+ Local setup, still on this machine:
62
+
63
+ 1. `uv sync --extra composio`. A normal `uv sync` does not install this extra.
64
+ 2. Put `COMPOSIO_API_KEY` in `.env`. Leave it empty in `.env.example`. The dashboard reads it on the server and does not show it.
65
+ 3. Set `APP_STATE_DIRECTORY` so the connection reference and assignments are kept in `connections.sqlite` beside the workflow database. Without that directory they last only for the process. Restart the dashboard after changing `.env`.
66
+ 4. In Google Cloud, enable the Google Sheets API. On the OAuth consent screen, add only `https://www.googleapis.com/auth/spreadsheets.readonly` and add your Google account as a test user. Create a web OAuth client. Leave Authorized JavaScript origins empty. Set the authorized redirect URI to `https://backend.composio.dev/api/v3/toolkits/auth/callback`.
67
+ 5. In Composio, create a custom Google Sheets auth config, not the managed Google app. The managed app cannot request the read-only Sheets scope. Use the same redirect URI, and request only `https://www.googleapis.com/auth/spreadsheets.readonly`. Put that config's `ac_` id in `COMPOSIO_GOOGLESHEETS_AUTH_CONFIG_ID`. Leave the placeholder empty in `.env.example`. Connect stays off until it is set.
68
+ 6. Open the dashboard and use Connections. Connect Google Sheets. Composio hosts the sign-in and sends the browser back to `http://127.0.0.1:<port>/connections/callback`. The server checks that return against the browser session and the Composio account before saving a connection reference. It does not store the Google token. Before opening sign-in it reads the auth config metadata and requires the Google Sheets toolkit and only the read-only scope. A missing toolkit, custom-app flag, or scope list does not start sign-in.
69
+ 7. On Sam's page, enter the spreadsheet id and one range that contains every column Sam should see, such as `Accounts!A1:C2`, then choose connected mode. `Accounts!A1:B20` does not include column C. The only read is `GOOGLESHEETS_BATCH_GET`, pinned to toolkit version `20261101_00`. The server rejects another spreadsheet, a range outside that window, and every write. The window is at most 100 rows, 26 columns, and 200 cells.
70
+
71
+ Limiting Sam to that read does not change the Google grant. The consent screen is the list you approve. Continue only when it asks to see spreadsheets for your own app. Stop if it asks to edit spreadsheets, to see or change Drive files, or to reach another Google product. An External app in Testing can show an unverified-app warning, and Google may expire that test grant after seven days. This local milestone does not submit the app for verification.
72
+
73
+ Connecting does not assign the account. Demo mode stays on Sam's page and is labelled separately. Removing the assignment on Sam's page clears only that window. Disconnect removes the local connection and every assignment that uses it, including another team's window. It does not revoke Google access. Connected mode does not answer from the demo fixture after that disconnect until you explicitly choose demo data. Sheet values are untrusted data and cannot change tools or instructions. There is no public or multi-user mode. Keep the dashboard on `127.0.0.1`. The page allows the https sign-in redirect that follows Connect, and it still refuses form posts to any other http host.
@@ -0,0 +1,37 @@
1
+ """Customer-service demonstration built on AgentBuildKit.
2
+
3
+ The records, including reference ``A-100``, are fixture data.
4
+ """
5
+
6
+ from agentbuildkit_templates.customer_service.evaluation import (
7
+ LOCAL_MOCK_TOKEN,
8
+ organisation_cases,
9
+ run_organisation_evaluation,
10
+ )
11
+ from agentbuildkit_templates.customer_service.models import CustomerRequest, FinalOutcome
12
+ from agentbuildkit_templates.customer_service.service import (
13
+ ServiceResult,
14
+ handle_request,
15
+ resume_service_action,
16
+ )
17
+ from agentbuildkit_templates.customer_service.team import (
18
+ ORGANISATION_SCOPE,
19
+ Organisation,
20
+ build_team,
21
+ production_clients,
22
+ )
23
+
24
+ __all__ = [
25
+ "LOCAL_MOCK_TOKEN",
26
+ "ORGANISATION_SCOPE",
27
+ "CustomerRequest",
28
+ "FinalOutcome",
29
+ "Organisation",
30
+ "ServiceResult",
31
+ "build_team",
32
+ "handle_request",
33
+ "organisation_cases",
34
+ "production_clients",
35
+ "resume_service_action",
36
+ "run_organisation_evaluation",
37
+ ]
@@ -0,0 +1,6 @@
1
+ """Run the reference organisation from the command line."""
2
+
3
+ from agentbuildkit_templates.customer_service.cli import main
4
+
5
+ if __name__ == "__main__":
6
+ main()
@@ -0,0 +1,185 @@
1
+ """Fixture business API for the customer-service example.
2
+
3
+ The HTTP client talks to an in-process mock at ``http://business.test``.
4
+ It does not call a network, a CRM, or a live customer-service backend.
5
+ Reference ``A-100`` and the account name Northwind are fixture data.
6
+ Reads are allowlisted tools. The one write is a separate side-effect tool
7
+ and is not given to either specialist.
8
+ """
9
+
10
+ import json
11
+ from typing import Any, cast
12
+
13
+ import httpx
14
+ from agent_framework import SecretString
15
+
16
+ from agentbuildkit.guardrails import ApprovalDecision, ToolEffect, prepare_tool
17
+ from agentbuildkit.integrations import HttpClient
18
+ from agentbuildkit.observability import AuditLog, current_correlation_id
19
+ from agentbuildkit_templates.customer_service.models import (
20
+ AccountView,
21
+ ActionReceipt,
22
+ ReferenceQuery,
23
+ ServiceActionRequest,
24
+ ServiceView,
25
+ )
26
+
27
+ # Fixture data. A-100 is not a live customer.
28
+ _ACCOUNTS = {
29
+ "A-100": {"account_name": "Northwind", "balance": "120.00"},
30
+ }
31
+ _SERVICES = {
32
+ "A-100": {"service_status": "open"},
33
+ }
34
+
35
+
36
+ class BusinessSystem:
37
+ """The mock company system and the tools that may call it."""
38
+
39
+ def __init__(
40
+ self,
41
+ *,
42
+ audit_log: AuditLog,
43
+ api_token: SecretString,
44
+ actions: list[str] | None = None,
45
+ ) -> None:
46
+ self.actions = actions if actions is not None else []
47
+ self.account_reads: list[str] = []
48
+ self.service_reads: list[str] = []
49
+ self.api = HttpClient(
50
+ name="business-api",
51
+ base_url="http://business.test",
52
+ audit_log=audit_log,
53
+ header_provider=lambda: {"Authorization": api_token},
54
+ transport=_transport(self, api_token),
55
+ )
56
+ self.read_account = prepare_tool(
57
+ self._read_account,
58
+ effect=ToolEffect.READ,
59
+ name="read_account",
60
+ description="Read one customer account. This cannot change the account.",
61
+ )
62
+ self.read_service = prepare_tool(
63
+ self._read_service,
64
+ effect=ToolEffect.READ,
65
+ name="read_service",
66
+ description="Read one service record. This cannot change the record.",
67
+ )
68
+ self.schedule_service = prepare_tool(
69
+ self._schedule_service,
70
+ effect=ToolEffect.SIDE_EFFECT,
71
+ name="schedule_service",
72
+ description="Schedule a service visit after a person has approved it.",
73
+ )
74
+
75
+ async def aclose(self) -> None:
76
+ await self.api.aclose()
77
+
78
+ async def demo_account(self, reference: str) -> str:
79
+ """Read the fixture account. Connected mode does not call this."""
80
+ return await self._read_account(reference)
81
+
82
+ async def _read_account(self, reference: str) -> str:
83
+ """Read one customer account. This cannot change the account."""
84
+ found = await self.api.read(
85
+ "/accounts",
86
+ response_type=AccountView,
87
+ operation="account.read",
88
+ query=ReferenceQuery(reference=reference),
89
+ correlation_id=current_correlation_id(),
90
+ )
91
+ return found.model_dump_json()
92
+
93
+ async def _read_service(self, reference: str) -> str:
94
+ """Read one service record. This cannot change the record."""
95
+ found = await self.api.read(
96
+ "/services",
97
+ response_type=ServiceView,
98
+ operation="service.read",
99
+ query=ReferenceQuery(reference=reference),
100
+ correlation_id=current_correlation_id(),
101
+ )
102
+ return found.model_dump_json()
103
+
104
+ async def _schedule_service(self, reference: str, action: str) -> str:
105
+ """Perform the service change after the workflow gate has approved it.
106
+
107
+ ``HttpClient.write`` asks for its own decision before it sends. This
108
+ function is invoked only by that gate, so the decision is supplied here.
109
+ """
110
+ receipt = await self.api.write(
111
+ "POST",
112
+ "/service-actions",
113
+ response_type=ActionReceipt,
114
+ operation="service.schedule",
115
+ body=ServiceActionRequest(reference=reference, action=action),
116
+ decision=ApprovalDecision("service.schedule", approved=True),
117
+ correlation_id=current_correlation_id(),
118
+ )
119
+ return receipt.status
120
+
121
+
122
+ def _transport(system: BusinessSystem, api_token: SecretString) -> httpx.MockTransport:
123
+ secret = api_token.get_secret_value()
124
+
125
+ def handle(request: httpx.Request) -> httpx.Response:
126
+ if request.headers.get("authorization") != secret:
127
+ return httpx.Response(401, json={"error": "unauthorized"})
128
+ if request.method == "GET" and request.url.path == "/accounts":
129
+ return _account(system, request.url.params.get("reference", ""))
130
+ if request.method == "GET" and request.url.path == "/services":
131
+ return _service(system, request.url.params.get("reference", ""))
132
+ if request.method == "POST" and request.url.path == "/service-actions":
133
+ return _schedule(system, request)
134
+ return httpx.Response(404, json={"error": "missing"})
135
+
136
+ return httpx.MockTransport(handle)
137
+
138
+
139
+ def _account(system: BusinessSystem, reference: str) -> httpx.Response:
140
+ record = _ACCOUNTS.get(reference)
141
+ if record is None:
142
+ return httpx.Response(404, json={"error": "missing"})
143
+ system.account_reads.append(reference)
144
+ return httpx.Response(
145
+ 200,
146
+ json={
147
+ "reference": reference,
148
+ "account_name": record["account_name"],
149
+ "balance": record["balance"],
150
+ },
151
+ )
152
+
153
+
154
+ def _service(system: BusinessSystem, reference: str) -> httpx.Response:
155
+ record = _SERVICES.get(reference)
156
+ if record is None:
157
+ return httpx.Response(404, json={"error": "missing"})
158
+ system.service_reads.append(reference)
159
+ return httpx.Response(
160
+ 200,
161
+ json={"reference": reference, "service_status": record["service_status"]},
162
+ )
163
+
164
+
165
+ def _schedule(system: BusinessSystem, request: httpx.Request) -> httpx.Response:
166
+ body = _object(json.loads(request.content))
167
+ if body is None:
168
+ return httpx.Response(400, json={"error": "invalid"})
169
+ reference = body.get("reference")
170
+ action = body.get("action")
171
+ if not isinstance(reference, str) or not isinstance(action, str):
172
+ return httpx.Response(400, json={"error": "invalid"})
173
+ system.actions.append(f"{reference}:{action}")
174
+ return httpx.Response(200, json={"reference": reference, "status": "scheduled"})
175
+
176
+
177
+ def _object(value: object) -> dict[str, Any] | None:
178
+ if not isinstance(value, dict):
179
+ return None
180
+ parsed: dict[str, Any] = {}
181
+ for key, item in cast(dict[Any, Any], value).items():
182
+ if not isinstance(key, str):
183
+ return None
184
+ parsed[key] = item
185
+ return parsed