@hanzo/build 0.2.0
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.
- package/LICENSE-APACHE +205 -0
- package/LICENSE-MIT +21 -0
- package/NOTICE +37 -0
- package/README.md +120 -0
- package/lib/account.d.ts +11 -0
- package/lib/account.js +26 -0
- package/lib/api/call.d.ts +38 -0
- package/lib/api/call.js +75 -0
- package/lib/api/coding.d.ts +56 -0
- package/lib/api/coding.js +58 -0
- package/lib/api/git.d.ts +27 -0
- package/lib/api/git.js +39 -0
- package/lib/api/github.d.ts +78 -0
- package/lib/api/github.js +73 -0
- package/lib/api/models.d.ts +17 -0
- package/lib/api/models.js +28 -0
- package/lib/api/places.d.ts +25 -0
- package/lib/api/places.js +31 -0
- package/lib/api/platform.d.ts +59 -0
- package/lib/api/platform.js +69 -0
- package/lib/api/projects.d.ts +52 -0
- package/lib/api/projects.js +97 -0
- package/lib/api/sessions.d.ts +74 -0
- package/lib/api/sessions.js +120 -0
- package/lib/api/sse.d.ts +24 -0
- package/lib/api/sse.js +68 -0
- package/lib/api/turn.d.ts +51 -0
- package/lib/api/turn.js +121 -0
- package/lib/api/verdict.d.ts +12 -0
- package/lib/api/verdict.js +20 -0
- package/lib/builder.d.ts +5 -0
- package/lib/builder.js +81 -0
- package/lib/data.d.ts +42 -0
- package/lib/data.js +178 -0
- package/lib/host.d.ts +57 -0
- package/lib/host.js +26 -0
- package/lib/index.d.ts +11 -0
- package/lib/index.js +10 -0
- package/lib/landing.d.ts +13 -0
- package/lib/landing.js +132 -0
- package/lib/out.d.ts +10 -0
- package/lib/out.js +4 -0
- package/lib/project.d.ts +3 -0
- package/lib/project.js +250 -0
- package/lib/publish.d.ts +15 -0
- package/lib/publish.js +94 -0
- package/lib/route.d.ts +30 -0
- package/lib/route.js +28 -0
- package/lib/run.d.ts +3 -0
- package/lib/run.js +67 -0
- package/lib/shelf.d.ts +2 -0
- package/lib/shelf.js +60 -0
- package/lib/tools.d.ts +25 -0
- package/lib/tools.js +64 -0
- package/lib/voice.d.ts +17 -0
- package/lib/voice.js +86 -0
- package/package.json +70 -0
package/LICENSE-APACHE
ADDED
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction, and
|
|
10
|
+
distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by the copyright
|
|
13
|
+
owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all other entities
|
|
16
|
+
that control, are controlled by, or are under common control with that entity.
|
|
17
|
+
For the purposes of this definition, "control" means (i) the power, direct or
|
|
18
|
+
indirect, to cause the direction or management of such entity, whether by
|
|
19
|
+
contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
20
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
21
|
+
|
|
22
|
+
"You" (or "Your") shall mean an individual or Legal Entity exercising
|
|
23
|
+
permissions granted by this License.
|
|
24
|
+
|
|
25
|
+
"Source" form shall mean the preferred form for making modifications, including
|
|
26
|
+
but not limited to software source code, documentation source, and configuration
|
|
27
|
+
files.
|
|
28
|
+
|
|
29
|
+
"Object" form shall mean any form resulting from mechanical transformation or
|
|
30
|
+
translation of a Source form, including but not limited to compiled object code,
|
|
31
|
+
generated documentation, and conversions to other media types.
|
|
32
|
+
|
|
33
|
+
"Work" shall mean the work of authorship, whether in Source or Object form, made
|
|
34
|
+
available under the License, as indicated by a copyright notice that is included
|
|
35
|
+
in or attached to the work (an example is provided in the Appendix below).
|
|
36
|
+
|
|
37
|
+
"Derivative Works" shall mean any work, whether in Source or Object form, that
|
|
38
|
+
is based on (or derived from) the Work and for which the editorial revisions,
|
|
39
|
+
annotations, elaborations, or other modifications represent, as a whole, an
|
|
40
|
+
original work of authorship. For the purposes of this License, Derivative Works
|
|
41
|
+
shall not include works that remain separable from, or merely link (or bind by
|
|
42
|
+
name) to the interfaces of, the Work and Derivative Works thereof.
|
|
43
|
+
|
|
44
|
+
"Contribution" shall mean any work of authorship, including the original version
|
|
45
|
+
of the Work and any modifications or additions to that Work or Derivative Works
|
|
46
|
+
thereof, that is intentionally submitted to Licensor for inclusion in the Work
|
|
47
|
+
by the copyright owner or by an individual or Legal Entity authorized to submit
|
|
48
|
+
on behalf of the copyright owner. For the purposes of this definition,
|
|
49
|
+
"submitted" means any form of electronic, verbal, or written communication sent
|
|
50
|
+
to the Licensor or its representatives, including but not limited to
|
|
51
|
+
communication on electronic mailing lists, source code control systems, and
|
|
52
|
+
issue tracking systems that are managed by, or on behalf of, the Licensor for
|
|
53
|
+
the purpose of discussing and improving the Work, but excluding communication
|
|
54
|
+
that is conspicuously marked or otherwise designated in writing by the copyright
|
|
55
|
+
owner as "Not a Contribution."
|
|
56
|
+
|
|
57
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf
|
|
58
|
+
of whom a Contribution has been received by Licensor and subsequently
|
|
59
|
+
incorporated within the Work.
|
|
60
|
+
|
|
61
|
+
2. Grant of Copyright License.
|
|
62
|
+
|
|
63
|
+
Subject to the terms and conditions of this License, each Contributor hereby
|
|
64
|
+
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
|
|
65
|
+
irrevocable copyright license to reproduce, prepare Derivative Works of,
|
|
66
|
+
publicly display, publicly perform, sublicense, and distribute the Work and such
|
|
67
|
+
Derivative Works in Source or Object form.
|
|
68
|
+
|
|
69
|
+
3. Grant of Patent License.
|
|
70
|
+
|
|
71
|
+
Subject to the terms and conditions of this License, each Contributor hereby
|
|
72
|
+
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
|
|
73
|
+
irrevocable (except as stated in this section) patent license to make, have
|
|
74
|
+
made, use, offer to sell, sell, import, and otherwise transfer the Work, where
|
|
75
|
+
such license applies only to those patent claims licensable by such Contributor
|
|
76
|
+
that are necessarily infringed by their Contribution(s) alone or by combination
|
|
77
|
+
of their Contribution(s) with the Work to which such Contribution(s) was
|
|
78
|
+
submitted. If You institute patent litigation against any entity (including a
|
|
79
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work or a
|
|
80
|
+
Contribution incorporated within the Work constitutes direct or contributory
|
|
81
|
+
patent infringement, then any patent licenses granted to You under this License
|
|
82
|
+
for that Work shall terminate as of the date such litigation is filed.
|
|
83
|
+
|
|
84
|
+
4. Redistribution.
|
|
85
|
+
|
|
86
|
+
You may reproduce and distribute copies of the Work or Derivative Works thereof
|
|
87
|
+
in any medium, with or without modifications, and in Source or Object form,
|
|
88
|
+
provided that You meet the following conditions:
|
|
89
|
+
|
|
90
|
+
You must give any other recipients of the Work or Derivative Works a copy of
|
|
91
|
+
this License; and
|
|
92
|
+
You must cause any modified files to carry prominent notices stating that You
|
|
93
|
+
changed the files; and
|
|
94
|
+
You must retain, in the Source form of any Derivative Works that You distribute,
|
|
95
|
+
all copyright, patent, trademark, and attribution notices from the Source form
|
|
96
|
+
of the Work, excluding those notices that do not pertain to any part of the
|
|
97
|
+
Derivative Works; and
|
|
98
|
+
If the Work includes a "NOTICE" text file as part of its distribution, then any
|
|
99
|
+
Derivative Works that You distribute must include a readable copy of the
|
|
100
|
+
attribution notices contained within such NOTICE file, excluding those notices
|
|
101
|
+
that do not pertain to any part of the Derivative Works, in at least one of the
|
|
102
|
+
following places: within a NOTICE text file distributed as part of the
|
|
103
|
+
Derivative Works; within the Source form or documentation, if provided along
|
|
104
|
+
with the Derivative Works; or, within a display generated by the Derivative
|
|
105
|
+
Works, if and wherever such third-party notices normally appear. The contents of
|
|
106
|
+
the NOTICE file are for informational purposes only and do not modify the
|
|
107
|
+
License. You may add Your own attribution notices within Derivative Works that
|
|
108
|
+
You distribute, alongside or as an addendum to the NOTICE text from the Work,
|
|
109
|
+
provided that such additional attribution notices cannot be construed as
|
|
110
|
+
modifying the License.
|
|
111
|
+
You may add Your own copyright statement to Your modifications and may provide
|
|
112
|
+
additional or different license terms and conditions for use, reproduction, or
|
|
113
|
+
distribution of Your modifications, or for any such Derivative Works as a whole,
|
|
114
|
+
provided Your use, reproduction, and distribution of the Work otherwise complies
|
|
115
|
+
with the conditions stated in this License.
|
|
116
|
+
|
|
117
|
+
5. Submission of Contributions.
|
|
118
|
+
|
|
119
|
+
Unless You explicitly state otherwise, any Contribution intentionally submitted
|
|
120
|
+
for inclusion in the Work by You to the Licensor shall be under the terms and
|
|
121
|
+
conditions of this License, without any additional terms or conditions.
|
|
122
|
+
Notwithstanding the above, nothing herein shall supersede or modify the terms of
|
|
123
|
+
any separate license agreement you may have executed with Licensor regarding
|
|
124
|
+
such Contributions.
|
|
125
|
+
|
|
126
|
+
6. Trademarks.
|
|
127
|
+
|
|
128
|
+
This License does not grant permission to use the trade names, trademarks,
|
|
129
|
+
service marks, or product names of the Licensor, except as required for
|
|
130
|
+
reasonable and customary use in describing the origin of the Work and
|
|
131
|
+
reproducing the content of the NOTICE file.
|
|
132
|
+
|
|
133
|
+
7. Disclaimer of Warranty.
|
|
134
|
+
|
|
135
|
+
Unless required by applicable law or agreed to in writing, Licensor provides the
|
|
136
|
+
Work (and each Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
137
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
|
|
138
|
+
including, without limitation, any warranties or conditions of TITLE,
|
|
139
|
+
NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are
|
|
140
|
+
solely responsible for determining the appropriateness of using or
|
|
141
|
+
redistributing the Work and assume any risks associated with Your exercise of
|
|
142
|
+
permissions under this License.
|
|
143
|
+
|
|
144
|
+
8. Limitation of Liability.
|
|
145
|
+
|
|
146
|
+
In no event and under no legal theory, whether in tort (including negligence),
|
|
147
|
+
contract, or otherwise, unless required by applicable law (such as deliberate
|
|
148
|
+
and grossly negligent acts) or agreed to in writing, shall any Contributor be
|
|
149
|
+
liable to You for damages, including any direct, indirect, special, incidental,
|
|
150
|
+
or consequential damages of any character arising as a result of this License or
|
|
151
|
+
out of the use or inability to use the Work (including but not limited to
|
|
152
|
+
damages for loss of goodwill, work stoppage, computer failure or malfunction, or
|
|
153
|
+
any and all other commercial damages or losses), even if such Contributor has
|
|
154
|
+
been advised of the possibility of such damages.
|
|
155
|
+
|
|
156
|
+
9. Accepting Warranty or Additional Liability.
|
|
157
|
+
|
|
158
|
+
While redistributing the Work or Derivative Works thereof, You may choose to
|
|
159
|
+
offer, and charge a fee for, acceptance of support, warranty, indemnity, or
|
|
160
|
+
other liability obligations and/or rights consistent with this License. However,
|
|
161
|
+
in accepting such obligations, You may act only on Your own behalf and on Your
|
|
162
|
+
sole responsibility, not on behalf of any other Contributor, and only if You
|
|
163
|
+
agree to indemnify, defend, and hold each Contributor harmless for any liability
|
|
164
|
+
incurred by, or claims asserted against, such Contributor by reason of your
|
|
165
|
+
accepting any such warranty or additional liability.
|
|
166
|
+
|
|
167
|
+
END OF TERMS AND CONDITIONS
|
|
168
|
+
|
|
169
|
+
APPENDIX: How to apply the Apache License to your work
|
|
170
|
+
|
|
171
|
+
To apply the Apache License to your work, attach the following boilerplate
|
|
172
|
+
notice, with the fields enclosed by brackets "[]" replaced with your own
|
|
173
|
+
identifying information. (Don't include the brackets!) The text should be
|
|
174
|
+
enclosed in the appropriate comment syntax for the file format. We also
|
|
175
|
+
recommend that a file or class name and description of purpose be included on
|
|
176
|
+
the same "printed page" as the copyright notice for easier identification within
|
|
177
|
+
third-party archives.
|
|
178
|
+
|
|
179
|
+
Copyright [yyyy] [name of copyright owner]
|
|
180
|
+
|
|
181
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
182
|
+
you may not use this file except in compliance with the License.
|
|
183
|
+
You may obtain a copy of the License at
|
|
184
|
+
|
|
185
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
186
|
+
|
|
187
|
+
Unless required by applicable law or agreed to in writing, software
|
|
188
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
189
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
190
|
+
See the License for the specific language governing permissions and
|
|
191
|
+
limitations under the License.
|
|
192
|
+
|
|
193
|
+
Copyright 2026 Hanzo AI, Inc
|
|
194
|
+
|
|
195
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
196
|
+
you may not use this file except in compliance with the License.
|
|
197
|
+
You may obtain a copy of the License at
|
|
198
|
+
|
|
199
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
200
|
+
|
|
201
|
+
Unless required by applicable law or agreed to in writing, software
|
|
202
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
203
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
204
|
+
See the License for the specific language governing permissions and
|
|
205
|
+
limitations under the License.
|
package/LICENSE-MIT
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Hanzo AI, Inc
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
Hanzo Build
|
|
2
|
+
Copyright (c) 2026 Hanzo AI, Inc.
|
|
3
|
+
|
|
4
|
+
Licensed under either of Apache License, Version 2.0 (LICENSE-APACHE) or
|
|
5
|
+
MIT license (LICENSE-MIT) at your option.
|
|
6
|
+
|
|
7
|
+
Unless you explicitly state otherwise, any contribution intentionally
|
|
8
|
+
submitted for inclusion in this work by you, as defined in the Apache-2.0
|
|
9
|
+
licence, shall be dual licensed as above, without any additional terms or
|
|
10
|
+
conditions.
|
|
11
|
+
|
|
12
|
+
The builder in this repository was extracted from the Hanzo workspace
|
|
13
|
+
(github.com/hanzoai/app). Its project workspace (src/project.tsx) is a port
|
|
14
|
+
of the Hanzo App v2 editor (github.com/hanzoai/build-v2), which is derived
|
|
15
|
+
from OSW Studio by Otto Stahl (github.com/o-stahl/osw-studio, MIT, Copyright
|
|
16
|
+
(c) 2025 Otto Stahl), itself derived from DeepSite v2 by enzostvs and the
|
|
17
|
+
DeepSite authors (huggingface.co/spaces/enzostvs/deepsite, MIT). Both are
|
|
18
|
+
used under the MIT License; their notices are reproduced here:
|
|
19
|
+
|
|
20
|
+
Permission is hereby granted, free of charge, to any person obtaining a
|
|
21
|
+
copy of this software and associated documentation files (the
|
|
22
|
+
"Software"), to deal in the Software without restriction, including
|
|
23
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
24
|
+
distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
25
|
+
persons to whom the Software is furnished to do so, subject to the
|
|
26
|
+
following conditions: The above copyright notice and this permission
|
|
27
|
+
notice shall be included in all copies or substantial portions of the
|
|
28
|
+
Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND.
|
|
29
|
+
|
|
30
|
+
Bundled at build time, under their own licences:
|
|
31
|
+
@hanzo/ui, @hanzo/gui MIT github.com/hanzoai/ui
|
|
32
|
+
@hanzo/iam MIT github.com/hanzoai/iam
|
|
33
|
+
@hanzo/font MIT github.com/hanzoai/font
|
|
34
|
+
@hanzogui/lucide-icons-2 ISC github.com/lucide-icons/lucide
|
|
35
|
+
react, react-dom MIT github.com/facebook/react
|
|
36
|
+
react-router MIT github.com/remix-run/react-router
|
|
37
|
+
next-themes MIT github.com/pacocoursey/next-themes
|
package/README.md
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# Hanzo Build
|
|
2
|
+
|
|
3
|
+
Say what you want. Hanzo writes it, runs it, and puts it on a live URL — with
|
|
4
|
+
the database, the sign-in and the storage already there.
|
|
5
|
+
|
|
6
|
+
The builder is one component with two hosts: this page (hanzo.build), and the
|
|
7
|
+
platform console at platform.hanzo.ai/dev. Both mount `<Builder host={…} />`
|
|
8
|
+
from `@hanzo/build`; neither forks it.
|
|
9
|
+
|
|
10
|
+
```
|
|
11
|
+
pnpm install
|
|
12
|
+
pnpm dev # http://localhost:3200
|
|
13
|
+
pnpm test # the transport contract and the address grammar
|
|
14
|
+
pnpm build:lib # lib/ — what npm ships
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
The port is not a preference. `vite.config.ts` pins 3200 for both `dev` and
|
|
18
|
+
`preview`, and IAM lists `http://localhost:3200/auth/callback` among this
|
|
19
|
+
client's redirects — sign in from any other port and the authorize call is
|
|
20
|
+
refused.
|
|
21
|
+
|
|
22
|
+
`/v1` is proxied to `api.hanzo.ai` from the dev server and from the preview of
|
|
23
|
+
a build: the gateway admits an origin by allowlist and a localhost port is not
|
|
24
|
+
on it.
|
|
25
|
+
|
|
26
|
+
## Mounting it
|
|
27
|
+
|
|
28
|
+
```tsx
|
|
29
|
+
import { Builder, type Host } from '@hanzo/build'
|
|
30
|
+
|
|
31
|
+
<Hanzo theme="dark">
|
|
32
|
+
<div style={{ height: '100dvh', display: 'flex' }}>
|
|
33
|
+
<Builder host={host} />
|
|
34
|
+
</div>
|
|
35
|
+
</Hanzo>
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
`Host` is everything that differs between hosts: where the platform is
|
|
39
|
+
(`api`), the bearer (`token()`, read at call time), the org (`org`), who is
|
|
40
|
+
signed in (`person`), whether they administer the org (`admin`), the address
|
|
41
|
+
under the mount (`path`) and how to move (`go`), and where to link out
|
|
42
|
+
(`links`, `open`). Peers: `@hanzo/ui`, `@hanzo/gui`, `@hanzogui/lucide-icons-2`,
|
|
43
|
+
`react`.
|
|
44
|
+
|
|
45
|
+
## Addresses
|
|
46
|
+
|
|
47
|
+
| path | screen |
|
|
48
|
+
|---|---|
|
|
49
|
+
| `''` | New — the empty state and the composer |
|
|
50
|
+
| `sess_<32 hex>` | one run, live |
|
|
51
|
+
| `-/artifacts` | what the org has built |
|
|
52
|
+
| `-/templates` | the public starters |
|
|
53
|
+
| `<slug>` | a project's workspace |
|
|
54
|
+
|
|
55
|
+
A project slug holds no `_` and never starts with `-`, so the forms cannot
|
|
56
|
+
collide.
|
|
57
|
+
|
|
58
|
+
## What is on the screen
|
|
59
|
+
|
|
60
|
+
**The rail.** New, Artifacts, Customize (the platform's plugins), More
|
|
61
|
+
(Templates, Machines, Docs), then the org's coding runs newest first with a
|
|
62
|
+
live status dot, and the account. Collapse is an explicit toggle kept in this
|
|
63
|
+
browser.
|
|
64
|
+
|
|
65
|
+
**New.** "What's up next?", and at the foot the composer: where the run runs
|
|
66
|
+
(Default is the platform's sandbox; the org's machines follow), the repository
|
|
67
|
+
and the branch — both searchable, paged popovers opening upward — then the
|
|
68
|
+
ask. Under it: attach (files ride the prompt as text), dictate, Build or Plan,
|
|
69
|
+
and the model and effort. A repository row can be added to a project.
|
|
70
|
+
|
|
71
|
+
**A run.** The transcript as it streams, steering while it works, Stop, and
|
|
72
|
+
the pull request once it pushes one.
|
|
73
|
+
|
|
74
|
+
**A project.** The v2 workspace in the same window: its runs as a
|
|
75
|
+
conversation with suggestions and a Build/Plan composer on the left; Preview,
|
|
76
|
+
Files, Code and Layers on the right with desktop/mobile, reload, the page
|
|
77
|
+
picker and open-in-tab; Share and Publish; the console dock under it.
|
|
78
|
+
|
|
79
|
+
## The contract
|
|
80
|
+
|
|
81
|
+
| call | what |
|
|
82
|
+
|---|---|
|
|
83
|
+
| `POST /v1/agent/coding` | start a run → 202 `{sessionId, …}` |
|
|
84
|
+
| `GET /v1/agent/sessions?kind=coding` | Recents, and a project's runs |
|
|
85
|
+
| `GET /v1/agent/sessions/{id}` · `GET /v1/agent/sessions/stream?root=` | a run, and its live feed (SSE over fetch) |
|
|
86
|
+
| `POST /v1/agent/sessions/{id}/message` · `/stop` | steer, stop |
|
|
87
|
+
| `GET /v1/agent/targets` | the org's machines |
|
|
88
|
+
| `GET /v1/provider/github/repos` · `…/{owner}/{repo}/branches` | the chips' pagers |
|
|
89
|
+
| `POST /v1/provider/github/user/connect` | connect a person's GitHub |
|
|
90
|
+
| `GET /v1/projects` · `POST /v1/projects/fork` · `GET /v1/templates` | artifacts, templates |
|
|
91
|
+
| `GET /v1/git/repos/{name}/tree` · `/blob` | Files and Code |
|
|
92
|
+
| `POST /v1/platform/apps` · `GET /v1/platform/builds` | Add to project, Publish |
|
|
93
|
+
| `GET /v1/models` · `POST /v1/event` | the model list, a verdict |
|
|
94
|
+
|
|
95
|
+
`mode`, `model` and `effort` are sent with a run as asked; the platform
|
|
96
|
+
honours them where it does and nothing here simulates them.
|
|
97
|
+
|
|
98
|
+
## Layout
|
|
99
|
+
|
|
100
|
+
```
|
|
101
|
+
src/
|
|
102
|
+
index.ts the library surface
|
|
103
|
+
builder.tsx the rail and the pane the address names
|
|
104
|
+
landing.tsx New
|
|
105
|
+
run.tsx one run
|
|
106
|
+
project.tsx a project's workspace
|
|
107
|
+
shelf.tsx Artifacts and Templates
|
|
108
|
+
publish.tsx Add to project / Publish
|
|
109
|
+
account.tsx the account and find-a-run dialogs
|
|
110
|
+
data.ts reads as hooks
|
|
111
|
+
host.tsx what a host provides
|
|
112
|
+
route.ts the address grammar
|
|
113
|
+
api/ one typed client per surface, over one call()
|
|
114
|
+
app/ this page's host: IAM, the router, the mount
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## Licence
|
|
118
|
+
|
|
119
|
+
Apache-2.0 OR MIT, at your option. See `NOTICE` — the project workspace is a
|
|
120
|
+
port of the v2 editor, derived from OSW Studio and DeepSite (MIT).
|
package/lib/account.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { RailSession } from '@hanzo/ui/chat';
|
|
2
|
+
export declare function Account({ open, onOpenChange }: {
|
|
3
|
+
open: boolean;
|
|
4
|
+
onOpenChange: (o: boolean) => void;
|
|
5
|
+
}): import("react").JSX.Element;
|
|
6
|
+
export declare function Find({ open, onOpenChange, recents, onOpen, }: {
|
|
7
|
+
open: boolean;
|
|
8
|
+
onOpenChange: (o: boolean) => void;
|
|
9
|
+
recents: RailSession[];
|
|
10
|
+
onOpen: (id: string) => void;
|
|
11
|
+
}): import("react").JSX.Element;
|
package/lib/account.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* The rail's two small dialogs: the account (the caret by the email), and
|
|
4
|
+
* finding a run by name (the search icon).
|
|
5
|
+
*/
|
|
6
|
+
import { SizableText, XStack, YStack } from '@hanzo/gui';
|
|
7
|
+
import { LogOut, Settings } from '@hanzogui/lucide-icons-2';
|
|
8
|
+
import { Button, Dialog, DialogContent, DialogTitle, Input } from '@hanzo/ui';
|
|
9
|
+
import { useMemo, useState } from 'react';
|
|
10
|
+
import { useHost } from './host.js';
|
|
11
|
+
export function Account({ open, onOpenChange }) {
|
|
12
|
+
const host = useHost();
|
|
13
|
+
const who = host.person;
|
|
14
|
+
return (_jsx(Dialog, { open: open, onOpenChange: onOpenChange, children: _jsxs(DialogContent, { maxW: 360, children: [_jsx(DialogTitle, { children: "Account" }), _jsxs(YStack, { gap: "$1", children: [_jsx(SizableText, { size: "$3", color: "$ink", numberOfLines: 1, children: who?.name || who?.email || 'Signed out' }), who?.email && who.name ? (_jsx(SizableText, { size: "$2", color: "$soft", numberOfLines: 1, children: who.email })) : null, host.org ? (_jsxs(SizableText, { size: "$1", color: "$soft", children: ["Organization: ", host.org] })) : null] }), _jsxs(XStack, { gap: "$2", justify: "flex-end", flexWrap: "wrap", children: [_jsxs(Button, { variant: "outline", size: "sm", onPress: () => host.open(host.links.settings), children: [_jsx(Settings, { size: 14 }), " Settings"] }), host.signOut ? (_jsxs(Button, { variant: "outline", size: "sm", onPress: () => host.signOut?.(), children: [_jsx(LogOut, { size: 14 }), " Sign out"] })) : null] })] }) }));
|
|
15
|
+
}
|
|
16
|
+
export function Find({ open, onOpenChange, recents, onOpen, }) {
|
|
17
|
+
const [q, setQ] = useState('');
|
|
18
|
+
const hits = useMemo(() => {
|
|
19
|
+
const n = q.trim().toLowerCase();
|
|
20
|
+
return (n ? recents.filter((r) => r.title.toLowerCase().includes(n)) : recents).slice(0, 12);
|
|
21
|
+
}, [q, recents]);
|
|
22
|
+
return (_jsx(Dialog, { open: open, onOpenChange: onOpenChange, children: _jsxs(DialogContent, { maxW: 480, children: [_jsx(DialogTitle, { children: "Find a run" }), _jsx(Input, { autoFocus: true, value: q, onChangeText: setQ, placeholder: "Search runs\u2026", "aria-label": "Search runs", onKeyDown: (e) => {
|
|
23
|
+
if ((e.key ?? e.nativeEvent?.key) === 'Enter' && hits[0])
|
|
24
|
+
onOpen(hits[0].id);
|
|
25
|
+
} }), _jsx(YStack, { gap: "$1", role: "list", children: hits.length === 0 ? (_jsx(SizableText, { size: "$2", color: "$soft", children: "No run matches." })) : (hits.map((r) => (_jsx(XStack, { role: "listitem", render: "button", onPress: () => onOpen(r.id), px: "$2", py: "$1.5", rounded: "$3", hoverStyle: { bg: '$hover' }, children: _jsx(SizableText, { size: "$2", color: "$ink", numberOfLines: 1, children: r.title }) }, r.id)))) })] }) }));
|
|
26
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One request path to the platform.
|
|
3
|
+
*
|
|
4
|
+
* Every typed op below goes through `call`, so the bearer, the org scope, the
|
|
5
|
+
* no-store cache rule and the reading of a refusal are decided once. The
|
|
6
|
+
* platform answers a refusal as RFC 9457 problem details; older handlers still
|
|
7
|
+
* answer `{error:{message}}` or `{msg}`, and all three read the same way here.
|
|
8
|
+
*/
|
|
9
|
+
/** Where the platform is and who is asking. The host supplies it. */
|
|
10
|
+
export interface Target {
|
|
11
|
+
/** The platform origin, no trailing slash: calls are `${api}/v1/…`. */
|
|
12
|
+
api: string;
|
|
13
|
+
/** The signed-in person's bearer, or null for nobody. */
|
|
14
|
+
token: () => string | null;
|
|
15
|
+
/** The org every call is scoped to, sent as `X-Org-Id`. */
|
|
16
|
+
org: string | null;
|
|
17
|
+
}
|
|
18
|
+
/** A refusal: the status, and the platform's own sentence for it. */
|
|
19
|
+
export declare class Refusal extends Error {
|
|
20
|
+
readonly status: number;
|
|
21
|
+
constructor(status: number, message: string);
|
|
22
|
+
}
|
|
23
|
+
export type Query = Record<string, string | number | boolean | null | undefined>;
|
|
24
|
+
/** `?a=1&b=2` from the defined, non-empty entries of `q`, or ''. */
|
|
25
|
+
export declare function query(q?: Query): string;
|
|
26
|
+
/** The headers every call carries: the bearer and the org, when there are ones. */
|
|
27
|
+
export declare function headers(t: Target, extra?: HeadersInit): Headers;
|
|
28
|
+
/** The sentence a refusal carries, whichever envelope it arrived in. */
|
|
29
|
+
export declare function reason(res: Response): Promise<string>;
|
|
30
|
+
/** A path segment, escaped. Ids and names from a row never compose a path raw. */
|
|
31
|
+
export declare const seg: (s: string) => string;
|
|
32
|
+
/**
|
|
33
|
+
* One JSON call. Throws `Refusal` on any non-2xx, with the platform's reason, or
|
|
34
|
+
* the status when it gave none. A 204 answers `undefined`.
|
|
35
|
+
*/
|
|
36
|
+
export declare function call<T>(t: Target, method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE', path: string, body?: unknown, init?: {
|
|
37
|
+
signal?: AbortSignal;
|
|
38
|
+
}): Promise<T>;
|
package/lib/api/call.js
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One request path to the platform.
|
|
3
|
+
*
|
|
4
|
+
* Every typed op below goes through `call`, so the bearer, the org scope, the
|
|
5
|
+
* no-store cache rule and the reading of a refusal are decided once. The
|
|
6
|
+
* platform answers a refusal as RFC 9457 problem details; older handlers still
|
|
7
|
+
* answer `{error:{message}}` or `{msg}`, and all three read the same way here.
|
|
8
|
+
*/
|
|
9
|
+
/** A refusal: the status, and the platform's own sentence for it. */
|
|
10
|
+
export class Refusal extends Error {
|
|
11
|
+
status;
|
|
12
|
+
constructor(status, message) {
|
|
13
|
+
super(message);
|
|
14
|
+
this.status = status;
|
|
15
|
+
this.name = 'Refusal';
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
/** `?a=1&b=2` from the defined, non-empty entries of `q`, or ''. */
|
|
19
|
+
export function query(q = {}) {
|
|
20
|
+
const s = new URLSearchParams();
|
|
21
|
+
for (const [k, v] of Object.entries(q)) {
|
|
22
|
+
if (v === undefined || v === null || v === '')
|
|
23
|
+
continue;
|
|
24
|
+
s.set(k, String(v));
|
|
25
|
+
}
|
|
26
|
+
const out = s.toString();
|
|
27
|
+
return out ? `?${out}` : '';
|
|
28
|
+
}
|
|
29
|
+
/** The headers every call carries: the bearer and the org, when there are ones. */
|
|
30
|
+
export function headers(t, extra) {
|
|
31
|
+
const h = new Headers(extra);
|
|
32
|
+
const token = t.token();
|
|
33
|
+
if (token && !h.has('Authorization'))
|
|
34
|
+
h.set('Authorization', `Bearer ${token}`);
|
|
35
|
+
if (t.org && !h.has('X-Org-Id'))
|
|
36
|
+
h.set('X-Org-Id', t.org);
|
|
37
|
+
return h;
|
|
38
|
+
}
|
|
39
|
+
/** The sentence a refusal carries, whichever envelope it arrived in. */
|
|
40
|
+
export async function reason(res) {
|
|
41
|
+
try {
|
|
42
|
+
const body = (await res.json());
|
|
43
|
+
const err = typeof body.error === 'string' ? body.error : body.error?.message;
|
|
44
|
+
return body.detail || err || body.msg || body.message || body.title || '';
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
return '';
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
/** A path segment, escaped. Ids and names from a row never compose a path raw. */
|
|
51
|
+
export const seg = (s) => encodeURIComponent(s);
|
|
52
|
+
/**
|
|
53
|
+
* One JSON call. Throws `Refusal` on any non-2xx, with the platform's reason, or
|
|
54
|
+
* the status when it gave none. A 204 answers `undefined`.
|
|
55
|
+
*/
|
|
56
|
+
export async function call(t, method, path, body, init) {
|
|
57
|
+
const h = headers(t, body === undefined ? undefined : { 'Content-Type': 'application/json' });
|
|
58
|
+
const res = await fetch(`${t.api}${path}`, {
|
|
59
|
+
method,
|
|
60
|
+
headers: h,
|
|
61
|
+
body: body === undefined ? undefined : JSON.stringify(body),
|
|
62
|
+
// A run, a repo list and a status are facts about now. A cached refusal
|
|
63
|
+
// outlives the fix.
|
|
64
|
+
cache: 'no-store',
|
|
65
|
+
signal: init?.signal,
|
|
66
|
+
});
|
|
67
|
+
if (!res.ok) {
|
|
68
|
+
const why = await reason(res);
|
|
69
|
+
throw new Refusal(res.status, why || `${method} ${path.split('?')[0]} answered ${res.status}`);
|
|
70
|
+
}
|
|
71
|
+
if (res.status === 204)
|
|
72
|
+
return undefined;
|
|
73
|
+
const text = await res.text();
|
|
74
|
+
return (text ? JSON.parse(text) : undefined);
|
|
75
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Starting a coding run.
|
|
3
|
+
*
|
|
4
|
+
* POST /v1/agent/coding → 202 {sessionId, repo, branch, project, routed, targetId}
|
|
5
|
+
*
|
|
6
|
+
* 202 is ADMITTED, not finished: the answer is the session the run narrates
|
|
7
|
+
* itself in, and the session stream is how it is watched.
|
|
8
|
+
*
|
|
9
|
+
* Where it runs is one field. No `targetId` is the platform's sandbox; a target
|
|
10
|
+
* id routes it to one of the org's machines, and `routed` says whether it got
|
|
11
|
+
* there.
|
|
12
|
+
*
|
|
13
|
+
* `mode`, `model` and `effort` are this surface's asks of the contract: `plan`
|
|
14
|
+
* is a run that plans and writes nothing, `build` edits, commits and pushes.
|
|
15
|
+
* They are sent as asked and never simulated here — a run the platform has not
|
|
16
|
+
* been told how to plan is not made to look like one.
|
|
17
|
+
*/
|
|
18
|
+
import { type Target } from './call.ts';
|
|
19
|
+
export type Mode = 'build' | 'plan';
|
|
20
|
+
/**
|
|
21
|
+
* The modes the platform honours today. `CodingStartIn` takes no `mode` yet, so
|
|
22
|
+
* a plan run would edit, commit and push like any other — on a machine, with
|
|
23
|
+
* that machine's credentials. Until the platform takes `plan`, a plan ask is
|
|
24
|
+
* refused here rather than sent to become a build.
|
|
25
|
+
*/
|
|
26
|
+
export declare const HONOURED: readonly Mode[];
|
|
27
|
+
/** Why a mode cannot be asked for yet, or '' when it can. */
|
|
28
|
+
export declare const unhonoured: (mode: Mode | undefined) => string;
|
|
29
|
+
export interface Ask {
|
|
30
|
+
/** The task, in the words you would use with a colleague. */
|
|
31
|
+
prompt: string;
|
|
32
|
+
/** `owner/name`. Omitted starts something new, in a repository named for it. */
|
|
33
|
+
repo?: string;
|
|
34
|
+
/** The branch to start from. Omitted takes the repository's default. */
|
|
35
|
+
base?: string;
|
|
36
|
+
/** One of the org's machines. Omitted is the sandbox. */
|
|
37
|
+
targetId?: string;
|
|
38
|
+
/** The project slug the run works on. */
|
|
39
|
+
project?: string;
|
|
40
|
+
/** An earlier run's session to continue from, on the branch it pushed. */
|
|
41
|
+
after?: string;
|
|
42
|
+
mode?: Mode;
|
|
43
|
+
model?: string;
|
|
44
|
+
effort?: string;
|
|
45
|
+
}
|
|
46
|
+
export interface Run {
|
|
47
|
+
session: string;
|
|
48
|
+
repo: string;
|
|
49
|
+
branch: string;
|
|
50
|
+
project: string;
|
|
51
|
+
routed: boolean;
|
|
52
|
+
target: string;
|
|
53
|
+
}
|
|
54
|
+
/** The request body: only what was asked, with no empty strings sent as values. */
|
|
55
|
+
export declare function body(ask: Ask): Record<string, string>;
|
|
56
|
+
export declare function start(t: Target, ask: Ask): Promise<Run>;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Starting a coding run.
|
|
3
|
+
*
|
|
4
|
+
* POST /v1/agent/coding → 202 {sessionId, repo, branch, project, routed, targetId}
|
|
5
|
+
*
|
|
6
|
+
* 202 is ADMITTED, not finished: the answer is the session the run narrates
|
|
7
|
+
* itself in, and the session stream is how it is watched.
|
|
8
|
+
*
|
|
9
|
+
* Where it runs is one field. No `targetId` is the platform's sandbox; a target
|
|
10
|
+
* id routes it to one of the org's machines, and `routed` says whether it got
|
|
11
|
+
* there.
|
|
12
|
+
*
|
|
13
|
+
* `mode`, `model` and `effort` are this surface's asks of the contract: `plan`
|
|
14
|
+
* is a run that plans and writes nothing, `build` edits, commits and pushes.
|
|
15
|
+
* They are sent as asked and never simulated here — a run the platform has not
|
|
16
|
+
* been told how to plan is not made to look like one.
|
|
17
|
+
*/
|
|
18
|
+
import { call, Refusal } from './call.js';
|
|
19
|
+
/**
|
|
20
|
+
* The modes the platform honours today. `CodingStartIn` takes no `mode` yet, so
|
|
21
|
+
* a plan run would edit, commit and push like any other — on a machine, with
|
|
22
|
+
* that machine's credentials. Until the platform takes `plan`, a plan ask is
|
|
23
|
+
* refused here rather than sent to become a build.
|
|
24
|
+
*/
|
|
25
|
+
export const HONOURED = ['build'];
|
|
26
|
+
/** Why a mode cannot be asked for yet, or '' when it can. */
|
|
27
|
+
export const unhonoured = (mode) => mode && !HONOURED.includes(mode)
|
|
28
|
+
? 'Plan needs the platform’s plan mode, which the coding API does not take yet — this ask would build. Switch to Build, or wait for Plan.'
|
|
29
|
+
: '';
|
|
30
|
+
/** The request body: only what was asked, with no empty strings sent as values. */
|
|
31
|
+
export function body(ask) {
|
|
32
|
+
const out = { prompt: ask.prompt.trim() };
|
|
33
|
+
for (const k of ['repo', 'base', 'targetId', 'project', 'after', 'mode', 'model', 'effort']) {
|
|
34
|
+
const v = ask[k]?.trim();
|
|
35
|
+
if (v)
|
|
36
|
+
out[k] = v;
|
|
37
|
+
}
|
|
38
|
+
return out;
|
|
39
|
+
}
|
|
40
|
+
export async function start(t, ask) {
|
|
41
|
+
if (!ask.prompt.trim())
|
|
42
|
+
throw new Refusal(400, 'Say what the run should do');
|
|
43
|
+
const why = unhonoured(ask.mode);
|
|
44
|
+
if (why)
|
|
45
|
+
throw new Refusal(400, why);
|
|
46
|
+
const r = await call(t, 'POST', '/v1/agent/coding', body(ask));
|
|
47
|
+
const s = (k) => (typeof r?.[k] === 'string' ? r[k] : '');
|
|
48
|
+
if (!s('sessionId'))
|
|
49
|
+
throw new Refusal(502, 'The run was admitted but named no session');
|
|
50
|
+
return {
|
|
51
|
+
session: s('sessionId'),
|
|
52
|
+
repo: s('repo'),
|
|
53
|
+
branch: s('branch'),
|
|
54
|
+
project: s('project'),
|
|
55
|
+
routed: r?.routed === true,
|
|
56
|
+
target: s('targetId'),
|
|
57
|
+
};
|
|
58
|
+
}
|