@takeshape/schema 11.41.0 → 11.44.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 (38) hide show
  1. package/dist/cjs/src/agents.js +87 -1
  2. package/dist/cjs/src/index.js +2 -0
  3. package/dist/cjs/src/relationships.js +86 -1
  4. package/dist/cjs/src/runtime-schema.js +81 -0
  5. package/dist/cjs/src/schemas/index.js +3 -7
  6. package/dist/cjs/src/schemas/project-schema/experimental.json +305 -0
  7. package/dist/cjs/src/schemas/project-schema/latest.json +1 -1
  8. package/dist/cjs/src/schemas/project-schema/v3.50.0.json +1 -1
  9. package/dist/cjs/src/service-dependencies.js +167 -0
  10. package/dist/cjs/src/util/patch-schema.js +33 -28
  11. package/dist/cjs/src/validate.js +40 -4
  12. package/dist/esm/src/agents.js +83 -0
  13. package/dist/esm/src/index.js +2 -0
  14. package/dist/esm/src/relationships.js +85 -1
  15. package/dist/esm/src/runtime-schema.js +73 -0
  16. package/dist/esm/src/schemas/index.js +0 -2
  17. package/dist/esm/src/schemas/project-schema/experimental.json +305 -0
  18. package/dist/esm/src/schemas/project-schema/latest.json +1 -1
  19. package/dist/esm/src/schemas/project-schema/v3.50.0.json +1 -1
  20. package/dist/esm/src/service-dependencies.js +159 -0
  21. package/dist/esm/src/util/patch-schema.js +33 -27
  22. package/dist/esm/src/validate.js +40 -4
  23. package/dist/types/src/agents.d.ts +4 -1
  24. package/dist/types/src/index.d.ts +2 -0
  25. package/dist/types/src/migration/types.d.ts +1 -3
  26. package/dist/types/src/project-schema/latest.d.ts +143 -4
  27. package/dist/types/src/project-schema/v3.48.0.d.ts +143 -4
  28. package/dist/types/src/project-schema/v3.49.0.d.ts +143 -4
  29. package/dist/types/src/project-schema/v3.50.0.d.ts +143 -4
  30. package/dist/types/src/relationships.d.ts +4 -0
  31. package/dist/types/src/runtime-schema.d.ts +5 -0
  32. package/dist/types/src/schemas/index.d.ts +0 -2
  33. package/dist/types/src/service-dependencies.d.ts +13 -0
  34. package/dist/types/src/types/types.d.ts +1 -0
  35. package/dist/types/src/util/patch-schema.d.ts +4 -4
  36. package/dist/types/src/validate.d.ts +8 -3
  37. package/dist/types/tsconfig.types.tsbuildinfo +1 -1
  38. package/package.json +6 -6
@@ -3,8 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getInspectAgentSessionQueryName = exports.getAgentEndStates = exports.getAgentEndTransitions = exports.BUILT_IN_CHAT_ARG_NAMES = exports.BUILT_IN_CHAT_ARGS = exports.END_AGENT_EXECUTION = void 0;
6
+ exports.addAiQueries = exports.createArgs = exports.removeBuiltInArgs = exports.getInspectAgentSessionQueryName = exports.getAgentEndStates = exports.getAgentEndTransitions = exports.BUILT_IN_CHAT_ARG_NAMES = exports.BUILT_IN_CHAT_ARGS = exports.END_AGENT_EXECUTION = void 0;
7
7
  const upperFirst_js_1 = __importDefault(require("lodash/upperFirst.js"));
8
+ const uniq_js_1 = __importDefault(require("lodash/uniq.js"));
9
+ const uniqBy_js_1 = __importDefault(require("lodash/uniqBy.js"));
8
10
  exports.END_AGENT_EXECUTION = 'endAgentExecution';
