qati-sdk 1.0.2 → 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.cjs +259 -151
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +259 -151
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -897,20 +897,26 @@ var HTTP_METHODS = ["GET", "POST", "PUT", "PATCH", "DELETE"];
|
|
|
897
897
|
|
|
898
898
|
// src/v1/schemas/api-call.ts
|
|
899
899
|
var ApiCallSignalPayloadSchema = z.object({
|
|
900
|
-
service_id: nonEmptyString(),
|
|
901
|
-
endpoint: nonEmptyString(),
|
|
902
|
-
method: z.enum(HTTP_METHODS),
|
|
903
|
-
status_code: z.number().int().min(100).max(599),
|
|
904
|
-
authorized: z.boolean().nullable()
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
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.")
|
|
914
920
|
});
|
|
915
921
|
BaseEventSchema.extend({
|
|
916
922
|
signal_payload: ApiCallSignalPayloadSchema
|
|
@@ -922,16 +928,16 @@ var createApiCallEvent = (event) => {
|
|
|
922
928
|
return buildRawEventRequest(event, signalPayload, "API_CALL");
|
|
923
929
|
};
|
|
924
930
|
var AuthSignalPayloadSchema = z.object({
|
|
925
|
-
result: z.string().nullable().optional(),
|
|
926
|
-
auth_method: z.string().nullable().optional(),
|
|
927
|
-
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"),
|
|
928
934
|
mfa_bypassed: z.boolean().optional().default(false),
|
|
929
935
|
failed_attempts: z.number().int().nonnegative().optional().default(0),
|
|
930
936
|
ip: z.string().nullable().optional(),
|
|
931
|
-
country: z.string().nullable().optional(),
|
|
937
|
+
country: z.string().nullable().optional().describe("ISO 3166-1 alpha-2 country code"),
|
|
932
938
|
user_agent: z.string().nullable().optional(),
|
|
933
939
|
unusual_location: z.boolean().optional().default(false),
|
|
934
|
-
after_hours_login: z.boolean().optional().default(false)
|
|
940
|
+
after_hours_login: z.boolean().optional().default(false).describe("Login outside normal business hours")
|
|
935
941
|
});
|
|
936
942
|
BaseEventSchema.extend({
|
|
937
943
|
signal_payload: AuthSignalPayloadSchema
|
|
@@ -967,24 +973,50 @@ var CONTEXT_SOURCES = [
|
|
|
967
973
|
|
|
968
974
|
// src/v1/schemas/context-integrity.ts
|
|
969
975
|
var ContextIntegritySignalPayloadSchema = z.object({
|
|
970
|
-
context_source: z.enum(CONTEXT_SOURCES)
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
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
|
+
)
|
|
988
1020
|
});
|
|
989
1021
|
BaseEventSchema.extend({
|
|
990
1022
|
signal_payload: ContextIntegritySignalPayloadSchema
|
|
@@ -1000,17 +1032,29 @@ var createContextIntegrityEvent = (event) => {
|
|
|
1000
1032
|
var ModelOutputSignalPayloadSchema = z.object({
|
|
1001
1033
|
missing_citations_rate: fraction01Nullable(),
|
|
1002
1034
|
citation_rate: fraction01Nullable(),
|
|
1003
|
-
expected_citation_rate: fraction01Nullable()
|
|
1004
|
-
|
|
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."),
|
|
1005
1039
|
policy_violation_rate: fraction01Nullable(),
|
|
1006
1040
|
tool_call_inconsistency: fraction01().optional().default(0),
|
|
1007
|
-
tool_inconsistency_rate: fraction01Nullable()
|
|
1041
|
+
tool_inconsistency_rate: fraction01Nullable().describe(
|
|
1042
|
+
"Rate of inconsistent tool calls in the eval window"
|
|
1043
|
+
),
|
|
1008
1044
|
tool_miss_rate: fraction01Nullable(),
|
|
1009
|
-
eval_window_n: z.number().int().min(1).nullable().optional(),
|
|
1010
|
-
hallucination_risk_score: fraction01Nullable()
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
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
|
+
)
|
|
1014
1058
|
});
|
|
1015
1059
|
BaseEventSchema.extend({
|
|
1016
1060
|
signal_payload: ModelOutputSignalPayloadSchema
|
|
@@ -1029,8 +1073,10 @@ var NetworkSignalPayloadSchema = z.object({
|
|
|
1029
1073
|
reputation_score: fraction01Nullable(),
|
|
1030
1074
|
threat_score: fraction01Nullable(),
|
|
1031
1075
|
is_datacenter: z.boolean().nullable().optional(),
|
|
1032
|
-
is_untrusted_segment: z.boolean().optional().default(false),
|
|
1033
|
-
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
|
+
)
|
|
1034
1080
|
});
|
|
1035
1081
|
BaseEventSchema.extend({
|
|
1036
1082
|
signal_payload: NetworkSignalPayloadSchema
|
|
@@ -1055,14 +1101,18 @@ var POLICY_RESULTS = ["PASS", "WARN", "FAIL", "BLOCKED"];
|
|
|
1055
1101
|
|
|
1056
1102
|
// src/v1/schemas/policy-event.ts
|
|
1057
1103
|
var PolicyEventSignalPayloadSchema = z.object({
|
|
1058
|
-
policy_check_name: nonEmptyString(),
|
|
1059
|
-
policy_category: z.enum(POLICY_CATEGORIES)
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
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.")
|
|
1066
1116
|
});
|
|
1067
1117
|
BaseEventSchema.extend({
|
|
1068
1118
|
signal_payload: PolicyEventSignalPayloadSchema
|
|
@@ -1075,18 +1125,30 @@ var createPolicyEvent = (event) => {
|
|
|
1075
1125
|
);
|
|
1076
1126
|
return buildRawEventRequest(event, signalPayload, "POLICY_EVENT");
|
|
1077
1127
|
};
|
|
1078
|
-
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).");
|
|
1079
1129
|
var PromptInputSignalPayloadSchema = z.object({
|
|
1080
|
-
prompt_length_chars: z.number().int().nonnegative(),
|
|
1081
|
-
conversation_turn_index: z.number().int().nonnegative(),
|
|
1082
|
-
contains_instruction_override: z.boolean()
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
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
|
+
),
|
|
1090
1152
|
prompt_hash: promptHashSchema
|
|
1091
1153
|
});
|
|
1092
1154
|
BaseEventSchema.extend({
|
|
@@ -1101,17 +1163,25 @@ var createPromptInputEvent = (event) => {
|
|
|
1101
1163
|
return buildRawEventRequest(event, signalPayload, "PROMPT_INPUT");
|
|
1102
1164
|
};
|
|
1103
1165
|
var RagRetrievalSignalPayloadSchema = z.object({
|
|
1104
|
-
retriever_id: nonEmptyString(),
|
|
1105
|
-
query_hash: z.string().nullable().optional(),
|
|
1106
|
-
documents_retrieved: z.number().int().nonnegative(),
|
|
1107
|
-
top_k: z.number().int().min(1),
|
|
1108
|
-
average_relevance_score: fraction01()
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
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.")
|
|
1115
1185
|
});
|
|
1116
1186
|
BaseEventSchema.extend({
|
|
1117
1187
|
signal_payload: RagRetrievalSignalPayloadSchema
|
|
@@ -1136,16 +1206,18 @@ var SESSION_STATUSES = [
|
|
|
1136
1206
|
|
|
1137
1207
|
// src/v1/schemas/session.ts
|
|
1138
1208
|
var SessionSignalPayloadSchema = z.object({
|
|
1139
|
-
session_status: z.enum(SESSION_STATUSES)
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
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.")
|
|
1149
1221
|
});
|
|
1150
1222
|
BaseEventSchema.extend({
|
|
1151
1223
|
signal_payload: SessionSignalPayloadSchema
|
|
@@ -1162,11 +1234,19 @@ var SystemTelemetrySignalPayloadSchema = z.object({
|
|
|
1162
1234
|
baseline: z.number().nullable().optional(),
|
|
1163
1235
|
window_seconds: z.number().int().min(1).nullable().optional(),
|
|
1164
1236
|
error_rate: fraction01().optional().default(0),
|
|
1165
|
-
baseline_error_rate: fraction01Nullable()
|
|
1237
|
+
baseline_error_rate: fraction01Nullable().describe(
|
|
1238
|
+
"Expected or steady-state error rate (excess over this drives impact)"
|
|
1239
|
+
),
|
|
1166
1240
|
unusual_auth_rate: fraction01().optional().default(0),
|
|
1167
|
-
firmware_hash_changed: z.boolean().optional().default(false)
|
|
1168
|
-
|
|
1169
|
-
|
|
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
|
+
)
|
|
1170
1250
|
});
|
|
1171
1251
|
BaseEventSchema.extend({
|
|
1172
1252
|
signal_payload: SystemTelemetrySignalPayloadSchema
|
|
@@ -1194,24 +1274,38 @@ var TOOL_CATEGORIES = [
|
|
|
1194
1274
|
|
|
1195
1275
|
// src/v1/schemas/tool-call.ts
|
|
1196
1276
|
var ToolCallSignalPayloadSchema = z.object({
|
|
1197
|
-
tool_name: nonEmptyString(),
|
|
1198
|
-
tool_category: z.enum(TOOL_CATEGORIES)
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
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.")
|
|
1215
1309
|
});
|
|
1216
1310
|
BaseEventSchema.extend({
|
|
1217
1311
|
signal_payload: ToolCallSignalPayloadSchema
|
|
@@ -1223,27 +1317,29 @@ var createToolCallEvent = (event) => {
|
|
|
1223
1317
|
return buildRawEventRequest(event, signalPayload, "TOOL_CALL");
|
|
1224
1318
|
};
|
|
1225
1319
|
var TransactionSignalPayloadSchema = z.object({
|
|
1226
|
-
amount: z.number().nonnegative().default(0),
|
|
1227
|
-
amount_minor: z.number().int().nonnegative().nullable().optional(),
|
|
1228
|
-
amount_usd: z.number().nonnegative().nullable().optional(),
|
|
1229
|
-
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"),
|
|
1230
1324
|
merchant_category: z.string().nullable().optional(),
|
|
1231
1325
|
merchant_id: z.string().nullable().optional(),
|
|
1232
|
-
channel: z.string().nullable().optional(),
|
|
1233
|
-
country: z.string().nullable().optional(),
|
|
1234
|
-
velocity: z.number().nonnegative().nullable().optional(),
|
|
1235
|
-
external_anomaly_score: z.number().nullable().optional()
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
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")
|
|
1247
1343
|
});
|
|
1248
1344
|
BaseEventSchema.extend({
|
|
1249
1345
|
signal_payload: TransactionSignalPayloadSchema
|
|
@@ -1276,13 +1372,19 @@ var FEEDBACK_ISSUE_TYPES = [
|
|
|
1276
1372
|
|
|
1277
1373
|
// src/v1/schemas/user-feedback.ts
|
|
1278
1374
|
var UserFeedbackSignalPayloadSchema = z.object({
|
|
1279
|
-
feedback_type: z.enum(FEEDBACK_TYPES)
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
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.")
|
|
1286
1388
|
});
|
|
1287
1389
|
BaseEventSchema.extend({
|
|
1288
1390
|
signal_payload: UserFeedbackSignalPayloadSchema
|
|
@@ -1317,22 +1419,28 @@ var WORKFLOW_ACTOR_TYPES = ["USER", "AI_AGENT", "SYSTEM"];
|
|
|
1317
1419
|
|
|
1318
1420
|
// src/v1/schemas/workflow-action.ts
|
|
1319
1421
|
var WorkflowActionSignalPayloadSchema = z.object({
|
|
1320
|
-
workflow_id: nonEmptyString(),
|
|
1321
|
-
workflow_type: nonEmptyString(),
|
|
1322
|
-
action_name: nonEmptyString(),
|
|
1323
|
-
action_category: z.enum(WORKFLOW_ACTION_CATEGORIES)
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
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.")
|
|
1336
1444
|
});
|
|
1337
1445
|
BaseEventSchema.extend({
|
|
1338
1446
|
signal_payload: WorkflowActionSignalPayloadSchema
|