loopzero-sdk-pty 0.0.0-stage → 0.1.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/CHANGELOG.md ADDED
@@ -0,0 +1,229 @@
1
+ # loopzero-sdk-pty
2
+
3
+ ## 0.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#1275](https://github.com/getloopscale/loopzero-sdk/pull/1275) [`bae4bde`](https://github.com/getloopscale/loopzero-sdk/commit/bae4bde53fa6a24184fca17804d41ffc7f3cdd8e) Thanks [@aifactory-paulohenriquevn](https://github.com/apps/aifactory-paulohenriquevn)! - Add `createConfinedPtyBackend` (root-forced cwd, sandbox wrap, scrubbed environment) and `probeConfinement`, which proves on this host that the confinement works and returns the reason when it does not ([#1040](https://github.com/getloopscale/loopzero-sdk/issues/1040)).
8
+
9
+ ## 0.3.6
10
+
11
+ ## 0.3.6-next.1
12
+
13
+ ### Patch Changes
14
+
15
+ - Updated dependencies [667bd3d]
16
+ - Updated dependencies [edfa59c]
17
+ - Updated dependencies [4415f83]
18
+ - Updated dependencies [9181434]
19
+ - Updated dependencies [edfa59c]
20
+ - Updated dependencies [edfa59c]
21
+ - Updated dependencies [4be7411]
22
+ - Updated dependencies [24fb692]
23
+ - Updated dependencies [edfa59c]
24
+ - Updated dependencies [912e3b9]
25
+ - Updated dependencies [374dd5f]
26
+ - Updated dependencies [16a996f]
27
+ - Updated dependencies [667bd3d]
28
+ - Updated dependencies [63617cd]
29
+ - Updated dependencies [edfa59c]
30
+ - Updated dependencies [edfa59c]
31
+ - Updated dependencies [926cb81]
32
+ - Updated dependencies [7f91326]
33
+ - Updated dependencies [edfa59c]
34
+ - Updated dependencies [243bd2c]
35
+ - Updated dependencies [edfa59c]
36
+ - Updated dependencies [ba6549f]
37
+ - Updated dependencies [edfa59c]
38
+ - Updated dependencies [374dd5f]
39
+ - Updated dependencies [374dd5f]
40
+ - Updated dependencies [21be5cb]
41
+ - Updated dependencies [edfa59c]
42
+ - Updated dependencies [5d174f2]
43
+ - Updated dependencies [0c4df84]
44
+ - Updated dependencies [618cd02]
45
+ - Updated dependencies [edfa59c]
46
+ - Updated dependencies [d1182ae]
47
+ - Updated dependencies [31fea8f]
48
+ - Updated dependencies [691d8e6]
49
+ - Updated dependencies [1499923]
50
+ - Updated dependencies [0ceeddc]
51
+ - Updated dependencies [f64ab2b]
52
+ - Updated dependencies [558dd30]
53
+ - Updated dependencies [94722e8]
54
+ - Updated dependencies [6aeeadb]
55
+ - Updated dependencies [7f2bce4]
56
+ - Updated dependencies [edfa59c]
57
+ - Updated dependencies [266ffc8]
58
+ - Updated dependencies [e0a1ab9]
59
+ - Updated dependencies [edfa59c]
60
+ - loopzero-sdk@5.0.0-next.1
61
+
62
+ ## 0.3.6-next.0
63
+
64
+ ### Patch Changes
65
+
66
+ - Updated dependencies [01630ec]
67
+ - loopzero-sdk@4.63.4-next.0
68
+
69
+ ## 0.3.5
70
+
71
+ ### Patch Changes
72
+
73
+ - e8b8930: Raises the `loopzero-sdk` peer floor from `>=4.4.1` to `>=4.54.0`.
74
+
75
+ This range **passed** the CI leg that builds each package against its own floor, and that is what
76
+ makes it worth recording. `sdk-pty`'s build does not typecheck the SDK's declarations, so a broken
77
+ `.d.ts` never reaches its compiler. A consumer's does.
78
+
79
+ Measured across the 4.x line with `skipLibCheck: false` and `@types/node` + `zod` installed —
80
+ the environment a real consumer has:
81
+
82
+ | version | errors inside the SDK's own `.d.ts` |
83
+ | ---------- | ----------------------------------- |
84
+ | 4.4.1 | 6 |
85
+ | 4.19.3 | 7 |
86
+ | 4.53.1 | 7 |
87
+ | **4.54.0** | **0** |
88
+
89
+ 4.54.0 is the first version a TypeScript consumer can compile against at all (#335 / #345 / #348).
90
+ The old floor was true about this repository's build and false about the consumers the field exists
91
+ to inform — and where those disagree, the consumer's answer is the one a peer range is making a
92
+ claim about.
93
+
94
+ ## 0.3.4
95
+
96
+ ### Patch Changes
97
+
98
+ - e3f2a82: Public-API documentation reviewed file by file, and corrected wherever it disagreed
99
+ with the code. The docblocks ship in the `.d.ts`, so these read as behaviour changes
100
+ in an editor even though no behaviour changed.
101
+
102
+ The corrections that change what a caller would do:
103
+
104
+ - **`sdk-cache` documented its own premise backwards.** The header example labelled a
105
+ semantic hit as if it avoided the provider call. `asPlugin()` returns the cached
106
+ answer as `recalledContext`, which the agent loop injects as a `<memory-context>`
107
+ block _before_ the prompt — the request still goes to the provider. The two modes
108
+ are now labelled separately, with a table saying which one short-circuits and which
109
+ one seeds.
110
+ - **`sdk-handoff`'s five error classes said "throw".** Under the plugin wiring the
111
+ handler never throws; every failure becomes a tool result `{"ok":false,…}` handed
112
+ back to the model. Each class now says where it is actually observable. The header
113
+ also told readers to `import { Handoff } from "loopzero-sdk"`, from which it was
114
+ extracted.
115
+ - **`sdk-budget`'s `charge()` claimed idempotency across concurrent calls.** The mutex
116
+ serialises, it does not deduplicate: two identical calls record twice. Related, and
117
+ newly documented: with `maxUsd` set, a model missing from the pricing table denies
118
+ every request rather than passing it — and the table matches by exact string, so
119
+ `"openai/gpt-4o"` does not match `"gpt-4o"`.
120
+ - **The three `memory-*` adapters advertised an env-var fallback they do not read**,
121
+ and their peer dependencies are required rather than optional. Their behavioural
122
+ differences are now stated where they break the "interchangeable adapter"
123
+ assumption — honcho ignores `k` and always throws on `delete`; mem0 recalls across
124
+ sessions by design; supermemory ignores `sessionId` entirely.
125
+ - **`sdk-memory`'s `truncated` flag was documented as its own inverse**, and its
126
+ dreaming sweep claimed a mutex it never takes against the writer it names.
127
+ - **`sdk-tools`** corrected `run_vitest`'s unreachable `no_vitest` code, `truncation`'s
128
+ replacement-character claim, and two return shapes missing a live error code.
129
+ - **`acp`/`cli`** corrected sixteen statements including a named error class that is
130
+ not the one raised, a handler documented as calling `fork()` that refuses
131
+ unconditionally, handlers described as pure that mint ids and mutate a store, a
132
+ config loader credited to Zod in a package that does not import it, and a `--force`
133
+ scaffold described as atomic that deletes the destination before the rename.
134
+
135
+ Undocumented public symbols were documented across every package, with each claim
136
+ checked against the implementation rather than inferred from the name.
137
+
138
+ - e368fc1: Every published declaration file now compiles without `skipLibCheck` (#345). The
139
+ DTS rollup emitted symbols as a re-export from a chunk while omitting them from
140
+ that chunk's `import`, and dropped type-only imports from external packages —
141
+ leaving 51 unresolved references across ten of the twelve packages. Nothing broke
142
+ at runtime, and `tsc` stayed green for anyone with `skipLibCheck` on, but a
143
+ consumer running type-aware lint saw every type reached through one degrade to
144
+ `error`.
145
+
146
+ The declarations are repaired at build time from the compiler's own diagnostics.
147
+ No source or API change.
148
+
149
+ - 1ac974f: **`loopzero-sdk-pty` declares its licence.** Every published version up to now shipped with no `license` field in the manifest. npm reads the field, not the directory, so the tarball was all-rights-reserved to whoever installed it — the terms were sitting in the `LICENSE` file it already shipped, saying nothing. The field now says `Apache-2.0`, which is what that file has always been and what all eleven sibling packages declare.
150
+
151
+ **Four packages now ship the licence they declare.** `loopzero-cli`, `loopzero-memory-honcho`, `loopzero-memory-mem0` and `loopzero-memory-supermemory` declared `Apache-2.0` and listed `LICENSE` in `files`, and no such file existed. npm omits a declared-but-absent path in silence, so every published tarball asserted the licence while carrying none of its terms — and §4(a) requires a copy to travel with the distribution. The file is there now, byte-identical to the one the other packages ship.
152
+
153
+ **Six packages complete the rest of their published metadata.** Each field is here for what its absence costs a consumer:
154
+
155
+ - `homepage` and `bugs` — the npm page renders both; without them someone who hits a defect has no route back to the project.
156
+ - `engines.node` — npm warns on an unsupported runtime only when the range is declared. `loopzero-sdk-pty` declared none, so a Node 18 install failed later and somewhere unrelated.
157
+ - `sideEffects` — a bundler keeps every module of a package that stays silent. Declared only after checking: a clean scan of each built ESM entry found zero top-level statements, the residual hits being closing tokens of declarations. `loopzero-sdk` keeps its path-array form, which is the honest shape for a package whose agent entry registers on import.
158
+ - `publishConfig.access` — a scoped package defaults to `restricted`. Three declared none and reached npm public only because the release flow supplied the flag; the manifest states it now instead of depending on how it is invoked.
159
+ - `loopzero-sdk-pty` also ships its `CHANGELOG.md`, which existed on disk and was absent from `files`.
160
+
161
+ The gate that should have caught any of this covered three packages out of twelve, by way of a hand-written list. It now derives the list from `packages/`, asserts the whole contract, and fails when the sweep discovers nothing rather than passing by having nothing to check.
162
+
163
+ - e699569: **The repository moved to the official `getloopscale` organization.** Every `repository`, `bugs` and `homepage` field now points there, along with the README, `CONTRIBUTING.md`, `SECURITY.md` and the issue templates. Existing clones and any URL already published keep working — GitHub redirects a transferred repository permanently — so this is a correctness fix for the metadata npm renders, not a break.
164
+
165
+ **The Apache-2.0 text every package ships was replaced with the official one.** The copy distributed until now had paragraph 4(d) truncated: it read "except as required for describing the origin of the Work and reproducing the content of the NOTICE file", dropping "reasonable and customary use" from the licensed clause. §4(d) governs what a redistributor must do with attribution notices, and the omission narrowed it.
166
+
167
+ That matters more than a typo would. The manifests declare the SPDX identifier `Apache-2.0`, which is an assertion that the terms are _the_ Apache-2.0 terms — a licence scanner resolves the identifier and never reads the file. A consumer's compliance review, which does read the file, would find a body that no longer matches the identifier and has no name of its own. Every `LICENSE` in this repository is now byte-identical to the canonical text, with the appendix filled in.
168
+
169
+ Nothing else about the terms changed: the licence is the same licence it has always been meant to be, and no package changes what it grants.
170
+
171
+ - c7385d2: Test runs no longer claim every core on the host.
172
+
173
+ None of the package configs capped `maxWorkers`, so vitest's default applied: `os.availableParallelism()`,
174
+ one fork per core, each booting a full test environment. The repo's `test` script is
175
+ `turbo run test --filter='./packages/*'`, so that default is paid once per package _concurrently_ —
176
+ nproc forks times turbo's concurrency, on nproc cores. Measured on a 12-thread machine during an
177
+ unrelated investigation, two vitest pools alone were enough to reach load average 33.89 with the
178
+ desktop unusable; a full fan-out is several times that.
179
+
180
+ `loopzero-sdk` is the interesting case. B-104 recorded on 2026-08-19 that the `poolOptions.forks.*`
181
+ block was 100% dead in Vitest 4, deleted it, and noted that `fileParallelism: false` was forcing
182
+ `maxWorkers` to 1 unconditionally, so a fork-count knob could not act. B-059 then flipped
183
+ `fileParallelism` to `true` on 2026-08-20, which made the knob able to act again — and nothing
184
+ reintroduced one, so the package silently went back to the uncapped default. That comment has been
185
+ corrected along with the config; it claimed no knob existed, which is no longer true.
186
+
187
+ The cap leaves 4 cores free (`Math.max(2, cpus().length - 4)`), scaling with the runner rather than
188
+ hard-coding one machine's core count. It costs no wall-clock: measured in `loopzero-ui`, the full
189
+ suite ran 73.96s at 4 workers against 74.36s at 12, so the parallelism above the cap was already
190
+ noise. Verified as resolved config rather than as file contents — `createVitest` reports
191
+ `maxWorkers: 8` on a 12-thread host, which is the formula, not the default.
192
+
193
+ This changes no published behaviour; it is test tooling only. Refs getloopscale/loopzero-ui#51.
194
+
195
+ ## 0.3.3
196
+
197
+ ### Patch Changes
198
+
199
+ - a3ae640: Declare `repository` so these packages can publish with provenance.
200
+
201
+ npm cross-checks a manifest's `repository.url` against the repository recorded in the signed
202
+ provenance statement, and an empty value cannot match — the PUT is refused with E422 after the
203
+ statement has been signed and written to the public transparency log. Six of the twelve publishable
204
+ packages carried an empty field; it went unnoticed because nothing needed it until provenance was
205
+ enabled, and because each package publishes independently, so the release run went red while the
206
+ package everyone was watching succeeded.
207
+
208
+ `directory` is set alongside the URL, so the registry links to each package rather than to the
209
+ repository root.
210
+
211
+ ## 0.3.2
212
+
213
+ ### Patch Changes
214
+
215
+ - 8790f70: Refuse a `workspace:` range before it can reach npm.
216
+
217
+ Five of this repo's twelve publishable packages declare internal dependencies as `workspace:^`, which
218
+ is correct on disk and becomes an unrecoverable defect if the publish goes out through a tool that
219
+ does not rewrite it: `pnpm` resolves the protocol while packing, `npm` ships the manifest verbatim.
220
+ A version published that way fails to install for everyone and cannot be corrected — only
221
+ deprecated.
222
+
223
+ Every publishable package now runs the guard in `prepublishOnly`, so it fires whichever way the
224
+ publish is invoked, and `pnpm release` runs it once across the repo before `changeset publish`.
225
+
226
+ Note for anyone reading a published manifest: the `prepublishOnly` entry points at a path inside
227
+ this repository. It never runs for a consumer — the hook only fires when the package itself is
228
+ published — and guarding the entry point that a hand-run `npm publish` actually uses was worth the
229
+ cosmetic wart of shipping the line.
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 by 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 based on (or derived from) 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 getloopscale.com
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 implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,67 @@
1
- # Temporary Holding Version
1
+ # loopzero-sdk-pty
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
+ Local, `node-pty`-backed implementation of `loopzero-sdk`'s `InteractiveBackend`.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ pnpm add loopzero-sdk-pty
9
+ ```
10
+
11
+ `loopzero-sdk` (>=4.4.1) is a peer dependency. `node-pty` is an OPTIONAL dependency of this package,
12
+ so an environment that cannot build the native module still installs — and every method then throws
13
+ the SDK's typed `InteractiveUnavailableError`, which is the signal to fall back to non-interactive
14
+ exec rather than a crash at import time.
15
+
16
+ Opt-in and **terminal-surface only** — this is the ONLY package in the loopzero
17
+ ecosystem that depends on `node-pty` (optionally, so install never fails on a
18
+ native build). Core / `loopzero-sdk-tools` / cluster / desktop backends never
19
+ touch it.
20
+
21
+ ```ts
22
+ import { PtyInteractiveBackend } from "loopzero-sdk-pty";
23
+ // inject into an interactive shell tool that depends on InteractiveBackend
24
+ const interactive = new PtyInteractiveBackend();
25
+ ```
26
+
27
+ When `node-pty` is unavailable (or a spawn fails), every method throws the SDK's
28
+ typed `InteractiveUnavailableError` so the caller falls back to non-interactive exec.
29
+
30
+ ## Confined shell
31
+
32
+ `createConfinedPtyBackend` returns an `InteractiveBackend` where every session starts in `root`
33
+ (a `cwd` passed to `startInteractive` is ignored), runs under `interactiveWrapCommand({ mode })`
34
+ from `loopzero-sdk/sandbox`, and executes as `env -i <allowlisted vars> HOME=<root> /bin/sh -c <command>`.
35
+ The default allowlist is `PATH USER LOGNAME LANG LC_ALL LC_CTYPE TERM TZ`; override it with
36
+ `envAllowlist`, and the source with `sourceEnv` (default `process.env`). `maxSessions` defaults to 4.
37
+ The scrub applies to the executed command and its descendants; the outer PTY shell is spawned by
38
+ `node-pty` first.
39
+
40
+ ```ts
41
+ import { createConfinedPtyBackend, probeConfinement } from "loopzero-sdk-pty";
42
+
43
+ const backend = createConfinedPtyBackend({ root, mode: "workspace-write" });
44
+ const proof = await probeConfinement(backend, { inside: `${root}/.probe`, outside: `${root}.probe` });
45
+ if (!proof.confined) console.warn(proof.reason, proof.detail); // do not enable the shell
46
+ ```
47
+
48
+ `probeConfinement` starts a real session that touches `inside` and `outside`, waits up to
49
+ `timeoutMs` (default 3000) for `inside`, waits 300 ms more, then kills the session and removes both
50
+ files (use distinct, disposable paths). Results: `{ confined: true }`, or `confined: false` with
51
+ `reason` `cannot_write_inside`, `wrote_outside`, or `start_failed` (`startInteractive` rejected;
52
+ `detail` holds the message). A passing probe holds for this host at this moment only; if the
53
+ sandbox is unavailable `interactiveWrapCommand` wraps nothing, which the probe reports as
54
+ `wrote_outside`.
55
+
56
+ ## API reference
57
+
58
+ Every symbol this package exports, with the exact specifier to import it from, is in the generated
59
+ capability map that ships inside `loopzero-sdk`:
60
+
61
+ ```
62
+ node_modules/loopzero-sdk/docs/harness-capability-map.md # symbol -> import specifier
63
+ node_modules/loopzero-sdk/docs/error-codes.md # every `code` an error can carry
64
+ ```
65
+
66
+ Both are generated from the built type declarations, so they describe the version you installed
67
+ rather than the version someone wrote a page about.