tangram-app-sdk 0.1.0rc2__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 (80) hide show
  1. tangram_app_sdk-0.1.0rc2/.gitignore +7 -0
  2. tangram_app_sdk-0.1.0rc2/LICENSE +202 -0
  3. tangram_app_sdk-0.1.0rc2/PKG-INFO +410 -0
  4. tangram_app_sdk-0.1.0rc2/README.md +389 -0
  5. tangram_app_sdk-0.1.0rc2/conformance/backend-sdk-contract-1.json +224 -0
  6. tangram_app_sdk-0.1.0rc2/docs/actions-and-agents.md +291 -0
  7. tangram_app_sdk-0.1.0rc2/docs/cli-reference.md +92 -0
  8. tangram_app_sdk-0.1.0rc2/docs/local-runtime.md +203 -0
  9. tangram_app_sdk-0.1.0rc2/docs/manifest-authoring.md +135 -0
  10. tangram_app_sdk-0.1.0rc2/docs/sdk-guide.md +206 -0
  11. tangram_app_sdk-0.1.0rc2/docs/sdk-host-abi.md +156 -0
  12. tangram_app_sdk-0.1.0rc2/docs/security-and-operations.md +166 -0
  13. tangram_app_sdk-0.1.0rc2/pyproject.toml +34 -0
  14. tangram_app_sdk-0.1.0rc2/schema/capability-graph.schema.json +179 -0
  15. tangram_app_sdk-0.1.0rc2/src/tangram_app/__init__.py +183 -0
  16. tangram_app_sdk-0.1.0rc2/src/tangram_app/__main__.py +4 -0
  17. tangram_app_sdk-0.1.0rc2/src/tangram_app/app.py +295 -0
  18. tangram_app_sdk-0.1.0rc2/src/tangram_app/backend_runtime_sdk.py +401 -0
  19. tangram_app_sdk-0.1.0rc2/src/tangram_app/cli.py +567 -0
  20. tangram_app_sdk-0.1.0rc2/src/tangram_app/cli_actions.py +117 -0
  21. tangram_app_sdk-0.1.0rc2/src/tangram_app/cli_connections.py +79 -0
  22. tangram_app_sdk-0.1.0rc2/src/tangram_app/compiler.py +664 -0
  23. tangram_app_sdk-0.1.0rc2/src/tangram_app/errors.py +105 -0
  24. tangram_app_sdk-0.1.0rc2/src/tangram_app/host.py +226 -0
  25. tangram_app_sdk-0.1.0rc2/src/tangram_app/http_driver.py +399 -0
  26. tangram_app_sdk-0.1.0rc2/src/tangram_app/local_actions.py +206 -0
  27. tangram_app_sdk-0.1.0rc2/src/tangram_app/local_connections.py +166 -0
  28. tangram_app_sdk-0.1.0rc2/src/tangram_app/local_database.py +384 -0
  29. tangram_app_sdk-0.1.0rc2/src/tangram_app/local_oauth.py +348 -0
  30. tangram_app_sdk-0.1.0rc2/src/tangram_app/local_os.py +168 -0
  31. tangram_app_sdk-0.1.0rc2/src/tangram_app/local_runtime.py +808 -0
  32. tangram_app_sdk-0.1.0rc2/src/tangram_app/local_schedules.py +495 -0
  33. tangram_app_sdk-0.1.0rc2/src/tangram_app/local_store.py +188 -0
  34. tangram_app_sdk-0.1.0rc2/src/tangram_app/local_ui.py +477 -0
  35. tangram_app_sdk-0.1.0rc2/src/tangram_app/manifest.py +575 -0
  36. tangram_app_sdk-0.1.0rc2/src/tangram_app/models.py +439 -0
  37. tangram_app_sdk-0.1.0rc2/src/tangram_app/pkl.py +212 -0
  38. tangram_app_sdk-0.1.0rc2/src/tangram_app/policy.py +73 -0
  39. tangram_app_sdk-0.1.0rc2/src/tangram_app/project.py +57 -0
  40. tangram_app_sdk-0.1.0rc2/src/tangram_app/schema.py +216 -0
  41. tangram_app_sdk-0.1.0rc2/src/tangram_app/skills.py +253 -0
  42. tangram_app_sdk-0.1.0rc2/src/tangram_app/skills_data/tangram-app-builder/SKILL.md +287 -0
  43. tangram_app_sdk-0.1.0rc2/src/tangram_app/skills_data/tangram-connector-builder/SKILL.md +224 -0
  44. tangram_app_sdk-0.1.0rc2/src/tangram_app/validation.py +1029 -0
  45. tangram_app_sdk-0.1.0rc2/tests/fixtures/blocked-env.pkl +1 -0
  46. tangram_app_sdk-0.1.0rc2/tests/fixtures/minimal-app/manifests/PklProject +1 -0
  47. tangram_app_sdk-0.1.0rc2/tests/fixtures/minimal-app/manifests/PklProject.deps.json +1 -0
  48. tangram_app_sdk-0.1.0rc2/tests/fixtures/minimal-app/manifests/api/open_api.yml +25 -0
  49. tangram_app_sdk-0.1.0rc2/tests/fixtures/minimal-app/manifests/api/resources.pkl +30 -0
  50. tangram_app_sdk-0.1.0rc2/tests/fixtures/minimal-app/manifests/api/spec.pkl +5 -0
  51. tangram_app_sdk-0.1.0rc2/tests/fixtures/minimal-app/manifests/app.pkl +7 -0
  52. tangram_app_sdk-0.1.0rc2/tests/fixtures/minimal-app/manifests/settings.pkl +8 -0
  53. tangram_app_sdk-0.1.0rc2/tests/fixtures/minimal-connector/manifests/PklProject +1 -0
  54. tangram_app_sdk-0.1.0rc2/tests/fixtures/minimal-connector/manifests/PklProject.deps.json +1 -0
  55. tangram_app_sdk-0.1.0rc2/tests/fixtures/minimal-connector/manifests/api/open_api.yml +12 -0
  56. tangram_app_sdk-0.1.0rc2/tests/fixtures/minimal-connector/manifests/api/resources.pkl +23 -0
  57. tangram_app_sdk-0.1.0rc2/tests/fixtures/minimal-connector/manifests/api/spec.pkl +10 -0
  58. tangram_app_sdk-0.1.0rc2/tests/fixtures/minimal-connector/manifests/app.pkl +7 -0
  59. tangram_app_sdk-0.1.0rc2/tests/fixtures/project-package/PklProject +5 -0
  60. tangram_app_sdk-0.1.0rc2/tests/fixtures/project-package/PklProject.deps.json +10 -0
  61. tangram_app_sdk-0.1.0rc2/tests/fixtures/project-package/main.pkl +3 -0
  62. tangram_app_sdk-0.1.0rc2/tests/fixtures/project-package-dependency/PklProject +8 -0
  63. tangram_app_sdk-0.1.0rc2/tests/fixtures/project-package-dependency/message.pkl +1 -0
  64. tangram_app_sdk-0.1.0rc2/tests/test_backend_sdk_conformance.py +107 -0
  65. tangram_app_sdk-0.1.0rc2/tests/test_builder_skill.py +129 -0
  66. tangram_app_sdk-0.1.0rc2/tests/test_cli_actions.py +173 -0
  67. tangram_app_sdk-0.1.0rc2/tests/test_cli_skill.py +411 -0
  68. tangram_app_sdk-0.1.0rc2/tests/test_compiler.py +238 -0
  69. tangram_app_sdk-0.1.0rc2/tests/test_http_driver.py +329 -0
  70. tangram_app_sdk-0.1.0rc2/tests/test_local_actions.py +183 -0
  71. tangram_app_sdk-0.1.0rc2/tests/test_local_connections.py +170 -0
  72. tangram_app_sdk-0.1.0rc2/tests/test_local_database.py +73 -0
  73. tangram_app_sdk-0.1.0rc2/tests/test_local_notifications.py +130 -0
  74. tangram_app_sdk-0.1.0rc2/tests/test_local_oauth.py +262 -0
  75. tangram_app_sdk-0.1.0rc2/tests/test_local_os.py +144 -0
  76. tangram_app_sdk-0.1.0rc2/tests/test_local_runtime.py +328 -0
  77. tangram_app_sdk-0.1.0rc2/tests/test_local_schedules.py +417 -0
  78. tangram_app_sdk-0.1.0rc2/tests/test_local_store.py +123 -0
  79. tangram_app_sdk-0.1.0rc2/tests/test_manifest.py +324 -0
  80. tangram_app_sdk-0.1.0rc2/tests/test_sdk.py +284 -0
