branchyard 0.6.2__py3-none-any.whl

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 (35) hide show
  1. branchyard-0.6.2.dist-info/METADATA +196 -0
  2. branchyard-0.6.2.dist-info/RECORD +35 -0
  3. branchyard-0.6.2.dist-info/WHEEL +5 -0
  4. branchyard-0.6.2.dist-info/entry_points.txt +2 -0
  5. branchyard-0.6.2.dist-info/top_level.txt +3 -0
  6. branchyard.py +1556 -0
  7. branchyard_artifacts/__init__.py +5 -0
  8. branchyard_artifacts/__main__.py +147 -0
  9. branchyard_artifacts/analysis.py +256 -0
  10. branchyard_artifacts/common.py +177 -0
  11. branchyard_artifacts/deck.py +229 -0
  12. branchyard_artifacts/doctor.py +65 -0
  13. branchyard_artifacts/docx.py +132 -0
  14. branchyard_artifacts/evidence.py +423 -0
  15. branchyard_artifacts/examples/calculate.json +12 -0
  16. branchyard_artifacts/examples/claim-verify.json +13 -0
  17. branchyard_artifacts/examples/data-clean.json +8 -0
  18. branchyard_artifacts/examples/deck.json +27 -0
  19. branchyard_artifacts/examples/docx.json +12 -0
  20. branchyard_artifacts/examples/pdf.json +12 -0
  21. branchyard_artifacts/examples/pivot.json +18 -0
  22. branchyard_artifacts/examples/section.json +61 -0
  23. branchyard_artifacts/examples/source-capture.json +10 -0
  24. branchyard_artifacts/examples/xlsx.json +22 -0
  25. branchyard_artifacts/manifest.py +51 -0
  26. branchyard_artifacts/native.py +495 -0
  27. branchyard_artifacts/pdf.py +130 -0
  28. branchyard_artifacts/pptx.py +276 -0
  29. branchyard_artifacts/preview.py +836 -0
  30. branchyard_artifacts/schemas/deck-v1.json +143 -0
  31. branchyard_artifacts/schemas/section-v1.json +336 -0
  32. branchyard_artifacts/tables.py +153 -0
  33. branchyard_artifacts/uno_backend.py +106 -0
  34. branchyard_artifacts/xlsx.py +155 -0
  35. branchyard_client.py +6085 -0
