@huaweidevtools/aishell-dsh-e2b 0.0.0-stage → 0.0.1-beta.3

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 ADDED
@@ -0,0 +1,201 @@
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,
10
+ and distribution as defined in Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is derived from (or based upon) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 Huawei Cloud AI Shell
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
200
+ implied. See the License for the specific language governing
201
+ permissions and limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,201 @@
1
- # Temporary Holding Version
1
+ # @huaweidevtools/aishell-dsh-e2b
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Runs throwaway and preview deployments in E2B sandboxes — sandbox lifecycle,
4
+ commands, and files, as tools the model calls.
5
+
6
+ > **Not to be confused with `@deepseek-ai/dsh-e2b`.** That official package
7
+ > replaces the harness's execution world: mount it and *all* of the agent's own
8
+ > file and command work runs in a remote sandbox. This package instead adds
9
+ > *tools*, so the agent keeps working locally and reaches a sandbox only when it
10
+ > decides to.
11
+ >
12
+ > The two can be mounted together. This package registers its tools under the
13
+ > `aishell__` prefix (`aishell__sandbox_create`), so a tool name cannot collide
14
+ > with the official package's, whichever names it uses.
15
+
16
+ ## Why this exists
17
+
18
+ Every deployment request currently reaches the same path — the Huawei Cloud
19
+ operations server, provisioning real resources with real cost, real credentials,
20
+ and real cleanup obligations. A large fraction of requests do not need that: a
21
+ static page, a small service, something to look at once. Those need a place to
22
+ run and an address to open, and nothing that outlives the task.
23
+
24
+ This plugin adds that second tier, and contributes a prompt section stating when
25
+ each is appropriate. Tools alone would leave the choice to guesswork.
26
+
27
+ ## How it reaches the service
28
+
29
+ ```
30
+ POST https://openapi.aishell.openbuildlab.com/e2b/keys (AK/SK signed)
31
+ → {"api_key": "sk-e2b-…", "expires_at": "…"} presented as X-API-KEY
32
+ ```
33
+
34
+ The key is a **stored credential**, kept under `AISHELL_E2B_API_KEY` in the same
35
+ credential store the AK/SK live in:
36
+
37
+ 1. Read it from the store.
38
+ 2. Missing, past its `expires_at`, **or minted under different credentials** →
39
+ `POST /e2b/keys` once, and store the result.
40
+ 3. Present the stored key on every sandbox call.
41
+ 4. If a sandbox call is refused as unauthenticated → discard the key, issue a
42
+ new one, and retry that call once.
43
+
44
+ A key issued with no expiry records `9999-12-31` as its expiry, so "never
45
+ expires" stays one comparison rather than a second shape.
46
+
47
+ ### The key belongs to the credentials that minted it
48
+
49
+ The key entry also records a **fingerprint of the AK** that requested it, and a
50
+ stored key is used only while it matches the credentials in hand. Without that,
51
+ clearing or replacing the AK/SK would leave the old key — and so the old tenant,
52
+ with all its sandboxes — alive and usable, which is the opposite of what
53
+ clearing credentials means.
54
+
55
+ Three consequences are deliberate:
56
+
57
+ - **No credentials at all invalidates it too.** Clearing them states that
58
+ nothing granted under them may still be presented.
59
+ - **Re-entering the same AK/SK does not rotate the key.** The fingerprint
60
+ answers "which identity minted this", not "when was it written". Re-saving the
61
+ same pair has changed nothing, and throwing away running sandboxes for it
62
+ would be gratuitous.
63
+ - **No event listener is needed.** The check is on the read path, so it also
64
+ catches a store changed outside the credential form, or while this plugin was
65
+ not mounted.
66
+
67
+ A mismatch does **not** delete the stored entry: an empty read is not proof of a
68
+ clear (a locked keyring answers `undefined` for entries that are really there),
69
+ and deleting on it would rotate the tenant on every keyring hiccup. The entry is
70
+ overwritten by the next successful create. A key stored by an older build
71
+ carries no fingerprint and is trusted as-is, so upgrading does not orphan
72
+ existing sandboxes; the 401 path still catches a key that has really stopped
73
+ working.
74
+
75
+ The key is the tenant: the gateway derives a caller identity from the presented
76
+ key and scopes every sandbox to it. That is why it is **persisted rather than
77
+ held in memory** — a key re-created on every start would be a new tenant, and
78
+ every sandbox made before it would stop being reachable, which surfaces as "no
79
+ such sandbox" and points nowhere near the cause. A replacement key is a new
80
+ tenant for the same reason, so the 401 path is a recovery for a dead key, not a
81
+ routine refresh.
82
+
83
+ The sandbox protocol itself is spoken by the official `e2b` client library,
84
+ pointed at the gateway's domain — the configuration the gateway exists to accept.
85
+
86
+ ## Tools
87
+
88
+ Registered under `aishell__`, like every tool this plugin set contributes. The
89
+ prefix is what makes several packages' tools coexist in one registry: a bare
90
+ `sandbox_create` is fine until another package registers the same name, and then
91
+ one of the two silently loses.
92
+
93
+ | Tool | E2B SDK method |
94
+ |---|---|
95
+ | `aishell__sandbox_create` | `Sandbox.create` |
96
+ | `aishell__sandbox_list` | `Sandbox.list` |
97
+ | `aishell__sandbox_info` | `getInfo` |
98
+ | `aishell__sandbox_kill` | `kill` |
99
+ | `aishell__sandbox_set_timeout` | `setTimeout` |
100
+ | `aishell__sandbox_commands_run` | `commands.run` |
101
+ | `aishell__sandbox_commands_kill` | `commands.kill` |
102
+ | `aishell__sandbox_files_write` | `files.write` |
103
+ | `aishell__sandbox_files_read` | `files.read` |
104
+ | `aishell__sandbox_files_download` | `files.read` → `ctx.fs` |
105
+ | `aishell__sandbox_files_list` | `files.list` |
106
+ | `aishell__sandbox_get_port_url` | `getHost` |
107
+
108
+ ### One conversation, one sandbox
109
+
110
+ A conversation works in at most one sandbox. No tool but `aishell__sandbox_create` takes a
111
+ `sandboxId` — there is nothing to choose between, so there is no parameter to get
112
+ wrong and no way for a call to land somewhere the model did not mean.
113
+
114
+ `aishell__sandbox_create` binds the sandbox to the conversation; creating a second one
115
+ replaces the binding, and the first keeps running until its lifetime expires, so
116
+ `aishell__sandbox_kill` is how it is released.
117
+
118
+ **The binding is never created implicitly.** A tool called with no sandbox fails
119
+ and names `aishell__sandbox_create`. A tool that quietly created one would have to pick
120
+ the template and the lifetime, and those are the two decisions the create tool's
121
+ parameters exist to put in the conversation.
122
+
123
+ **The binding survives a restart.** The sandbox is tagged with its conversation
124
+ in its own `metadata` at creation, and a process that has no binding rebuilds it
125
+ by querying for that tag — so a plugin reload does not orphan a running sandbox.
126
+ A paused sandbox is not adopted, because using it would mean resuming it and
127
+ restarting its clock.
128
+
129
+ ### Three conventions worth knowing
130
+
131
+ - **`timeoutMs` is milliseconds.** The TypeScript SDK counts milliseconds where
132
+ the Python one counts seconds. The service caps a lifetime at 24 hours for a
133
+ pro account and 1 hour for a hobby account.
134
+ - **A sandbox that has expired is distinguished from one that never existed.**
135
+ The first means the previous sandbox's contents are gone and a replacement
136
+ starts empty; the error says so, because the model has to know that before it
137
+ decides to carry on.
138
+ - **A non-zero exit is a result, not a failure.** `aishell__sandbox_commands_run` reports
139
+ the exit code and both streams, so a failing test or a compile error reads as
140
+ an outcome to reason about rather than a broken tool.
141
+
142
+ ## Config
143
+
144
+ | Field | Default | Meaning |
145
+ |---|---|---|
146
+ | `apiBaseUrl` | `https://openapi.aishell.openbuildlab.com` | The key provisioning service |
147
+ | `domain` | `aishell.openbuildlab.com` | The sandbox gateway's domain (an E2B client's `E2B_DOMAIN`) |
148
+ | `requestTimeoutMs` | `60,000` | Per-request timeout, key fetch and SDK calls alike |
149
+
150
+ Credentials are the same Huawei Cloud AK/SK pair the other plugins in this set
151
+ use, read from the same store. Store them through the credential button in the
152
+ composer — the Huawei Cloud chip under the input bar, or the same chip on the
153
+ New-Session row. Clicking it opens the credential form in the current
154
+ conversation; there is no Settings section to find.
155
+
156
+ ## What it does NOT do
157
+
158
+ - **It does not provision cloud resources.** Persistent infrastructure belongs to
159
+ the operations server; nothing here survives a sandbox's lifetime.
160
+ - **It does not move the agent's own work into a sandbox.** Files the agent reads
161
+ and commands it runs stay local unless it calls one of these tools. For the
162
+ other arrangement, mount the official `@deepseek-ai/dsh-e2b`.
163
+ - **It does not gate destructive calls behind approval.** `aishell__sandbox_kill` and
164
+ `aishell__sandbox_commands_run` run without an approval prompt in this version.
165
+ - **It cannot write a binary file to the local workspace.** The sandbox side
166
+ supports it — `files.read` returns bytes, and `sandbox.downloadUrl` issues a
167
+ presigned URL — but the harness filesystem (`ctx.fs`) accepts UTF-8 text only,
168
+ with no binary write on either the abstract provider or the local backend. So
169
+ `aishell__sandbox_files_download` writes text as text and, for a binary file, returns
170
+ base64 and says so rather than writing a mangled copy.
171
+ - **It does not adopt a paused sandbox.** Recovery only takes a sandbox the
172
+ gateway reports as running. A paused one would have to be resumed to be used,
173
+ which restarts its clock — a billing decision left to `aishell__sandbox_create`.
174
+ - **It does not tag pre-existing sandboxes.** A sandbox created outside this
175
+ plugin carries no conversation tag, so `aishell__sandbox_list` shows it but no
176
+ conversation adopts it.
177
+
178
+ ## Install
179
+
180
+ ```sh
181
+ # Standalone
182
+ dsh plugin --profile <name> add @huaweidevtools/aishell-dsh-e2b
183
+
184
+ # Or as part of the set
185
+ dsh plugin --profile <name> add @huaweidevtools/aishell-dsh-base
186
+ ```
187
+
188
+ ## Known gaps
189
+
190
+ - **Public reachability of a port URL is not yet settled.** `aishell__sandbox_get_port_url`
191
+ returns `https://<port>-<sandboxId>.<domain>`, following the E2B SDK, whose
192
+ `getHost` composes exactly that hostname. Whether that address is open to
193
+ anyone or requires the sandbox's traffic token is decided by the gateway's
194
+ network configuration, and has not been verified against a live deployment.
195
+ - **`files.write` feature gates depend on the sandbox's `envd` version.** In
196
+ particular `useOctetStream` needs envd ≥ 0.5.7 — below that the SDK silently
197
+ falls back to multipart. The text writes this plugin performs are unaffected.
198
+
199
+ ## License
200
+
201
+ Apache License 2.0. See [LICENSE](../../LICENSE).
@@ -0,0 +1,19 @@
1
+ # aishell-e2b bundle patch: inserts the sandbox-tools plugin.
2
+ # Install standalone: `dsh plugin --profile <name> add @huaweidevtools/aishell-dsh-e2b`
3
+ #
4
+ # The single row mounts a host-only plugin: it registers the sandbox tools
5
+ # and one prompt section saying when a sandbox is the right tier rather than
6
+ # provisioning real resources. It has no browser half.
7
+ #
8
+ # The name is close to the official `@deepseek-ai/dsh-e2b`, which is a
9
+ # different thing: that package replaces the harness's execution world so all
10
+ # of the agent's own file and command work runs remotely. This one adds tools
11
+ # the agent calls deliberately, and leaves its local work local. Only the names
12
+ # resemble each other.
13
+ #
14
+ # The row carries no `config`: the defaults point at the published AI Shell
15
+ # services, and a profile that needs another deployment sets apiBaseUrl and
16
+ # domain itself.
17
+ - insert:
18
+ - id: aishell-e2b
19
+ name: '@huaweidevtools/aishell-dsh-e2b'