9
11
  exports.BUILT_IN_CHAT_ARGS = [
10
12
  {
@@ -56,3 +58,87 @@ const getInspectAgentSessionQueryName = (agentName) => {
56
58
  return `inspect${(0, upperFirst_js_1.default)(agentName)}`;
57
59
  };
58
60
  exports.getInspectAgentSessionQueryName = getInspectAgentSessionQueryName;
61
+ const removeBuiltInArgs = (args) => {
62
+ return args.filter(arg => !exports.BUILT_IN_CHAT_ARG_NAMES.includes(arg.argName));
63
+ };
64
+ exports.removeBuiltInArgs = removeBuiltInArgs;
65
+ const createArgs = (agent) => {
66
+ let apiArguments = (0, uniqBy_js_1.default)(agent.api.arguments ?? [], arg => arg.argName);
67
+ if (agent.api.type === 'chat') {
68
+ apiArguments = (0, exports.removeBuiltInArgs)(apiArguments).concat(exports.BUILT_IN_CHAT_ARGS);
69
+ }
70
+ return apiArguments.length > 0
71
+ ? {
72
+ type: 'object',
73
+ properties: apiArguments.reduce((acc, argument) => {
74
+ acc[argument.argName] = {
75
+ type: argument.argType === 'sessionId' ? 'string' : argument.argType
76
+ };
77
+ return acc;
78
+ }, {}),
79
+ required: apiArguments.filter(arg => arg.required).map(arg => arg.argName)
80
+ }
81
+ : undefined;
82
+ };
83
+ exports.createArgs = createArgs;
84
+ function addAiQueries(projectSchema) {
85
+ const agents = projectSchema['ai-experimental']?.agents;
86
+ if (!agents) {
87
+ return projectSchema;
88
+ }
89
+ const newSchema = {
90
+ ...projectSchema,
91
+ queries: { ...projectSchema.queries },
92
+ mutations: { ...projectSchema.mutations }
93
+ };
94
+ for (const [agentName, agent] of Object.entries(agents)) {
95
+ // Get valid return types based on states that could possibly be the end state
96
+ // TODO In the future the agent will have a return type defined and we will instead validate
97
+ // that all the return states will return the correct shape.
98
+ const returnStates = [...(0, exports.getAgentEndStates)(agent, true)];
99
+ const returnTypes = (0, uniq_js_1.default)(returnStates.map(stateId => {
100
+ const { execution } = agent.states[stateId];
101
+ if (execution.type === 'chat') {
102
+ return 'TSChatResponse';
103
+ }
104
+ if (execution.type === 'generate') {
105
+ return execution.outputShape ? execution.outputShape : 'string';
106
+ }
107
+ return 'JSON';
108
+ }));
109
+ const shape = returnTypes.length === 0 ? 'string' : returnTypes.length === 1 ? returnTypes[0] : 'JSON';
110
+ if (newSchema.mutations[agentName] !== undefined) {
111
+ throw new Error(`Schema already has a mutation with the name ${agentName}`);
112
+ }
113
+ newSchema.mutations[agentName] = {
114
+ description: agent.description,
115
+ args: (0, exports.createArgs)(agent),
116
+ shape,
117
+ resolver: {
118
+ name: 'ai:runAgent',
119
+ agentName
120
+ }
121
+ };
122
+ if (shape === 'TSChatResponse') {
123
+ newSchema.queries[(0, exports.getInspectAgentSessionQueryName)(agentName)] ||= {
124
+ description: `Inspect a session for the ${agentName} agent`,
125
+ args: {
126
+ type: 'object',
127
+ properties: {
128
+ sessionId: {
129
+ type: 'string'
130
+ }
131
+ },
132
+ required: ['sessionId']
133
+ },
134
+ shape: 'TSAgentSession',
135
+ resolver: {
136
+ name: 'ai:inspectAgentSession',
137
+ agentName
138
+ }
139
+ };
140
+ }
141
+ }
142
+ return newSchema;
143
+ }
144
+ exports.addAiQueries = addAiQueries;
@@ -58,3 +58,5 @@ __exportStar(require("./util/merge"), exports);
58
58
  __exportStar(require("./util/patch-schema"), exports);
59
59
  __exportStar(require("./util/shapes"), exports);
60
60
  __exportStar(require("./constants"), exports);
61
+ __exportStar(require("./runtime-schema"), exports);
62
+ __exportStar(require("./service-dependencies"), exports);
@@ -3,9 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.hasUnequalRelationships = exports.isEqualRelationship = exports.findExistingRelationships = exports.getRelationship = exports.getLegacyRelationship = exports.getRelationshipShapeIds = exports.getRelationshipShapes = exports.getRelationshipShapeRefs = exports.getRelationshipSchema = void 0;
6
+ exports.addRelatedFields = exports.hasUnequalRelationships = exports.isEqualRelationship = exports.findExistingRelationships = exports.getRelationship = exports.getLegacyRelationship = exports.getRelationshipShapeIds = exports.getRelationshipShapes = exports.getRelationshipShapeRefs = exports.getRelationshipSchema = void 0;
7
7
  const util_1 = require("@takeshape/util");
8
8
  const find_js_1 = __importDefault(require("lodash/find.js"));
9
+ const camelCase_js_1 = __importDefault(require("lodash/camelCase.js"));
10
+ const uniq_js_1 = __importDefault(require("lodash/uniq.js"));
9
11
  const types_1 = require("./types");
10
12
  const refs_1 = require("./refs");
11
13
  const unions_1 = require("./unions");
@@ -235,3 +237,86 @@ function hasUnequalRelationships(relationships) {
235
237
  }));
