@theokit/sdk-tools 0.22.0 → 0.22.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/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +17 -3
- package/dist/index.d.ts +17 -3
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -681,6 +681,16 @@ interface QuestionToolOptions {
|
|
|
681
681
|
askUser?: (question: string) => Promise<string>;
|
|
682
682
|
/** Maximum time to wait for user response in ms. Default: 300_000 (5 min). */
|
|
683
683
|
timeoutMs?: number;
|
|
684
|
+
/**
|
|
685
|
+
* M76 — nome exposto ao modelo. Omitido ⇒ `"question"` (aditivo).
|
|
686
|
+
*
|
|
687
|
+
* O consumidor precisava disto: o Codex chama a tool de `request_user_input`, e sem a opção ele
|
|
688
|
+
* era obrigado a reconstruir o objeto inteiro à mão — o adaptador com dois casts que a T3.3
|
|
689
|
+
* eliminou.
|
|
690
|
+
*/
|
|
691
|
+
name?: string;
|
|
692
|
+
/** M76 — descrição exposta ao modelo. Omitida ⇒ o literal de hoje (aditivo). */
|
|
693
|
+
description?: string;
|
|
684
694
|
}
|
|
685
695
|
/**
|
|
686
696
|
* M76 — alinhado ao `CustomTool` do SDK. Era uma interface própria com `inputSchema: unknown`, o que
|
|
@@ -695,9 +705,13 @@ interface QuestionTool {
|
|
|
695
705
|
name: string;
|
|
696
706
|
description: string;
|
|
697
707
|
inputSchema: Record<string, unknown>;
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
708
|
+
/**
|
|
709
|
+
* M76 — o input é `Record<string, unknown>`, não `{ question: string }`, por CONTRAVARIÂNCIA: um
|
|
710
|
+
* handler que aceita só o tipo estreito não é atribuível a um que aceita o largo, e o `CustomTool`
|
|
711
|
+
* do SDK declara o largo. Declarar estreito aqui obrigava o consumidor a um cast — que era
|
|
712
|
+
* exatamente o defeito. O estreitamento acontece DENTRO do handler, onde há validação.
|
|
713
|
+
*/
|
|
714
|
+
handler: (input: Record<string, unknown>, ctx?: {
|
|
701
715
|
signal?: AbortSignal;
|
|
702
716
|
context?: unknown;
|
|
703
717
|
threadId?: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -681,6 +681,16 @@ interface QuestionToolOptions {
|
|
|
681
681
|
askUser?: (question: string) => Promise<string>;
|
|
682
682
|
/** Maximum time to wait for user response in ms. Default: 300_000 (5 min). */
|
|
683
683
|
timeoutMs?: number;
|
|
684
|
+
/**
|
|
685
|
+
* M76 — nome exposto ao modelo. Omitido ⇒ `"question"` (aditivo).
|
|
686
|
+
*
|
|
687
|
+
* O consumidor precisava disto: o Codex chama a tool de `request_user_input`, e sem a opção ele
|
|
688
|
+
* era obrigado a reconstruir o objeto inteiro à mão — o adaptador com dois casts que a T3.3
|
|
689
|
+
* eliminou.
|
|
690
|
+
*/
|
|
691
|
+
name?: string;
|
|
692
|
+
/** M76 — descrição exposta ao modelo. Omitida ⇒ o literal de hoje (aditivo). */
|
|
693
|
+
description?: string;
|
|
684
694
|
}
|
|
685
695
|
/**
|
|
686
696
|
* M76 — alinhado ao `CustomTool` do SDK. Era uma interface própria com `inputSchema: unknown`, o que
|
|
@@ -695,9 +705,13 @@ interface QuestionTool {
|
|
|
695
705
|
name: string;
|
|
696
706
|
description: string;
|
|
697
707
|
inputSchema: Record<string, unknown>;
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
708
|
+
/**
|
|
709
|
+
* M76 — o input é `Record<string, unknown>`, não `{ question: string }`, por CONTRAVARIÂNCIA: um
|
|
710
|
+
* handler que aceita só o tipo estreito não é atribuível a um que aceita o largo, e o `CustomTool`
|
|
711
|
+
* do SDK declara o largo. Declarar estreito aqui obrigava o consumidor a um cast — que era
|
|
712
|
+
* exatamente o defeito. O estreitamento acontece DENTRO do handler, onde há validação.
|
|
713
|
+
*/
|
|
714
|
+
handler: (input: Record<string, unknown>, ctx?: {
|
|
701
715
|
signal?: AbortSignal;
|
|
702
716
|
context?: unknown;
|
|
703
717
|
threadId?: string;
|
package/dist/index.js
CHANGED
|
@@ -1737,8 +1737,8 @@ function askerDoContexto(context) {
|
|
|
1737
1737
|
function createQuestionTool(opts) {
|
|
1738
1738
|
const timeoutMs = opts.timeoutMs ?? 3e5;
|
|
1739
1739
|
return {
|
|
1740
|
-
name: "question",
|
|
1741
|
-
description: "Ask the user a question and wait for their response. Use when you need clarification or confirmation before proceeding. Returns { ok, answer } or { ok: false, error: 'timeout' }.",
|
|
1740
|
+
name: opts.name ?? "question",
|
|
1741
|
+
description: opts.description ?? "Ask the user a question and wait for their response. Use when you need clarification or confirmation before proceeding. Returns { ok, answer } or { ok: false, error: 'timeout' }.",
|
|
1742
1742
|
inputSchema: {
|
|
1743
1743
|
type: "object",
|
|
1744
1744
|
properties: {
|
|
@@ -1759,7 +1759,7 @@ function createQuestionTool(opts) {
|
|
|
1759
1759
|
setTimeout(() => reject(new Error("timeout")), timeoutMs);
|
|
1760
1760
|
});
|
|
1761
1761
|
try {
|
|
1762
|
-
const answer = await Promise.race([askUser(input.question), timeout]);
|
|
1762
|
+
const answer = await Promise.race([askUser(String(input.question ?? "")), timeout]);
|
|
1763
1763
|
return JSON.stringify({ ok: true, answer });
|
|
1764
1764
|
} catch (err) {
|
|
1765
1765
|
if (err instanceof Error && err.message === "timeout") {
|