qati-sdk 1.0.1 → 1.0.3

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/dist/index.js CHANGED
@@ -634,7 +634,7 @@ var TrustStateResource = class {
634
634
  /**
635
635
  * Fetches the latest trust state for one entity.
636
636
  *
637
- * @param entityType - Lowercase entity class: `user`, `device`, `account`, `model`, `session`, or `service` (see {@link EntityTypeLowerCase}).
637
+ * @param entityType - Lowercase entity class (see {@link EntityTypeLowerCase}).
638
638
  * @param entityId - Id for the entity(Required)
639
639
  * @param options - Optional contributor limits/window.
640
640
  * @returns {@link TrustState} including `current_closure_score`, `risk_tier`, and `top_contributors`.
@@ -655,7 +655,7 @@ var TrustStateResource = class {
655
655
  /**
656
656
  * Fetches trust states for many entities in one request.
657
657
  *
658
- * @param entityType - Lowercase entity class: `user`, `device`, `account`, `model`, `session`, or `service` (see {@link EntityTypeLowerCase}).
658
+ * @param entityType - Lowercase entity class (see {@link EntityTypeLowerCase}).
659
659
  * @param entityIds - Distinct ids to query. Prefer length ≤ 100 or the server may reject the request.
660
660
  * @param options - Optional contributor limits/window.
661
661
  * @returns Array of {@link TrustState} in server-defined order; empty array when `entityIds` is empty.
@@ -822,8 +822,13 @@ var EventPrincipalSchema = z.object({
822
822
  device_id: z.string().min(1).optional(),
823
823
  session_id: z.string().min(1).optional(),
824
824
  model_id: z.string().min(1).optional(),
825
- service_id: z.string().min(1).optional()
826
- });
825
+ service_id: z.string().min(1).optional(),
826
+ conversation_id: z.string().min(1).optional(),
827
+ document_id: z.string().min(1).optional(),
828
+ tool_id: z.string().min(1).optional(),
829
+ workflow_id: z.string().min(1).optional(),
830
+ api_key_id: z.string().min(1).optional()
831
+ }).strict();
827
832
 
828
833
  // src/v1/schemas/raw-event.ts
829
834
  var BaseEventSchema = z.object({
@@ -892,20 +897,26 @@ var HTTP_METHODS = ["GET", "POST", "PUT", "PATCH", "DELETE"];
892
897
 
893
898
  // src/v1/schemas/api-call.ts
894
899
  var ApiCallSignalPayloadSchema = z.object({
895
- service_id: nonEmptyString(),
896
- endpoint: nonEmptyString(),
897
- method: z.enum(HTTP_METHODS),
898
- status_code: z.number().int().min(100).max(599),
899
- authorized: z.boolean().nullable(),
900
- authentication_present: z.boolean().nullable().optional(),
901
- rate_limited: z.boolean().nullable().optional(),
902
- external_side_effect: z.boolean().nullable().optional(),
903
- records_returned: z.number().int().nonnegative().nullable().optional(),
904
- records_modified: z.number().int().nonnegative().nullable().optional(),
905
- contains_sensitive_data: z.boolean().nullable().optional(),
906
- latency_ms: z.number().nonnegative().nullable().optional(),
907
- retry_count: z.number().int().nonnegative().nullable().optional(),
908
- api_key_id: z.string().nullable().optional()
900
+ service_id: nonEmptyString().describe("Target service identifier."),
901
+ endpoint: nonEmptyString().describe("API route path."),
902
+ method: z.enum(HTTP_METHODS).describe("HTTP method: GET, POST, PUT, PATCH, or DELETE."),
903
+ status_code: z.number().int().min(100).max(599).describe("HTTP response status code."),
904
+ authorized: z.boolean().nullable().describe(
905
+ "Whether the call was authorized; null means authorization is unknown."
906
+ ),
907
+ authentication_present: z.boolean().nullable().optional().describe(
908
+ "Whether authentication credentials were present when known."
909
+ ),
910
+ rate_limited: z.boolean().nullable().optional().describe("Whether the call was rate limited when known."),
911
+ external_side_effect: z.boolean().nullable().optional().describe(
912
+ "Whether the call modifies state outside the caller context when known."
913
+ ),
914
+ records_returned: z.number().int().nonnegative().nullable().optional().describe("Number of records returned when available."),
915
+ records_modified: z.number().int().nonnegative().nullable().optional().describe("Number of records modified when available."),
916
+ contains_sensitive_data: z.boolean().nullable().optional().describe("Whether sensitive data was involved when known."),
917
+ latency_ms: z.number().nonnegative().nullable().optional().describe("API latency in milliseconds when available."),
918
+ retry_count: z.number().int().nonnegative().nullable().optional().describe("Number of retry attempts when available."),
919
+ api_key_id: z.string().nullable().optional().describe("API key identifier used for the call when applicable.")
909
920
  });
910
921
  BaseEventSchema.extend({
911
922
  signal_payload: ApiCallSignalPayloadSchema
@@ -917,16 +928,16 @@ var createApiCallEvent = (event) => {
917
928
  return buildRawEventRequest(event, signalPayload, "API_CALL");
918
929
  };
919
930
  var AuthSignalPayloadSchema = z.object({
920
- result: z.string().nullable().optional(),
921
- auth_method: z.string().nullable().optional(),
922
- mfa_used: z.boolean().nullable().optional(),
931
+ result: z.string().nullable().optional().describe("Auth result (SUCCESS, FAILURE)"),
932
+ auth_method: z.string().nullable().optional().describe("Auth method (PASSWORD, MFA_TOTP, etc.)"),
933
+ mfa_used: z.boolean().nullable().optional().describe("Whether MFA was used"),
923
934
  mfa_bypassed: z.boolean().optional().default(false),
924
935
  failed_attempts: z.number().int().nonnegative().optional().default(0),
925
936
  ip: z.string().nullable().optional(),
926
- country: z.string().nullable().optional(),
937
+ country: z.string().nullable().optional().describe("ISO 3166-1 alpha-2 country code"),
927
938
  user_agent: z.string().nullable().optional(),
928
939
  unusual_location: z.boolean().optional().default(false),
929
- after_hours_login: z.boolean().optional().default(false)
940
+ after_hours_login: z.boolean().optional().default(false).describe("Login outside normal business hours")
930
941
  });
931
942
  BaseEventSchema.extend({
932
943
  signal_payload: AuthSignalPayloadSchema
@@ -962,24 +973,50 @@ var CONTEXT_SOURCES = [
962
973
 
963
974
  // src/v1/schemas/context-integrity.ts
964
975
  var ContextIntegritySignalPayloadSchema = z.object({
965
- context_source: z.enum(CONTEXT_SOURCES),
966
- instruction_conflict_detected: z.boolean(),
967
- untrusted_instruction_detected: z.boolean(),
968
- context_priority_violation: z.boolean(),
969
- recursive_instruction_pattern: z.boolean().optional().default(false),
970
- context_drift_score: fraction01Nullable(),
971
- system_prompt_conflict_score: fraction01Nullable(),
972
- developer_prompt_conflict_score: fraction01Nullable(),
973
- retrieved_instruction_count: z.number().int().nonnegative().optional().default(0),
974
- hidden_instruction_score: fraction01Nullable(),
975
- source_document_id: z.string().nullable().optional(),
976
- untrusted_source_count: z.number().int().nonnegative().optional().default(0),
977
- source_trust_score: fraction01Nullable(),
978
- lowest_source_trust_score: fraction01Nullable(),
979
- recursive_pattern_score: fraction01Nullable(),
980
- prompt_injection_score: fraction01Nullable(),
981
- contains_instruction_override: z.boolean().optional().default(false),
982
- context_injection_score: fraction01Nullable()
976
+ context_source: z.enum(CONTEXT_SOURCES).describe(
977
+ "Origin of the evaluated context: CONVERSATION_HISTORY, RETRIEVED_DOCUMENT, TOOL_OUTPUT, SYSTEM, DEVELOPER, or USER."
978
+ ),
979
+ instruction_conflict_detected: z.boolean().describe("Whether conflicting instructions were detected in context."),
980
+ untrusted_instruction_detected: z.boolean().describe(
981
+ "Whether an untrusted source contains instruction-like text."
982
+ ),
983
+ context_priority_violation: z.boolean().describe(
984
+ "Whether lower-priority context attempts to override higher-priority context."
985
+ ),
986
+ recursive_instruction_pattern: z.boolean().optional().default(false).describe("Whether the context contains a loop or recursive instruction."),
987
+ context_drift_score: fraction01Nullable().describe(
988
+ "0\u20131 context drift score when available."
989
+ ),
990
+ system_prompt_conflict_score: fraction01Nullable().describe(
991
+ "0\u20131 conflict with system prompt intent when available."
992
+ ),
993
+ developer_prompt_conflict_score: fraction01Nullable().describe(
994
+ "0\u20131 conflict with developer prompt intent when available."
995
+ ),
996
+ retrieved_instruction_count: z.number().int().nonnegative().optional().default(0).describe("Count of instruction-like snippets in retrieved context."),
997
+ hidden_instruction_score: fraction01Nullable().describe(
998
+ "0\u20131 likelihood of hidden instructions when available."
999
+ ),
1000
+ source_document_id: z.string().nullable().optional().describe("Related document identifier when applicable."),
1001
+ untrusted_source_count: z.number().int().nonnegative().optional().default(0).describe(
1002
+ "Count of untrusted sources; contributes to untrusted-instruction detection."
1003
+ ),
1004
+ source_trust_score: fraction01Nullable().describe(
1005
+ "0\u20131 trust score for the context source when available."
1006
+ ),
1007
+ lowest_source_trust_score: fraction01Nullable().describe(
1008
+ "0\u20131 lowest trust score among sources when available."
1009
+ ),
1010
+ recursive_pattern_score: fraction01Nullable().describe(
1011
+ "0\u20131 recursive pattern score when available."
1012
+ ),
1013
+ prompt_injection_score: fraction01Nullable().describe(
1014
+ "0\u20131 prompt injection score when available; omit if unknown."
1015
+ ),
1016
+ contains_instruction_override: z.boolean().optional().default(false).describe("Whether the context contains an instruction override."),
1017
+ context_injection_score: fraction01Nullable().describe(
1018
+ "0\u20131 context injection score when available; omit if unknown."
1019
+ )
983
1020
  });
984
1021
  BaseEventSchema.extend({
985
1022
  signal_payload: ContextIntegritySignalPayloadSchema
@@ -995,17 +1032,29 @@ var createContextIntegrityEvent = (event) => {
995
1032
  var ModelOutputSignalPayloadSchema = z.object({
996
1033
  missing_citations_rate: fraction01Nullable(),
997
1034
  citation_rate: fraction01Nullable(),
998
- expected_citation_rate: fraction01Nullable(),
999
- policy_violations: z.number().int().nonnegative().optional().default(0),
1035
+ expected_citation_rate: fraction01Nullable().describe(
1036
+ "Baseline or policy-expected citation rate (use with citation_rate)"
1037
+ ),
1038
+ policy_violations: z.number().int().nonnegative().optional().default(0).describe("Count of policy violations when available."),
1000
1039
  policy_violation_rate: fraction01Nullable(),
1001
1040
  tool_call_inconsistency: fraction01().optional().default(0),
1002
- tool_inconsistency_rate: fraction01Nullable(),
1041
+ tool_inconsistency_rate: fraction01Nullable().describe(
1042
+ "Rate of inconsistent tool calls in the eval window"
1043
+ ),
1003
1044
  tool_miss_rate: fraction01Nullable(),
1004
- eval_window_n: z.number().int().min(1).nullable().optional(),
1005
- hallucination_risk_score: fraction01Nullable(),
1006
- self_contradiction_score: fraction01Nullable(),
1007
- grounding_score: fraction01Nullable(),
1008
- contains_unsupported_claims: z.boolean().optional().default(false)
1045
+ eval_window_n: z.number().int().min(1).nullable().optional().describe("Evaluation window size"),
1046
+ hallucination_risk_score: fraction01Nullable().describe(
1047
+ "0\u20131 hallucination risk when available; omit if unknown."
1048
+ ),
1049
+ self_contradiction_score: fraction01Nullable().describe(
1050
+ "0\u20131 self-contradiction score when available; omit if unknown."
1051
+ ),
1052
+ grounding_score: fraction01Nullable().describe(
1053
+ "0\u20131 grounding score when available; omit if unknown."
1054
+ ),
1055
+ contains_unsupported_claims: z.boolean().optional().default(false).describe(
1056
+ "Whether the output contains unsupported claims; confirm with clients."
1057
+ )
1009
1058
  });
1010
1059
  BaseEventSchema.extend({
1011
1060
  signal_payload: ModelOutputSignalPayloadSchema
@@ -1024,8 +1073,10 @@ var NetworkSignalPayloadSchema = z.object({
1024
1073
  reputation_score: fraction01Nullable(),
1025
1074
  threat_score: fraction01Nullable(),
1026
1075
  is_datacenter: z.boolean().nullable().optional(),
1027
- is_untrusted_segment: z.boolean().optional().default(false),
1028
- asn_reputation: fraction01Nullable()
1076
+ is_untrusted_segment: z.boolean().optional().default(false).describe("Traffic originated from an untrusted network segment"),
1077
+ asn_reputation: fraction01Nullable().describe(
1078
+ "Reputation score for the origin ASN (0\u20131, higher is more trusted)"
1079
+ )
1029
1080
  });
1030
1081
  BaseEventSchema.extend({
1031
1082
  signal_payload: NetworkSignalPayloadSchema
@@ -1050,14 +1101,18 @@ var POLICY_RESULTS = ["PASS", "WARN", "FAIL", "BLOCKED"];
1050
1101
 
1051
1102
  // src/v1/schemas/policy-event.ts
1052
1103
  var PolicyEventSignalPayloadSchema = z.object({
1053
- policy_check_name: nonEmptyString(),
1054
- policy_category: z.enum(POLICY_CATEGORIES),
1055
- policy_result: z.enum(POLICY_RESULTS),
1056
- severity: fraction01(),
1057
- blocked: z.boolean().optional().default(false),
1058
- violation_count: z.number().int().nonnegative().optional().default(0),
1059
- policy_confidence: fraction01Nullable(),
1060
- redaction_applied: z.boolean().optional().default(false)
1104
+ policy_check_name: nonEmptyString().describe("Name of the policy check."),
1105
+ policy_category: z.enum(POLICY_CATEGORIES).describe(
1106
+ "Policy domain: SAFETY, PRIVACY, SECURITY, COMPLIANCE, CONTENT, or OTHER."
1107
+ ),
1108
+ policy_result: z.enum(POLICY_RESULTS).describe("Policy check result: PASS, WARN, FAIL, or BLOCKED."),
1109
+ severity: fraction01().describe("0\u20131 policy event severity."),
1110
+ blocked: z.boolean().optional().default(false).describe("Whether the action or output was blocked."),
1111
+ violation_count: z.number().int().nonnegative().optional().default(0).describe("Count of policy violations when available."),
1112
+ policy_confidence: fraction01Nullable().describe(
1113
+ "0\u20131 policy classifier confidence when available."
1114
+ ),
1115
+ redaction_applied: z.boolean().optional().default(false).describe("Whether content was redacted.")
1061
1116
  });
1062
1117
  BaseEventSchema.extend({
1063
1118
  signal_payload: PolicyEventSignalPayloadSchema
@@ -1070,18 +1125,30 @@ var createPolicyEvent = (event) => {
1070
1125
  );
1071
1126
  return buildRawEventRequest(event, signalPayload, "POLICY_EVENT");
1072
1127
  };
1073
- var promptHashSchema = z.string().regex(/^[a-fA-F0-9]{64}$/).optional();
1128
+ var promptHashSchema = z.string().regex(/^[a-fA-F0-9]{64}$/).optional().describe("Optional SHA-256 hash of prompt text (64 hex characters).");
1074
1129
  var PromptInputSignalPayloadSchema = z.object({
1075
- prompt_length_chars: z.number().int().nonnegative(),
1076
- conversation_turn_index: z.number().int().nonnegative(),
1077
- contains_instruction_override: z.boolean(),
1078
- contains_tool_request: z.boolean().optional().default(false),
1079
- contains_secret_request: z.boolean().optional().default(false),
1080
- contains_policy_challenge: z.boolean().optional().default(false),
1081
- recursive_pattern_score: fraction01Nullable(),
1082
- prompt_injection_score: fraction01Nullable(),
1083
- sensitive_domain: z.boolean().optional().default(false),
1084
- complexity_score: fraction01Nullable(),
1130
+ prompt_length_chars: z.number().int().nonnegative().describe("Prompt size in characters."),
1131
+ conversation_turn_index: z.number().int().nonnegative().describe("Turn number in the conversation."),
1132
+ contains_instruction_override: z.boolean().describe(
1133
+ "Whether the prompt tries to override prior rules or instructions."
1134
+ ),
1135
+ contains_tool_request: z.boolean().optional().default(false).describe("Whether the prompt requests tool or API execution."),
1136
+ contains_secret_request: z.boolean().optional().default(false).describe(
1137
+ "Whether the prompt requests hidden or confidential information."
1138
+ ),
1139
+ contains_policy_challenge: z.boolean().optional().default(false).describe("Whether the prompt challenges rules, safety, or policy."),
1140
+ recursive_pattern_score: fraction01Nullable().describe(
1141
+ "0\u20131 recursive or looping structure score; omit or null to treat as 0.0."
1142
+ ),
1143
+ prompt_injection_score: fraction01Nullable().describe(
1144
+ "0\u20131 prompt-injection likelihood score; omit or null to treat as 0.0."
1145
+ ),
1146
+ sensitive_domain: z.boolean().optional().default(false).describe(
1147
+ "Whether the prompt targets a sensitive domain (finance, health, legal, cybersecurity, etc.)."
1148
+ ),
1149
+ complexity_score: fraction01Nullable().describe(
1150
+ "0\u20131 prompt complexity or ambiguity score; omit or null to treat as 0.0."
1151
+ ),
1085
1152
  prompt_hash: promptHashSchema
1086
1153
  });
1087
1154
  BaseEventSchema.extend({
@@ -1096,17 +1163,25 @@ var createPromptInputEvent = (event) => {
1096
1163
  return buildRawEventRequest(event, signalPayload, "PROMPT_INPUT");
1097
1164
  };
1098
1165
  var RagRetrievalSignalPayloadSchema = z.object({
1099
- retriever_id: nonEmptyString(),
1100
- query_hash: z.string().nullable().optional(),
1101
- documents_retrieved: z.number().int().nonnegative(),
1102
- top_k: z.number().int().min(1),
1103
- average_relevance_score: fraction01(),
1104
- source_trust_score: fraction01(),
1105
- lowest_source_trust_score: fraction01Nullable(),
1106
- untrusted_source_count: z.number().int().nonnegative().optional().default(0),
1107
- retrieved_context_tokens: z.number().int().nonnegative().optional().default(0),
1108
- context_injection_score: fraction01().optional().default(0),
1109
- document_ids: z.array(z.string()).optional().default([])
1166
+ retriever_id: nonEmptyString().describe("Retriever service identifier."),
1167
+ query_hash: z.string().nullable().optional().describe("Hash of the retrieval query when available."),
1168
+ documents_retrieved: z.number().int().nonnegative().describe("Number of documents retrieved."),
1169
+ top_k: z.number().int().min(1).describe("Requested top-k document count."),
1170
+ average_relevance_score: fraction01().describe(
1171
+ "0\u20131 average relevance score across retrieved documents."
1172
+ ),
1173
+ source_trust_score: fraction01().describe(
1174
+ "0\u20131 average trust score across retrieved sources."
1175
+ ),
1176
+ lowest_source_trust_score: fraction01Nullable().describe(
1177
+ "0\u20131 weakest source trust score when available."
1178
+ ),
1179
+ untrusted_source_count: z.number().int().nonnegative().optional().default(0).describe("Count of low-trust or untrusted retrieved sources."),
1180
+ retrieved_context_tokens: z.number().int().nonnegative().optional().default(0).describe("Total retrieved context token count when available."),
1181
+ context_injection_score: fraction01().optional().default(0).describe(
1182
+ "0\u20131 context injection risk score; use 0.0 when unavailable."
1183
+ ),
1184
+ document_ids: z.array(z.string()).optional().default([]).describe("Identifiers for retrieved documents when available.")
1110
1185
  });
1111
1186
  BaseEventSchema.extend({
1112
1187
  signal_payload: RagRetrievalSignalPayloadSchema
@@ -1131,16 +1206,18 @@ var SESSION_STATUSES = [
1131
1206
 
1132
1207
  // src/v1/schemas/session.ts
1133
1208
  var SessionSignalPayloadSchema = z.object({
1134
- session_status: z.enum(SESSION_STATUSES),
1135
- session_age_seconds: z.number().nonnegative().optional().default(0),
1136
- turn_count: z.number().int().nonnegative().optional().default(0),
1137
- messages_last_minute: z.number().nonnegative().optional().default(0),
1138
- avg_seconds_between_turns: z.number().nonnegative().nullable().optional(),
1139
- restart_count_10m: z.number().int().nonnegative().optional().default(0),
1140
- session_timeout: z.boolean().optional().default(false),
1141
- abandoned: z.boolean().optional().default(false),
1142
- conversation_id: z.string().nullable().optional(),
1143
- user_id: z.string().nullable().optional()
1209
+ session_status: z.enum(SESSION_STATUSES).describe(
1210
+ "Session lifecycle status: STARTED, ACTIVE, ENDED, TIMEOUT, or ABANDONED."
1211
+ ),
1212
+ session_age_seconds: z.number().nonnegative().optional().default(0).describe("Current duration of the session in seconds."),
1213
+ turn_count: z.number().int().nonnegative().optional().default(0).describe("Number of user/model turns in the session."),
1214
+ messages_last_minute: z.number().nonnegative().optional().default(0).describe("Prompt or message rate over the last minute."),
1215
+ avg_seconds_between_turns: z.number().nonnegative().nullable().optional().describe("Average interaction cadence between turns in seconds."),
1216
+ restart_count_10m: z.number().int().nonnegative().optional().default(0).describe("How often the user restarted sessions in the last 10 minutes."),
1217
+ session_timeout: z.boolean().optional().default(false).describe("Whether the session ended due to a timeout."),
1218
+ abandoned: z.boolean().optional().default(false).describe("Whether the session ended abruptly without a clean close."),
1219
+ conversation_id: z.string().nullable().optional().describe("Related conversation identifier when available."),
1220
+ user_id: z.string().nullable().optional().describe("Related user identifier when available.")
1144
1221
  });
1145
1222
  BaseEventSchema.extend({
1146
1223
  signal_payload: SessionSignalPayloadSchema
@@ -1157,11 +1234,19 @@ var SystemTelemetrySignalPayloadSchema = z.object({
1157
1234
  baseline: z.number().nullable().optional(),
1158
1235
  window_seconds: z.number().int().min(1).nullable().optional(),
1159
1236
  error_rate: fraction01().optional().default(0),
1160
- baseline_error_rate: fraction01Nullable(),
1237
+ baseline_error_rate: fraction01Nullable().describe(
1238
+ "Expected or steady-state error rate (excess over this drives impact)"
1239
+ ),
1161
1240
  unusual_auth_rate: fraction01().optional().default(0),
1162
- firmware_hash_changed: z.boolean().optional().default(false),
1163
- expected_hash_match: z.boolean().nullable().optional(),
1164
- sensor_deviation_score: fraction01Nullable()
1241
+ firmware_hash_changed: z.boolean().optional().default(false).describe(
1242
+ "Device or component firmware hash differs from prior observation"
1243
+ ),
1244
+ expected_hash_match: z.boolean().nullable().optional().describe(
1245
+ "True if hash matched expected; False if mismatch; omit if unknown"
1246
+ ),
1247
+ sensor_deviation_score: fraction01Nullable().describe(
1248
+ "Normalized deviation of sensor readings from baseline"
1249
+ )
1165
1250
  });
1166
1251
  BaseEventSchema.extend({
1167
1252
  signal_payload: SystemTelemetrySignalPayloadSchema
@@ -1189,24 +1274,38 @@ var TOOL_CATEGORIES = [
1189
1274
 
1190
1275
  // src/v1/schemas/tool-call.ts
1191
1276
  var ToolCallSignalPayloadSchema = z.object({
1192
- tool_name: nonEmptyString(),
1193
- tool_category: z.enum(TOOL_CATEGORIES),
1194
- action: nonEmptyString(),
1195
- authorized: z.boolean().nullable(),
1196
- safety_critical: z.boolean(),
1197
- external_side_effect: z.boolean(),
1198
- tool_call_success: z.boolean().nullable().optional(),
1199
- latency_ms: z.number().nonnegative().nullable().optional(),
1200
- error_code: z.string().nullable().optional(),
1201
- argument_risk_score: fraction01Nullable(),
1202
- result_size_bytes: z.number().int().nonnegative().nullable().optional(),
1203
- records_accessed: z.number().int().nonnegative().optional().default(0),
1204
- contains_sensitive_data: z.boolean().optional().default(false),
1205
- action_category: z.string().nullable().optional(),
1206
- method: z.string().nullable().optional(),
1207
- sensitive_data_involved: z.boolean().optional().default(false),
1208
- contains_phi: z.boolean().optional().default(false),
1209
- sensitive_domain: z.boolean().optional().default(false)
1277
+ tool_name: nonEmptyString().describe("Tool identifier."),
1278
+ tool_category: z.enum(TOOL_CATEGORIES).describe(
1279
+ "Tool category: RETRIEVAL, DATABASE, PAYMENT, MESSAGING, CODE_EXECUTION, FILE, EXTERNAL_API, or OTHER."
1280
+ ),
1281
+ action: nonEmptyString().describe("Action attempted by the tool call."),
1282
+ authorized: z.boolean().nullable().describe(
1283
+ "Whether policy allowed the tool call; null means authorization is unknown."
1284
+ ),
1285
+ safety_critical: z.boolean().describe("Whether the call can create serious consequences."),
1286
+ external_side_effect: z.boolean().describe(
1287
+ "Whether the action changes state outside the model context."
1288
+ ),
1289
+ tool_call_success: z.boolean().nullable().optional().describe("Whether the tool call succeeded when known."),
1290
+ latency_ms: z.number().nonnegative().nullable().optional().describe("Tool latency in milliseconds when available."),
1291
+ error_code: z.string().nullable().optional().describe("Error code when the tool call failed."),
1292
+ argument_risk_score: fraction01Nullable().describe(
1293
+ "0\u20131 risk score for tool call arguments when available."
1294
+ ),
1295
+ result_size_bytes: z.number().int().nonnegative().nullable().optional().describe("Size of returned data in bytes when available."),
1296
+ records_accessed: z.number().int().nonnegative().optional().default(0).describe("Number of records touched by the call when available."),
1297
+ contains_sensitive_data: z.boolean().optional().default(false).describe("Whether sensitive data was returned or touched."),
1298
+ action_category: z.string().nullable().optional().describe(
1299
+ "Risk category for the attempted action (e.g. SECURITY, CODE, FINANCIAL, ADMIN) when available."
1300
+ ),
1301
+ method: z.string().nullable().optional().describe("HTTP or RPC method for the tool call when applicable."),
1302
+ sensitive_data_involved: z.boolean().optional().default(false).describe(
1303
+ "Whether sensitive data was involved in the request or result."
1304
+ ),
1305
+ contains_phi: z.boolean().optional().default(false).describe(
1306
+ "Whether protected health information was returned or touched."
1307
+ ),
1308
+ sensitive_domain: z.boolean().optional().default(false).describe("Whether the tool call applies to a sensitive domain.")
1210
1309
  });
1211
1310
  BaseEventSchema.extend({
1212
1311
  signal_payload: ToolCallSignalPayloadSchema
@@ -1218,27 +1317,29 @@ var createToolCallEvent = (event) => {
1218
1317
  return buildRawEventRequest(event, signalPayload, "TOOL_CALL");
1219
1318
  };
1220
1319
  var TransactionSignalPayloadSchema = z.object({
1221
- amount: z.number().nonnegative().default(0),
1222
- amount_minor: z.number().int().nonnegative().nullable().optional(),
1223
- amount_usd: z.number().nonnegative().nullable().optional(),
1224
- currency: z.string().nullable().optional(),
1320
+ amount: z.number().nonnegative().default(0).describe("Transaction amount in base currency"),
1321
+ amount_minor: z.number().int().nonnegative().nullable().optional().describe("Transaction amount in minor units (e.g. cents)"),
1322
+ amount_usd: z.number().nonnegative().nullable().optional().describe("Transaction amount normalized to USD"),
1323
+ currency: z.string().nullable().optional().describe("ISO 4217 currency code"),
1225
1324
  merchant_category: z.string().nullable().optional(),
1226
1325
  merchant_id: z.string().nullable().optional(),
1227
- channel: z.string().nullable().optional(),
1228
- country: z.string().nullable().optional(),
1229
- velocity: z.number().nonnegative().nullable().optional(),
1230
- external_anomaly_score: z.number().nullable().optional(),
1231
- geo_distance: z.number().nonnegative().nullable().optional(),
1232
- geo_distance_km: z.number().nonnegative().nullable().optional(),
1233
- records_accessed: z.number().int().nonnegative().nullable().optional(),
1234
- baseline_records_accessed: z.number().int().nonnegative().nullable().optional(),
1235
- sensitivity_level: z.string().nullable().optional(),
1236
- export_count: z.number().int().nonnegative().nullable().optional(),
1237
- bulk_export: z.boolean().optional().default(false),
1238
- contains_phi: z.boolean().optional().default(false),
1239
- control_command: z.string().nullable().optional(),
1240
- authorized: z.boolean().nullable().optional(),
1241
- safety_critical: z.boolean().optional().default(false)
1326
+ channel: z.string().nullable().optional().describe("Transaction channel (WEB, MOBILE, ECOM)"),
1327
+ country: z.string().nullable().optional().describe("ISO 3166-1 alpha-2 country code"),
1328
+ velocity: z.number().nonnegative().nullable().optional().describe("Transactions per minute"),
1329
+ external_anomaly_score: z.number().nullable().optional().describe(
1330
+ "Externally supplied anomaly score. When present, bypasses the internal extraction formula and is used directly as raw_value."
1331
+ ),
1332
+ geo_distance: z.number().nonnegative().nullable().optional().describe("Distance in km from usual location"),
1333
+ geo_distance_km: z.number().nonnegative().nullable().optional().describe("Distance in km from usual location"),
1334
+ records_accessed: z.number().int().nonnegative().nullable().optional().describe("Count of records touched in this transaction"),
1335
+ baseline_records_accessed: z.number().int().nonnegative().nullable().optional().describe("Typical or policy baseline record count for comparison"),
1336
+ sensitivity_level: z.string().nullable().optional().describe("Data sensitivity (e.g. LOW, MEDIUM, HIGH)"),
1337
+ export_count: z.number().int().nonnegative().nullable().optional().describe("Number of export operations"),
1338
+ bulk_export: z.boolean().optional().default(false).describe("Whether this is a bulk export"),
1339
+ contains_phi: z.boolean().optional().default(false).describe("Whether exported or accessed data includes PHI"),
1340
+ control_command: z.string().nullable().optional().describe("Issued control or OT command (e.g. VALVE_OPEN)"),
1341
+ authorized: z.boolean().nullable().optional().describe("Whether the action was authorized; omit if unknown"),
1342
+ safety_critical: z.boolean().optional().default(false).describe("Whether the transaction affects safety-critical systems")
1242
1343
  });
1243
1344
  BaseEventSchema.extend({
1244
1345
  signal_payload: TransactionSignalPayloadSchema
@@ -1271,13 +1372,19 @@ var FEEDBACK_ISSUE_TYPES = [
1271
1372
 
1272
1373
  // src/v1/schemas/user-feedback.ts
1273
1374
  var UserFeedbackSignalPayloadSchema = z.object({
1274
- feedback_type: z.enum(FEEDBACK_TYPES),
1275
- rating: z.number().nullable().optional(),
1276
- reported_issue: z.boolean().optional().default(false),
1277
- issue_type: z.enum(FEEDBACK_ISSUE_TYPES).nullable().optional(),
1278
- severity: fraction01Nullable(),
1279
- response_id: z.string().nullable().optional(),
1280
- user_comment_hash: z.string().nullable().optional()
1375
+ feedback_type: z.enum(FEEDBACK_TYPES).describe(
1376
+ "User feedback category: THUMBS_UP, THUMBS_DOWN, REPORT, CORRECTION, or RATING."
1377
+ ),
1378
+ rating: z.number().nullable().optional().describe("Optional rating in [-1, 1] or on a 1\u20135 scale."),
1379
+ reported_issue: z.boolean().optional().default(false).describe("Whether the user reported a problem."),
1380
+ issue_type: z.enum(FEEDBACK_ISSUE_TYPES).nullable().optional().describe(
1381
+ "Category of the reported issue: hallucination, unsafe, irrelevant, privacy, offensive, or other."
1382
+ ),
1383
+ severity: fraction01Nullable().describe(
1384
+ "0\u20131 user-reported severity when available."
1385
+ ),
1386
+ response_id: z.string().nullable().optional().describe("Identifier of the response being evaluated."),
1387
+ user_comment_hash: z.string().nullable().optional().describe("Hash of optional user comment when available.")
1281
1388
  });
1282
1389
  BaseEventSchema.extend({
1283
1390
  signal_payload: UserFeedbackSignalPayloadSchema
@@ -1312,22 +1419,28 @@ var WORKFLOW_ACTOR_TYPES = ["USER", "AI_AGENT", "SYSTEM"];
1312
1419
 
1313
1420
  // src/v1/schemas/workflow-action.ts
1314
1421
  var WorkflowActionSignalPayloadSchema = z.object({
1315
- workflow_id: nonEmptyString(),
1316
- workflow_type: nonEmptyString(),
1317
- action_name: nonEmptyString(),
1318
- action_category: z.enum(WORKFLOW_ACTION_CATEGORIES),
1319
- action_stage: z.enum(WORKFLOW_ACTION_STAGES),
1320
- actor_type: z.enum(WORKFLOW_ACTOR_TYPES),
1321
- requires_approval: z.boolean().optional().default(false),
1322
- approval_present: z.boolean().optional().default(false),
1323
- external_side_effect: z.boolean().nullable().optional(),
1324
- safety_critical: z.boolean().nullable().optional(),
1325
- amount_usd: z.number().nonnegative().nullable().optional(),
1326
- sensitive_data_involved: z.boolean().optional().default(false),
1327
- new_counterparty: z.boolean().optional().default(false),
1328
- is_new_vendor: z.boolean().optional().default(false),
1329
- is_new_recipient: z.boolean().optional().default(false),
1330
- is_new_endpoint: z.boolean().optional().default(false)
1422
+ workflow_id: nonEmptyString().describe("Workflow identifier."),
1423
+ workflow_type: nonEmptyString().describe("Type of workflow."),
1424
+ action_name: nonEmptyString().describe("Workflow action attempted."),
1425
+ action_category: z.enum(WORKFLOW_ACTION_CATEGORIES).describe(
1426
+ "Risk category: FINANCIAL, DATA_ACCESS, COMMUNICATION, ADMIN, SECURITY, CODE, or OTHER."
1427
+ ),
1428
+ action_stage: z.enum(WORKFLOW_ACTION_STAGES).describe(
1429
+ "Lifecycle stage: PROPOSED, PRE_EXECUTION, EXECUTED, FAILED, or ROLLED_BACK."
1430
+ ),
1431
+ actor_type: z.enum(WORKFLOW_ACTOR_TYPES).describe("Who initiated the action: USER, AI_AGENT, or SYSTEM."),
1432
+ requires_approval: z.boolean().optional().default(false).describe("Whether approval is required before execution."),
1433
+ approval_present: z.boolean().optional().default(false).describe("Whether required approval is present."),
1434
+ external_side_effect: z.boolean().nullable().optional().describe("Whether the action changes external state when known."),
1435
+ safety_critical: z.boolean().nullable().optional().describe(
1436
+ "Whether the action is safety, security, or business critical when known."
1437
+ ),
1438
+ amount_usd: z.number().nonnegative().nullable().optional().describe("Financial magnitude in USD when applicable."),
1439
+ sensitive_data_involved: z.boolean().optional().default(false).describe("Whether sensitive data was touched."),
1440
+ new_counterparty: z.boolean().optional().default(false).describe("Whether a new vendor, customer, or recipient is involved."),
1441
+ is_new_vendor: z.boolean().optional().default(false).describe("Whether the action involves a new vendor."),
1442
+ is_new_recipient: z.boolean().optional().default(false).describe("Whether the action involves a new recipient."),
1443
+ is_new_endpoint: z.boolean().optional().default(false).describe("Whether the action targets a new endpoint.")
1331
1444
  });
1332
1445
  BaseEventSchema.extend({
1333
1446
  signal_payload: WorkflowActionSignalPayloadSchema