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