@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/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 +90 -90
- package/dist/index.d.ts +90 -90
- package/dist/index.js +32 -13
- package/dist/index.js.map +1 -1
- package/package.json +11 -11
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 —
|
|
30
|
-
*
|
|
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 —
|
|
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 —
|
|
110
|
-
*
|
|
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 —
|
|
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
|
-
*
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
*
|
|
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 —
|
|
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 —
|
|
191
|
-
*
|
|
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 —
|
|
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 —
|
|
211
|
-
*
|
|
212
|
-
*
|
|
213
|
-
*
|
|
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`
|
|
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
|
-
*
|
|
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
|
-
*
|
|
232
|
-
*
|
|
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
|
-
*
|
|
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 —
|
|
242
|
+
/** M76 — description exposed to the model. Omitted => the literal below (additive). */
|
|
243
243
|
description?: string;
|
|
244
244
|
/**
|
|
245
|
-
*
|
|
245
|
+
* Include the branch line (`-b`) at the start of the output. Default `true`.
|
|
246
246
|
*
|
|
247
|
-
*
|
|
248
|
-
*
|
|
249
|
-
*
|
|
247
|
+
* Without it the agent sees what changed but not WHERE — and "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 —
|
|
268
|
-
*
|
|
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 —
|
|
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 —
|
|
300
|
-
*
|
|
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 —
|
|
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
|
-
*
|
|
622
|
-
*
|
|
623
|
-
*
|
|
624
|
-
*
|
|
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 —
|
|
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
|
-
*
|
|
634
|
-
*
|
|
635
|
-
*
|
|
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 —
|
|
700
|
-
*
|
|
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 —
|
|
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
|
|
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`),
|
|
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
|
-
*
|
|
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
|
-
*
|
|
731
|
-
*
|
|
732
|
-
*
|
|
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 forever — the 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
|
-
*
|
|
741
|
-
*
|
|
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 hand — the two-cast adapter T3.3
|
|
742
742
|
* eliminou.
|
|
743
743
|
*/
|
|
744
744
|
name?: string;
|
|
745
|
-
/** M76 —
|
|
745
|
+
/** M76 — description exposed to the model. Omitted => today's literal (additive). */
|
|
746
746
|
description?: string;
|
|
747
747
|
}
|
|
748
748
|
/**
|
|
749
|
-
* M76 —
|
|
750
|
-
*
|
|
751
|
-
*
|
|
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
|
-
*
|
|
754
|
-
*
|
|
755
|
-
*
|
|
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 —
|
|
763
|
-
* handler
|
|
764
|
-
*
|
|
765
|
-
*
|
|
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 —
|
|
822
|
-
*
|
|
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 —
|
|
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 —
|
|
906
|
-
*
|
|
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 —
|
|
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
|
-
*
|
|
951
|
-
*
|
|
952
|
-
*
|
|
953
|
-
*
|
|
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 —
|
|
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
|
-
*
|
|
991
|
-
*
|
|
992
|
-
*
|
|
993
|
-
*
|
|
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 —
|
|
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 —
|
|
1190
|
-
*
|
|
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 —
|
|
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 —
|
|
1234
|
-
*
|
|
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 —
|
|
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 —
|
|
1328
|
-
*
|
|
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 —
|
|
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 =
|
|
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
|
|
876
|
+
function buildArgs(path, withBranch) {
|
|
877
877
|
const args = ["status", "--porcelain=v1"];
|
|
878
|
-
if (
|
|
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
|
|
1569
|
-
if (
|
|
1570
|
-
if (
|
|
1571
|
-
return listViaLocalFs(
|
|
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
|
|
1583
|
-
|
|
1601
|
+
const refuse = (error) => ({
|
|
1602
|
+
error: JSON.stringify({ ok: false, error, path: original })
|
|
1584
1603
|
});
|
|
1585
|
-
if (relative3 !== "." && isForbiddenPath(relative3)) return
|
|
1604
|
+
if (relative3 !== "." && isForbiddenPath(relative3)) return refuse("forbidden_path");
|
|
1586
1605
|
if (!isAbsolute(relative3)) return {};
|
|
1587
|
-
if (!allowAbsolute) return
|
|
1588
|
-
if (ehProibidoEmQualquerProfundidade(relative3)) return
|
|
1589
|
-
return {
|
|
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);
|