236
238
  }
237
239
  exports.hasUnequalRelationships = hasUnequalRelationships;
240
+ function getRelatedShapeIds(relationships) {
241
+ return (0, uniq_js_1.default)(relationships.map(rel => (rel.hasBackreference ? rel.shapeId : undefined)).filter(util_1.isDefined));
242
+ }
243
+ function getShapes(projectSchema, shapeIds) {
244
+ return shapeIds.map(shapeId => (0, shapes_1.getShapeById)(projectSchema, shapeId)).filter(util_1.isDefined);
245
+ }
246
+ /**
247
+ * Adds backreference fields to the schema.
248
+ */
249
+ function addRelatedFields(projectSchema, allRelationships) {
250
+ for (const [shapeId, shapeRelationships] of Object.entries(allRelationships)) {
251
+ const shape = (0, shapes_1.getShapeById)(projectSchema, shapeId);
252
+ if (shape && (0, types_1.isObjectSchema)(shape.schema)) {
253
+ const relatedShapeIds = getRelatedShapeIds(shapeRelationships);
254
+ const relatedShapeNames = getShapes(projectSchema, relatedShapeIds).map(shape => shape.name);
255
+ if (relatedShapeNames.length) {
256
+ let shapeName;
257
+ if (relatedShapeNames.length === 1) {
258
+ // If only one back reference exists, _references is a regular shape
259
+ shapeName = relatedShapeNames[0];
260
+ }
261
+ else {
262
+ // If many back references exist, _references will be a union of referring shapes
263
+ shapeName = `${shape.name}Reference`;
264
+ projectSchema.shapes[shapeName] = {
265
+ id: shapeName,
266
+ name: shapeName,
267
+ title: shapeName,
268
+ schema: {
269
+ oneOf: relatedShapeNames.map(name => ({ '@ref': `local:${name}` }))
270
+ }
271
+ };
272
+ }
273
+ // _references, a list of all backreferences across all fields on this shape.
274
+ // It lists all the items that have references to the current item.
275
+ // It is for convenience.
276
+ if (shapeRelationships.some(rel => rel.hasBackreference)) {
277
+ shape.schema.properties._references = {
278
+ '@args': `TSListArgs<local:${shapeName}>`,
279
+ '@ref': `PaginatedList<local:${shapeName}>`,
280
+ '@resolver': {
281
+ name: 'shapedb:list',
282
+ service: 'shapedb',
283
+ args: {
284
+ ops: [
285
+ { path: '$', mapping: '$args' },
286
+ { path: `baseWhere._references.eq`, mapping: '$source._id' },
287
+ { path: `baseWhere._shapeId.in`, value: relatedShapeIds }
288
+ ]
289
+ }
290
+ }
291
+ };
292
+ }
293
+ }
294
+ // Create a schema for the backreference on the referred-to shape
295
+ for (const relationship of shapeRelationships) {
296
+ const relatedShape = (0, shapes_1.getShapeById)(projectSchema, relationship.shapeId);
297
+ if (relatedShape && relationship.hasBackreference) {
298
+ const { relatedName } = relationship;
299
+ const relatedFieldName = relatedName ? relatedName : `${(0, camelCase_js_1.default)(relatedShape.name)}Set`;
300
+ const filterField = relatedName ? relationship.path.concat('_id').join('.') : '_references';
301
+ shape.schema.properties[relatedFieldName] = {
302
+ '@args': `TSListArgs<local:${relatedShape.name}>`,
303
+ '@ref': `PaginatedList<local:${relatedShape.name}>`,
304
+ '@resolver': {
305
+ name: 'shapedb:list',
306
+ service: 'shapedb',
307
+ args: {
308
+ ops: [
309
+ { path: '$', mapping: '$args' },
310
+ { path: `baseWhere.${filterField}.eq`, mapping: '$source._id' },
311
+ { path: `baseWhere._shapeId.eq`, value: relatedShape.id }
312
+ ]
313
+ }
314
+ }
315
+ };
316
+ }
317
+ }
318
+ }
319
+ }
320
+ return projectSchema;
321
+ }
322
+ exports.addRelatedFields = addRelatedFields;
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.buildRuntimeSchema = exports.applyDefaultsAndFlatten = exports.applyLegacyCompatibilityTweaks = void 0;
7
+ const errors_1 = require("@takeshape/errors");
8
+ const compose_js_1 = __importDefault(require("lodash/fp/compose.js"));
9
+ const util_1 = require("@takeshape/util");
10
+ const set_js_1 = __importDefault(require("lodash/set.js"));
11
+ const isError_js_1 = __importDefault(require("lodash/isError.js"));
12
+ const types_1 = require("./types");
13
+ const schema_util_1 = require("./schema-util");
14
+ const relationships_1 = require("./relationships");
15
+ const flatten_templates_1 = require("./flatten-templates");
16
+ const agents_1 = require("./agents");
17
+ const service_dependencies_1 = require("./service-dependencies");
18
+ function applyLegacyCompatibilityTweaks(projectSchema) {
19
+ const newSchema = (0, util_1.deepClone)(projectSchema);
20
+ let hasSearchableShapes = false;
21
+ for (const [shapeName, shape] of Object.entries(newSchema.shapes)) {
22
+ if ((0, types_1.isModelShape)(shape)) {
23
+ hasSearchableShapes = true;
24
+ // Magic _contentTypeId field used for V1 compatibility
25
+ (0, set_js_1.default)(shape, ['schema', 'properties', '_contentTypeId'], { type: 'string' });
26
+ (0, set_js_1.default)(shape, ['schema', 'properties', '_contentTypeName'], { type: 'string' });
27
+ if (shape.model?.type !== 'single') {
28
+ newSchema.queries[`search${shapeName}Index`] = {
29
+ shape: `SearchResults<${shapeName}>`,
30
+ resolver: {
31
+ name: 'takeshape:search',
32
+ service: 'takeshape',
33
+ shapeName
34
+ },
35
+ args: `TSSearchArgs<${shapeName}>`
36
+ };
37
+ }
38
+ }
39
+ if (shapeName === 'Asset') {
40
+ // Magic s3Key field to provide V1 compatibility with old projects until the field is
41
+ // formally removed and users are notified
42
+ (0, set_js_1.default)(shape, ['schema', 'properties', 's3Key'], {
43
+ title: 's3 key',
44
+ type: 'string',
45
+ '@mapping': 'shapedb:Asset.Hk6FQuz5',
46
+ '@deprecationReason': 'Use path instead'
47
+ });
48
+ }
49
+ }
50
+ if (hasSearchableShapes) {
51
+ // A placeholder shape for the TSSearchable interface
52
+ newSchema.shapes.TSSearchable = (0, schema_util_1.createShape)('TSSearchable', { type: 'object', properties: {} });
53
+ newSchema.queries.search = {
54
+ shape: 'SearchResults<TSSearchable>',
55
+ resolver: {
56
+ name: 'takeshape:search',
57
+ service: 'takeshape'
58
+ },
59
+ args: 'TSSearchArgs<TSSearchable>'
60
+ };
61
+ }
62
+ (0, relationships_1.addRelatedFields)(newSchema, (0, relationships_1.findExistingRelationships)(projectSchema, projectSchema.shapes));
63
+ return newSchema;
64
+ }
65
+ exports.applyLegacyCompatibilityTweaks = applyLegacyCompatibilityTweaks;
66
+ exports.applyDefaultsAndFlatten = (0, compose_js_1.default)(flatten_templates_1.flattenTemplates, applyLegacyCompatibilityTweaks, schema_util_1.applyDefaultsToSchema, agents_1.addAiQueries);
67
+ function buildRuntimeSchema(projectSchema, serviceLayers, log) {
68
+ try {
69
+ const projectSchemaWithDependencies = (0, service_dependencies_1.resolveSchemaShapeDependencies)(projectSchema, serviceLayers);
70
+ return (0, exports.applyDefaultsAndFlatten)(projectSchemaWithDependencies);
71
+ }
72
+ catch (err) {
73
+ const error = new errors_1.SchemaBuildError('An error occurred while building the schema', {
74
+ cause: (0, isError_js_1.default)(err) ? err : undefined,
75
+ schema: projectSchema
76
+ });
77
+ log('build runtime error', error);
78
+ throw error;
79
+ }
80
+ }
81
+ exports.buildRuntimeSchema = buildRuntimeSchema;
@@ -3,18 +3,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.allProjectSchemas = exports.experimentalSchemaJson = exports.authSchemaJson = exports.latestSchemaJson = exports.anyProjectSchema = exports.CURRENT_SCHEMA_VERSION = void 0;
6
+ exports.allProjectSchemas = exports.latestSchemaJson = exports.anyProjectSchema = exports.CURRENT_SCHEMA_VERSION = void 0;
7
7
  // This file is generated by "pnpm json2ts"
