@theokit/sdk-tools 0.26.0 → 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/dist/index.d.ts CHANGED
@@ -26,10 +26,10 @@ import { InteractiveProvider } from '@theokit/sdk/interactive';
26
26
  */
27
27
 
28
28
  interface CreateApplyPatchToolOptions {
29
- /** M76 — nome exposto ao modelo. Omitido o literal de hoje (aditivo). O nome é contrato: chave
30
- * de approval, o que o modelo e o que o telemetry registra. */
29
+ /** M76 — name exposed to the model. Omitted => today's literal (additive). The name is a contract:
30
+ * the approval key, what the model sees and what telemetry records. */
31
31
  name?: string;
32
- /** M76 — descrição exposta ao modelo. Omitida o literal de hoje (aditivo). */
32
+ /** M76 — description exposed to the model. Omitted => today's literal (additive). */
33
33
  description?: string;
34
34
  /** Absolute path to the project root. Every hunk path is gated against this boundary. */
35
35
  projectRoot: string;
@@ -106,10 +106,10 @@ declare function createSessionArtifactStore(options: SessionArtifactStoreOptions
106
106
  */
107
107
 
108
108
  interface CreateCurrentTimeToolOptions {
109
- /** M76 — nome exposto ao modelo. Omitido o literal de hoje (aditivo). O nome é contrato: chave
110
- * de approval, o que o modelo e o que o telemetry registra. */
109
+ /** M76 — name exposed to the model. Omitted => today's literal (additive). The name is a contract:
110
+ * the approval key, what the model sees and what telemetry records. */
111
111
  name?: string;
112
- /** M76 — descrição exposta ao modelo. Omitida o literal de hoje (aditivo). */
112
+ /** M76 — description exposed to the model. Omitted => today's literal (additive). */
113
113
  description?: string;
114
114
  /** Injectable clock — defaults to `() => new Date()`. Pass a fixed clock for deterministic tests. */
115
115
  clock?: () => Date;
@@ -132,13 +132,13 @@ interface CreateEditFileToolOptions {
132
132
  /**
133
133
  * M76 — nome exposto ao modelo. Omitido ⇒ o literal de hoje (aditivo).
134
134
  *
135
- * Existe porque, no Codex, o nome NASCE na definição da tool e é a chave de decisão de approval
136
- * três consumidores (modelo, approval, telemetry) de uma string decidida num lugar só. Renomear
137
- * depois da construção é mudar a identidade de algo publicado ao modelo. `withName` continua
138
- * para o caso genuinamente dinâmico.
135
+ * It exists because, in Codex, the name is BORN in the tool definition and is the approval decision
136
+ * key three consumers (model, approval, telemetry) of a string decided in one place. Renaming
137
+ * after construction changes the identity of something already published to the model. `withName`
138
+ * remains for the genuinely dynamic case.
139
139
  */
140
140
  name?: string;
141
- /** M76 — descrição exposta ao modelo. Omitida o literal de hoje (aditivo). */
141
+ /** M76 — description exposed to the model. Omitted => today's literal (additive). */
142
142
  description?: string;
143
143
  /** Absolute path to the project root. Every edit is gated against this boundary. */
144
144
  projectRoot: string;
@@ -187,10 +187,10 @@ declare function formatError(message: string, code?: string): string;
187
187
  */
188
188
 
189
189
  interface CreateGitDiffToolOptions {
190
- /** M76 — nome exposto ao modelo. Omitido o literal de hoje (aditivo). O nome é contrato: chave
191
- * de approval, o que o modelo e o que o telemetry registra. */
190
+ /** M76 — name exposed to the model. Omitted => today's literal (additive). The name is a contract:
191
+ * the approval key, what the model sees and what telemetry records. */
192
192
  name?: string;
193
- /** M76 — descrição exposta ao modelo. Omitida o literal de hoje (aditivo). */
193
+ /** M76 — description exposed to the model. Omitted => today's literal (additive). */
194
194
  description?: string;
195
195
  projectRoot: string;
196
196
  timeoutMs?: number;
@@ -207,13 +207,13 @@ declare function createGitDiffTool(opts: CreateGitDiffToolOptions): CustomTool;
207
207
  * Returns the working-tree status in porcelain v1 format (`git status --porcelain`), which is the
208
208
  * stable machine-readable form — the human format is explicitly not guaranteed across git versions.
209
209
  *
210
- * M76 — nasce ao lado de `git_diff` e compartilha o motor de execução (`internal/git-exec.ts`): teto
211
- * de stdout, kill do grupo de processos no timeout e mapeamento para erro tipado são a MESMA regra
212
- * para qualquer subcomando do git. O consumidor (agent-builder) tinha isto local em 62 LoC; nada ali
213
- * era específico dele.
210
+ * M76 — born alongside `git_diff` and sharing the execution engine (`internal/git-exec.ts`): the stdout
211
+ * ceiling, process-group kill on timeout and mapping to a typed error are the SAME rule
212
+ * for any git subcommand. The consumer (agent-builder) had this locally in 62 LoC; nothing there
213
+ * was specific to it.
214
214
  *
215
215
  * Result shape (always a JSON string):
216
- * - `{ ok: true, diff: string, truncated?: boolean }` — `diff` carrega a saída porcelain
216
+ * - `{ ok: true, diff: string, truncated?: boolean }` — `diff` carries the porcelain output
217
217
  * - `{ ok: false, error: 'not_a_repo' | 'path_traversal' | 'timeout' | 'git_failed' }`
218
218
  */
219
219
 
@@ -225,28 +225,28 @@ interface CreateGitStatusToolOptions {
225
225
  /** Cap on captured stdout; excess sets `truncated: true`. Default 5 MB. */
226
226
  maxStdoutBytes?: number;
227
227
  /**
228
- * Backend de execução injetado (`@theokit/sdk/sandbox`) — quando presente, `git status` roda via
228
+ * Injected execution backend (`@theokit/sdk/sandbox`) — when present, `git status` runs via
229
229
  * `SandboxBackend.execute`; omitido ⇒ o `git` local (inalterado).
230
230
  *
231
- * Simetria com `createGitDiffTool`, apontada pelo review do M76: sem isto `git_diff` rodaria
232
- * confinado e `git_status` não, na mesma sessãoe a assimetria seria invisível até alguém
231
+ * Symmetry with `createGitDiffTool`, flagged by the M76 review: without it `git_diff` would run
232
+ * confined and `git_status` not, in the same session and the asymmetry would be invisible until someone
233
233
  * perceber que uma das duas escapa do sandbox.
234
234
  */
235
235
  sandbox?: SandboxProvider;
236
236
  /**
237
237
  * M76 — nome exposto ao modelo. Omitido ⇒ `"git_status"` (aditivo).
238
238
  *
239
- * O nome é contrato: chave de approval, o que o modelo e o que o telemetry registra.
239
+ * The name is a contract: the approval key, what the model sees and what telemetry records.
240
240
  */
241
241
  name?: string;
242
- /** M76 — descrição exposta ao modelo. Omitida o literal abaixo (aditivo). */
242
+ /** M76 — description exposed to the model. Omitted => the literal below (additive). */
243
243
  description?: string;
244
244
  /**
245
- * Incluir a linha de branch (`-b`) no início da saída. Default `true`.
245
+ * Include the branch line (`-b`) at the start of the output. Default `true`.
246
246
  *
247
- * Sem ela o agente o que mudou mas não ONDE e "estou na branch certa?" é a pergunta que
248
- * precede qualquer commit. O consumidor (agent-builder) dependia disso; omiti-la faria a
249
- * migração perder comportamento em silêncio, que é o que a deleção de código local não pode custar.
247
+ * Without it the agent sees what changed but not WHEREand "am I on the right branch?" is the question that
248
+ * precedes any commit. The consumer (agent-builder) already depended on it; omitting it would make the
249
+ * migration lose behavior silently, which is what deleting local code must not cost.
250
250
  */
251
251
  includeBranch?: boolean;
252
252
  }
@@ -264,10 +264,10 @@ declare function createGitStatusTool(opts: CreateGitStatusToolOptions): CustomTo
264
264
  */
265
265
 
266
266
  interface CreateGlobToolOptions {
267
- /** M76 — nome exposto ao modelo. Omitido o literal de hoje (aditivo). O nome é contrato: chave
268
- * de approval, o que o modelo e o que o telemetry registra. */
267
+ /** M76 — name exposed to the model. Omitted => today's literal (additive). The name is a contract:
268
+ * the approval key, what the model sees and what telemetry records. */
269
269
  name?: string;
270
- /** M76 — descrição exposta ao modelo. Omitida o literal de hoje (aditivo). */
270
+ /** M76 — description exposed to the model. Omitted => today's literal (additive). */
271
271
  description?: string;
272
272
  /** Absolute path to the project root. */
273
273
  projectRoot: string;
@@ -296,10 +296,10 @@ declare function createGlobTool(opts: CreateGlobToolOptions): CustomTool;
296
296
  */
297
297
 
298
298
  interface CreateInteractiveShellToolOptions {
299
- /** M76 — nome exposto ao modelo. Omitido o literal de hoje (aditivo). O nome é contrato: chave
300
- * de approval, o que o modelo e o que o telemetry registra. */
299
+ /** M76 — name exposed to the model. Omitted => today's literal (additive). The name is a contract:
300
+ * the approval key, what the model sees and what telemetry records. */
301
301
  name?: string;
302
- /** M76 — descrição exposta ao modelo. Omitida o literal de hoje (aditivo). */
302
+ /** M76 — description exposed to the model. Omitted => today's literal (additive). */
303
303
  description?: string;
304
304
  /** The interactive backend, or a per-request resolver of one (injected — never a direct native dep). */
305
305
  interactive: InteractiveProvider<unknown>;
@@ -618,21 +618,21 @@ interface CreateListDirToolOptions {
618
618
  /**
619
619
  * M76 — nome exposto ao modelo. Omitido ⇒ o literal de hoje (aditivo).
620
620
  *
621
- * Existe porque, no Codex, o nome NASCE na definição da tool e é a chave de decisão de approval
622
- * três consumidores (modelo, approval, telemetry) de uma string decidida num lugar só. Renomear
623
- * depois da construção é mudar a identidade de algo publicado ao modelo. `withName` continua
624
- * para o caso genuinamente dinâmico.
621
+ * It exists because, in Codex, the name is BORN in the tool definition and is the approval decision key
622
+ * three consumers (model, approval, telemetry) of a string decided in one place. Renaming
623
+ * after construction changes the identity of something already published to the model. `withName` remains
624
+ * for the genuinely dynamic case.
625
625
  */
626
626
  name?: string;
627
- /** M76 — descrição exposta ao modelo. Omitida o literal de hoje (aditivo). */
627
+ /** M76 — description exposed to the model. Omitted => today's literal (additive). */
628
628
  description?: string;
629
629
  /**
630
630
  * M76 — opt-in "lista-em-qualquer-lugar": honra um `path` ABSOLUTO fora de `projectRoot`
631
631
  * (paridade com `createReadFileTool`/`createSearchTextTool`, sandbox read-only do Codex).
632
632
  *
633
- * O guard de segredo por QUALQUER segmento continua valendo, e não é separável: `isForbiddenPath`
634
- * bloqueia o item sensível quando ele é o PRIMEIRO segmento, então um `/home/u/proj/.env/sub`
635
- * passaria. Ligar o flag sem o guard é abrir exfiltração. Default `false` absoluto rejeitado.
633
+ * The ANY-segment secret guard still applies, and is not separable: `isForbiddenPath`
634
+ * only blocks the sensitive item when it is the FIRST segment, so a `/home/u/proj/.env/sub`
635
+ * would pass. Enabling the flag without the guard opens exfiltration. Default `false` => absolute rejected.
636
636
  */
637
637
  allowAbsolute?: boolean;
638
638
  /** Absolute path to the project root. Every listing is gated against this boundary. */
@@ -696,10 +696,10 @@ interface PlanModeToolWithStore {
696
696
  * @public
697
697
  */
698
698
  interface PlanModeToolOptions {
699
- /** M76 — nome exposto ao modelo. Omitido o literal de hoje (aditivo). O nome é contrato: chave
700
- * de approval, o que o modelo e o que o telemetry registra. */
699
+ /** M76 — name exposed to the model. Omitted => today's literal (additive). The name is a contract:
700
+ * the approval key, what the model sees and what telemetry records. */
701
701
  name?: string;
702
- /** M76 — descrição exposta ao modelo. Omitida o literal de hoje (aditivo). */
702
+ /** M76 — description exposed to the model. Omitted => today's literal (additive). */
703
703
  description?: string;
704
704
  /** Store the submitted `plan` is persisted to on `exit`. */
705
705
  artifactStore: SessionArtifactStore;
@@ -718,18 +718,18 @@ declare function createPlanModeTool(options: PlanModeToolOptions): PlanModeToolW
718
718
  */
719
719
  interface QuestionToolOptions {
720
720
  /**
721
- * Callback que apresenta a pergunta ao usuário e resolve com a resposta.
721
+ * Callback that presents the question to the user and resolves with the answer.
722
722
  *
723
723
  * M76 — passou a ser OPCIONAL: o asker preferencial vem do contexto da run
724
- * (`ctx.context.askUser`), porque um valor fixado aqui é o "baked into each factory" que a doc do
724
+ * (`ctx.context.askUser`), because a value pinned here is the "baked into each factory" that the
725
725
  * `CustomTool.handler` aponta como o problema que `ctx.context` existe para resolver. Este campo
726
- * permanece como fallback, para quem constrói a tool com um asker fixo (retrocompatível).
726
+ * remains as a fallback, for callers building the tool with a fixed asker (backward-compatible).
727
727
  */
728
728
  askUser?: (question: string, threadId?: string) => Promise<string>;
729
729
  /**
730
- * Chamado quando a pergunta é ABANDONADA (timeout ou cancelamento da run), para que o lado da UI
731
- * libere o slot. Sem ele o timeout deixa a pergunta pendente para sempre a UI segue mostrando
732
- * um prompt que ninguém aguarda e a próxima pergunta falha com " uma pendente".
730
+ * Called when the question is ABANDONED (timeout or run cancellation), so the UI side can
731
+ * release the slot. Without it the timeout leaves the question pending foreverthe UI keeps showing
732
+ * a prompt nobody is waiting on and the next question fails with "one is already pending".
733
733
  */
734
734
  onAbandon?: (threadId?: string) => void;
735
735
  /** Maximum time to wait for user response in ms. Default: 300_000 (5 min). */
@@ -737,32 +737,32 @@ interface QuestionToolOptions {
737
737
  /**
738
738
  * M76 — nome exposto ao modelo. Omitido ⇒ `"question"` (aditivo).
739
739
  *
740
- * O consumidor precisava disto: o Codex chama a tool de `request_user_input`, e sem a opção ele
741
- * era obrigado a reconstruir o objeto inteiro à mão o adaptador com dois casts que a T3.3
740
+ * The consumer needed this: Codex calls the tool `request_user_input`, and without the option it
741
+ * had to rebuild the whole object by handthe two-cast adapter T3.3
742
742
  * eliminou.
743
743
  */
744
744
  name?: string;
745
- /** M76 — descrição exposta ao modelo. Omitida o literal de hoje (aditivo). */
745
+ /** M76 — description exposed to the model. Omitted => today's literal (additive). */
746
746
  description?: string;
747
747
  }
748
748
  /**
749
- * M76 — alinhado ao `CustomTool` do SDK. Era uma interface própria com `inputSchema: unknown`, o que
750
- * obrigava todo consumidor a escrever um cast para registrar a tool — e cast não conserta contrato,
751
- * silencia o compilador, transformando uma futura mudança de assinatura em erro de RUNTIME.
749
+ * M76 — aligned with the SDK's `CustomTool`. It used to be its own interface with `inputSchema: unknown`, which
750
+ * forced every consumer to write a cast to register the tool — and a cast does not fix a contract,
751
+ * it only silences the compiler, turning a future signature change into a RUNTIME error.
752
752
  *
753
- * Estreitar foi aditivo: o valor sempre foi um objeto (`{ type: "object", properties, required }`
754
- * logo abaixo); o tipo declarado estava frouxo. O handler aceita o argumento opcional do
755
- * contrato (`ctx`), por onde o M76 passa a resolver o asker por sessão.
753
+ * Narrowing was additive: the value has always been an object (`{ type: "object", properties, required }`
754
+ * just below); only the declared type was loose. The handler accepts the contract's optional 2nd
755
+ * argument (`ctx`), through which M76 now resolves the asker per session.
756
756
  */
757
757
  interface QuestionTool {
758
758
  name: string;
759
759
  description: string;
760
760
  inputSchema: Record<string, unknown>;
761
761
  /**
762
- * M76 — o input é `Record<string, unknown>`, não `{ question: string }`, por CONTRAVARIÂNCIA: um
763
- * handler que aceita o tipo estreito não é atribuível a um que aceita o largo, e o `CustomTool`
764
- * do SDK declara o largo. Declarar estreito aqui obrigava o consumidor a um cast — que era
765
- * exatamente o defeito. O estreitamento acontece DENTRO do handler, onde validação.
762
+ * M76 — the input is `Record<string, unknown>`, not `{ question: string }`, by CONTRAVARIANCE: a
763
+ * handler accepting only the narrow type is not assignable to one accepting the wide type, and `CustomTool`
764
+ * SDK declares the wide one. Declaring narrow here forced the consumer into a cast — which was
765
+ * exactly the defect. Narrowing happens INSIDE the handler, where validation lives.
766
766
  */
767
767
  handler: (input: Record<string, unknown>, ctx?: {
768
768
  signal?: AbortSignal;
@@ -818,10 +818,10 @@ declare class ReadTracker {
818
818
  */
819
819
 
820
820
  interface CreateReadFileToolOptions {
821
- /** M76 — nome exposto ao modelo. Omitido o literal de hoje (aditivo). O nome é contrato: chave
822
- * de approval, o que o modelo e o que o telemetry registra. */
821
+ /** M76 — name exposed to the model. Omitted => today's literal (additive). The name is a contract:
822
+ * the approval key, what the model sees and what telemetry records. */
823
823
  name?: string;
824
- /** M76 — descrição exposta ao modelo. Omitida o literal de hoje (aditivo). */
824
+ /** M76 — description exposed to the model. Omitted => today's literal (additive). */
825
825
  description?: string;
826
826
  /** Absolute path to the project root. Every read is gated against this boundary. */
827
827
  projectRoot: string;
@@ -902,10 +902,10 @@ declare class ReasoningTools {
902
902
  */
903
903
 
904
904
  interface CreateRunVitestToolOptions {
905
- /** M76 — nome exposto ao modelo. Omitido o literal de hoje (aditivo). O nome é contrato: chave
906
- * de approval, o que o modelo e o que o telemetry registra. */
905
+ /** M76 — name exposed to the model. Omitted => today's literal (additive). The name is a contract:
906
+ * the approval key, what the model sees and what telemetry records. */
907
907
  name?: string;
908
- /** M76 — descrição exposta ao modelo. Omitida o literal de hoje (aditivo). */
908
+ /** M76 — description exposed to the model. Omitted => today's literal (additive). */
909
909
  description?: string;
910
910
  projectRoot: string;
911
911
  timeoutMs?: number;
@@ -947,13 +947,13 @@ interface CreateSearchTextToolOptions {
947
947
  /**
948
948
  * M76 — nome exposto ao modelo. Omitido ⇒ o literal de hoje (aditivo).
949
949
  *
950
- * Existe porque, no Codex, o nome NASCE na definição da tool e é a chave de decisão de approval
951
- * três consumidores (modelo, approval, telemetry) de uma string decidida num lugar só. Renomear
952
- * depois da construção é mudar a identidade de algo publicado ao modelo. `withName` continua
953
- * para o caso genuinamente dinâmico.
950
+ * It exists because, in Codex, the name is BORN in the tool definition and is the approval decision
951
+ * key three consumers (model, approval, telemetry) of a string decided in one place. Renaming
952
+ * after construction changes the identity of something already published to the model. `withName`
953
+ * remains for the genuinely dynamic case.
954
954
  */
955
955
  name?: string;
956
- /** M76 — descrição exposta ao modelo. Omitida o literal de hoje (aditivo). */
956
+ /** M76 — description exposed to the model. Omitted => today's literal (additive). */
957
957
  description?: string;
958
958
  projectRoot: string;
959
959
  /** Cap on total matches returned. Default 100. */
@@ -987,13 +987,13 @@ interface CreateShellToolOptions {
987
987
  /**
988
988
  * M76 — nome exposto ao modelo. Omitido ⇒ o literal de hoje (aditivo).
989
989
  *
990
- * Existe porque, no Codex, o nome NASCE na definição da tool e é a chave de decisão de approval
991
- * três consumidores (modelo, approval, telemetry) de uma string decidida num lugar só. Renomear
992
- * depois da construção é mudar a identidade de algo publicado ao modelo. `withName` continua
993
- * para o caso genuinamente dinâmico.
990
+ * It exists because, in Codex, the name is BORN in the tool definition and is the approval decision
991
+ * key three consumers (model, approval, telemetry) of a string decided in one place. Renaming
992
+ * after construction changes the identity of something already published to the model. `withName`
993
+ * remains for the genuinely dynamic case.
994
994
  */
995
995
  name?: string;
996
- /** M76 — descrição exposta ao modelo. Omitida o literal de hoje (aditivo). */
996
+ /** M76 — description exposed to the model. Omitted => today's literal (additive). */
997
997
  description?: string;
998
998
  /** Absolute path to the project root. Commands execute in this cwd. */
999
999
  projectRoot: string;
@@ -1186,10 +1186,10 @@ declare function createUpdatePlanTool(): CustomTool;
1186
1186
  */
1187
1187
 
1188
1188
  interface CreateWebFetchToolOptions {
1189
- /** M76 — nome exposto ao modelo. Omitido o literal de hoje (aditivo). O nome é contrato: chave
1190
- * de approval, o que o modelo e o que o telemetry registra. */
1189
+ /** M76 — name exposed to the model. Omitted => today's literal (additive). The name is a contract:
1190
+ * the approval key, what the model sees and what telemetry records. */
1191
1191
  name?: string;
1192
- /** M76 — descrição exposta ao modelo. Omitida o literal de hoje (aditivo). */
1192
+ /** M76 — description exposed to the model. Omitted => today's literal (additive). */
1193
1193
  description?: string;
1194
1194
  /** Default timeout in ms. */
1195
1195
  defaultTimeoutMs?: number;
@@ -1230,10 +1230,10 @@ interface WebSearchResult {
1230
1230
  }
1231
1231
  type WebSearchCallback = (query: string, maxResults: number) => Promise<WebSearchResult[]>;
1232
1232
  interface CreateWebSearchToolOptions {
1233
- /** M76 — nome exposto ao modelo. Omitido o literal de hoje (aditivo). O nome é contrato: chave
1234
- * de approval, o que o modelo e o que o telemetry registra. */
1233
+ /** M76 — name exposed to the model. Omitted => today's literal (additive). The name is a contract:
1234
+ * the approval key, what the model sees and what telemetry records. */
1235
1235
  name?: string;
1236
- /** M76 — descrição exposta ao modelo. Omitida o literal de hoje (aditivo). */
1236
+ /** M76 — description exposed to the model. Omitted => today's literal (additive). */
1237
1237
  description?: string;
1238
1238
  /** Search provider callback — consumer injects the implementation. */
1239
1239
  search: WebSearchCallback;
@@ -1324,10 +1324,10 @@ type WriteToolContext = {
1324
1324
  context?: unknown;
1325
1325
  };
1326
1326
  interface CreateWriteFileToolOptions {
1327
- /** M76 — nome exposto ao modelo. Omitido o literal de hoje (aditivo). O nome é contrato: chave
1328
- * de approval, o que o modelo e o que o telemetry registra. */
1327
+ /** M76 — name exposed to the model. Omitted => today's literal (additive). The name is a contract:
1328
+ * the approval key, what the model sees and what telemetry records. */
1329
1329
  name?: string;
1330
- /** M76 — descrição exposta ao modelo. Omitida o literal de hoje (aditivo). */
1330
+ /** M76 — description exposed to the model. Omitted => today's literal (additive). */
1331
1331
  description?: string;
1332
1332
  /** Absolute path to the project root. Every write is gated against this boundary. */
1333
1333
  projectRoot: string;
@@ -1351,4 +1351,4 @@ interface CreateWriteFileToolOptions {
1351
1351
  }
1352
1352
  declare function createWriteFileTool(opts: CreateWriteFileToolOptions): CustomTool;
1353
1353
 
1354
- export { CatastrophicCommandError, type CommandPolicy, ContextMatchError, type ContextMatchReason, type CreateApplyPatchToolOptions, type CreateBraveWebSearchAdapterOptions, type CreateCurrentTimeToolOptions, type CreateEditFileToolOptions, type CreateGenericHttpSearchAdapterOptions, type CreateGitDiffToolOptions, type CreateGitStatusToolOptions, type CreateGlobToolOptions, type CreateInteractiveShellToolOptions, type CreateListDirToolOptions, type CreateReadFileToolOptions, type CreateRunVitestToolOptions, type CreateSearchTextToolOptions, type CreateShellToolOptions, type CreateWebFetchToolOptions, type CreateWebSearchToolOptions, type CreateWriteFileToolOptions, DEFAULT_TOOL_GUIDANCE, type EnvContextOptions, type PlanModeTool, type PlanModeToolOptions, type PlanModeToolWithStore, type PlanNode, type QuestionTool, type QuestionToolOptions, ReadTracker, ReasoningTools, RedirectBlockedError, type RepoMapOptions, type ResolveAndScreenOptions, type ScreenedFetchOptions, type SessionArtifactStore, type SessionArtifactStoreOptions, SsrfBlockedError, type TodoItem, type TodolistTool, type ToolGuidanceMap, type TruncationOptions, type TruncationResult, type VitestSummary, type WebSearchCallback, type WebSearchResult, buildEnvContext, buildRepoMap, catastrophicShellReason, commandDenialReason, createApplyPatchTool, createBraveWebSearchAdapter, createCurrentTimeTool, createEditFileTool, createGenericHttpSearchAdapter, createGitDiffTool, createGitStatusTool, createGlobTool, createInteractiveShellTool, createListDirTool, createPlanModeTool, createQuestionTool, createReadFileTool, createRunVitestTool, createSearchTextTool, createSessionArtifactStore, createShellTool, createTodolistTool, createUpdatePlanTool, createWebFetchTool, createWebSearchTool, createWriteFileTool, createWriteStdinTool, denyCatastrophicCommands, formatCode, formatDiff, formatError, formatFileList, injectGuidance, isBlockedIp, isCommandAllowed, renderToolList, replaceUnique, resolveAndScreen, screenedFetch, todoItemsToPlanNodes, truncateOutput, withDefaultGuidance, withDescription, withName, withShellExitGuidance, withToolResultGuidance };
1354
+ export { CatastrophicCommandError, type CommandPolicy, ContextMatchError, type ContextMatchReason, type CreateApplyPatchToolOptions, type CreateBraveWebSearchAdapterOptions, type CreateCurrentTimeToolOptions, type CreateEditFileToolOptions, type CreateGenericHttpSearchAdapterOptions, type CreateGitDiffToolOptions, type CreateGitStatusToolOptions, type CreateGlobToolOptions, type CreateInteractiveShellToolOptions, type CreateListDirToolOptions, type CreateReadFileToolOptions, type CreateRunVitestToolOptions, type CreateSearchTextToolOptions, type CreateShellToolOptions, type CreateWebFetchToolOptions, type CreateWebSearchToolOptions, type CreateWriteFileToolOptions, DEFAULT_TOOL_GUIDANCE, type EnvContextOptions, type PlanModeTool, type PlanModeToolOptions, type PlanModeToolWithStore, type PlanNode, type QuestionTool, type QuestionToolOptions, ReadTracker, ReasoningTools, RedirectBlockedError, type RepoMapOptions, type ResolveAndScreenOptions, type ScreenedFetchOptions, type SessionArtifactStore, type SessionArtifactStoreOptions, SsrfBlockedError, type TodoItem, type TodolistTool, type ToolGuidanceMap, type TruncationMode, type TruncationOptions, type TruncationResult, type VitestSummary, type WebSearchCallback, type WebSearchResult, buildEnvContext, buildRepoMap, catastrophicShellReason, commandDenialReason, createApplyPatchTool, createBraveWebSearchAdapter, createCurrentTimeTool, createEditFileTool, createGenericHttpSearchAdapter, createGitDiffTool, createGitStatusTool, createGlobTool, createInteractiveShellTool, createListDirTool, createPlanModeTool, createQuestionTool, createReadFileTool, createRunVitestTool, createSearchTextTool, createSessionArtifactStore, createShellTool, createTodolistTool, createUpdatePlanTool, createWebFetchTool, createWebSearchTool, createWriteFileTool, createWriteStdinTool, denyCatastrophicCommands, formatCode, formatDiff, formatError, formatFileList, injectGuidance, isBlockedIp, isCommandAllowed, renderToolList, replaceUnique, resolveAndScreen, screenedFetch, todoItemsToPlanNodes, truncateOutput, withDefaultGuidance, withDescription, withName, withShellExitGuidance, withToolResultGuidance };
package/dist/index.js CHANGED
@@ -864,7 +864,7 @@ function createGitStatusTool(opts) {
864
864
  }
865
865
  const scopeCheck = checkPathScope(path, projectRoot);
866
866
  if (scopeCheck !== null) return scopeCheck;
867
- const args = montarArgs(path, opts.includeBranch !== false);
867
+ const args = buildArgs(path, opts.includeBranch !== false);
868
868
  if (opts.sandbox !== void 0) {
869
869
  return statusViaSandbox(opts.sandbox, ctx, args, timeoutMs);
870
870
  }
@@ -873,9 +873,9 @@ function createGitStatusTool(opts) {
873
873
  }
874
874
  });
875
875
  }
876
- function montarArgs(path, comBranch) {
876
+ function buildArgs(path, withBranch) {
877
877
  const args = ["status", "--porcelain=v1"];
878
- if (comBranch) args.push("-b");
878
+ if (withBranch) args.push("-b");
879
879
  if (path !== void 0 && path !== "") args.push("--", path);
880
880
  return args;
881
881
  }
@@ -1002,7 +1002,26 @@ function globToRegex(pattern) {
1002
1002
  }
1003
1003
  return new RegExp(`^${regexStr}$`);
1004
1004
  }
1005
+ function capFields(err) {
1006
+ const e = err;
1007
+ if (typeof e.max !== "number") return void 0;
1008
+ if (!Array.isArray(e.liveSessionIds)) return void 0;
1009
+ if (!e.liveSessionIds.every((id) => typeof id === "string")) return void 0;
1010
+ return { max: e.max, liveSessionIds: e.liveSessionIds };
1011
+ }
1005
1012
  function toErrorJson(err) {
1013
+ if (typeof err === "object" && err !== null) {
1014
+ const cap = capFields(err);
1015
+ if (cap !== void 0) {
1016
+ return JSON.stringify({
1017
+ ok: false,
1018
+ error: "interactive_session_limit",
1019
+ max: cap.max,
1020
+ live_session_ids: [...cap.liveSessionIds],
1021
+ message: err.message
1022
+ });
1023
+ }
1024
+ }
1006
1025
  if (err instanceof InteractiveUnavailableError) {
1007
1026
  return JSON.stringify({ ok: false, error: "interactive_unavailable" });
1008
1027
  }
@@ -1565,10 +1584,10 @@ function createListDirTool(opts) {
1565
1584
  }),
1566
1585
  handler: async ({ path }, ctx) => {
1567
1586
  const relative3 = path === "" || path === "." ? "." : path;
1568
- const veredito = decidirEscopo(relative3, path, opts.allowAbsolute === true);
1569
- if (veredito.erro !== void 0) return veredito.erro;
1570
- if (veredito.raizAbsoluta !== void 0) {
1571
- return listViaLocalFs(veredito.raizAbsoluta, ".", path, max);
1587
+ const verdict = decidirEscopo(relative3, path, opts.allowAbsolute === true);
1588
+ if (verdict.error !== void 0) return verdict.error;
1589
+ if (verdict.absoluteRoot !== void 0) {
1590
+ return listViaLocalFs(verdict.absoluteRoot, ".", path, max);
1572
1591
  }
1573
1592
  if (filesystem) {
1574
1593
  const backend = await resolveFilesystem(filesystem, ctx ?? {});
@@ -1579,14 +1598,14 @@ function createListDirTool(opts) {
1579
1598
  });
1580
1599
  }
1581
1600
  function decidirEscopo(relative3, original, allowAbsolute) {
1582
- const recusa = (error) => ({
1583
- erro: JSON.stringify({ ok: false, error, path: original })
1601
+ const refuse = (error) => ({
1602
+ error: JSON.stringify({ ok: false, error, path: original })
1584
1603
  });
1585
- if (relative3 !== "." && isForbiddenPath(relative3)) return recusa("forbidden_path");
1604
+ if (relative3 !== "." && isForbiddenPath(relative3)) return refuse("forbidden_path");
1586
1605
  if (!isAbsolute(relative3)) return {};
1587
- if (!allowAbsolute) return recusa("path_traversal");
1588
- if (ehProibidoEmQualquerProfundidade(relative3)) return recusa("forbidden_path");
1589
- return { raizAbsoluta: relative3 };
1606
+ if (!allowAbsolute) return refuse("path_traversal");
1607
+ if (ehProibidoEmQualquerProfundidade(relative3)) return refuse("forbidden_path");
1608
+ return { absoluteRoot: relative3 };
1590
1609
  }
1591
1610
  async function listViaLocalFs(projectRoot, relative3, originalPath, max) {
1592
1611
  const boundary = resolveDirBoundary(relative3, projectRoot, originalPath);