llm-testrunner-components 1.2.4 → 1.3.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.
Files changed (78) hide show
  1. package/README.md +9 -5
  2. package/dist/cjs/app-chips_5.cjs.entry.js +1 -1
  3. package/dist/cjs/app-chips_5.cjs.entry.js.map +1 -1
  4. package/dist/cjs/index.cjs.js +464 -66
  5. package/dist/cjs/index.cjs.js.map +1 -1
  6. package/dist/cjs/llm-testrunner.cjs.js +1 -1
  7. package/dist/cjs/loader.cjs.js +1 -1
  8. package/dist/collection/components/llm-test-runner/llm-test-runner.js +46 -13
  9. package/dist/collection/components/llm-test-runner/llm-test-runner.js.map +1 -1
  10. package/dist/collection/components/llm-test-runner/test-cases/chat-history.css +5 -5
  11. package/dist/collection/components/llm-test-runner/test-cases/expected-outcome-renderer.js +45 -5
  12. package/dist/collection/components/llm-test-runner/test-cases/expected-outcome-renderer.js.map +1 -1
  13. package/dist/collection/components/llm-test-runner/test-cases/llm-test-case-row.css +21 -0
  14. package/dist/collection/components/llm-test-runner/test-cases/llm-test-case-row.js +2 -2
  15. package/dist/collection/components/llm-test-runner/test-cases/llm-test-case-row.js.map +1 -1
  16. package/dist/collection/components/llm-test-runner/test-cases/llm-test-cases.js +2 -2
  17. package/dist/collection/components/llm-test-runner/test-cases/llm-test-cases.js.map +1 -1
  18. package/dist/collection/components/llm-test-runner/test-cases/output/response-output.js +1 -1
  19. package/dist/collection/components/llm-test-runner/test-cases/output/response-output.js.map +1 -1
  20. package/dist/collection/lib/evaluation/actual-value-resolver.js +52 -0
  21. package/dist/collection/lib/evaluation/actual-value-resolver.js.map +1 -0
  22. package/dist/collection/lib/evaluation/evaluation-engine.js +1 -1
  23. package/dist/collection/lib/evaluation/evaluation-engine.js.map +1 -1
  24. package/dist/collection/lib/evaluation/evaluation-service.js +55 -17
  25. package/dist/collection/lib/evaluation/evaluation-service.js.map +1 -1
  26. package/dist/collection/lib/evaluation/types.js.map +1 -1
  27. package/dist/collection/lib/import-export/test-suite-importer.js +7 -1
  28. package/dist/collection/lib/import-export/test-suite-importer.js.map +1 -1
  29. package/dist/collection/lib/test-cases/test-case-factory.js +5 -0
  30. package/dist/collection/lib/test-cases/test-case-factory.js.map +1 -1
  31. package/dist/collection/lib/test-cases/test-case-mutations.js +58 -23
  32. package/dist/collection/lib/test-cases/test-case-mutations.js.map +1 -1
  33. package/dist/collection/schemas/expected-outcome.js +39 -0
  34. package/dist/collection/schemas/expected-outcome.js.map +1 -1
  35. package/dist/collection/schemas/model-response.js +7 -0
  36. package/dist/collection/schemas/model-response.js.map +1 -0
  37. package/dist/collection/schemas/test-case.js +2 -1
  38. package/dist/collection/schemas/test-case.js.map +1 -1
  39. package/dist/collection/types/expected-outcome.js.map +1 -1
  40. package/dist/collection/types/llm-test-runner.js.map +1 -1
  41. package/dist/components/chat-history.js +1 -1
  42. package/dist/components/index.js +1 -1
  43. package/dist/components/llm-test-runner.js +1 -1
  44. package/dist/components/p-kmtfMXcQ.js +2 -0
  45. package/dist/components/p-kmtfMXcQ.js.map +1 -0
  46. package/dist/components/{p-B87Lt3z4.js → p-wzA48RFK.js} +3 -3
  47. package/dist/components/p-wzA48RFK.js.map +1 -0
  48. package/dist/esm/app-chips_5.entry.js +1 -1
  49. package/dist/esm/app-chips_5.entry.js.map +1 -1
  50. package/dist/esm/index.js +464 -66
  51. package/dist/esm/index.js.map +1 -1
  52. package/dist/esm/llm-testrunner.js +1 -1
  53. package/dist/esm/loader.js +1 -1
  54. package/dist/llm-testrunner/index.esm.js +2 -2
  55. package/dist/llm-testrunner/index.esm.js.map +1 -1
  56. package/dist/llm-testrunner/llm-testrunner.esm.js +1 -1
  57. package/dist/llm-testrunner/{p-21202f12.entry.js → p-5bf1fc78.entry.js} +2 -2
  58. package/dist/llm-testrunner/{p-21202f12.entry.js.map → p-5bf1fc78.entry.js.map} +1 -1
  59. package/dist/types/components/llm-test-runner/llm-test-runner.d.ts +3 -4
  60. package/dist/types/components/llm-test-runner/test-cases/expected-outcome-renderer.d.ts +1 -0
  61. package/dist/types/components/llm-test-runner/test-cases/llm-test-case-row.d.ts +1 -0
  62. package/dist/types/components/llm-test-runner/test-cases/llm-test-cases.d.ts +1 -0
  63. package/dist/types/components/llm-test-runner/test-cases/output/response-output.d.ts +2 -1
  64. package/dist/types/components.d.ts +4 -2
  65. package/dist/types/lib/evaluation/actual-value-resolver.d.ts +9 -0
  66. package/dist/types/lib/evaluation/evaluation-service.d.ts +2 -2
  67. package/dist/types/lib/evaluation/types.d.ts +1 -1
  68. package/dist/types/lib/import-export/test-suite-importer.d.ts +1 -1
  69. package/dist/types/lib/test-cases/test-case-mutations.d.ts +10 -1
  70. package/dist/types/schemas/expected-outcome.d.ts +116 -0
  71. package/dist/types/schemas/model-response.d.ts +7 -0
  72. package/dist/types/schemas/test-case.d.ts +76 -1
  73. package/dist/types/types/expected-outcome.d.ts +1 -1
  74. package/dist/types/types/llm-test-runner.d.ts +4 -2
  75. package/package.json +1 -1
  76. package/dist/components/p-B87Lt3z4.js.map +0 -1
  77. package/dist/components/p-Bx2jqguC.js +0 -2
  78. package/dist/components/p-Bx2jqguC.js.map +0 -1
@@ -6,6 +6,19 @@ const optionalPositiveInt = z.number().int().positive().optional();
6
6
  const optionalString = z.string().optional();
7
7
  const selectOptionsSchema = z.array(nonEmptyString).min(1);
