@theokit/sdk-tools 0.6.0 → 0.8.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 +12 -0
- package/dist/index.cjs +50 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +64 -8
- package/dist/index.d.ts +64 -8
- package/dist/index.js +50 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.8.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- ac3f77d: @theokit/sdk: resolveModelCapabilities catalog gains cheap OpenRouter slugs (qwen3-coder, deepseek v4-flash/v3.2, glm-4.7-flash, gemini-2.5-flash-lite/pro) so they resolve real context windows instead of the 4096 default. @theokit/sdk-tools: new createGenericHttpSearchAdapter (env-keyed generic HTTP WebSearchCallback alongside Brave); buildEnvContext gains git-branch detection + an injectable clock. @theokit/sdk-cache: ships createLexicalEmbedder (zero-dependency token-hash lexical embedder built-in).
|
|
8
|
+
|
|
9
|
+
## 0.7.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- 5bd2f9c: @theokit/sdk: `shouldCompact`/`ShouldCompactInput` gains an optional `maxOutput` output-reserve term (`estimated >= contextWindow - buffer - (maxOutput ?? 0)`), defaulting to today's behavior. `AgentOptions.plugins` now also accepts an array of code `Plugin` objects (matching the runtime + docs), not only `{ enabled }`. @theokit/sdk-tools: `renderToolList` gains an optional `{ mode: "full" | "summary" | "names" }` — `"full"` (default) is the existing `<tools>` XML; `"summary"` renders `- name: <first sentence>`; `"names"` renders `- name`.
|
|
14
|
+
|
|
3
15
|
## 0.6.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
package/dist/index.cjs
CHANGED
|
@@ -887,15 +887,26 @@ function safeReadHead(p, n) {
|
|
|
887
887
|
return "";
|
|
888
888
|
}
|
|
889
889
|
}
|
|
890
|
-
function
|
|
890
|
+
function gitBranch(headPath) {
|
|
891
|
+
try {
|
|
892
|
+
const head = fs.readFileSync(headPath, "utf-8").trim();
|
|
893
|
+
const match = head.match(/^ref:\s*refs\/heads\/(.+)$/);
|
|
894
|
+
return match ? match[1] : void 0;
|
|
895
|
+
} catch {
|
|
896
|
+
return void 0;
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
function buildEnvContext(cwd, opts = {}) {
|
|
891
900
|
const lines = [
|
|
892
901
|
"<env>",
|
|
893
902
|
` Working directory: ${cwd}`,
|
|
894
903
|
` Platform: ${process.platform} (${process.arch})`,
|
|
895
904
|
` Node: ${process.version}`,
|
|
896
|
-
` Is git repo: ${safeExists(path.join(cwd, ".git")) ? "yes" : "no"}
|
|
897
|
-
` Today's date: ${(/* @__PURE__ */ new Date()).toDateString()}`
|
|
905
|
+
` Is git repo: ${safeExists(path.join(cwd, ".git")) ? "yes" : "no"}`
|
|
898
906
|
];
|
|
907
|
+
const branch = gitBranch(opts.gitHeadPath ?? path.join(cwd, ".git", "HEAD"));
|
|
908
|
+
if (branch) lines.push(` Branch: ${branch}`);
|
|
909
|
+
lines.push(` Today's date: ${(opts.now ?? /* @__PURE__ */ new Date()).toDateString()}`);
|
|
899
910
|
const docs = PROJECT_DOCS.filter((d) => safeExists(path.join(cwd, d)));
|
|
900
911
|
if (docs.length > 0) {
|
|
901
912
|
lines.push(` Project docs: ${docs.join(", ")}`);
|
|
@@ -981,7 +992,18 @@ function withDescription(tool, description) {
|
|
|
981
992
|
function esc(s) {
|
|
982
993
|
return String(s).replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">");
|
|
983
994
|
}
|
|
984
|
-
function
|
|
995
|
+
function firstSentence(d) {
|
|
996
|
+
const m = d.trim().match(/\.\s+(?=[A-Z(]|$)/);
|
|
997
|
+
return m?.index == null ? d.trim() : d.trim().slice(0, m.index + 1);
|
|
998
|
+
}
|
|
999
|
+
function renderToolList(tools, options) {
|
|
1000
|
+
const mode = options?.mode ?? "full";
|
|
1001
|
+
if (mode === "summary") {
|
|
1002
|
+
return tools.map((t) => `- ${t.name}: ${firstSentence(t.description)}`).join("\n");
|
|
1003
|
+
}
|
|
1004
|
+
if (mode === "names") {
|
|
1005
|
+
return tools.map((t) => `- ${t.name}`).join("\n");
|
|
1006
|
+
}
|
|
985
1007
|
if (tools.length === 0) return "<tools></tools>";
|
|
986
1008
|
const lines = ["<tools>"];
|
|
987
1009
|
for (const t of tools) {
|
|
@@ -1923,6 +1945,29 @@ function createBraveWebSearchAdapter(opts = {}) {
|
|
|
1923
1945
|
}));
|
|
1924
1946
|
};
|
|
1925
1947
|
}
|
|
1948
|
+
|
|
1949
|
+
// src/web-search-http.ts
|
|
1950
|
+
function createGenericHttpSearchAdapter(opts = {}) {
|
|
1951
|
+
const apiKey = opts.apiKey ?? process.env.THEOKIT_SEARCH_API_KEY;
|
|
1952
|
+
const endpoint = opts.endpoint ?? process.env.THEOKIT_SEARCH_API_URL;
|
|
1953
|
+
const fetchImpl = opts.fetchImpl ?? globalThis.fetch;
|
|
1954
|
+
return async (query, maxResults) => {
|
|
1955
|
+
if (!apiKey || !endpoint) return [];
|
|
1956
|
+
try {
|
|
1957
|
+
const url = `${endpoint}?q=${encodeURIComponent(query)}&n=${maxResults}`;
|
|
1958
|
+
const res = await fetchImpl(url, { headers: { Authorization: `Bearer ${apiKey}` } });
|
|
1959
|
+
if (!res.ok) return [];
|
|
1960
|
+
const data = await res.json();
|
|
1961
|
+
return (data?.results ?? []).slice(0, maxResults).map((r) => ({
|
|
1962
|
+
title: String(r?.title ?? ""),
|
|
1963
|
+
url: String(r?.url ?? ""),
|
|
1964
|
+
snippet: String(r?.snippet ?? "")
|
|
1965
|
+
}));
|
|
1966
|
+
} catch {
|
|
1967
|
+
return [];
|
|
1968
|
+
}
|
|
1969
|
+
};
|
|
1970
|
+
}
|
|
1926
1971
|
var BINARY_PROBE_BYTES3 = 8 * 1024;
|
|
1927
1972
|
function createWriteFileTool(opts) {
|
|
1928
1973
|
const { projectRoot } = opts;
|
|
@@ -1990,6 +2035,7 @@ exports.commandDenialReason = commandDenialReason;
|
|
|
1990
2035
|
exports.createApplyPatchTool = createApplyPatchTool;
|
|
1991
2036
|
exports.createBraveWebSearchAdapter = createBraveWebSearchAdapter;
|
|
1992
2037
|
exports.createEditFileTool = createEditFileTool;
|
|
2038
|
+
exports.createGenericHttpSearchAdapter = createGenericHttpSearchAdapter;
|
|
1993
2039
|
exports.createGitDiffTool = createGitDiffTool;
|
|
1994
2040
|
exports.createGlobTool = createGlobTool;
|
|
1995
2041
|
exports.createListDirTool = createListDirTool;
|