@declaw/sdk 1.0.2 → 1.0.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/CHANGELOG.md +20 -0
- package/dist/index.cjs +17 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +30 -4
- package/dist/index.d.ts +30 -4
- package/dist/index.js +17 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,26 @@ All notable changes to the Declaw TypeScript / JavaScript SDK are documented in
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [1.0.3]
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- `sandbox.pty.connect(pid, { onData })` — reattach a fresh data callback
|
|
13
|
+
to an already-running PTY session by pid. Multiple clients can
|
|
14
|
+
subscribe concurrently; each receives output from the moment it
|
|
15
|
+
connects (no scrollback replay).
|
|
16
|
+
- Server-side PTY session TTL. The `timeout` option on
|
|
17
|
+
`sandbox.pty.create()` is now enforced inside the sandbox — the PTY
|
|
18
|
+
is terminated when the deadline elapses, even if no client is
|
|
19
|
+
attached. `timeout: 0` keeps it alive indefinitely.
|
|
20
|
+
|
|
21
|
+
### Changed
|
|
22
|
+
|
|
23
|
+
- `PtyHandle.wait()` now resolves with a `PtyResult` object (`{ exitCode }`)
|
|
24
|
+
instead of a bare number. This matches the shape of other lifecycle
|
|
25
|
+
APIs and leaves room for future fields (e.g. signal). Existing
|
|
26
|
+
numeric access becomes `(await handle.wait()).exitCode`.
|
|
27
|
+
|
|
8
28
|
## [1.0.2]
|
|
9
29
|
|
|
10
30
|
### Added
|
package/dist/index.cjs
CHANGED
|
@@ -1641,7 +1641,7 @@ var PtyHandle = class {
|
|
|
1641
1641
|
disconnect() {
|
|
1642
1642
|
this.aborter.abort();
|
|
1643
1643
|
}
|
|
1644
|
-
/** Resolves with the remote exit
|
|
1644
|
+
/** Resolves with the remote exit result when the PTY process exits. */
|
|
1645
1645
|
wait() {
|
|
1646
1646
|
return this.exitPromise;
|
|
1647
1647
|
}
|
|
@@ -1678,7 +1678,7 @@ var PtyHandle = class {
|
|
|
1678
1678
|
const parsed = parseSSEFrame(frame);
|
|
1679
1679
|
if (!parsed) continue;
|
|
1680
1680
|
if (parsed.event === "exit") {
|
|
1681
|
-
this.resolveExit(parsed.exitCode ?? -1);
|
|
1681
|
+
this.resolveExit({ exitCode: parsed.exitCode ?? -1 });
|
|
1682
1682
|
return;
|
|
1683
1683
|
}
|
|
1684
1684
|
if (parsed.bytes) {
|
|
@@ -1700,7 +1700,7 @@ var PtyHandle = class {
|
|
|
1700
1700
|
throw err;
|
|
1701
1701
|
}
|
|
1702
1702
|
} finally {
|
|
1703
|
-
this.resolveExit(-1);
|
|
1703
|
+
this.resolveExit({ exitCode: -1 });
|
|
1704
1704
|
}
|
|
1705
1705
|
}
|
|
1706
1706
|
};
|
|
@@ -1747,11 +1747,11 @@ var Pty = class {
|
|
|
1747
1747
|
const user = opts?.user ?? "user";
|
|
1748
1748
|
const body = {
|
|
1749
1749
|
size: { cols: size.cols, rows: size.rows },
|
|
1750
|
-
user
|
|
1750
|
+
user,
|
|
1751
|
+
timeout: opts?.timeout ?? 3600
|
|
1751
1752
|
};
|
|
1752
1753
|
if (opts?.cwd !== void 0) body.cwd = opts.cwd;
|
|
1753
1754
|
if (opts?.envs !== void 0) body.envs = opts.envs;
|
|
1754
|
-
if (opts?.timeout !== void 0) body.timeout = opts.timeout;
|
|
1755
1755
|
const data = await this.client.post(
|
|
1756
1756
|
`/sandboxes/${this.sandboxId}/pty`,
|
|
1757
1757
|
{ json: body, timeout: opts?.requestTimeout }
|
|
@@ -1759,7 +1759,18 @@ var Pty = class {
|
|
|
1759
1759
|
const pid = data.pid;
|
|
1760
1760
|
return new PtyHandle(pid, this.sandboxId, this.client, opts?.onData);
|
|
1761
1761
|
}
|
|
1762
|
-
|
|
1762
|
+
/**
|
|
1763
|
+
* Reattach to an already-running PTY by its pid.
|
|
1764
|
+
*
|
|
1765
|
+
* Returns a fresh `PtyHandle` that streams the live output of the
|
|
1766
|
+
* existing session. Multiple clients can subscribe to the same pid
|
|
1767
|
+
* concurrently — each receives output from the moment it connects
|
|
1768
|
+
* (no scrollback replay).
|
|
1769
|
+
*/
|
|
1770
|
+
connect(pid, opts) {
|
|
1771
|
+
return new PtyHandle(pid, this.sandboxId, this.client, opts?.onData);
|
|
1772
|
+
}
|
|
1773
|
+
// --- Low-level API by pid (kept for callers that already hold one). ---
|
|
1763
1774
|
async kill(pid, requestTimeout) {
|
|
1764
1775
|
const data = await this.client.delete(
|
|
1765
1776
|
`/sandboxes/${this.sandboxId}/pty/${pid}`,
|