8
8
  exports.CURRENT_SCHEMA_VERSION = '3.50.0';
9
9
  var project_schema_json_1 = require("./project-schema.json");
10
10
  Object.defineProperty(exports, "anyProjectSchema", { enumerable: true, get: function () { return __importDefault(project_schema_json_1).default; } });
11
11
  var v3_50_0_json_1 = require("./project-schema/v3.50.0.json");
12
12
  Object.defineProperty(exports, "latestSchemaJson", { enumerable: true, get: function () { return __importDefault(v3_50_0_json_1).default; } });
13
- var auth_schemas_json_1 = require("./auth-schemas.json");
14
- Object.defineProperty(exports, "authSchemaJson", { enumerable: true, get: function () { return __importDefault(auth_schemas_json_1).default; } });
15
- var experimental_json_1 = require("./project-schema/experimental.json");
16
- Object.defineProperty(exports, "experimentalSchemaJson", { enumerable: true, get: function () { return __importDefault(experimental_json_1).default; } });
17
- const experimental_json_2 = __importDefault(require("./project-schema/experimental.json"));
13
+ const experimental_json_1 = __importDefault(require("./project-schema/experimental.json"));
18
14
  const meta_schema_v1_0_0_json_1 = __importDefault(require("./project-schema/meta-schema-v1.0.0.json"));
