@takeshape/schema 11.43.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.
@@ -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
+ }
@@ -493,8 +493,8 @@ function validateShapeLoaders(context, projectSchema, shape) {
493
493
  }
494
494
  }
495
495
  }
496
- if (shape.cache?.triggers) {
497
- const min = context.entitlements?.minScheduleTriggerInterval ?? util_1.DEFAULT_MIN_SCHEDULE_TRIGGER_INTERVAL;
496
+ if (shape.cache?.triggers && !context.ignoreEntitlements) {
497
+ const min = context.entitlements.minScheduleTriggerInterval ?? util_1.DEFAULT_MIN_SCHEDULE_TRIGGER_INTERVAL;
498
498
  for (let i = 0; i < shape.cache.triggers.length; i++) {
499
499
  const trigger = shape.cache.triggers[i];
500
500
  if (trigger.type === 'schedule' && trigger.interval < min) {
@@ -792,14 +792,16 @@ function validateInterfaceImplementations(projectSchema) {
792
792
  function validateAgents(projectSchema) {
793
793
  const getNamespace = (0, refs_1.createGetNamespace)(projectSchema);
794
794
  const errors = [];
795
+ const guards = projectSchema['ai-experimental']?.guards;
795
796
  const agents = projectSchema['ai-experimental']?.agents;
796
797
  if (!agents) {
797
798
  return errors;
798
799
  }
799
800
  for (const [agentName, agent] of Object.entries(agents)) {
800
801
  const stateNames = new Set();
802
+ const agentPath = ['ai-experimental', 'agents', agentName];
801
803
  for (const [stateId, state] of Object.entries(agent.states)) {
802
- const statePath = ['ai-experimental', 'agents', agentName, 'states', stateId];
804
+ const statePath = [...agentPath, 'states', stateId];
803
805
  if (stateNames.has(state.name)) {
804
806
  errors.push({
805
807
  path: [...statePath, 'name'],
@@ -825,6 +827,17 @@ function validateAgents(projectSchema) {
825
827
  });
826
828
  }
827
829
  }
830
+ if (agent.guards) {
831
+ const invalidGuards = agent.guards.filter(({ guardId }) => !guards?.[guardId]);
832
+ if (invalidGuards.length) {
833
+ const guardPath = [...agentPath, 'guards'];
834
+ errors.push(...invalidGuards.map(({ guardId }, index) => ({
835
+ path: [...guardPath, index, 'guardId'],
836
+ type: 'notFound',
837
+ message: `Invalid guardId "${guardId}"`
838
+ })));
839
+ }
840
+ }
828
841
  }
829
842
  return errors;
830
843
  }
@@ -912,6 +925,22 @@ function validateStructure(schemaVersion, context, schema, ref) {
912
925
  }
913
926
  return { valid: true, schema: schema, errors: undefined };
914
927
  }
928
+ function validateGuards(context, schema) {
929
+ const errors = [];
930
+ if (context.ignoreEntitlements) {
931
+ return errors;
932
+ }
933
+ const numOfGuards = schema['ai-experimental']?.guards ? Object.keys(schema['ai-experimental']?.guards).length : 0;
934
+ const entitledToGuards = context.entitlements.guards ?? 0;
935
+ if (numOfGuards > entitledToGuards) {
936
+ errors.push({
937
+ type: 'entitlement',
938
+ message: `Number of guards exceeds your entitled limit of ${entitledToGuards}`,
939
+ path: ['ai-experimental', 'guards']
940
+ });
941
+ }
942
+ return errors;
943
+ }
915
944
  function formatValidationResult(context, errors, schema) {
916
945
  const { suppressErrorPaths } = context;
917
946
  if (suppressErrorPaths) {
@@ -938,7 +967,8 @@ function validateSyntax(context, schema) {
938
967
  .concat(validateIndexedShapes(context, schema))
939
968
  .concat(validateInterfaces(schema))
940
969
  .concat(validateInterfaceImplementations(schema))
941
- .concat(validateAgents(schema));
970
+ .concat(validateAgents(schema))
971
+ .concat(validateGuards(context, schema));
942
972
  return formatValidationResult(context, errors, schema);
943
973
  }
944
974
  async function validateReferences(context, schema) {
@@ -2,8 +2,6 @@
2
2
  export const CURRENT_SCHEMA_VERSION = '3.50.0';
3
3
  export { default as anyProjectSchema } from './project-schema.json';
4
4
  export { default as latestSchemaJson } from './project-schema/v3.50.0.json';
5
- export { default as authSchemaJson } from './auth-schemas.json';
6
- export { default as experimentalSchemaJson } from './project-schema/experimental.json';
7
5
  import experimentalSchemaJson from './project-schema/experimental.json';
8
6
  import metaSchemaV1_0_0 from './project-schema/meta-schema-v1.0.0.json';
9
7
  import projectSchemaV1_0_0 from './project-schema/v1.0.0.json';