@gotgenes/pi-permission-system 8.0.0 → 8.2.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 +21 -0
- package/config/config.example.json +3 -0
- package/package.json +1 -1
- package/schemas/permissions.schema.json +12 -0
- package/src/extension-config.ts +23 -0
- package/src/handlers/gates/bash-external-directory.ts +2 -4
- package/src/handlers/gates/bash-path.ts +2 -4
- package/src/handlers/gates/descriptor.ts +6 -6
- package/src/handlers/gates/external-directory.ts +2 -4
- package/src/handlers/gates/helpers.ts +30 -1
- package/src/handlers/gates/path.ts +2 -4
- package/src/handlers/gates/runner.ts +29 -56
- package/src/handlers/gates/tool.ts +9 -6
- package/src/handlers/permission-gate-handler.ts +110 -141
- package/src/permission-manager.ts +6 -49
- package/src/permission-prompts.ts +5 -2
- package/src/permission-session.ts +3 -2
- package/src/scope-merge.ts +72 -0
- package/src/session-approval.ts +43 -0
- package/src/session-rules.ts +13 -0
- package/src/tool-input-preview.ts +0 -116
- package/src/tool-preview-formatter.ts +188 -0
- package/test/extension-config.test.ts +93 -0
- package/test/handlers/external-directory-integration.test.ts +3 -1
- package/test/handlers/external-directory-session-dedup.test.ts +17 -12
- package/test/handlers/gates/bash-external-directory.test.ts +11 -9
- package/test/handlers/gates/external-directory.test.ts +2 -5
- package/test/handlers/gates/helpers.test.ts +81 -0
- package/test/handlers/gates/path.test.ts +2 -2
- package/test/handlers/gates/runner.test.ts +18 -23
- package/test/handlers/gates/tool.test.ts +31 -4
- package/test/handlers/input-events.test.ts +1 -1
- package/test/handlers/input.test.ts +1 -1
- package/test/handlers/tool-call-events.test.ts +3 -2
- package/test/handlers/tool-call.test.ts +3 -2
- package/test/handlers/validate-requested-tool.test.ts +92 -0
- package/test/permission-prompts.test.ts +66 -38
- package/test/permission-session.test.ts +6 -3
- package/test/scope-merge.test.ts +116 -0
- package/test/session-approval.test.ts +75 -0
- package/test/session-rules.test.ts +49 -0
- package/test/tool-input-preview.test.ts +0 -244
- package/test/tool-preview-formatter.test.ts +385 -0
|
@@ -0,0 +1,385 @@
|
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, test, vi } from "vitest";
|
|
2
|
+
|
|
3
|
+
// Mock logging collaborator before importing the module under test.
|
|
4
|
+
vi.mock("../src/logging.js", () => ({
|
|
5
|
+
safeJsonStringify: vi.fn((value: unknown) => JSON.stringify(value)),
|
|
6
|
+
}));
|
|
7
|
+
|
|
8
|
+
import { safeJsonStringify } from "#src/logging";
|
|
9
|
+
import {
|
|
10
|
+
TOOL_INPUT_LOG_PREVIEW_MAX_LENGTH,
|
|
11
|
+
TOOL_INPUT_PREVIEW_MAX_LENGTH,
|
|
12
|
+
TOOL_TEXT_SUMMARY_MAX_LENGTH,
|
|
13
|
+
} from "#src/tool-input-preview";
|
|
14
|
+
import {
|
|
15
|
+
resolveToolPreviewLimits,
|
|
16
|
+
ToolPreviewFormatter,
|
|
17
|
+
type ToolPreviewFormatterOptions,
|
|
18
|
+
} from "#src/tool-preview-formatter";
|
|
19
|
+
import type { PermissionCheckResult } from "#src/types";
|
|
20
|
+
|
|
21
|
+
const mockedStringify = vi.mocked(safeJsonStringify);
|
|
22
|
+
|
|
23
|
+
function makeFormatter(
|
|
24
|
+
overrides: Partial<ToolPreviewFormatterOptions> = {},
|
|
25
|
+
): ToolPreviewFormatter {
|
|
26
|
+
return new ToolPreviewFormatter({
|
|
27
|
+
toolInputPreviewMaxLength: TOOL_INPUT_PREVIEW_MAX_LENGTH,
|
|
28
|
+
toolTextSummaryMaxLength: TOOL_TEXT_SUMMARY_MAX_LENGTH,
|
|
29
|
+
toolInputLogPreviewMaxLength: TOOL_INPUT_LOG_PREVIEW_MAX_LENGTH,
|
|
30
|
+
...overrides,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function makeResult(
|
|
35
|
+
toolName: string,
|
|
36
|
+
overrides: Partial<PermissionCheckResult> = {},
|
|
37
|
+
): PermissionCheckResult {
|
|
38
|
+
return {
|
|
39
|
+
toolName,
|
|
40
|
+
state: "allow",
|
|
41
|
+
source: "tool",
|
|
42
|
+
origin: "builtin",
|
|
43
|
+
...overrides,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
beforeEach(() => {
|
|
48
|
+
mockedStringify.mockReset();
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
afterEach(() => {
|
|
52
|
+
vi.restoreAllMocks();
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
// ── sanitizeInlineText ────────────────────────────────────────────────────
|
|
56
|
+
|
|
57
|
+
describe("ToolPreviewFormatter.sanitizeInlineText", () => {
|
|
58
|
+
test("collapses whitespace and trims", () => {
|
|
59
|
+
const f = makeFormatter();
|
|
60
|
+
expect(f.sanitizeInlineText(" hello world ")).toBe("hello world");
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
test("returns 'empty text' for blank string", () => {
|
|
64
|
+
const f = makeFormatter();
|
|
65
|
+
expect(f.sanitizeInlineText("")).toBe("empty text");
|
|
66
|
+
expect(f.sanitizeInlineText(" ")).toBe("empty text");
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
test("truncates at constructor toolTextSummaryMaxLength", () => {
|
|
70
|
+
const f = makeFormatter({ toolTextSummaryMaxLength: 5 });
|
|
71
|
+
const result = f.sanitizeInlineText("hello world");
|
|
72
|
+
expect(result).toBe("hello…");
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
test("explicit maxLength override takes precedence over constructor default", () => {
|
|
76
|
+
const f = makeFormatter({ toolTextSummaryMaxLength: 80 });
|
|
77
|
+
const result = f.sanitizeInlineText("hello world", 5);
|
|
78
|
+
expect(result).toBe("hello…");
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
// ── formatJsonInputForPrompt ──────────────────────────────────────────────
|
|
83
|
+
|
|
84
|
+
describe("ToolPreviewFormatter.formatJsonInputForPrompt", () => {
|
|
85
|
+
test("returns empty string when serialization yields empty", () => {
|
|
86
|
+
mockedStringify.mockReturnValue(undefined);
|
|
87
|
+
const f = makeFormatter();
|
|
88
|
+
expect(f.formatJsonInputForPrompt({})).toBe("");
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
test("returns prefixed JSON with 'with input' prefix", () => {
|
|
92
|
+
mockedStringify.mockReturnValue('{"k":"v"}');
|
|
93
|
+
const f = makeFormatter();
|
|
94
|
+
expect(f.formatJsonInputForPrompt({ k: "v" })).toBe('with input {"k":"v"}');
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
test("truncates at constructor toolInputPreviewMaxLength", () => {
|
|
98
|
+
const longJson = `"${"x".repeat(20)}"`;
|
|
99
|
+
mockedStringify.mockReturnValue(longJson);
|
|
100
|
+
const f = makeFormatter({ toolInputPreviewMaxLength: 10 });
|
|
101
|
+
const result = f.formatJsonInputForPrompt({});
|
|
102
|
+
// "with input " + 10 chars + ellipsis
|
|
103
|
+
const preview = result.slice("with input ".length);
|
|
104
|
+
expect(preview.length).toBe(11); // 10 + 1 for "…"
|
|
105
|
+
expect(preview.endsWith("…")).toBe(true);
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
test("does not truncate when within toolInputPreviewMaxLength", () => {
|
|
109
|
+
mockedStringify.mockReturnValue('{"k":"v"}');
|
|
110
|
+
const f = makeFormatter({ toolInputPreviewMaxLength: 200 });
|
|
111
|
+
expect(f.formatJsonInputForPrompt({ k: "v" })).toBe('with input {"k":"v"}');
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
// ── formatSearchInputForPrompt ────────────────────────────────────────────
|
|
116
|
+
|
|
117
|
+
describe("ToolPreviewFormatter.formatSearchInputForPrompt", () => {
|
|
118
|
+
test("includes pattern and path", () => {
|
|
119
|
+
const f = makeFormatter();
|
|
120
|
+
const result = f.formatSearchInputForPrompt("grep", {
|
|
121
|
+
pattern: "TODO",
|
|
122
|
+
path: "/src",
|
|
123
|
+
});
|
|
124
|
+
expect(result).toContain("pattern 'TODO'");
|
|
125
|
+
expect(result).toContain("path '/src'");
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
test("truncates pattern at toolTextSummaryMaxLength", () => {
|
|
129
|
+
const f = makeFormatter({ toolTextSummaryMaxLength: 5 });
|
|
130
|
+
const result = f.formatSearchInputForPrompt("grep", {
|
|
131
|
+
pattern: "abcdefgh",
|
|
132
|
+
});
|
|
133
|
+
expect(result).toContain("abcde…");
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
test("uses 'current working directory' for find/grep/ls without path", () => {
|
|
137
|
+
const f = makeFormatter();
|
|
138
|
+
for (const toolName of ["find", "grep", "ls"]) {
|
|
139
|
+
const result = f.formatSearchInputForPrompt(toolName, {});
|
|
140
|
+
expect(result).toContain("current working directory");
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
test("returns empty string for unknown tool with no input", () => {
|
|
145
|
+
const f = makeFormatter();
|
|
146
|
+
expect(f.formatSearchInputForPrompt("other", {})).toBe("");
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
// ── formatToolInputForPrompt ──────────────────────────────────────────────
|
|
151
|
+
|
|
152
|
+
describe("ToolPreviewFormatter.formatToolInputForPrompt", () => {
|
|
153
|
+
test("dispatches 'edit' to standalone formatEditInputForPrompt", () => {
|
|
154
|
+
mockedStringify.mockReturnValue(undefined);
|
|
155
|
+
const f = makeFormatter();
|
|
156
|
+
const result = f.formatToolInputForPrompt("edit", {
|
|
157
|
+
path: "/foo.ts",
|
|
158
|
+
edits: [],
|
|
159
|
+
});
|
|
160
|
+
expect(result).toContain("for '/foo.ts'");
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
test("dispatches 'write' to standalone formatWriteInputForPrompt", () => {
|
|
164
|
+
const f = makeFormatter();
|
|
165
|
+
const result = f.formatToolInputForPrompt("write", {
|
|
166
|
+
path: "/out.ts",
|
|
167
|
+
content: "hi",
|
|
168
|
+
});
|
|
169
|
+
expect(result).toContain("for '/out.ts'");
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
test("dispatches 'read' to standalone formatReadInputForPrompt", () => {
|
|
173
|
+
const f = makeFormatter();
|
|
174
|
+
const result = f.formatToolInputForPrompt("read", { path: "/src/x.ts" });
|
|
175
|
+
expect(result).toContain("path '/src/x.ts'");
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
test("dispatches 'find'/'grep'/'ls' to formatSearchInputForPrompt", () => {
|
|
179
|
+
const f = makeFormatter();
|
|
180
|
+
for (const tool of ["find", "grep", "ls"]) {
|
|
181
|
+
const result = f.formatToolInputForPrompt(tool, {});
|
|
182
|
+
expect(result).toContain("current working directory");
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
test("falls back to formatJsonInputForPrompt for unknown tools", () => {
|
|
187
|
+
mockedStringify.mockReturnValue('{"x":1}');
|
|
188
|
+
const f = makeFormatter();
|
|
189
|
+
const result = f.formatToolInputForPrompt("unknown", { x: 1 });
|
|
190
|
+
expect(result).toContain('{"x":1}');
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
test("unknown tool truncates at constructor toolInputPreviewMaxLength", () => {
|
|
194
|
+
const longJson = `{"k":"${"x".repeat(50)}"}`;
|
|
195
|
+
mockedStringify.mockReturnValue(longJson);
|
|
196
|
+
const f = makeFormatter({ toolInputPreviewMaxLength: 10 });
|
|
197
|
+
const result = f.formatToolInputForPrompt("custom", {});
|
|
198
|
+
const preview = result.slice("with input ".length);
|
|
199
|
+
expect(preview.endsWith("…")).toBe(true);
|
|
200
|
+
expect(preview.length).toBe(11); // 10 + "…"
|
|
201
|
+
});
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
// ── formatGenericToolInputForLog ──────────────────────────────────────────
|
|
205
|
+
|
|
206
|
+
describe("ToolPreviewFormatter.formatGenericToolInputForLog", () => {
|
|
207
|
+
test("returns undefined when serialization yields empty string", () => {
|
|
208
|
+
mockedStringify.mockReturnValue(undefined);
|
|
209
|
+
const f = makeFormatter();
|
|
210
|
+
expect(f.formatGenericToolInputForLog({})).toBeUndefined();
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
test("returns prefixed input preview", () => {
|
|
214
|
+
mockedStringify.mockReturnValue('{"k":"v"}');
|
|
215
|
+
const f = makeFormatter();
|
|
216
|
+
expect(f.formatGenericToolInputForLog({ k: "v" })).toBe('input {"k":"v"}');
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
test("truncates at constructor toolInputLogPreviewMaxLength", () => {
|
|
220
|
+
const longJson = `{"k":"${"x".repeat(50)}"}`;
|
|
221
|
+
mockedStringify.mockReturnValue(longJson);
|
|
222
|
+
const f = makeFormatter({ toolInputLogPreviewMaxLength: 10 });
|
|
223
|
+
const result = f.formatGenericToolInputForLog({});
|
|
224
|
+
expect(result).toBeDefined();
|
|
225
|
+
const preview = result!.slice("input ".length);
|
|
226
|
+
expect(preview.length).toBe(11); // 10 + "…"
|
|
227
|
+
expect(preview.endsWith("…")).toBe(true);
|
|
228
|
+
});
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
// ── getToolInputPreviewForLog ─────────────────────────────────────────────
|
|
232
|
+
|
|
233
|
+
describe("ToolPreviewFormatter.getToolInputPreviewForLog", () => {
|
|
234
|
+
const pathBearingTools = new Set(["read", "write", "edit"]);
|
|
235
|
+
|
|
236
|
+
test("returns undefined for bash tool", () => {
|
|
237
|
+
const f = makeFormatter();
|
|
238
|
+
expect(
|
|
239
|
+
f.getToolInputPreviewForLog(
|
|
240
|
+
makeResult("bash"),
|
|
241
|
+
{ command: "ls" },
|
|
242
|
+
pathBearingTools,
|
|
243
|
+
),
|
|
244
|
+
).toBeUndefined();
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
test("returns undefined for mcp tool", () => {
|
|
248
|
+
const f = makeFormatter();
|
|
249
|
+
expect(
|
|
250
|
+
f.getToolInputPreviewForLog(makeResult("mcp"), {}, pathBearingTools),
|
|
251
|
+
).toBeUndefined();
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
test("returns undefined for mcp source", () => {
|
|
255
|
+
const f = makeFormatter();
|
|
256
|
+
const result = makeResult("some-server:some-tool", { source: "mcp" });
|
|
257
|
+
expect(
|
|
258
|
+
f.getToolInputPreviewForLog(result, {}, pathBearingTools),
|
|
259
|
+
).toBeUndefined();
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
test("returns path-based preview for path-bearing tools", () => {
|
|
263
|
+
const f = makeFormatter();
|
|
264
|
+
const preview = f.getToolInputPreviewForLog(
|
|
265
|
+
makeResult("read"),
|
|
266
|
+
{ path: "/src/foo.ts" },
|
|
267
|
+
pathBearingTools,
|
|
268
|
+
);
|
|
269
|
+
expect(preview).toContain("/src/foo.ts");
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
test("truncates path preview at toolInputLogPreviewMaxLength", () => {
|
|
273
|
+
const f = makeFormatter({ toolInputLogPreviewMaxLength: 15 });
|
|
274
|
+
const longPath = `/src/${"a".repeat(50)}.ts`;
|
|
275
|
+
const preview = f.getToolInputPreviewForLog(
|
|
276
|
+
makeResult("read"),
|
|
277
|
+
{ path: longPath },
|
|
278
|
+
pathBearingTools,
|
|
279
|
+
);
|
|
280
|
+
expect(preview).toBeDefined();
|
|
281
|
+
expect(preview!.length).toBeLessThanOrEqual(16); // 15 + "…"
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
test("returns generic JSON preview for non-path-bearing tools", () => {
|
|
285
|
+
mockedStringify.mockReturnValue('{"n":1}');
|
|
286
|
+
const f = makeFormatter();
|
|
287
|
+
const preview = f.getToolInputPreviewForLog(
|
|
288
|
+
makeResult("task"),
|
|
289
|
+
{ n: 1 },
|
|
290
|
+
pathBearingTools,
|
|
291
|
+
);
|
|
292
|
+
expect(preview).toContain('{"n":1}');
|
|
293
|
+
});
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
// ── getPermissionLogContext ───────────────────────────────────────────────
|
|
297
|
+
|
|
298
|
+
describe("ToolPreviewFormatter.getPermissionLogContext", () => {
|
|
299
|
+
const pathBearingTools = new Set(["read", "write", "edit"]);
|
|
300
|
+
|
|
301
|
+
test("returns command, target, toolInputPreview, and origin fields", () => {
|
|
302
|
+
const f = makeFormatter();
|
|
303
|
+
const result = makeResult("bash", { command: "ls -la" });
|
|
304
|
+
const ctx = f.getPermissionLogContext(result, {}, pathBearingTools);
|
|
305
|
+
expect(ctx.command).toBe("ls -la");
|
|
306
|
+
expect(ctx.target).toBeUndefined();
|
|
307
|
+
expect(ctx.toolInputPreview).toBeUndefined();
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
test("includes toolInputPreview for non-bash path-bearing tools", () => {
|
|
311
|
+
const f = makeFormatter();
|
|
312
|
+
const result = makeResult("read");
|
|
313
|
+
const ctx = f.getPermissionLogContext(
|
|
314
|
+
result,
|
|
315
|
+
{ path: "/foo.ts" },
|
|
316
|
+
pathBearingTools,
|
|
317
|
+
);
|
|
318
|
+
expect(ctx.toolInputPreview).toContain("/foo.ts");
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
test("includes origin from check result", () => {
|
|
322
|
+
const f = makeFormatter();
|
|
323
|
+
const result = makeResult("read", { origin: "project" });
|
|
324
|
+
const ctx = f.getPermissionLogContext(result, {}, pathBearingTools);
|
|
325
|
+
expect(ctx.origin).toBe("project");
|
|
326
|
+
});
|
|
327
|
+
|
|
328
|
+
test("toolInputPreview respects toolInputLogPreviewMaxLength", () => {
|
|
329
|
+
const f = makeFormatter({ toolInputLogPreviewMaxLength: 15 });
|
|
330
|
+
const longPath = `/src/${"a".repeat(50)}.ts`;
|
|
331
|
+
const ctx = f.getPermissionLogContext(
|
|
332
|
+
makeResult("read"),
|
|
333
|
+
{ path: longPath },
|
|
334
|
+
pathBearingTools,
|
|
335
|
+
);
|
|
336
|
+
expect(ctx.toolInputPreview).toBeDefined();
|
|
337
|
+
expect(ctx.toolInputPreview!.length).toBeLessThanOrEqual(16);
|
|
338
|
+
});
|
|
339
|
+
});
|
|
340
|
+
|
|
341
|
+
// ── resolveToolPreviewLimits ───────────────────────────────────────────────
|
|
342
|
+
|
|
343
|
+
describe("resolveToolPreviewLimits", () => {
|
|
344
|
+
test("uses configured toolInputPreviewMaxLength when provided", () => {
|
|
345
|
+
const opts = resolveToolPreviewLimits({ toolInputPreviewMaxLength: 400 });
|
|
346
|
+
expect(opts.toolInputPreviewMaxLength).toBe(400);
|
|
347
|
+
});
|
|
348
|
+
|
|
349
|
+
test("falls back to TOOL_INPUT_PREVIEW_MAX_LENGTH when toolInputPreviewMaxLength is absent", () => {
|
|
350
|
+
const opts = resolveToolPreviewLimits({});
|
|
351
|
+
expect(opts.toolInputPreviewMaxLength).toBe(TOOL_INPUT_PREVIEW_MAX_LENGTH);
|
|
352
|
+
});
|
|
353
|
+
|
|
354
|
+
test("uses configured toolTextSummaryMaxLength when provided", () => {
|
|
355
|
+
const opts = resolveToolPreviewLimits({ toolTextSummaryMaxLength: 120 });
|
|
356
|
+
expect(opts.toolTextSummaryMaxLength).toBe(120);
|
|
357
|
+
});
|
|
358
|
+
|
|
359
|
+
test("falls back to TOOL_TEXT_SUMMARY_MAX_LENGTH when toolTextSummaryMaxLength is absent", () => {
|
|
360
|
+
const opts = resolveToolPreviewLimits({});
|
|
361
|
+
expect(opts.toolTextSummaryMaxLength).toBe(TOOL_TEXT_SUMMARY_MAX_LENGTH);
|
|
362
|
+
});
|
|
363
|
+
|
|
364
|
+
test("always sets toolInputLogPreviewMaxLength to TOOL_INPUT_LOG_PREVIEW_MAX_LENGTH", () => {
|
|
365
|
+
const opts = resolveToolPreviewLimits({
|
|
366
|
+
toolInputPreviewMaxLength: 999,
|
|
367
|
+
toolTextSummaryMaxLength: 999,
|
|
368
|
+
});
|
|
369
|
+
expect(opts.toolInputLogPreviewMaxLength).toBe(
|
|
370
|
+
TOOL_INPUT_LOG_PREVIEW_MAX_LENGTH,
|
|
371
|
+
);
|
|
372
|
+
});
|
|
373
|
+
|
|
374
|
+
test("returns all three options when both fields are configured", () => {
|
|
375
|
+
const opts = resolveToolPreviewLimits({
|
|
376
|
+
toolInputPreviewMaxLength: 400,
|
|
377
|
+
toolTextSummaryMaxLength: 120,
|
|
378
|
+
});
|
|
379
|
+
expect(opts).toEqual({
|
|
380
|
+
toolInputPreviewMaxLength: 400,
|
|
381
|
+
toolTextSummaryMaxLength: 120,
|
|
382
|
+
toolInputLogPreviewMaxLength: TOOL_INPUT_LOG_PREVIEW_MAX_LENGTH,
|
|
383
|
+
});
|
|
384
|
+
});
|
|
385
|
+
});
|