@theokit/sdk-tools 0.26.1 → 0.26.2
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/README.md +1 -1
- package/dist/index.cjs +32 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +89 -89
- package/dist/index.d.ts +89 -89
- package/dist/index.js +32 -13
- package/dist/index.js.map +1 -1
- package/package.json +11 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.26.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- a713fc7: `interactive_shell` no longer flattens a session-cap error into
|
|
8
|
+
`interactive_unavailable`.
|
|
9
|
+
|
|
10
|
+
`toErrorJson` matched `InteractiveUnavailableError` first, so `MaxSessionsError` — which extends it —
|
|
11
|
+
took that branch and lost `max` and `liveSessionIds`. Those are the only actionable fields in the
|
|
12
|
+
error: without them the model cannot tell a missing backend from a session cap it could clear by
|
|
13
|
+
reusing one of the open sessions, which is exactly what `@theokit/sdk-pty`'s docblock says those
|
|
14
|
+
fields exist for.
|
|
15
|
+
|
|
16
|
+
The check is structural rather than `instanceof`, because the class lives in `@theokit/sdk-pty` and
|
|
17
|
+
this package does not depend on it — and the tool takes an injected backend, so any provider
|
|
18
|
+
reporting the same two fields gets the same treatment.
|
|
19
|
+
|
|
20
|
+
Measured from a consumer that had forked this tool's entire schema and handler to recover the fields,
|
|
21
|
+
since there is no error seam to override.
|
|
22
|
+
|
|
3
23
|
## 0.20.1
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ Built-in tools for `@theokit/sdk` agents. File system, git, subprocess, search-t
|
|
|
4
4
|
|
|
5
5
|
Extracted from `@theokit/sdk@1.7.0` as part of the SDK 2.0 package split.
|
|
6
6
|
|
|
7
|
-
See the [**Theo Harness Capability Map**](../../
|
|
7
|
+
See the [**Theo Harness Capability Map**](../../wiki/reference/harness-capability-map.md) for every tool + guard primitive (`buildRepoMap`, `isBlockedIp`, `screenedFetch`, `catastrophicShellReason`, ...) with import paths and examples.
|
|
8
8
|
|
|
9
9
|
## Install
|
|
10
10
|
|
package/dist/index.cjs
CHANGED
|
@@ -866,7 +866,7 @@ function createGitStatusTool(opts) {
|
|
|
866
866
|
}
|
|
867
867
|
const scopeCheck = checkPathScope(path$1, projectRoot);
|
|
868
868
|
if (scopeCheck !== null) return scopeCheck;
|
|
869
|
-
const args =
|
|
869
|
+
const args = buildArgs(path$1, opts.includeBranch !== false);
|
|
870
870
|
if (opts.sandbox !== void 0) {
|
|
871
871
|
return statusViaSandbox(opts.sandbox, ctx, args, timeoutMs);
|
|
872
872
|
}
|
|
@@ -875,9 +875,9 @@ function createGitStatusTool(opts) {
|
|
|
875
875
|
}
|
|
876
876
|
});
|
|
877
877
|
}
|
|
878
|
-
function
|
|
878
|
+
function buildArgs(path, withBranch) {
|
|
879
879
|
const args = ["status", "--porcelain=v1"];
|
|
880
|
-
if (
|
|
880
|
+
if (withBranch) args.push("-b");
|
|
881
881
|
if (path !== void 0 && path !== "") args.push("--", path);
|
|
882
882
|
return args;
|
|
883
883
|
}
|
|
@@ -1004,7 +1004,26 @@ function globToRegex(pattern) {
|
|
|
1004
1004
|
}
|
|
1005
1005
|
return new RegExp(`^${regexStr}$`);
|
|
1006
1006
|
}
|
|
1007
|
+
function capFields(err) {
|
|
1008
|
+
const e = err;
|
|
1009
|
+
if (typeof e.max !== "number") return void 0;
|
|
1010
|
+
if (!Array.isArray(e.liveSessionIds)) return void 0;
|
|
1011
|
+
if (!e.liveSessionIds.every((id) => typeof id === "string")) return void 0;
|
|
1012
|
+
return { max: e.max, liveSessionIds: e.liveSessionIds };
|
|
1013
|
+
}
|
|
1007
1014
|
function toErrorJson(err) {
|
|
1015
|
+
if (typeof err === "object" && err !== null) {
|
|
1016
|
+
const cap = capFields(err);
|
|
1017
|
+
if (cap !== void 0) {
|
|
1018
|
+
return JSON.stringify({
|
|
1019
|
+
ok: false,
|
|
1020
|
+
error: "interactive_session_limit",
|
|
1021
|
+
max: cap.max,
|
|
1022
|
+
live_session_ids: [...cap.liveSessionIds],
|
|
1023
|
+
message: err.message
|
|
1024
|
+
});
|
|
1025
|
+
}
|
|
1026
|
+
}
|
|
1008
1027
|
if (err instanceof interactive.InteractiveUnavailableError) {
|
|
1009
1028
|
return JSON.stringify({ ok: false, error: "interactive_unavailable" });
|
|
1010
1029
|
}
|
|
@@ -1567,10 +1586,10 @@ function createListDirTool(opts) {
|
|
|
1567
1586
|
}),
|
|
1568
1587
|
handler: async ({ path }, ctx) => {
|
|
1569
1588
|
const relative3 = path === "" || path === "." ? "." : path;
|
|
1570
|
-
const
|
|
1571
|
-
if (
|
|
1572
|
-
if (
|
|
1573
|
-
return listViaLocalFs(
|
|
1589
|
+
const verdict = decidirEscopo(relative3, path, opts.allowAbsolute === true);
|
|
1590
|
+
if (verdict.error !== void 0) return verdict.error;
|
|
1591
|
+
if (verdict.absoluteRoot !== void 0) {
|
|
1592
|
+
return listViaLocalFs(verdict.absoluteRoot, ".", path, max);
|
|
1574
1593
|
}
|
|
1575
1594
|
if (filesystem$1) {
|
|
1576
1595
|
const backend = await filesystem.resolveFilesystem(filesystem$1, ctx ?? {});
|
|
@@ -1581,14 +1600,14 @@ function createListDirTool(opts) {
|
|
|
1581
1600
|
});
|
|
1582
1601
|
}
|
|
1583
1602
|
function decidirEscopo(relative3, original, allowAbsolute) {
|
|
1584
|
-
const
|
|
1585
|
-
|
|
1603
|
+
const refuse = (error) => ({
|
|
1604
|
+
error: JSON.stringify({ ok: false, error, path: original })
|
|
1586
1605
|
});
|
|
1587
|
-
if (relative3 !== "." && pathSafety.isForbiddenPath(relative3)) return
|
|
1606
|
+
if (relative3 !== "." && pathSafety.isForbiddenPath(relative3)) return refuse("forbidden_path");
|
|
1588
1607
|
if (!path.isAbsolute(relative3)) return {};
|
|
1589
|
-
if (!allowAbsolute) return
|
|
1590
|
-
if (ehProibidoEmQualquerProfundidade(relative3)) return
|
|
1591
|
-
return {
|
|
1608
|
+
if (!allowAbsolute) return refuse("path_traversal");
|
|
1609
|
+
if (ehProibidoEmQualquerProfundidade(relative3)) return refuse("forbidden_path");
|
|
1610
|
+
return { absoluteRoot: relative3 };
|
|
1592
1611
|
}
|
|
1593
1612
|
async function listViaLocalFs(projectRoot, relative3, originalPath, max) {
|
|
1594
1613
|
const boundary = resolveDirBoundary(relative3, projectRoot, originalPath);
|