19
15
  const v1_0_0_json_1 = __importDefault(require("./project-schema/v1.0.0.json"));
20
16
  const meta_schema_v3_0_0_json_1 = __importDefault(require("./project-schema/meta-schema-v3.0.0.json"));
@@ -88,7 +84,7 @@ const v3_49_0_json_1 = __importDefault(require("./project-schema/v3.49.0.json"))
88
84
  const v3_50_0_json_2 = __importDefault(require("./project-schema/v3.50.0.json"));
89
85
  const v4_0_0_json_1 = __importDefault(require("./project-schema/v4.0.0.json"));
90
86
  exports.allProjectSchemas = [
91
- experimental_json_2.default,
87
+ experimental_json_1.default,
92
88
  meta_schema_v1_0_0_json_1.default,
93
89
  v1_0_0_json_1.default,
94
90
  meta_schema_v3_0_0_json_1.default,
@@ -21,6 +21,13 @@
21
21
  },
22
22
  "states": {
23
23
  "$ref": "#/definitions/agentStateMap"
24
+ },
25
+ "guards": {
26
+ "title": "AgentGuardList",
27
+ "type": "array",
28
+ "items": {
29
+ "$ref": "#/definitions/agentGuard"
30
+ }
24
31
  }
25
32
  },
26
33
  "required": ["start", "states", "api"],