8
8
  const optionalNumber = z.number().optional();
9
+ const textEvaluationSourceSchema = z.object({
10
+ type: z.literal('text'),
11
+ });
12
+ const customEvaluationSourceSchema = z.object({
13
+ type: z.literal('custom'),
14
+ extractorId: nonEmptyString,
15
+ });
16
+ export const evaluationSourceExtractorSchema = z.custom(value => typeof value === 'function', 'Extractor must be a function.');
17
+ export const evaluationSourceExtractorsSchema = z.record(z.string().min(1), evaluationSourceExtractorSchema);
18
+ export const evaluationSourceSchema = z.discriminatedUnion('type', [
19
+ textEvaluationSourceSchema,
20
+ customEvaluationSourceSchema,
21
+ ]);
9
22
  export const expectedOutcomeModeSchema = z.enum(['static', 'dynamic']);
10
23
  const evaluationParametersSchema = z.object({
11
24
  approach: z.enum(EvaluationApproach),
@@ -23,6 +36,7 @@ const selectEvaluationParametersSchema = evaluationParametersSchema.superRefine(
23
36
  const defaultExpectedOutcomeBaseSchema = z.object({
24
37
  label: nonEmptyString,
25
38
  placeholder: optionalString,
39
+ evaluationSource: evaluationSourceSchema.optional(),
26
40
  });
27
41
  const createDefaultExpectedOutcomeFieldSchemas = (baseSchema) => ({
28
42
  text: baseSchema.extend({
@@ -122,4 +136,29 @@ export function validateExpectedOutcomeArray(expectedOutcome) {
122
136
  throw new Error(`Invalid expectedOutcome: ${parsed.error.issues[0].message}`);
123
137
  }
124
138
  }
139
+ export function validateExpectedOutcomeArrayWithExtractors(expectedOutcome, allowedExtractorIds) {
140
+ const allowed = new Set(allowedExtractorIds);
141
+ const schema = expectedOutcomeArraySchema.superRefine((fields, ctx) => {
142
+ fields.forEach((field, index) => {
143
+ if (field.evaluationSource?.type !== 'custom') {
144
+ return;
145
+ }
146
+ if (allowed.has(field.evaluationSource.extractorId)) {
147
+ return;
148
+ }
149
+ ctx.addIssue({
150
+ code: 'custom',
151
+ path: [index, 'evaluationSource', 'extractorId'],
152
+ message: `Invalid expectedOutcome: Extractor "${field.evaluationSource.extractorId}" is not registered.`,
153
+ });
154
+ });
155
+ });
156
+ const parsed = schema.safeParse(expectedOutcome);
157
+ if (!parsed.success) {
158
+ throw new Error(parsed.error.issues[0].message);
159
+ }
160
+ }
161
+ export function getExtractorIds(extractors) {
162
+ return Object.keys(extractors || {});
163
+ }
125
164
  //# sourceMappingURL=expected-outcome.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"expected-outcome.js","sourceRoot":"","sources":["../../src/schemas/expected-outcome.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAE,6BAA6B,EAAE,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,KAAK,CAAC,4BAA4B,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;IAChF,CAAC;AACH,CAAC","sourcesContent":["import { z } from 'zod';\nimport { EvaluationApproach } from '../lib/evaluation/constants';\nimport { isApproachAllowedForFieldType } from '../lib/evaluation/field-evaluation-approach';\n\nconst nonEmptyString = z.string().trim().min(1);\nconst optionalPositiveInt = z.number().int().positive().optional();\nconst optionalString = z.string().optional();\nconst selectOptionsSchema = z.array(nonEmptyString).min(1);\nconst optionalNumber = z.number().optional();\n\nexport const expectedOutcomeModeSchema = z.enum(['static', 'dynamic']);\nexport type ExpectedOutcomeMode = z.infer<typeof expectedOutcomeModeSchema>;\n\nconst evaluationParametersSchema = z.object({\n approach: z.enum(EvaluationApproach),\n threshold: optionalNumber,\n});\n\nconst selectEvaluationParametersSchema = evaluationParametersSchema.superRefine(\n (parameters, ctx) => {\n if (!isApproachAllowedForFieldType('select', parameters.approach)) {\n ctx.addIssue({\n code: 'custom',\n path: ['approach'],\n message: `select fields only support \"${EvaluationApproach.EXACT}\" evaluation approach.`,\n });\n }\n },\n);\n\nconst defaultExpectedOutcomeBaseSchema = z.object({\n label: nonEmptyString,\n placeholder: optionalString,\n});\n\nconst createDefaultExpectedOutcomeFieldSchemas = (\n baseSchema: typeof defaultExpectedOutcomeBaseSchema,\n) => ({\n text: baseSchema.extend({\n type: z.literal('text'),\n evaluationParameters: evaluationParametersSchema.optional(),\n }),\n textarea: baseSchema.extend({\n type: z.literal('textarea'),\n rows: optionalPositiveInt,\n evaluationParameters: evaluationParametersSchema.optional(),\n }),\n chipsInput: baseSchema.extend({\n type: z.literal('chips-input'),\n evaluationParameters: evaluationParametersSchema.optional(),\n }),\n select: baseSchema.extend({\n type: z.literal('select'),\n options: selectOptionsSchema,\n evaluationParameters: selectEvaluationParametersSchema.optional(),\n }),\n});\n\nfunction hasDuplicateChips(values: string[]): boolean {\n const seen = new Set<string>();\n for (const value of values) {\n const normalized = value.trim().toLowerCase();\n if (seen.has(normalized)) {\n return true;\n }\n seen.add(normalized);\n }\n return false;\n}\n\nconst defaultFieldDefinitions =\n createDefaultExpectedOutcomeFieldSchemas(defaultExpectedOutcomeBaseSchema);\n\nexport const expectedOutcomeSchemaFieldSchema = z.discriminatedUnion('type', [\n defaultFieldDefinitions.text,\n defaultFieldDefinitions.textarea,\n defaultFieldDefinitions.chipsInput,\n defaultFieldDefinitions.select,\n]);\n\nexport const expectedOutcomeSchemaSchema = z\n .array(expectedOutcomeSchemaFieldSchema)\n .min(1);\n\nexport const expectedOutcomeFieldSchema = z.discriminatedUnion('type', [\n defaultFieldDefinitions.text.extend({\n value: z.string(),\n }),\n defaultFieldDefinitions.textarea\n .extend({\n value: z.string(),\n outcomeMode: expectedOutcomeModeSchema.default('static'),\n resolutionQuery: z.string().optional(),\n })\n .superRefine((field, ctx) => {\n if (\n field.outcomeMode === 'dynamic' &&\n (!field.resolutionQuery || field.resolutionQuery.trim().length === 0)\n ) {\n ctx.addIssue({\n code: 'custom',\n path: ['resolutionQuery'],\n message: 'resolutionQuery is required when outcomeMode is dynamic.',\n });\n }\n }),\n defaultFieldDefinitions.chipsInput.extend({\n value: z.array(z.string()).superRefine((values, ctx) => {\n if (hasDuplicateChips(values)) {\n ctx.addIssue({\n code: 'custom',\n message:\n 'chips-input values must be unique (case-insensitive, trimmed).',\n });\n }\n }),\n }),\n defaultFieldDefinitions.select\n .extend({\n value: z.string(),\n })\n .superRefine((field, ctx) => {\n if (!field.options.includes(field.value)) {\n ctx.addIssue({\n code: 'custom',\n path: ['value'],\n message: 'select value must be one of the provided options.',\n });\n }\n }),\n]);\n\nexport const expectedOutcomeArraySchema = z.array(expectedOutcomeFieldSchema).min(1);\n\nexport type ExpectedOutcomeSchemaField = z.infer<\n typeof expectedOutcomeSchemaFieldSchema\n>;\nexport type ExpectedOutcomeSchema = z.infer<typeof expectedOutcomeSchemaSchema>;\nexport type ExpectedOutcomeField = z.input<typeof expectedOutcomeFieldSchema>;\nexport type ExpectedOutcomeFieldType = ExpectedOutcomeField['type'];\nexport type ExpectedOutcomeBase = z.infer<typeof defaultExpectedOutcomeBaseSchema>;\n\nexport type TextExpectedOutcomeSchemaField = Extract<\n ExpectedOutcomeSchemaField,\n { type: 'text' }\n>;\nexport type TextareaExpectedOutcomeSchemaField = Extract<\n ExpectedOutcomeSchemaField,\n { type: 'textarea' }\n>;\nexport type ChipsExpectedOutcomeSchemaField = Extract<\n ExpectedOutcomeSchemaField,\n { type: 'chips-input' }\n>;\nexport type SelectExpectedOutcomeSchemaField = Extract<\n ExpectedOutcomeSchemaField,\n { type: 'select' }\n>;\n\nexport type TextExpectedOutcomeField = Extract<\n ExpectedOutcomeField,\n { type: 'text' }\n>;\nexport type TextareaExpectedOutcomeField = Extract<\n ExpectedOutcomeField,\n { type: 'textarea' }\n>;\nexport type ChipsExpectedOutcomeField = Extract<\n ExpectedOutcomeField,\n { type: 'chips-input' }\n>;\nexport type SelectExpectedOutcomeField = Extract<\n ExpectedOutcomeField,\n { type: 'select' }\n>;\n\nexport function validateExpectedOutcomeSchema(\n schema: unknown,\n): asserts schema is ExpectedOutcomeSchema {\n const parsed = expectedOutcomeSchemaSchema.safeParse(schema);\n if (!parsed.success) {\n throw new Error(\n `Invalid expectedOutcomeSchema: ${parsed.error.issues[0].message}`,\n );\n }\n}\n\nexport function validateExpectedOutcomeArray(\n expectedOutcome: unknown,\n): asserts expectedOutcome is ExpectedOutcomeField[] {\n const parsed = expectedOutcomeArraySchema.safeParse(expectedOutcome);\n if (!parsed.success) {\n throw new Error(`Invalid expectedOutcome: ${parsed.error.issues[0].message}`);\n }\n}\n"]}
1
+ {"version":3,"file":"expected-outcome.js","sourceRoot":"","sources":["../../src/schemas/expected-outcome.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,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,CAAC;YAED,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,gBAAgB,CAAC,WAAW,CAAC,EAAE,CAAC;gBACpD,OAAO;YACT,CAAC;YAED,GAAG,CAAC,QAAQ,CAAC;gBACX,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,CAAC,KAAK,EAAE,kBAAkB,EAAE,aAAa,CAAC;gBAChD,OAAO,EAAE,uCAAuC,KAAK,CAAC,gBAAgB,CAAC,WAAW,sBAAsB;aACzG,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC;IACjD,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;IAClD,CAAC;AACH,CAAC;AAED,MAAM,UAAU,eAAe,CAC7B,UAAuC;IAEvC,OAAO,MAAM,CAAC,IAAI,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC;AACvC,CAAC","sourcesContent":["import { z } from 'zod';\nimport { EvaluationApproach } from '../lib/evaluation/constants';\nimport { isApproachAllowedForFieldType } from '../lib/evaluation/field-evaluation-approach';\nimport type { ModelResponsePayload } from './model-response';\n\nconst nonEmptyString = z.string().trim().min(1);\nconst optionalPositiveInt = z.number().int().positive().optional();\nconst optionalString = z.string().optional();\nconst selectOptionsSchema = z.array(nonEmptyString).min(1);\nconst optionalNumber = z.number().optional();\nconst textEvaluationSourceSchema = z.object({\n type: z.literal('text'),\n});\nconst customEvaluationSourceSchema = z.object({\n type: z.literal('custom'),\n extractorId: nonEmptyString,\n});\n\nexport const evaluationSourceExtractorSchema = z.custom<\n (payload: ModelResponsePayload) => string | Promise<string>\n>(\n value => typeof value === 'function',\n 'Extractor must be a function.',\n);\n\nexport const evaluationSourceExtractorsSchema = z.record(\n z.string().min(1),\n evaluationSourceExtractorSchema,\n);\n\nexport const evaluationSourceSchema = z.discriminatedUnion('type', [\n textEvaluationSourceSchema,\n customEvaluationSourceSchema,\n]);\n\nexport const expectedOutcomeModeSchema = z.enum(['static', 'dynamic']);\nexport type ExpectedOutcomeMode = z.infer<typeof expectedOutcomeModeSchema>;\nexport type EvaluationSource = z.infer<typeof evaluationSourceSchema>;\nexport type EvaluationSourceExtractor = z.infer<\n typeof evaluationSourceExtractorSchema\n>;\nexport type EvaluationSourceExtractors = z.infer<\n typeof evaluationSourceExtractorsSchema\n>;\n\nconst evaluationParametersSchema = z.object({\n approach: z.enum(EvaluationApproach),\n threshold: optionalNumber,\n});\n\nconst selectEvaluationParametersSchema = evaluationParametersSchema.superRefine(\n (parameters, ctx) => {\n if (!isApproachAllowedForFieldType('select', parameters.approach)) {\n ctx.addIssue({\n code: 'custom',\n path: ['approach'],\n message: `select fields only support \"${EvaluationApproach.EXACT}\" evaluation approach.`,\n });\n }\n },\n);\n\nconst defaultExpectedOutcomeBaseSchema = z.object({\n label: nonEmptyString,\n placeholder: optionalString,\n evaluationSource: evaluationSourceSchema.optional(),\n});\n\nconst createDefaultExpectedOutcomeFieldSchemas = (\n baseSchema: typeof defaultExpectedOutcomeBaseSchema,\n) => ({\n text: baseSchema.extend({\n type: z.literal('text'),\n evaluationParameters: evaluationParametersSchema.optional(),\n }),\n textarea: baseSchema.extend({\n type: z.literal('textarea'),\n rows: optionalPositiveInt,\n evaluationParameters: evaluationParametersSchema.optional(),\n }),\n chipsInput: baseSchema.extend({\n type: z.literal('chips-input'),\n evaluationParameters: evaluationParametersSchema.optional(),\n }),\n select: baseSchema.extend({\n type: z.literal('select'),\n options: selectOptionsSchema,\n evaluationParameters: selectEvaluationParametersSchema.optional(),\n }),\n});\n\nfunction hasDuplicateChips(values: string[]): boolean {\n const seen = new Set<string>();\n for (const value of values) {\n const normalized = value.trim().toLowerCase();\n if (seen.has(normalized)) {\n return true;\n }\n seen.add(normalized);\n }\n return false;\n}\n\nconst defaultFieldDefinitions =\n createDefaultExpectedOutcomeFieldSchemas(defaultExpectedOutcomeBaseSchema);\n\nexport const expectedOutcomeSchemaFieldSchema = z.discriminatedUnion('type', [\n defaultFieldDefinitions.text,\n defaultFieldDefinitions.textarea,\n defaultFieldDefinitions.chipsInput,\n defaultFieldDefinitions.select,\n]);\n\nexport const expectedOutcomeSchemaSchema = z\n .array(expectedOutcomeSchemaFieldSchema)\n .min(1);\n\nexport const expectedOutcomeFieldSchema = z.discriminatedUnion('type', [\n defaultFieldDefinitions.text.extend({\n value: z.string(),\n }),\n defaultFieldDefinitions.textarea\n .extend({\n value: z.string(),\n outcomeMode: expectedOutcomeModeSchema.default('static'),\n resolutionQuery: z.string().optional(),\n })\n .superRefine((field, ctx) => {\n if (\n field.outcomeMode === 'dynamic' &&\n (!field.resolutionQuery || field.resolutionQuery.trim().length === 0)\n ) {\n ctx.addIssue({\n code: 'custom',\n path: ['resolutionQuery'],\n message: 'resolutionQuery is required when outcomeMode is dynamic.',\n });\n }\n }),\n defaultFieldDefinitions.chipsInput.extend({\n value: z.array(z.string()).superRefine((values, ctx) => {\n if (hasDuplicateChips(values)) {\n ctx.addIssue({\n code: 'custom',\n message:\n 'chips-input values must be unique (case-insensitive, trimmed).',\n });\n }\n }),\n }),\n defaultFieldDefinitions.select\n .extend({\n value: z.string(),\n })\n .superRefine((field, ctx) => {\n if (!field.options.includes(field.value)) {\n ctx.addIssue({\n code: 'custom',\n path: ['value'],\n message: 'select value must be one of the provided options.',\n });\n }\n }),\n]);\n\nexport const expectedOutcomeArraySchema = z.array(expectedOutcomeFieldSchema).min(1);\n\nexport type ExpectedOutcomeSchemaField = z.infer<\n typeof expectedOutcomeSchemaFieldSchema\n>;\nexport type ExpectedOutcomeSchema = z.infer<typeof expectedOutcomeSchemaSchema>;\nexport type ExpectedOutcomeField = z.input<typeof expectedOutcomeFieldSchema>;\nexport type ExpectedOutcomeFieldType = ExpectedOutcomeField['type'];\nexport type ExpectedOutcomeBase = z.infer<typeof defaultExpectedOutcomeBaseSchema>;\n\nexport type TextExpectedOutcomeSchemaField = Extract<\n ExpectedOutcomeSchemaField,\n { type: 'text' }\n>;\nexport type TextareaExpectedOutcomeSchemaField = Extract<\n ExpectedOutcomeSchemaField,\n { type: 'textarea' }\n>;\nexport type ChipsExpectedOutcomeSchemaField = Extract<\n ExpectedOutcomeSchemaField,\n { type: 'chips-input' }\n>;\nexport type SelectExpectedOutcomeSchemaField = Extract<\n ExpectedOutcomeSchemaField,\n { type: 'select' }\n>;\n\nexport type TextExpectedOutcomeField = Extract<\n ExpectedOutcomeField,\n { type: 'text' }\n>;\nexport type TextareaExpectedOutcomeField = Extract<\n ExpectedOutcomeField,\n { type: 'textarea' }\n>;\nexport type ChipsExpectedOutcomeField = Extract<\n ExpectedOutcomeField,\n { type: 'chips-input' }\n>;\nexport type SelectExpectedOutcomeField = Extract<\n ExpectedOutcomeField,\n { type: 'select' }\n>;\n\nexport function validateExpectedOutcomeSchema(\n schema: unknown,\n): asserts schema is ExpectedOutcomeSchema {\n const parsed = expectedOutcomeSchemaSchema.safeParse(schema);\n if (!parsed.success) {\n throw new Error(\n `Invalid expectedOutcomeSchema: ${parsed.error.issues[0].message}`,\n );\n }\n}\n\nexport function validateExpectedOutcomeArray(\n expectedOutcome: unknown,\n): asserts expectedOutcome is ExpectedOutcomeField[] {\n const parsed = expectedOutcomeArraySchema.safeParse(expectedOutcome);\n if (!parsed.success) {\n throw new Error(`Invalid expectedOutcome: ${parsed.error.issues[0].message}`);\n }\n}\n\nexport function validateExpectedOutcomeArrayWithExtractors(\n expectedOutcome: unknown,\n allowedExtractorIds: string[],\n): asserts expectedOutcome is ExpectedOutcomeField[] {\n const allowed = new Set(allowedExtractorIds);\n const schema = expectedOutcomeArraySchema.superRefine((fields, ctx) => {\n fields.forEach((field, index) => {\n if (field.evaluationSource?.type !== 'custom') {\n return;\n }\n\n if (allowed.has(field.evaluationSource.extractorId)) {\n return;\n }\n\n ctx.addIssue({\n code: 'custom',\n path: [index, 'evaluationSource', 'extractorId'],\n message: `Invalid expectedOutcome: Extractor \"${field.evaluationSource.extractorId}\" is not registered.`,\n });\n });\n });\n\n const parsed = schema.safeParse(expectedOutcome);\n if (!parsed.success) {\n throw new Error(parsed.error.issues[0].message);\n }\n}\n\nexport function getExtractorIds(\n extractors?: EvaluationSourceExtractors,\n): string[] {\n return Object.keys(extractors || {});\n}\n"]}
@@ -0,0 +1,7 @@
1
+ import { z } from "zod";
2
+ export const modelResponseMetadataSchema = z.record(z.string(), z.unknown());
3
+ export const modelResponsePayloadSchema = z.object({
4
+ text: z.string().optional(),
5
+ metadata: modelResponseMetadataSchema.optional(),
6
+ });
7
+ //# sourceMappingURL=model-response.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-response.js","sourceRoot":"","sources":["../../src/schemas/model-response.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;AAE7E,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,CAAC,MAAM,CAAC;IACjD,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC3B,QAAQ,EAAE,2BAA2B,CAAC,QAAQ,EAAE;CACjD,CAAC,CAAC","sourcesContent":["import { z } from 'zod';\n\nexport const modelResponseMetadataSchema = z.record(z.string(), z.unknown());\n\nexport const modelResponsePayloadSchema = z.object({\n text: z.string().optional(),\n metadata: modelResponseMetadataSchema.optional(),\n});\n\nexport type ModelResponsePayload = z.infer<typeof modelResponsePayloadSchema>;\n"]}
@@ -1,5 +1,6 @@
1
1
  import { z } from "zod";
2
2
  import { expectedOutcomeArraySchema } from "./expected-outcome";
3
+ import { modelResponsePayloadSchema } from "./model-response";
3
4
  export const testCaseChatHistorySchema = z.object({
4
5
  enabled: z.boolean(),
5
6
  value: z.string(),
@@ -15,8 +16,8 @@ export const testCaseSchema = z.object({
15
16
  id: z.string(),
16
17
  question: z.string(),
17
18
  expectedOutcome: expectedOutcomeArraySchema,
19
+ output: modelResponsePayloadSchema.optional(),
18
20
  chatHistory: testCaseChatHistorySchema,
19
- output: z.string().optional(),
20
21
  isRunning: z.boolean().optional(),
21
22
  error: z.string().optional(),
22
23
  evaluationResult: z.custom().optional(),
@@ -1 +1 @@
1
- {"version":3,"file":"test-case.js","sourceRoot":"","sources":["../../src/schemas/test-case.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAEhE,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,CAAC,MAAM,CAAC;IAChD,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE;IACpB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;CAClB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1C,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE;IACd,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE;IACpB,eAAe,EAAE,0BAA0B;IAC3C,WAAW,EAAE,yBAAyB,CAAC,QAAQ,EAAE;CAClD,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC;AAErE,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC;IACrC,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE;IACd,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE;IACpB,eAAe,EAAE,0BAA0B;IAC3C,WAAW,EAAE,yBAAyB;IACtC,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC7B,SAAS,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IACjC,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC5B,gBAAgB,EAAE,CAAC,CAAC,MAAM,EAAoB,CAAC,QAAQ,EAAE;IACzD,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CACpC,CAAC,CAAC;AAMH,MAAM,UAAU,qBAAqB,CACnC,IAAa;IAEb,MAAM,MAAM,GAAG,mBAAmB,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IACnD,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CAAC,4BAA4B,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;IAChF,CAAC;AACH,CAAC;AAED,MAAM,UAAU,0BAA0B,CACxC,IAAa;IAEb,MAAM,MAAM,GAAG,wBAAwB,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IACxD,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACpB,MAAM,UAAU,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QAC1C,MAAM,OAAO,GACX,UAAU,CAAC,IAAI,KAAK,cAAc;YAChC,CAAC,CAAC,gDAAgD;YAClD,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC;QACzB,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;IAC3B,CAAC;AACH,CAAC","sourcesContent":["import { z } from 'zod';\nimport type { EvaluationResult } from '../lib/evaluation/types';\nimport { expectedOutcomeArraySchema } from './expected-outcome';\n\nexport const testCaseChatHistorySchema = z.object({\n enabled: z.boolean(),\n value: z.string(),\n});\n\nexport const testCaseInputSchema = z.object({\n id: z.string(),\n question: z.string(),\n expectedOutcome: expectedOutcomeArraySchema,\n chatHistory: testCaseChatHistorySchema.optional(),\n});\n\nexport const testCaseInputArraySchema = z.array(testCaseInputSchema);\n\nexport const testCaseSchema = z.object({\n id: z.string(),\n question: z.string(),\n expectedOutcome: expectedOutcomeArraySchema,\n chatHistory: testCaseChatHistorySchema,\n output: z.string().optional(),\n isRunning: z.boolean().optional(),\n error: z.string().optional(),\n evaluationResult: z.custom<EvaluationResult>().optional(),\n responseTime: z.number().optional(),\n});\n\nexport type TestCaseChatHistory = z.infer<typeof testCaseChatHistorySchema>;\nexport type TestCaseInput = z.input<typeof testCaseInputSchema>;\nexport type TestCase = z.input<typeof testCaseSchema>;\n\nexport function validateTestCaseInput(\n data: unknown,\n): asserts data is TestCaseInput {\n const parsed = testCaseInputSchema.safeParse(data);\n if (!parsed.success) {\n throw new Error(`Invalid test case input: ${parsed.error.issues[0].message}`);\n }\n}\n\nexport function validateTestCaseInputArray(\n data: unknown,\n): asserts data is TestCaseInput[] {\n const parsed = testCaseInputArraySchema.safeParse(data);\n if (!parsed.success) {\n const firstIssue = parsed.error.issues[0];\n const message =\n firstIssue.code === 'invalid_type'\n ? 'Invalid JSON structure. Expected a JSON array.'\n : firstIssue.message;\n throw new Error(message);\n }\n}\n"]}
1
+ {"version":3,"file":"test-case.js","sourceRoot":"","sources":["../../src/schemas/test-case.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAC;AAE9D,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,CAAC,MAAM,CAAC;IAChD,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE;IACpB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;CAClB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1C,EAAE,EAAE,CAAC,CA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AAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QAC1C,MAAM,OAAO,GACX,UAAU,CAAC,IAAI,KAAK,cAAc;YAChC,CAAC,CAAC,gDAAgD;YAClD,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC;QACzB,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;IAC3B,CAAC;AACH,CAAC","sourcesContent":["import { z } from 'zod';\nimport type { EvaluationResult } from '../lib/evaluation/types';\nimport { expectedOutcomeArraySchema } from './expected-outcome';\nimport { modelResponsePayloadSchema } from './model-response';\n\nexport const testCaseChatHistorySchema = z.object({\n enabled: z.boolean(),\n value: z.string(),\n});\n\nexport const testCaseInputSchema = z.object({\n id: z.string(),\n question: z.string(),\n expectedOutcome: expectedOutcomeArraySchema,\n chatHistory: testCaseChatHistorySchema.optional(),\n});\n\nexport const testCaseInputArraySchema = z.array(testCaseInputSchema);\n\nexport const testCaseSchema = z.object({\n id: z.string(),\n question: z.string(),\n expectedOutcome: expectedOutcomeArraySchema,\n output: modelResponsePayloadSchema.optional(),\n chatHistory: testCaseChatHistorySchema,\n isRunning: z.boolean().optional(),\n error: z.string().optional(),\n evaluationResult: z.custom<EvaluationResult>().optional(),\n responseTime: z.number().optional(),\n});\n\nexport type TestCaseChatHistory = z.infer<typeof testCaseChatHistorySchema>;\nexport type TestCaseInput = z.input<typeof testCaseInputSchema>;\nexport type TestCase = z.input<typeof testCaseSchema>;\n\nexport function validateTestCaseInput(\n data: unknown,\n): asserts data is TestCaseInput {\n const parsed = testCaseInputSchema.safeParse(data);\n if (!parsed.success) {\n throw new Error(`Invalid test case input: ${parsed.error.issues[0].message}`);\n }\n}\n\nexport function validateTestCaseInputArray(\n data: unknown,\n): asserts data is TestCaseInput[] {\n const parsed = testCaseInputArraySchema.safeParse(data);\n if (!parsed.success) {\n const firstIssue = parsed.error.issues[0];\n const message =\n firstIssue.code === 'invalid_type'\n ? 'Invalid JSON structure. Expected a JSON array.'\n : firstIssue.message;\n throw new Error(message);\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"expected-outcome.js","sourceRoot":"","sources":["../../src/types/expected-outcome.ts"],"names":[],"mappings":"","sourcesContent":["export type {\n ExpectedOutcomeMode,\n ExpectedOutcomeSchemaField,\n ExpectedOutcomeSchema,\n ExpectedOutcomeField,\n ExpectedOutcomeFieldType,\n ExpectedOutcomeBase,\n TextExpectedOutcomeSchemaField,\n TextareaExpectedOutcomeSchemaField,\n ChipsExpectedOutcomeSchemaField,\n SelectExpectedOutcomeSchemaField,\n TextExpectedOutcomeField,\n TextareaExpectedOutcomeField,\n ChipsExpectedOutcomeField,\n SelectExpectedOutcomeField,\n} from '../schemas/expected-outcome';\n"]}
1
+ {"version":3,"file":"expected-outcome.js","sourceRoot":"","sources":["../../src/types/expected-outcome.ts"],"names":[],"mappings":"","sourcesContent":["export type {\n EvaluationSource,\n EvaluationSourceExtractor,\n EvaluationSourceExtractors,\n ExpectedOutcomeMode,\n ExpectedOutcomeSchemaField,\n ExpectedOutcomeSchema,\n ExpectedOutcomeField,\n ExpectedOutcomeFieldType,\n ExpectedOutcomeBase,\n TextExpectedOutcomeSchemaField,\n TextareaExpectedOutcomeSchemaField,\n ChipsExpectedOutcomeSchemaField,\n SelectExpectedOutcomeSchemaField,\n TextExpectedOutcomeField,\n TextareaExpectedOutcomeField,\n ChipsExpectedOutcomeField,\n SelectExpectedOutcomeField,\n} from '../schemas/expected-outcome';\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"llm-test-runner.js","sourceRoot":"","sources":["../../src/types/llm-test-runner.ts"],"names":[],"mappings":"","sourcesContent":["import type { TestCase } from './test-case';\n\nexport type {\n ExpectedOutcomeMode,\n ExpectedOutcomeFieldType,\n ExpectedOutcomeBase,\n ExpectedOutcomeSchema,\n ExpectedOutcomeSchemaField,\n ExpectedOutcomeField,\n TextExpectedOutcomeSchemaField,\n TextareaExpectedOutcomeSchemaField,\n ChipsExpectedOutcomeSchemaField,\n SelectExpectedOutcomeSchemaField,\n TextExpectedOutcomeField,\n TextareaExpectedOutcomeField,\n ChipsExpectedOutcomeField,\n SelectExpectedOutcomeField,\n} from './expected-outcome';\nexport type {\n TestCaseChatHistory,\n TestCase,\n TestCaseInput,\n} from './test-case';\n\nexport interface LLMRequestPayload {\n prompt: string;\n chatHistory?: string;\n resolve: (result: string) => void;\n reject: (err: Error | unknown) => void;\n}\n\nexport interface SavePayload {\n timestamp: string;\n testCases: TestCase[];\n}\n"]}
1
+ {"version":3,"file":"llm-test-runner.js","sourceRoot":"","sources":["../../src/types/llm-test-runner.ts"],"names":[],"mappings":"","sourcesContent":["import type { TestCase } from './test-case';\nimport type { ModelResponsePayload } from '../schemas/model-response';\n\nexport type {\n EvaluationSource,\n EvaluationSourceExtractor,\n EvaluationSourceExtractors,\n ExpectedOutcomeMode,\n ExpectedOutcomeFieldType,\n ExpectedOutcomeBase,\n ExpectedOutcomeSchema,\n ExpectedOutcomeSchemaField,\n ExpectedOutcomeField,\n TextExpectedOutcomeSchemaField,\n TextareaExpectedOutcomeSchemaField,\n ChipsExpectedOutcomeSchemaField,\n SelectExpectedOutcomeSchemaField,\n TextExpectedOutcomeField,\n TextareaExpectedOutcomeField,\n ChipsExpectedOutcomeField,\n SelectExpectedOutcomeField,\n} from './expected-outcome';\nexport type {\n ModelResponsePayload,\n} from '../schemas/model-response';\nexport type {\n TestCaseChatHistory,\n TestCase,\n TestCaseInput,\n} from './test-case';\n\nexport interface LLMRequestPayload {\n prompt: string;\n resolve: (result: ModelResponsePayload) => void;\n chatHistory?: string;\n reject: (err: Error | unknown) => void;\n}\n\nexport interface SavePayload {\n timestamp: string;\n testCases: TestCase[];\n}\n"]}
@@ -1,2 +1,2 @@
1
- import{C as o,d as s}from"./p-Bx2jqguC.js";const t=o;const p=s;export{t as ChatHistory,p as defineCustomElement};
1
+ import{C as o,d as s}from"./p-kmtfMXcQ.js";const t=o;const c=s;export{t as ChatHistory,c as defineCustomElement};
2
2
  //# sourceMappingURL=chat-history.js.map
@@ -1,2 +1,2 @@
1
- import{G as t}from"./p-D9BrlHdP.js";export{g as getAssetPath,r as render,s as setAssetPath,a as setNonce,b as setPlatformOptions}from"./p-D9BrlHdP.js";export{L as LLMTestRunner}from"./p-B87Lt3z4.js";class e{sdk;constructor(s){this.sdk=new t({apiKey:s})}async invoke(s){const t=await this.sdk.models.generateContent({model:"gemini-3-flash-preview",contents:s});return t.text}}function n(){window.env={API_KEY:""};window.GeminiAdapter=e}const o=n||(()=>{});const i=o;i();
1
+ import{G as t}from"./p-D9BrlHdP.js";export{g as getAssetPath,r as render,s as setAssetPath,a as setNonce,b as setPlatformOptions}from"./p-D9BrlHdP.js";export{L as LLMTestRunner}from"./p-wzA48RFK.js";class e{sdk;constructor(s){this.sdk=new t({apiKey:s})}async invoke(s){const t=await this.sdk.models.generateContent({model:"gemini-3-flash-preview",contents:s});return t.text}}function n(){window.env={API_KEY:""};window.GeminiAdapter=e}const o=n||(()=>{});const i=o;i();
2
2
  //# sourceMappingURL=index.js.map
@@ -1,2 +1,2 @@
1
- import{L as o,d as s}from"./p-B87Lt3z4.js";const t=o;const p=s;export{t as LlmTestRunner,p as defineCustomElement};
1
+ import{L as o,d as s}from"./p-wzA48RFK.js";const t=o;const p=s;export{t as LlmTestRunner,p as defineCustomElement};
2
2
  //# sourceMappingURL=llm-test-runner.js.map
@@ -0,0 +1,2 @@
1
+ import{p as t,H as e,e as i,h as s,t as r}from"./p-D9BrlHdP.js";const a=()=>`.chat-history{display:flex;flex-direction:column;gap:var(--spacing-3);margin-top:var(--spacing-4)}.chat-history__toggle-row{display:flex;align-items:center}.chat-history__switch{position:relative;display:inline-flex;align-items:center;gap:var(--spacing-3);cursor:pointer;user-select:none}.chat-history__switch-input{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0, 0, 0, 0);white-space:nowrap;border:0}.chat-history__switch-ui{position:relative;flex-shrink:0;display:flex;align-items:center;padding:0px 4px;width:2.75rem;height:1.5rem;border-radius:var(--radius-full);background:var(--muted);border:var(--border-width) solid var(--border);transition:background 0.15s ease, border-color 0.15s ease}@media (prefers-reduced-motion: reduce){.chat-history__switch-ui,.chat-history__switch-thumb{transition:none}}.chat-history__switch-thumb{display:inline-block;width:calc(1.5rem - 6px);height:calc(1.5rem - 6px);border-radius:var(--radius-full);background:var(--background);box-shadow:var(--shadow-sm);transition:transform 0.15s ease}.chat-history__switch-input:checked+.chat-history__switch-ui{background:var(--primary);border-color:var(--primary)}.chat-history__switch-input:checked+.chat-history__switch-ui .chat-history__switch-thumb{transform:translateX(calc(2.75rem - (1.5rem - 6px)))}.chat-history__switch-input:focus-visible+.chat-history__switch-ui{outline:2px solid var(--ring);outline-offset:2px}.chat-history__switch-text{font-size:var(--font-size-sm, 0.875rem);color:var(--foreground)}.chat-history__textarea{width:100%;box-sizing:border-box;padding:var(--spacing-2) var(--spacing-3);border:var(--border-width) solid var(--border);border-radius:var(--radius-md);font:inherit;resize:vertical;min-height:9rem;background:var(--background)}.chat-history__textarea:focus-visible{outline:2px solid var(--ring);outline-offset:2px}`;const o=`[\n {"role": "user", "content": "How do I import a saved suite?"},\n {"role": "model", "content": "Use Import and pick the JSON from Export suite."}\n]`;const c=t(class t extends e{constructor(t){super();if(t!==false){this.__registerHost()}this.__attachShadow();this.chatHistoryChange=i(this,"chatHistoryChange")}chatHistoryEnabled=false;chatHistoryValue="";chatHistoryChange;emit(t){this.chatHistoryChange.emit(t)}onToggle=t=>{const e=t.target.checked;this.emit({enabled:e,value:this.chatHistoryValue})};onTextInput=t=>{const e=t.target.value;this.emit({enabled:this.chatHistoryEnabled,value:e})};render(){return s("div",{key:"f444a4b5bd9b48df151cad67b54bef54116d11b3",class:"chat-history"},s("div",{key:"7216d764fb905ac5e8e33209d9586525e59fa218",class:"chat-history__toggle-row"},s("label",{key:"d5d092c323b48543c96525d449bcb03dcaf5113b",class:"chat-history__switch"},s("input",{key:"5104ce460686434156454fc1dfd3685ba0e0968c",type:"checkbox",class:"chat-history__switch-input",checked:this.chatHistoryEnabled,onInput:this.onToggle}),s("span",{key:"fa2e51bce0d6ff2d3bf133383e1ce940521097b0",class:"chat-history__switch-ui","aria-hidden":"true"},s("span",{key:"e0d897ca166623ece09834b44b5baa12605cb9f3",class:"chat-history__switch-thumb"})),s("span",{key:"e769678fde5d670e634d7a8e905ef09ce936f440",class:"chat-history__switch-text"},"Chat history"))),this.chatHistoryEnabled?s("textarea",{class:"chat-history__textarea",value:this.chatHistoryValue,rows:8,placeholder:o,"aria-label":"Chat history",onInput:this.onTextInput}):null)}static get style(){return a()}},[513,"chat-history",{chatHistoryEnabled:[4,"chat-history-enabled"],chatHistoryValue:[1,"chat-history-value"]}]);function h(){if(typeof customElements==="undefined"){return}const t=["chat-history"];t.forEach((t=>{switch(t){case"chat-history":if(!customElements.get(r(t))){customElements.define(r(t),c)}break}}))}export{c as C,h as d};
2
+ //# sourceMappingURL=p-kmtfMXcQ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["chatHistoryCss","CHAT_HISTORY_PLACEHOLDER","ChatHistory","__stencil_proxyCustomElement","HTMLElement","chatHistoryEnabled","chatHistoryValue","chatHistoryChange","emit","detail","this","onToggle","e","checked","target","enabled","value","onTextInput","render","h","key","class","type","onInput","rows","placeholder"],"sources":["src/components/llm-test-runner/test-cases/chat-history.css?tag=chat-history&encapsulation=shadow","src/components/llm-test-runner/test-cases/chat-history.tsx"],"sourcesContent":[".chat-history {\n display: flex;\n flex-direction: column;\n gap: var(--spacing-3);\n margin-top: var(--spacing-4);\n}\n\n.chat-history__toggle-row {\n display: flex;\n align-items: center;\n}\n\n.chat-history__switch {\n position: relative;\n display: inline-flex;\n align-items: center;\n gap: var(--spacing-3);\n cursor: pointer;\n user-select: none;\n}\n\n.chat-history__switch-input {\n position: absolute;\n width: 1px;\n height: 1px;\n padding: 0;\n margin: -1px;\n overflow: hidden;\n clip: rect(0, 0, 0, 0);\n white-space: nowrap;\n border: 0;\n}\n\n.chat-history__switch-ui {\n position: relative;\n flex-shrink: 0;\n display: flex;\n align-items: center;\n padding: 0px 4px;\n width: 2.75rem;\n height: 1.5rem;\n border-radius: var(--radius-full);\n background: var(--muted);\n border: var(--border-width) solid var(--border);\n transition:\n background 0.15s ease,\n border-color 0.15s ease;\n}\n\n@media (prefers-reduced-motion: reduce) {\n .chat-history__switch-ui,\n .chat-history__switch-thumb {\n transition: none;\n }\n}\n\n.chat-history__switch-thumb {\n display: inline-block;\n width: calc(1.5rem - 6px);\n height: calc(1.5rem - 6px);\n border-radius: var(--radius-full);\n background: var(--background);\n box-shadow: var(--shadow-sm);\n transition: transform 0.15s ease;\n}\n\n.chat-history__switch-input:checked + .chat-history__switch-ui {\n background: var(--primary);\n border-color: var(--primary);\n}\n\n.chat-history__switch-input:checked + .chat-history__switch-ui .chat-history__switch-thumb {\n transform: translateX(calc(2.75rem - (1.5rem - 6px)));\n}\n\n.chat-history__switch-input:focus-visible + .chat-history__switch-ui {\n outline: 2px solid var(--ring);\n outline-offset: 2px;\n}\n\n.chat-history__switch-text {\n font-size: var(--font-size-sm, 0.875rem);\n color: var(--foreground);\n}\n\n.chat-history__textarea {\n width: 100%;\n box-sizing: border-box;\n padding: var(--spacing-2) var(--spacing-3);\n border: var(--border-width) solid var(--border);\n border-radius: var(--radius-md);\n font: inherit;\n resize: vertical;\n min-height: 9rem;\n background: var(--background);\n}\n\n.chat-history__textarea:focus-visible {\n outline: 2px solid var(--ring);\n outline-offset: 2px;\n}\n","import { Component, Event, EventEmitter, Prop, h } from '@stencil/core';\n\nconst CHAT_HISTORY_PLACEHOLDER = `[\n {\"role\": \"user\", \"content\": \"How do I import a saved suite?\"},\n {\"role\": \"model\", \"content\": \"Use Import and pick the JSON from Export suite.\"}\n]`;\n\nexport type ChatHistoryChangeDetail = {\n enabled: boolean;\n value: string;\n};\n\n@Component({\n tag: 'chat-history',\n styleUrl: 'chat-history.css',\n shadow: true,\n})\nexport class ChatHistory {\n @Prop() chatHistoryEnabled = false;\n @Prop() chatHistoryValue = '';\n\n @Event({ bubbles: true, composed: true })\n chatHistoryChange: EventEmitter<ChatHistoryChangeDetail>;\n\n private emit(detail: ChatHistoryChangeDetail) {\n this.chatHistoryChange.emit(detail);\n }\n\n private onToggle = (e: Event) => {\n const checked = (e.target as HTMLInputElement).checked;\n this.emit({ enabled: checked, value: this.chatHistoryValue });\n };\n\n private onTextInput = (e: Event) => {\n const value = (e.target as HTMLTextAreaElement).value;\n this.emit({ enabled: this.chatHistoryEnabled, value });\n };\n\n render() {\n return (\n <div class=\"chat-history\">\n <div class=\"chat-history__toggle-row\">\n <label class=\"chat-history__switch\">\n <input\n type=\"checkbox\"\n class=\"chat-history__switch-input\"\n checked={this.chatHistoryEnabled}\n onInput={this.onToggle}\n />\n <span class=\"chat-history__switch-ui\" aria-hidden=\"true\">\n <span class=\"chat-history__switch-thumb\" />\n </span>\n <span class=\"chat-history__switch-text\">Chat history</span>\n </label>\n </div>\n {this.chatHistoryEnabled ? (\n <textarea\n class=\"chat-history__textarea\"\n value={this.chatHistoryValue}\n rows={8}\n placeholder={CHAT_HISTORY_PLACEHOLDER}\n aria-label=\"Chat history\"\n onInput={this.onTextInput}\n />\n ) : null}\n </div>\n );\n }\n}\n"],"mappings":"gEAAA,MAAMA,EAAiB,IAAM,u1DCE7B,MAAMC,EAA2B,4J,MAepBC,EAAWC,EAAA,MAAAD,UAAAE,E,oIACdC,mBAAqB,MACrBC,iBAAmB,GAG3BC,kBAEQ,IAAAC,CAAKC,GACXC,KAAKH,kBAAkBC,KAAKC,E,CAGtBE,SAAYC,IAClB,MAAMC,EAAWD,EAAEE,OAA4BD,QAC/CH,KAAKF,KAAK,CAAEO,QAASF,EAASG,MAAON,KAAKJ,kBAAmB,EAGvDW,YAAeL,IACrB,MAAMI,EAASJ,EAAEE,OAA+BE,MAChDN,KAAKF,KAAK,CAAEO,QAASL,KAAKL,mBAAoBW,SAAQ,EAGxD,MAAAE,GACE,OACEC,EAAA,OAAAC,IAAA,2CAAKC,MAAM,gBACTF,EAAA,OAAAC,IAAA,2CAAKC,MAAM,4BACTF,EAAA,SAAAC,IAAA,2CAAOC,MAAM,wBACXF,EAAA,SAAAC,IAAA,2CACEE,KAAK,WACLD,MAAM,6BACNR,QAASH,KAAKL,mBACdkB,QAASb,KAAKC,WAEhBQ,EAAA,QAAAC,IAAA,2CAAMC,MAAM,0BAAyB,cAAa,QAChDF,EAAA,QAAAC,IAAA,2CAAMC,MAAM,gCAEdF,EAAA,QAAAC,IAAA,2CAAMC,MAAM,6BAA2B,kBAG1CX,KAAKL,mBACJc,EAAA,YACEE,MAAM,yBACNL,MAAON,KAAKJ,iBACZkB,KAAM,EACNC,YAAaxB,EAAwB,aAC1B,eACXsB,QAASb,KAAKO,cAEd,K","ignoreList":[]}