@theokit/sdk-tools 0.6.0 → 0.7.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 +6 -0
- package/dist/index.cjs +12 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +20 -6
- package/dist/index.d.ts +20 -6
- package/dist/index.js +12 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -332,12 +332,26 @@ declare function catastrophicShellReason(command: string): string | null;
|
|
|
332
332
|
* name/inputSchema/handler; does NOT mutate the original tool.
|
|
333
333
|
*/
|
|
334
334
|
declare function withDescription(tool: CustomTool, description: string): CustomTool;
|
|
335
|
-
/**
|
|
336
|
-
*
|
|
337
|
-
*
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
335
|
+
/** Render mode for {@link renderToolList}. Local — the published `renderToolList`
|
|
336
|
+
* signature inlines this union into its `.d.ts`, so consumers pass the literal
|
|
337
|
+
* ("summary" | "names" | "full") without needing the named type exported. */
|
|
338
|
+
type ToolListMode = "full" | "summary" | "names";
|
|
339
|
+
/**
|
|
340
|
+
* Render the agent's actual `CustomTool[]` — single source of truth, so an
|
|
341
|
+
* overridden/added/removed tool is reflected automatically. Never throws.
|
|
342
|
+
*
|
|
343
|
+
* Modes (`options.mode`, default `"full"`):
|
|
344
|
+
* - `"full"`: a `<tools>` XML block (name + description per tool, XML-escaped).
|
|
345
|
+
* An empty array yields `<tools></tools>`.
|
|
346
|
+
* - `"summary"`: markdown `- name: <first sentence>` per tool (NOT XML-escaped).
|
|
347
|
+
* - `"names"`: markdown `- name` per tool (NOT XML-escaped).
|
|
348
|
+
*
|
|
349
|
+
* Markdown modes on an empty array yield `""`. A non-object `options` arg (e.g. a
|
|
350
|
+
* map index from `tools.map(renderToolList)`) has no `.mode` → falls back to `"full"`.
|
|
351
|
+
*/
|
|
352
|
+
declare function renderToolList(tools: CustomTool[], options?: {
|
|
353
|
+
mode?: ToolListMode;
|
|
354
|
+
}): string;
|
|
341
355
|
|
|
342
356
|
/**
|
|
343
357
|
* Rich-error guidance for tool failures (M3-4).
|
package/dist/index.d.ts
CHANGED
|
@@ -332,12 +332,26 @@ declare function catastrophicShellReason(command: string): string | null;
|
|
|
332
332
|
* name/inputSchema/handler; does NOT mutate the original tool.
|
|
333
333
|
*/
|
|
334
334
|
declare function withDescription(tool: CustomTool, description: string): CustomTool;
|
|
335
|
-
/**
|
|
336
|
-
*
|
|
337
|
-
*
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
335
|
+
/** Render mode for {@link renderToolList}. Local — the published `renderToolList`
|
|
336
|
+
* signature inlines this union into its `.d.ts`, so consumers pass the literal
|
|
337
|
+
* ("summary" | "names" | "full") without needing the named type exported. */
|
|
338
|
+
type ToolListMode = "full" | "summary" | "names";
|
|
339
|
+
/**
|
|
340
|
+
* Render the agent's actual `CustomTool[]` — single source of truth, so an
|
|
341
|
+
* overridden/added/removed tool is reflected automatically. Never throws.
|
|
342
|
+
*
|
|
343
|
+
* Modes (`options.mode`, default `"full"`):
|
|
344
|
+
* - `"full"`: a `<tools>` XML block (name + description per tool, XML-escaped).
|
|
345
|
+
* An empty array yields `<tools></tools>`.
|
|
346
|
+
* - `"summary"`: markdown `- name: <first sentence>` per tool (NOT XML-escaped).
|
|
347
|
+
* - `"names"`: markdown `- name` per tool (NOT XML-escaped).
|
|
348
|
+
*
|
|
349
|
+
* Markdown modes on an empty array yield `""`. A non-object `options` arg (e.g. a
|
|
350
|
+
* map index from `tools.map(renderToolList)`) has no `.mode` → falls back to `"full"`.
|
|
351
|
+
*/
|
|
352
|
+
declare function renderToolList(tools: CustomTool[], options?: {
|
|
353
|
+
mode?: ToolListMode;
|
|
354
|
+
}): string;
|
|
341
355
|
|
|
342
356
|
/**
|
|
343
357
|
* Rich-error guidance for tool failures (M3-4).
|
package/dist/index.js
CHANGED
|
@@ -979,7 +979,18 @@ function withDescription(tool, description) {
|
|
|
979
979
|
function esc(s) {
|
|
980
980
|
return String(s).replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">");
|
|
981
981
|
}
|
|
982
|
-
function
|
|
982
|
+
function firstSentence(d) {
|
|
983
|
+
const m = d.trim().match(/\.\s+(?=[A-Z(]|$)/);
|
|
984
|
+
return m?.index == null ? d.trim() : d.trim().slice(0, m.index + 1);
|
|
985
|
+
}
|
|
986
|
+
function renderToolList(tools, options) {
|
|
987
|
+
const mode = options?.mode ?? "full";
|
|
988
|
+
if (mode === "summary") {
|
|
989
|
+
return tools.map((t) => `- ${t.name}: ${firstSentence(t.description)}`).join("\n");
|
|
990
|
+
}
|
|
991
|
+
if (mode === "names") {
|
|
992
|
+
return tools.map((t) => `- ${t.name}`).join("\n");
|
|
993
|
+
}
|
|
983
994
|
if (tools.length === 0) return "<tools></tools>";
|
|
984
995
|
const lines = ["<tools>"];
|
|
985
996
|
for (const t of tools) {
|