@@ -488,6 +495,17 @@
488
495
  }
489
496
  ]
490
497
  },
498
+ "agentGuard": {
499
+ "title": "AgentGuard",
500
+ "type": "object",
501
+ "properties": {
502
+ "guardId": {
503
+ "type": "string"
504
+ }
505
+ },
506
+ "required": ["guardId"],
507
+ "additionalProperties": false
508
+ },
491
509
  "agentToolConfig": {
492
510
  "title": "AgentToolConfig",
493
511
  "type": "object",
@@ -726,6 +744,10 @@
726
744
  "agents": {
727
745
  "$ref": "#/definitions/agentMap",
728
746
  "description": "An Agent is a configuration for an AI service such as a chat bot or a search engine."
747
+ },
748
+ "guards": {
749
+ "$ref": "#/definitions/guardMap",
750
+ "description": "A Guard is a configuration for an AI guardrail that can check inputs and outputs and provide safety and compliance."
729
751
  }
730
752
  },
731
753
  "additionalProperties": false
@@ -757,6 +779,289 @@
757
779
  ],
758
780
  "additionalProperties": false
759
781
  },
782
+ "guard": {
783
+ "title": "GuardJSON",
784
+ "description": "A Guard is a configuration for an AI guardrail that can check inputs and outputs and provide safety and compliance.",
785
+ "type": "object",
786
+ "properties": {
787
+ "name": {
788
+ "type": "string",
789
+ "title": "Name",
790
+ "description": "The human-readable name of the Guard."
791
+ },
792
+ "description": {
793
+ "type": "string",
794
+ "title": "Description",
795
+ "description": "A description of the Guard."
796
+ },
797
+ "blockedInputMessaging": {
798
+ "type": "string",
799
+ "title": "Blocked Input Messaging",
800
+ "description": "A message to return when the input message is blocked by the Guard."
801
+ },
802
+ "blockedOutputsMessaging": {
803
+ "type": "string",
804
+ "title": "Blocked Outputs Messaging",
805
+ "description": "A message to return when the output message is blocked by the Guard."
806
+ },
807
+ "topicPolicyConfig": {
808
+ "type": "object",
809
+ "title": "Topic Policy",
810
+ "description": "Topics to identify and block.",
811
+ "properties": {
812
+ "topicsConfig": {
813
+ "type": "array",
814
+ "items": {
815
+ "title": "Topic",
816
+ "description": "A topic to block.",
817
+ "type": "object",
818
+ "properties": {
819
+ "name": {
820
+ "type": "string"
821
+ },
822
+ "definition": {
823
+ "type": "string"
824
+ },
825
+ "examples": {
826
+ "type": "array",
827
+ "items": {
828
+ "type": "string"
829
+ }
830
+ },
831
+ "type": {
832
+ "type": "string",
833
+ "enum": ["DENY"]
834
+ }
835
+ },
836
+ "additionalProperties": false
837
+ }
838
+ }
839
+ },
840
+ "additionalProperties": false
841
+ },
842
+ "contentPolicyConfig": {
843
+ "type": "object",
844
+ "title": "Content Policy",
845
+ "description": "Types of content to filter and strength configuration.",
846
+ "properties": {
847
+ "filtersConfig": {
848
+ "type": "array",
849
+ "items": {
850
+ "title": "Filter",
851
+ "description": "Types of content to filter.",
852
+ "type": "object",
853
+ "properties": {
854
+ "type": {
855
+ "type": "string",
856
+ "enum": ["HATE", "INSULTS", "MICONDUCT", "PROMPT_ATTACK", "SEXUAL", "VIOLENCE"]
857
+ },
858
+ "inputStrength": {
859
+ "$ref": "#/definitions/guardrailFilterStrength"
860
+ },
861
+ "outputStrength": {
862
+ "$ref": "#/definitions/guardrailFilterStrength"
863
+ },
864
+ "inputModalities": {
865
+ "type": "array",
866
+ "items": {
867
+ "$ref": "#/definitions/guardrailModality"
868
+ }
869
+ },
870
+ "outputModalities": {
871
+ "type": "array",
872
+ "items": {
873
+ "$ref": "#/definitions/guardrailModality"
874
+ }
875
+ }
876
+ },
877
+ "additionalProperties": false
878
+ }
879
+ }
880
+ },
881
+ "additionalProperties": false
882
+ },
883
+ "wordPolicyConfig": {
884
+ "type": "object",
885
+ "title": "Word Policy",
886
+ "description":
887
+ "Specific words to identify and block. The managedWordListsConfig is solely used for blocking profanity.",
888
+ "properties": {
889
+ "wordsConfig": {
890
+ "type": "array",
891
+ "items": {
892
+ "title": "Word List",
893
+ "description": "Specific words to block.",
894
+ "type": "object",
895
+ "properties": {
896
+ "text": {
897
+ "type": "string"
898
+ }
899
+ },
900
+ "additionalProperties": false
901
+ }
902
+ },
903
+ "managedWordListsConfig": {
904
+ "type": "array",
905
+ "items": {
906
+ "title": "Managed Words",
907
+ "description": "Managed word list to block. This is solely used for blocking profanity.",
908
+ "type": "object",
909
+ "properties": {
910
+ "type": {
911
+ "type": "string",
912
+ "enum": ["PROFANITY"]
913
+ }
914
+ },
915
+ "additionalProperties": false
916
+ }
917
+ }
918
+ },
919
+ "additionalProperties": false
920
+ },
921
+ "sensitiveInformationPolicyConfig": {
922
+ "title": "Sensitive Information Policy",
923
+ "description":
924
+ "Filter out and block or obscure sensitive information. Matching text will be handled per the policy.",
925
+ "type": "object",
926
+ "properties": {
927
+ "piiEntitiesConfig": {
928
+ "type": "array",
929
+ "items": {
930
+ "title": "PII Entity",
931
+ "description": "PII entity to infer from the text.",
932
+ "type": "object",
933
+ "properties": {
934
+ "type": {
935
+ "type": "string",
936
+ "enum": [
937
+ "ADDRESS",
938
+ "AGE",
939
+ "AWS_ACCESS_KEY",
940
+ "AWS_SECRET_KEY",
941
+ "CA_HEALTH_NUMBER",
942
+ "CA_SOCIAL_INSURANCE_NUMBER",
943
+ "CREDIT_DEBIT_CARD_CVV",
944
+ "CREDIT_DEBIT_CARD_EXPIRY",
945
+ "CREDIT_DEBIT_CARD_NUMBER",
946
+ "DRIVER_ID",
947
+ "EMAIL",
948
+ "INTERNATIONAL_BANK_ACCOUNT_NUMBER",
949
+ "IP_ADDRESS",
950
+ "LICENSE_PLATE",
951
+ "MAC_ADDRESS",
952
+ "NAME",
953
+ "PASSWORD",
954
+ "PHONE",
955
+ "PIN",
956
+ "SWIFT_CODE",
957
+ "UK_NATIONAL_HEALTH_SERVICE_NUMBER",
958
+ "UK_NATIONAL_INSURANCE_NUMBER",
959
+ "UK_UNIQUE_TAXPAYER_REFERENCE_NUMBER",
960
+ "URL",
961
+ "USERNAME",
962
+ "US_BANK_ACCOUNT_NUMBER",
963
+ "US_BANK_ROUTING_NUMBER",
964
+ "US_INDIVIDUAL_TAX_IDENTIFICATION_NUMBER",
965
+ "US_PASSPORT_NUMBER",
966
+ "US_SOCIAL_SECURITY_NUMBER",
967
+ "VEHICLE_IDENTIFICATION_NUMBER"
968
+ ]
969
+ },
970
+ "action": {
971
+ "$ref": "#/definitions/guardrailSensitiveInformationAction"
972
+ }
973
+ },
974
+ "additionalProperties": false
975
+ }
976
+ },
977
+ "regexesConfig": {
978
+ "type": "array",
979
+ "items": {
980
+ "title": "Regular Expression",
981
+ "description": "A regular expression to match sensitive information.",
982
+ "type": "object",
983
+ "properties": {
984
+ "name": {
985
+ "type": "string"
986
+ },
987
+ "description": {
988
+ "type": "string"
989
+ },
990
+ "pattern": {
991
+ "type": "string"
992
+ },
993
+ "action": {
994
+ "$ref": "#/definitions/guardrailSensitiveInformationAction"
995
+ }
996
+ },
997
+ "additionalProperties": false
998
+ }
999
+ }
1000
+ },
1001
+ "additionalProperties": false
1002
+ },
1003
+ "contextualGroundingPolicyConfig": {
1004
+ "title": "Contextual Grounding Policy",
1005
+ "description":
1006
+ "Provides evaluations based on grounding text supplied by your in-context agent variables. Off-topic conversations can then be blocked.",
1007
+ "type": "object",
1008
+ "properties": {
1009
+ "filtersConfig": {
1010
+ "type": "array",
1011
+ "items": {
1012
+ "title": "Filter",
1013
+ "description": "Filter to evaluate grounding text.",
1014
+ "type": "object",
1015
+ "properties": {
1016
+ "type": {
1017
+ "title": "Type",
1018
+ "description": "The type of filter.",
1019
+ "type": "string",
1020
+ "enum": ["GROUNDING", "RELEVANCE"]
1021
+ },
1022
+ "threshold": {
1023
+ "title": "Threshold",
1024
+ "description": "The threshold for the filter as a floating point value between 0.0 - 1.0.",
1025
+ "type": "number",
1026
+ "minimum": 0,
1027
+ "maximum": 1
1028
+ }
1029
+ },
1030
+ "additionalProperties": false
1031
+ }
1032
+ }
1033
+ },
1034
+ "additionalProperties": false
1035
+ }
1036
+ },
1037
+ "required": ["name"],
1038
+ "additionalProperties": false
1039
+ },
1040
+ "guardMap": {
1041
+ "title": "GuardMap",
1042
+ "type": "object",
1043
+ "patternProperties": {
1044
+ "^[0-9A-Za-z_]+$": {
1045
+ "$ref": "#/definitions/guard"
1046
+ }
1047
+ },
1048
+ "additionalProperties": false
1049
+ },
1050
+ "guardrailFilterStrength": {
1051
+ "title": "Guardrail Filter Strength",
1052
+ "type": "string",
1053
+ "enum": ["NONE", "HIGH", "LOW", "MEDIUM"]
1054
+ },
1055
+ "guardrailModality": {
1056
+ "title": "Guardrail Modality",
1057
+ "type": "string",
1058
+ "enum": ["TEXT", "IMAGE"]
1059
+ },
1060
+ "guardrailSensitiveInformationAction": {
1061
+ "title": "Guardrail Sensitive Information Action",
1062
+ "type": "string",
1063
+ "enum": ["ANONYMIZE", "BLOCK"]
1064
+ },
760
1065
  "aiInspectAgentResolver": {
761
1066
  "title": "AIInspectAgentResolver",
762
1067
  "type": "object",
@@ -3717,4 +3717,4 @@
3717
3717
  "mutations",
3718
3718
  "workflows"
3719
3719
  ]
3720
- }
3720
+ }
@@ -3717,4 +3717,4 @@
3717
3717
  "mutations",
3718
3718
  "workflows"
3719
3719
  ]
3720
- }
3720
+ }