@@ -0,0 +1,196 @@
1
+ Metadata-Version: 2.4
2
+ Name: branchyard
3
+ Version: 0.6.2
4
+ Summary: Run and coordinate agent tasks from Python, with optional tools for documents, data and evidence.
5
+ License-Expression: Apache-2.0
6
+ Project-URL: Homepage, https://github.com/vamsiramakrishnan/branchyard
7
+ Project-URL: Documentation, https://github.com/vamsiramakrishnan/branchyard/blob/main/docs/sdk.md
8
+ Project-URL: Source, https://github.com/vamsiramakrishnan/branchyard/tree/main/sdk/python
9
+ Project-URL: Issues, https://github.com/vamsiramakrishnan/branchyard/issues
10
+ Keywords: branchyard,coding agents,git,harness,sdk
11
+ Classifier: Development Status :: 2 - Pre-Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Operating System :: POSIX
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3 :: Only
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
22
+ Classifier: Topic :: Software Development :: Version Control :: Git
23
+ Requires-Python: >=3.9
24
+ Description-Content-Type: text/markdown
25
+ Provides-Extra: artifacts
26
+ Requires-Dist: python-docx==1.2.0; extra == "artifacts"
27
+ Requires-Dist: openpyxl==3.1.5; extra == "artifacts"
28
+ Requires-Dist: python-pptx==1.0.2; extra == "artifacts"
29
+ Requires-Dist: pypdf==6.6.0; extra == "artifacts"
30
+ Requires-Dist: reportlab==4.4.10; extra == "artifacts"
31
+ Requires-Dist: Pillow==11.3.0; extra == "artifacts"
32
+ Requires-Dist: jsonschema==4.25.1; extra == "artifacts"
33
+ Requires-Dist: pdfplumber==0.11.9; python_version >= "3.10" and extra == "artifacts"
34
+ Requires-Dist: pandas==2.3.3; extra == "artifacts"
35
+ Requires-Dist: Pint==0.24.4; extra == "artifacts"
36
+
37
+ # Branchyard for Python
38
+
39
+ Two Python modules for [Branchyard](https://github.com/vamsiramakrishnan/branchyard), which runs coding-agent
40
+ harnesses (Claude Code, Codex, Gemini CLI and others) on git branches. Standard library only, Python 3.9 or newer.
41
+
42
+ | Module | For code that runs | How it reaches Branchyard |
43
+ |---|---|---|
44
+ | `branchyard_client` | anywhere: a script, a bot, a service | `by serve`'s HTTP API, or a `by serve` it starts itself (`Client.local`) |
45
+ | `branchyard` | inside a harness turn that Branchyard runs, delegating work to child branches | `by ... --json`, acting as that turn's branch |
46
+
47
+ Not on PyPI yet, so there is no `pip install branchyard` to run today. Both modules need a `by` to talk to.
48
+
49
+ ## Install
50
+
51
+ Install the released CLI without a Rust toolchain or source checkout:
52
+
53
+ ```sh
54
+ curl -fsSL https://github.com/vamsiramakrishnan/branchyard/releases/latest/download/install.sh | sh -s -- --no-setup
55
+ by --version
56
+ ```
57
+
58
+ Download `branchyard-sdk-<version>.zip` from the [latest release](https://github.com/vamsiramakrishnan/branchyard/releases/latest)
59
+ and extract it, then install both Python modules:
60
+
61
+ ```sh
62
+ python3 -m pip install ./branchyard-sdk
63
+ ```
64
+
65
+ From an existing checkout, use `python3 -m pip install ./sdk/python`. To build the CLI from that checkout instead,
66
+ run `cargo install --locked --path crates/branchyard-cli` with the repository's pinned Rust toolchain.
67
+
68
+ `by` is found from `BRANCHYARD_BY`, else `PATH`. The installer uses `~/.local/bin` by default; open a new terminal
69
+ or add that directory to `PATH` if needed. See [distribution](https://github.com/vamsiramakrishnan/branchyard/blob/main/docs/distribution.md#install-by)
70
+ for platform requirements and the `--runtime` build.
71
+
72
+ ## Run something
73
+
74
+ In a git repository with at least one commit. No server to start, no token to copy: `Client.local` runs a `by serve`
75
+ of its own on the repository and stops it when the block ends.
76
+
77
+ ```python
78
+ from branchyard_client import Client
79
+
80
+ with Client.local(".") as client:
81
+ app = client.repo("app")
82
+ op = app.task("Make the flaky parser test deterministic", name="flaky-parser", budget_usd=2,
83
+ policy={"preset": "edit-worktree"}) # the harness may read and edit files, nothing else
84
+ op = client.wait(op, check=True) # raises if the harness's turn failed, not only the request
85
+ branch = op.result_branches[0]
86
+ print(branch.name, branch.state) # flaky-parser ready
87
+ print(branch.candidate) # its commit and how much it changed, None if nothing
88
+ ```
89
+
90
+ The branch is the repository's: `by diff flaky-parser` and `by merge flaky-parser` work on it afterwards. `name=` is
91
+ optional; without it the branch is named from the prompt (`make-the-flaky-parser-test-deterministic`), with `-2`, `-3`
92
+ added when the name is taken. The harness is the repository's default; `harness="codex"` names another.
93
+ `wait(check=True)` raises `BranchFailedError` (a subclass of `OperationFailedError`) when the branch ended `failed`,
94
+ `budget_exceeded` or `interrupted`, naming it, its state and the way to find out why.
95
+
96
+ Runnable versions, which need no model (`--command` runs the harness as a stand-in): `examples/python/first_run.py`,
97
+ `stream_events.py` and `delegate.py` in the checkout.
98
+
99
+ ## Against a server
100
+
101
+ For a service that is not on the same machine as the work, or that outlives it:
102
+
103
+ ```sh
104
+ by serve --repo app=. # listening on http://127.0.0.1:8421; the token is in .branchyard/server/token
105
+ ```
106
+
107
+ ```python
108
+ from branchyard_client import Client
109
+
110
+ client = Client("http://127.0.0.1:8421", token_file=".branchyard/server/token")
111
+ app = client.repo("app") # the NAME in --repo NAME=PATH; the default name is the directory's
112
+ ```
113
+
114
+ Everything after `client.repo` is the same as above. `Client.repos()` lists what a server serves.
115
+
116
+ Read document previews and their images through the same authenticated client:
117
+
118
+ ```python
119
+ preview = app.preview_artifact("draft", "artifact-id", view="pages", page=1)
120
+ if preview.get("image"):
121
+ image_bytes = app.read_preview_asset("draft", "artifact-id", preview.image, view="pages", page=1)
122
+ ```
123
+
124
+ Table previews accept `sheet`, `offset` and `limit`. Image requests must repeat the preview options because the
125
+ server binds each image to its original artifact and options. The preview record reports conversion readiness;
126
+ these methods use the server's renderer and preserve its permission and availability errors.
127
+
128
+ ## Knowledge workspaces
129
+
130
+ An operator can enable managed knowledge projects on the server. These projects need no user repository or
131
+ client filesystem path. Workspace initialization and native sessions use the existing durable operation queue:
132
+
133
+ ```python
134
+ project = client.create_project("Quarterly review", key="quarterly-project")
135
+ allocation = client.create_workspace(project.id, "Cost review", key="quarterly-workspace")
136
+ client.wait(allocation, check=True)
137
+ workspace_id = allocation.workspace_id
138
+
139
+ current = client.workspace(workspace_id)
140
+ source = client.upload_workspace_source(
141
+ workspace_id, b"quarter,cost\nQ1,100\nQ2,120\n", "Inputs.csv",
142
+ media_type="text/csv", revision=current.revision, key="quarterly-input",
143
+ )
144
+ run = client.start_workspace_session(
145
+ workspace_id, "Analysis", "Analyze the supplied costs and return your conclusions as JSON.",
146
+ harness="codex", sources=[source.id], policy={"preset": "edit-worktree"},
147
+ result_contract={"schema": {"type": "object"}, "required": True}, key="quarterly-analysis",
148
+ )
149
+ client.wait(run, check=True)
150
+ print(client.workspace_sessions(workspace_id))
151
+ ```
152
+
153
+ The returned operations retain `workspace_id` and, when applicable, `session_id`. Keep each idempotency key when
154
+ retrying its request. `workspace_messages(workspace_id, session_id, after=cursor)` returns native messages and the
155
+ next cursor. Sending, steering and explicitly resuming use `send_workspace_message`; the server retains control
156
+ of harness installation, provider placement, native authentication and permissions.
157
+
158
+ Source uploads send original bytes with the title in `X-Source-Title-Encoded` (RFC 8187, any Unicode title) and an ASCII copy in `X-Source-Title`, `X-Workspace-Revision` and the declared media type.
159
+ `read_workspace_source` and `read_workspace_artifact` return authenticated bytes. Source and artifact preview
160
+ methods use the same bounded options as repository previews:
161
+
162
+ ```python
163
+ table = client.preview_workspace_source(workspace_id, source.id, view="table", limit=25)
164
+ print(table)
165
+
166
+ artifacts = client.workspace_artifacts(workspace_id)
167
+ if artifacts:
168
+ preview = client.preview_workspace_artifact(workspace_id, artifacts[0].id, view="pages", page=1)
169
+ if preview.get("image"):
170
+ image_bytes = client.read_workspace_artifact_preview_asset(
171
+ workspace_id, artifacts[0].id, preview.image, view="pages", page=1,
172
+ )
173
+ ```
174
+
175
+ Accepting deliverables with `finalize_workspace` requires current-turn provenance and the current workspace
176
+ revision. Code integration remains independent. Membership changes, comments and workspace lifecycle intents
177
+ also carry a revision; read the workspace again after a stale-revision error. Presence is advisory and does not
178
+ hold a writer lease. Subjects and comment authors come from verified server identity.
179
+
180
+ `workspace_runtime` reports owner-host readiness and provider capabilities. An authorized editor can open a
181
+ workspace terminal when the branch is idle and the operator has enabled shell access. Terminal output exposes
182
+ exact decoded bytes as `TerminalOutput.data_bytes`. Input uses explicit sequences starting at one; retry only
183
+ the last identical frame. A lost handle or uncertain input raises the server's error. The SDK never opens a new
184
+ shell or replays input automatically after a restart. Closing the terminal releases its writer lease.
185
+
186
+ Repository projects can inspect, publish and refresh a session's pull request through the workspace PR methods.
187
+ Publication requires the server's merge grant and forge policy; forge credentials stay with the worker. Resource
188
+ lifecycle operations preserve source originals and accepted deliverables, and never submit a model turn.
189
+
190
+ ## Where to go next
191
+
192
+ - [docs/sdk.md](https://github.com/vamsiramakrishnan/branchyard/blob/main/docs/sdk.md): the whole client, its errors,
193
+ streaming, connector grants, one conversation per branch for a chat bot, and what it does not do.
194
+ - [docs/server.md](https://github.com/vamsiramakrishnan/branchyard/blob/main/docs/server.md): the HTTP API it speaks.
195
+ - [docs/delegation.md](https://github.com/vamsiramakrishnan/branchyard/blob/main/docs/delegation.md#python): the
196
+ `branchyard` module inside a harness turn.
@@ -0,0 +1,35 @@
1
+ branchyard.py,sha256=R10ieMiFPK9zoFdeV-Zkk-XapZbuAV_jy5yTGrNKmno,57736
2
+ branchyard_client.py,sha256=Fd_72dPwRVcrTkV9qZNhk1rg15xgWxx9xheo3GL5PYc,266420
3
+ branchyard_artifacts/__init__.py,sha256=-IxcXNeegAgZSMQ427Hyq8e674zUZIBjKG3orvPyP1o,179
4
+ branchyard_artifacts/__main__.py,sha256=YPaAjCIQltayBxEUj_Xu6AKSMyn4oQOZBb5x7UdZ1uM,7018
5
+ branchyard_artifacts/analysis.py,sha256=PTzeubnsxb7x3NqNZU1jmf2ICElmUIcqBn4UMaE_Fmc,12673
6
+ branchyard_artifacts/common.py,sha256=kwfAohwKG2jC7FbrI5K7paJoc3OQvpyFhoWibJ1F9dE,6848
7
+ branchyard_artifacts/deck.py,sha256=_ob9IHWj7lAmSkRI_GEWf60D0O9PVmNit_S7JYkoVbU,10500
8
+ branchyard_artifacts/doctor.py,sha256=Z_FGinp2YQjndsRyNevKCCZDpCN92SytYlWkSS2U1HE,2660
9
+ branchyard_artifacts/docx.py,sha256=ZTg3U5enmIKJx0OkZMKeg_SwxuEhSX2V5eARGxZtTyE,6158
10
+ branchyard_artifacts/evidence.py,sha256=oueNgqYqWI8B5wYyDkTDRfKLLNLI-PXWmH7AAt4tpxs,19274
11
+ branchyard_artifacts/manifest.py,sha256=31QIDGn1i85TL2NaJ35iXf3sec6BxLRFBhF-SY1aWQA,2200
12
+ branchyard_artifacts/native.py,sha256=9c1xJs3TBhFWbx38tDXPxPzG_9Jhxgu6Rwz3J5GElWQ,22358
13
+ branchyard_artifacts/pdf.py,sha256=_ySXnoMnddMQ3dH1zU-f4wHxSVRk8siWME93UcaxgqU,5964
14
+ branchyard_artifacts/pptx.py,sha256=-vhHtQFBXFafFQ69JwlO8vPQnPNjgQielMJkPQ6o__U,13381
15
+ branchyard_artifacts/preview.py,sha256=z-b_r9y6OWFiem9kL0vw6408jUzUr3R_YJtaW5KZRgc,37429
16
+ branchyard_artifacts/tables.py,sha256=5lDXiZk2bnn8pCsX824WGTu0CMPPfrJOeKHQzHNke_c,6607
17
+ branchyard_artifacts/uno_backend.py,sha256=rjNr9fRizLFrYdXn7IWd226bq8PXLoGn0kAssa_mVdI,4373
18
+ branchyard_artifacts/xlsx.py,sha256=7laKJ0KqWkbj_yxvi0oOAIWrq6Fjoj72ZFCquFsonWU,7042
19
+ branchyard_artifacts/examples/calculate.json,sha256=es2wDQyO7u93I4vNu_K2rTgVbkLaDFij--RZV5G2RtQ,468
20
+ branchyard_artifacts/examples/claim-verify.json,sha256=k6_5MvGjB1ZQEVJjDsWI7FZ5wGr8H6CH2sTPgkqU06Y,384
21
+ branchyard_artifacts/examples/data-clean.json,sha256=PWDqycZK42uiDaj2Vg09SD7qATGO4oCku-36waErBoo,218
22
+ branchyard_artifacts/examples/deck.json,sha256=pFiv4IACcrkrb9xokyDmXgw5jX88izVrRTbELuKamog,566
23
+ branchyard_artifacts/examples/docx.json,sha256=e93r511ZqAAWirRXInIteghnSDp5rf484Nxaq-KzaWw,220
24
+ branchyard_artifacts/examples/pdf.json,sha256=A4_QsxkC8JyA4XOATgAD0116UTW4pju0kATqC_jv3bw,205
25
+ branchyard_artifacts/examples/pivot.json,sha256=tRNqiMqGtW9_QfI5FRzsjVft6M7hSWCuFXkPuMu8r8w,287
26
+ branchyard_artifacts/examples/section.json,sha256=ytDzdJedrJUCgnIDk30vRIL1GQEUQ-qD6_OTJtLPQk8,1228
27
+ branchyard_artifacts/examples/source-capture.json,sha256=mPtCXujeWp1UBgKwFm9hGax7tJifX78F7RTkSXejOUI,256
28
+ branchyard_artifacts/examples/xlsx.json,sha256=3hCeEmAZxmpjLg7-rC3fYjzKrerx0Up2zYNWCd-hKCs,360
29
+ branchyard_artifacts/schemas/deck-v1.json,sha256=2eLjAxVjkqck7_pMuvhcxElzUiy13dETDTAGOXfCFXA,3093
30
+ branchyard_artifacts/schemas/section-v1.json,sha256=oBpSPupJTKjWzldME-KQS-i5LsadwQcodd2GfdamNXU,9657
31
+ branchyard-0.6.2.dist-info/METADATA,sha256=-mMpePUop2Il_uazQE2VhYgBkHnGIClS8miGGIm6ok8,10529
32
+ branchyard-0.6.2.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
33
+ branchyard-0.6.2.dist-info/entry_points.txt,sha256=V_i82os-xyf4FL3nlNN3b6bhMK8oT7tKU2NsTf3BgwE,76
34
+ branchyard-0.6.2.dist-info/top_level.txt,sha256=m9ksdMAQk52QdaQoepSVdSIWs136Njsu06oYRb1jXHE,50
35
+ branchyard-0.6.2.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.2.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ branchyard-artifacts = branchyard_artifacts.__main__:main
@@ -0,0 +1,3 @@
1
+ branchyard
2
+ branchyard_artifacts
3
+ branchyard_client