@@ -0,0 +1,7 @@
1
+ __pycache__/
2
+ *.pyc
3
+ .pytest_cache/
4
+ .ruff_cache/
5
+ dist/
6
+ .venv/
7
+ .preview/
@@ -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,410 @@
1
+ Metadata-Version: 2.5
2
+ Name: tangram-app-sdk
3
+ Version: 0.1.0rc2
4
+ Summary: Python SDK for building, validating, and running Tangram apps and connectors locally
5
+ Project-URL: Homepage, https://github.com/tangram-data/tangram-app-manifest
6
+ Project-URL: Documentation, https://github.com/tangram-data/tangram-app-manifest/tree/main/python-sdk/docs
7
+ Project-URL: Source, https://github.com/tangram-data/tangram-app-manifest
8
+ Project-URL: Issues, https://github.com/tangram-data/tangram-app-manifest/issues
9
+ Author: Tangram
10
+ License-Expression: Apache-2.0
11
+ License-File: LICENSE
12
+ Keywords: agent,connector,manifest,sdk,tangram
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Requires-Python: >=3.11
19
+ Requires-Dist: pyyaml<7,>=6.0.2
20
+ Description-Content-Type: text/markdown
21
+
22
+ # Tangram App SDK for Python
23
+
24
+ The SDK documentation starts at [docs/sdk-guide.md](docs/sdk-guide.md). This
25
+ README provides the shorter repository overview and common examples.
26
+
27
+ This directory contains the first authoring and standalone runtime SDK layer for the
28
+ [Tangram App Manifest](../spec/README.md). It evaluates a real manifest package
29
+ with Pkl, decodes the result into Python dataclasses mirroring the public Scala
30
+ domain model, and separately loads compiled Tangram Capability Graphs for the
31
+ transport-independent action host.
32
+
33
+ The SDK is deliberately small. Its only Python dependency is PyYAML for
34
+ OpenAPI documents authored as YAML. It currently provides:
35
+
36
+ - immutable, validated capability-graph models;
37
+ - `Application`, `AppResourceTypeDefinition`, `AppResourceTypeVersion`,
38
+ `ResourceTypeAction`, `OpenApiMapping`, extractor, role, and configuration
39
+ dataclasses corresponding to the Scala manifest-facing classes;
40
+ - a restricted Python-driven `pkl eval` integration and standard package-entry
41
+ point loader;
42
+ - canonical action and binding lookup;
43
+ - JSON Schema input validation for the graph's supported schema subset;
44
+ - a read-only-by-default local development policy;
45
+ - one invocation path shared by future CLI, MCP, and HTTP adapters;
46
+ - pluggable execution drivers; and
47
+ - metadata-only audit events that do not record arguments or results.
48
+ - a `TangramApp` facade for package/graph discovery and local binding;
49
+ - a versioned JSON command surface through `python -m tangram_app` and
50
+ `tangram-app`; and
51
+ - integrity-locked portable agent-skill generation for shell-capable agents;
52
+ - a `TangramProject` facade for AI-assisted source validation and compilation;
53
+ - canonical `[tool.tangram.backend]` parsing and host-native FastAPI source
54
+ supervision; and
55
+ - a cached per-project Python 3.12 environment and staged backend `tangram`
56
+ module;
57
+ - a loopback per-project PostgreSQL provider with persistent `.preview/pgdata`
58
+ and checksum-ledgered migrations; and
59
+ - managed React component dependencies, esbuild compilation, and a loopback UI
60
+ host with a browser `window.tangram` bridge; and
61
+ - source-mode local calls that verify the live `/openapi.json` contract before
62
+ exposing any action.
63
+
64
+ It now compiles validated App and Connector mappings into a capability graph
65
+ and executes those bindings through a bounded HTTP driver, but does **not** yet
66
+ expose MCP. Agent skills use the Python command surface instead; protocol
67
+ adapters remain optional. The Tangram validator/compiler remains the publishing conformance authority;
68
+ Python's Pkl loader provides direct access to the manifest model and its draft
69
+ compiler derives the versioned runtime graph from the same evaluated values.
70
+ The graph wire contract is published as
71
+ [`schema/capability-graph.schema.json`](schema/capability-graph.schema.json).
72
+
73
+ ## Loading a manifest package
74
+
75
+ Install a compatible [Pkl CLI](https://pkl-lang.org/) and load the directory
76
+ that contains `manifests/`:
77
+
78
+ ```python
79
+ from tangram_app import PklManifestLoader
80
+
81
+ package = PklManifestLoader().load(".")
82
+
83
+ print(package.application.id)
84
+ orders = package.resource_type("Order")
85
+ list_orders = orders.active.action("List")
86
+ print(list_orders.effect, list_orders.all_open_api_mappings)
87
+ ```
88
+
89
+ The evaluator roots file access at the package directory, permits dependency
90
+ aliases declared by `PklProject`, rejects direct `package:` imports, and denies
91
+ ambient environment and author-defined external-property reads. Resolving a
92
+ declared dependency may still populate Pkl's package cache from its pinned
93
+ package URI; run with a pre-populated cache when validation must make no network
94
+ requests. Deployment expressions that require platform-injected properties are
95
+ outside this initial package-model loader.
96
+
97
+ ## Validating a package
98
+
99
+ `validate_manifest` returns structured findings instead of throwing on normal
100
+ manifest errors:
101
+
102
+ ```python
103
+ from tangram_app import validate_manifest
104
+
105
+ result = validate_manifest(".")
106
+
107
+ for finding in result.findings:
108
+ print(finding.severity.value, finding.code, finding.path, finding.message)
109
+
110
+ package = result.require_valid()
111
+ ```
112
+
113
+ Validation currently covers required layout and dependency locks, Pkl loading,
114
+ application metadata, settings and secrets, resource/version/action uniqueness,
115
+ required action semantics, OpenAPI 3 parsing, operation uniqueness, action
116
+ mapping and extractor resolution, Agent tool and skill shapes, Connector
117
+ endpoint/OAuth safety, application-type deployment restrictions, and core UI
118
+ component/path checks. Pkl schema constraints remain the first validation
119
+ layer; these checks handle relationships across evaluated files. App deployment
120
+ inputs and integration modules currently produce explicit coverage warnings;
121
+ use `tangram app manifest validate` for their authoritative schema-reflection
122
+ checks.
123
+
124
+ ## Compiling a capability graph
125
+
126
+ Compilation validates the package, selects active resource-type versions,
127
+ resolves mapped OpenAPI operations, flattens agent-facing inputs, records their
128
+ reverse path/query/header/body bindings, and calculates a deterministic digest
129
+ over `manifests/` and `libs/`:
130
+
131
+ ```python
132
+ from tangram_app import compile_manifest
133
+
134
+ compiled = compile_manifest(".")
135
+ graph = compiled.graph
136
+
137
+ print(graph.package.digest)
138
+ print(graph.actions[0].bindings[0].input_schema)
139
+ graph.write_file("dist/tangram-app.json")
140
+ ```
141
+
142
+ Only actions with `openApiMapping` or `openApiMappings` become executable graph
143
+ capabilities. Compilation findings retain validation warnings, including the
144
+ current deployment and integration coverage limits.
145
+
146
+ ## Using the facade and command line
147
+
148
+ `TangramApp.from_package` compiles source through Pkl. `from_graph` loads a
149
+ precompiled snapshot without Pkl. Runtime backend configuration is applied
150
+ separately with `bind`:
151
+
152
+ ```python
153
+ from tangram_app import TangramApp
154
+
155
+ app = TangramApp.from_package(".")
156
+ print([tool.id for tool in app.tools()])
157
+
158
+ bound = app.bind(backend="http://127.0.0.1:8000")
159
+ result = await bound.call("com.example/orders#Order.List@listOrders", {})
160
+ ```
161
+
162
+ The Python package also exposes a machine-readable command interface. Every
163
+ command writes exactly one versioned JSON envelope to stdout:
164
+
165
+ ```sh
166
+ python -m tangram_app build . --output dist/tangram-app.json
167
+ python -m tangram_app inspect . --tools --format json
168
+ printf '%s' '{}' | python -m tangram_app call \
169
+ dist/tangram-app.json \
170
+ com.example/orders#Order.List@listOrders \
171
+ --backend http://127.0.0.1:8000 \
172
+ --input-json -
173
+ ```
174
+
175
+ Python compiler results are labeled `authority: development` until shared
176
+ golden fixtures prove parity with Tangram's publishing validator. That authority,
177
+ plus a `developmentOnly` marker for local Pkl project dependencies, is persisted
178
+ in the graph so loading a snapshot cannot accidentally upgrade its provenance.
179
+ Source-mode inspection reports manifest/OpenAPI validation as enforced;
180
+ snapshot-mode inspection reports it as delegated to the compiled artifact.
181
+
182
+ Runtime requirements are also part of the graph. Settings, secrets, and
183
+ deployment claims owned by an already-running App service are reported as
184
+ delegated to that backend. Required Connector or Agent requirements that this
185
+ standalone host cannot resolve block `bind()` before any network request.
186
+
187
+ ## Authoring and running an agent-built app
188
+
189
+ `TangramProject` represents the mutable canonical source package used by a
190
+ coding agent or app author:
191
+
192
+ ```python
193
+ from tangram_app import TangramProject
194
+
195
+ project = TangramProject.open(".")
196
+ validation = project.validate()
197
+ app = project.compile()
198
+
199
+ with project.run_local() as running:
200
+ result = await running.call("com.example/todos#Todo.List@listTodos", {})
201
+ ```
202
+
203
+ The local runtime reads
204
+ `manifests/deployment/source/backend/pyproject.toml`, resolves the declared
205
+ Python 3.12 entry module under `src/`, prepares a cached
206
+ `.preview/backend-venv` from the Tangram runtime pins, stages the backend
207
+ `tangram` module, starts `entry:app` with uvicorn on loopback, waits for
208
+ `/openapi.json`, and refuses startup when a compiled action operation is
209
+ missing. It executes the source tree, never the deployment image.
210
+
211
+ When `deployment/dependencies.pkl` declares the canonical `main`
212
+ `PostgresqlDatabaseClaim`, the SDK discovers a host PostgreSQL installation,
213
+ starts a project-scoped instance backed by `.preview/pgdata`, creates the
214
+ `app` database, and applies `deployment/migrations/main/Vn__*.sql` in order.
215
+ Applied checksums are recorded in `_tangram_app_migrations`; changing an
216
+ already-applied migration is refused. Install PostgreSQL separately or set
217
+ `TANGRAM_LOCAL_PG_BIN_DIR` to its `bin` directory. Other infrastructure claims,
218
+ settings, and secrets remain explicit unsupported requirements.
219
+
220
+ The local host is read-only by default. Embedded callers can pass a
221
+ `LocalDevelopmentPolicy` to `run_local()` to grant specific mutating action IDs
222
+ and, separately, preauthorize confirmation-gated actions.
223
+
224
+ For one governed call, the CLI can own the backend lifecycle automatically:
225
+
226
+ ```sh
227
+ printf '%s' '{}' | python -m tangram_app call . \
228
+ com.example/todos#Todo.List@listTodos --local --input-json -
229
+ ```
230
+
231
+ For a long-running local backend session:
232
+
233
+ ```sh
234
+ python -m tangram_app run .
235
+ ```
236
+
237
+ The command emits one readiness envelope and stays in the foreground until
238
+ interrupted. It captures backend output in the contained `.preview` directory
239
+ and terminates the backend process group on shutdown.
240
+
241
+ Capability graphs retain declared root UI metadata, and `run_local()` compiles
242
+ the sandboxed root component and exposes it through `running.ui_url`. The first
243
+ run prepares `.preview/ui-runtime` with the server-compatible component catalog
244
+ and esbuild; callers may instead set `TANGRAM_ESBUILD_BIN` and
245
+ `TANGRAM_COMPONENT_NODE_MODULES`. The injected browser SDK routes
246
+ `performAction` to the same validated backend action host. Reversible UI actions
247
+ run directly; irreversible or confirmation-required actions require a browser
248
+ confirmation before the exact frozen request is retried.
249
+
250
+ ## Installing the authoring skills
251
+
252
+ The SDK bundles two authoring skills: `tangram-app-builder` (apps with
253
+ their own backend/database/UI: layout, manifest templates, the
254
+ validate/run/call loop, platform-parity gotchas) and
255
+ `tangram-connector-builder` (connectors mapping an external SaaS API —
256
+ Gmail/Slack style — into governed actions with platform-managed OAuth).
257
+ Install either where your agent discovers instructions:
258
+
259
+ ```sh
260
+ python -m tangram_app skill install NAME --project . # ./.claude/skills/ (Claude Code, this repo)
261
+ python -m tangram_app skill install NAME --user # ~/.claude/skills/ (Claude Code, all repos)
262
+ python -m tangram_app skill install NAME --codex # ~/.codex/prompts/ (Codex, no Claude needed)
263
+ ```
264
+
265
+ `skill install-builder` remains an alias for
266
+ `skill install tangram-app-builder`.
267
+
268
+ Claude Code users can instead install it as a plugin without the SDK:
269
+ `/plugin marketplace add tangram-data/tangram-app-manifest` then
270
+ `/plugin install tangram-app-builder`.
271
+
272
+ For **Codex-only** machines, `--codex` installs the full skill as the
273
+ custom prompt `/tangram-app-builder`. To make Codex apply it automatically
274
+ instead of on invocation, add to `~/.codex/AGENTS.md`:
275
+
276
+ ```markdown
277
+ When asked to create, modify, or debug a Tangram app, first read
278
+ ~/.codex/prompts/tangram-app-builder.md and follow it.
279
+ ```
280
+
281
+ The packaged copy is release-authoritative; the repo mirrors are
282
+ sha-checked against it in CI.
283
+
284
+ ## Installing and opening apps locally
285
+
286
+ Agents (or humans) can install a built app — a generated source package,
287
+ or an App Hub tarball — into the user-level store at `~/.tangram/apps/`,
288
+ then address it by id everywhere a package path is accepted:
289
+
290
+ ```sh
291
+ tangram-app app install ./my-app # or app.tar.gz, or an https URL
292
+ tangram-app app list
293
+ tangram-app open my-app # run + open the UI in a browser
294
+ printf '{}' | tangram-app call my-app 'com.example/my-app#Todo.List@listTodos' \
295
+ --local --input-json -
296
+ tangram-app app uninstall my-app
297
+ ```
298
+
299
+ `install` validates the package first and refuses stale layouts with
300
+ actionable findings. Runtime state stays under the installed app's own
301
+ `.preview/`. Override the store root with `TANGRAM_HOME`.
302
+
303
+ ## Generating an agent skill
304
+
305
+ Generate a portable, graph-backed skill for Codex, Claude, or another
306
+ shell-capable agent:
307
+
308
+ ```sh
309
+ python -m tangram_app skill generate . \
310
+ --output dist/agent-skills/orders
311
+ ```
312
+
313
+ The artifact contains a concise `SKILL.md`, optional Codex UI metadata, a
314
+ relative-path runner, a compact action catalog, an executable capability-graph
315
+ snapshot, and `skill.lock.json`. The runner verifies the graph against the lock
316
+ before every inspection or call and imports the installed Python SDK directly;
317
+ it does not require the native Tangram CLI or Pkl at invocation time.
318
+ When the canonical source package is available, the runner also accepts
319
+ `--local-package <app-dir>`: it recompiles the source, verifies its digest still
320
+ matches the skill snapshot, starts the declared Python backend, invokes the
321
+ action, and shuts the backend down. This source mode requires Pkl.
322
+
323
+ ## Calling a local HTTP backend
324
+
325
+ `LocalHttpDriver` reverses the graph's flat agent inputs into OpenAPI path,
326
+ query, header, and JSON-body inputs. It is loopback-only, disables redirects
327
+ and ambient proxies, bounds URLs/headers/bodies/responses, and redacts upstream
328
+ error bodies:
329
+
330
+ ```python
331
+ import asyncio
332
+
333
+ from tangram_app import LocalHttpDriver, TangramHost, compile_manifest
334
+
335
+
336
+ async def main() -> None:
337
+ graph = compile_manifest(".").graph
338
+ host = TangramHost(
339
+ graph,
340
+ driver=LocalHttpDriver("http://127.0.0.1:8000"),
341
+ )
342
+ result = await host.call(
343
+ "com.example/orders#Order.List",
344
+ {"status": "pending"},
345
+ )
346
+ print(result)
347
+
348
+
349
+ asyncio.run(main())
350
+ ```
351
+
352
+ `HttpExecutionDriver(..., allow_remote=True)` is the explicit remote connector
353
+ escape hatch. Only use it with a trusted configured base URL; redirects remain
354
+ disabled and configured headers are injected after agent-provided inputs so
355
+ credentials cannot be overridden.
356
+
357
+ ## Development
358
+
359
+ Create an isolated environment and install the SDK. The real-Pkl integration
360
+ tests run when `pkl` is installed and are otherwise skipped:
361
+
362
+ ```sh
363
+ cd python-sdk
364
+ python -m venv .venv
365
+ . .venv/bin/activate
366
+ python -m pip install -e .
367
+ python -m unittest discover -s tests -v
368
+ ```
369
+
370
+ ## Example
371
+
372
+ ```python
373
+ import asyncio
374
+
375
+ from tangram_app import (
376
+ CapabilityGraph,
377
+ InMemoryDriver,
378
+ LocalDevelopmentPolicy,
379
+ TangramHost,
380
+ )
381
+
382
+
383
+ async def main() -> None:
384
+ graph = CapabilityGraph.from_file("dist/tangram-app.json")
385
+ driver = InMemoryDriver()
386
+
387
+ @driver.handler("com.example/orders#Order.List@listOrders")
388
+ async def list_orders(arguments):
389
+ return {"orders": [], "status": arguments.get("status")}
390
+
391
+ host = TangramHost(
392
+ graph,
393
+ driver=driver,
394
+ policy=LocalDevelopmentPolicy(),
395
+ )
396
+ result = await host.call(
397
+ "com.example/orders#Order.List@listOrders",
398
+ {"status": "pending"},
399
+ )
400
+ print(result)
401
+
402
+
403
+ asyncio.run(main())
404
+ ```
405
+
406
+ `LocalDevelopmentPolicy` allows `Stateless` actions and denies mutations. A
407
+ mutating binding must be named explicitly in `allow_mutations`; an action that
408
+ requires confirmation must additionally be named in
409
+ `preauthorized_confirmations`. This is startup pre-authorization, not a claim
410
+ that a generic agent protocol supplied per-call human confirmation.