@declaw/sdk 1.0.2 → 1.0.4
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 +35 -0
- package/dist/index.cjs +19 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +30 -5
- package/dist/index.d.ts +30 -5
- package/dist/index.js +19 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,41 @@ 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.4]
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
|
|
12
|
+
- `InjectionAction` — dropped the `"sanitize"` value. The server
|
|
13
|
+
never implemented request-body sanitization for detected injections
|
|
14
|
+
(the classifier returns a whole-request verdict, not span offsets),
|
|
15
|
+
so the value was accepted client-side but silently behaved like
|
|
16
|
+
`log_only` at the edge proxy. Valid values are now `"block"` and
|
|
17
|
+
`"log_only"`. Default action changes from `"sanitize"` to
|
|
18
|
+
`"log_only"` so existing enforcement behaviour is preserved.
|
|
19
|
+
Callers passing `action: "sanitize"` will now raise at construction
|
|
20
|
+
time; migrate to `"log_only"` (same behaviour) or `"block"`
|
|
21
|
+
(hard-reject on detection).
|
|
22
|
+
|
|
23
|
+
## [1.0.3]
|
|
24
|
+
|
|
25
|
+
### Added
|
|
26
|
+
|
|
27
|
+
- `sandbox.pty.connect(pid, { onData })` — reattach a fresh data callback
|
|
28
|
+
to an already-running PTY session by pid. Multiple clients can
|
|
29
|
+
subscribe concurrently; each receives output from the moment it
|
|
30
|
+
connects (no scrollback replay).
|
|
31
|
+
- Server-side PTY session TTL. The `timeout` option on
|
|
32
|
+
`sandbox.pty.create()` is now enforced inside the sandbox — the PTY
|
|
33
|
+
is terminated when the deadline elapses, even if no client is
|
|
34
|
+
attached. `timeout: 0` keeps it alive indefinitely.
|
|
35
|
+
|
|
36
|
+
### Changed
|
|
37
|
+
|
|
38
|
+
- `PtyHandle.wait()` now resolves with a `PtyResult` object (`{ exitCode }`)
|
|
39
|
+
instead of a bare number. This matches the shape of other lifecycle
|
|
40
|
+
APIs and leaves room for future fields (e.g. signal). Existing
|
|
41
|
+
numeric access becomes `(await handle.wait()).exitCode`.
|
|
42
|
+
|
|
8
43
|
## [1.0.2]
|
|
9
44
|
|
|
10
45
|
### Added
|
package/dist/index.cjs
CHANGED
|
@@ -506,7 +506,6 @@ var InjectionSensitivity = /* @__PURE__ */ ((InjectionSensitivity2) => {
|
|
|
506
506
|
})(InjectionSensitivity || {});
|
|
507
507
|
var InjectionAction = /* @__PURE__ */ ((InjectionAction2) => {
|
|
508
508
|
InjectionAction2["Block"] = "block";
|
|
509
|
-
InjectionAction2["Sanitize"] = "sanitize";
|
|
510
509
|
InjectionAction2["LogOnly"] = "log_only";
|
|
511
510
|
return InjectionAction2;
|
|
512
511
|
})(InjectionAction || {});
|
|
@@ -516,7 +515,7 @@ function createInjectionDefenseConfig(opts) {
|
|
|
516
515
|
const config = {
|
|
517
516
|
enabled: opts?.enabled ?? false,
|
|
518
517
|
sensitivity: opts?.sensitivity ?? "medium" /* Medium */,
|
|
519
|
-
action: opts?.action ?? "
|
|
518
|
+
action: opts?.action ?? "log_only" /* LogOnly */,
|
|
520
519
|
threshold: opts?.threshold ?? 0.8,
|
|
521
520
|
domains: opts?.domains
|
|
522
521
|
};
|
|
@@ -541,7 +540,7 @@ function parseInjectionDefenseConfig(data) {
|
|
|
541
540
|
return {
|
|
542
541
|
enabled: data.enabled ?? false,
|
|
543
542
|
sensitivity: data.sensitivity ?? "medium" /* Medium */,
|
|
544
|
-
action: data.action ?? "
|
|
543
|
+
action: data.action ?? "log_only" /* LogOnly */,
|
|
545
544
|
threshold: data.threshold ?? 0.8,
|
|
546
545
|
domains: data.domains
|
|
547
546
|
};
|
|
@@ -1641,7 +1640,7 @@ var PtyHandle = class {
|
|
|
1641
1640
|
disconnect() {
|
|
1642
1641
|
this.aborter.abort();
|
|
1643
1642
|
}
|
|
1644
|
-
/** Resolves with the remote exit
|
|
1643
|
+
/** Resolves with the remote exit result when the PTY process exits. */
|
|
1645
1644
|
wait() {
|
|
1646
1645
|
return this.exitPromise;
|
|
1647
1646
|
}
|
|
@@ -1678,7 +1677,7 @@ var PtyHandle = class {
|
|
|
1678
1677
|
const parsed = parseSSEFrame(frame);
|
|
1679
1678
|
if (!parsed) continue;
|
|
1680
1679
|
if (parsed.event === "exit") {
|
|
1681
|
-
this.resolveExit(parsed.exitCode ?? -1);
|
|
1680
|
+
this.resolveExit({ exitCode: parsed.exitCode ?? -1 });
|
|
1682
1681
|
return;
|
|
1683
1682
|
}
|
|
1684
1683
|
if (parsed.bytes) {
|
|
@@ -1700,7 +1699,7 @@ var PtyHandle = class {
|
|
|
1700
1699
|
throw err;
|
|
1701
1700
|
}
|
|
1702
1701
|
} finally {
|
|
1703
|
-
this.resolveExit(-1);
|
|
1702
|
+
this.resolveExit({ exitCode: -1 });
|
|
1704
1703
|
}
|
|
1705
1704
|
}
|
|
1706
1705
|
};
|
|
@@ -1747,11 +1746,11 @@ var Pty = class {
|
|
|
1747
1746
|
const user = opts?.user ?? "user";
|
|
1748
1747
|
const body = {
|
|
1749
1748
|
size: { cols: size.cols, rows: size.rows },
|
|
1750
|
-
user
|
|
1749
|
+
user,
|
|
1750
|
+
timeout: opts?.timeout ?? 3600
|
|
1751
1751
|
};
|
|
1752
1752
|
if (opts?.cwd !== void 0) body.cwd = opts.cwd;
|
|
1753
1753
|
if (opts?.envs !== void 0) body.envs = opts.envs;
|
|
1754
|
-
if (opts?.timeout !== void 0) body.timeout = opts.timeout;
|
|
1755
1754
|
const data = await this.client.post(
|
|
1756
1755
|
`/sandboxes/${this.sandboxId}/pty`,
|
|
1757
1756
|
{ json: body, timeout: opts?.requestTimeout }
|
|
@@ -1759,7 +1758,18 @@ var Pty = class {
|
|
|
1759
1758
|
const pid = data.pid;
|
|
1760
1759
|
return new PtyHandle(pid, this.sandboxId, this.client, opts?.onData);
|
|
1761
1760
|
}
|
|
1762
|
-
|
|
1761
|
+
/**
|
|
1762
|
+
* Reattach to an already-running PTY by its pid.
|
|
1763
|
+
*
|
|
1764
|
+
* Returns a fresh `PtyHandle` that streams the live output of the
|
|
1765
|
+
* existing session. Multiple clients can subscribe to the same pid
|
|
1766
|
+
* concurrently — each receives output from the moment it connects
|
|
1767
|
+
* (no scrollback replay).
|
|
1768
|
+
*/
|
|
1769
|
+
connect(pid, opts) {
|
|
1770
|
+
return new PtyHandle(pid, this.sandboxId, this.client, opts?.onData);
|
|
1771
|
+
}
|
|
1772
|
+
// --- Low-level API by pid (kept for callers that already hold one). ---
|
|
1763
1773
|
async kill(pid, requestTimeout) {
|
|
1764
1774
|
const data = await this.client.delete(
|
|
1765
1775
|
`/sandboxes/${this.sandboxId}/pty/${pid}`,
|