@safenest/sdk 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +601 -0
- package/dist/client.d.ts +228 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +536 -0
- package/dist/client.js.map +1 -0
- package/dist/constants.d.ts +127 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +160 -0
- package/dist/constants.js.map +1 -0
- package/dist/errors.d.ts +52 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +87 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/types/analysis.d.ts +39 -0
- package/dist/types/analysis.d.ts.map +1 -0
- package/dist/types/analysis.js +4 -0
- package/dist/types/analysis.js.map +1 -0
- package/dist/types/guidance.d.ts +33 -0
- package/dist/types/guidance.d.ts.map +1 -0
- package/dist/types/guidance.js +2 -0
- package/dist/types/guidance.js.map +1 -0
- package/dist/types/index.d.ts +55 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +7 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/policy.d.ts +54 -0
- package/dist/types/policy.d.ts.map +1 -0
- package/dist/types/policy.js +5 -0
- package/dist/types/policy.js.map +1 -0
- package/dist/types/reports.d.ts +42 -0
- package/dist/types/reports.d.ts.map +1 -0
- package/dist/types/reports.js +2 -0
- package/dist/types/reports.js.map +1 -0
- package/dist/types/safety.d.ts +135 -0
- package/dist/types/safety.d.ts.map +1 -0
- package/dist/types/safety.js +4 -0
- package/dist/types/safety.js.map +1 -0
- package/dist/utils/retry.d.ts +17 -0
- package/dist/utils/retry.d.ts.map +1 -0
- package/dist/utils/retry.js +61 -0
- package/dist/utils/retry.js.map +1 -0
- package/package.json +67 -0
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SafeNest SDK Constants
|
|
3
|
+
* Mirrors the server-side constants for consistency
|
|
4
|
+
*/
|
|
5
|
+
// =============================================================================
|
|
6
|
+
// Safety Analysis Enums
|
|
7
|
+
// =============================================================================
|
|
8
|
+
/**
|
|
9
|
+
* Severity levels used across safety detection
|
|
10
|
+
*/
|
|
11
|
+
export var Severity;
|
|
12
|
+
(function (Severity) {
|
|
13
|
+
Severity["LOW"] = "low";
|
|
14
|
+
Severity["MEDIUM"] = "medium";
|
|
15
|
+
Severity["HIGH"] = "high";
|
|
16
|
+
Severity["CRITICAL"] = "critical";
|
|
17
|
+
})(Severity || (Severity = {}));
|
|
18
|
+
/**
|
|
19
|
+
* Grooming risk levels
|
|
20
|
+
*/
|
|
21
|
+
export var GroomingRisk;
|
|
22
|
+
(function (GroomingRisk) {
|
|
23
|
+
GroomingRisk["NONE"] = "none";
|
|
24
|
+
GroomingRisk["LOW"] = "low";
|
|
25
|
+
GroomingRisk["MEDIUM"] = "medium";
|
|
26
|
+
GroomingRisk["HIGH"] = "high";
|
|
27
|
+
GroomingRisk["CRITICAL"] = "critical";
|
|
28
|
+
})(GroomingRisk || (GroomingRisk = {}));
|
|
29
|
+
/**
|
|
30
|
+
* Risk levels for incidents (uses "moderate" instead of "medium" for clarity)
|
|
31
|
+
*/
|
|
32
|
+
export var RiskLevel;
|
|
33
|
+
(function (RiskLevel) {
|
|
34
|
+
RiskLevel["LOW"] = "low";
|
|
35
|
+
RiskLevel["MODERATE"] = "moderate";
|
|
36
|
+
RiskLevel["HIGH"] = "high";
|
|
37
|
+
RiskLevel["CRITICAL"] = "critical";
|
|
38
|
+
})(RiskLevel || (RiskLevel = {}));
|
|
39
|
+
/**
|
|
40
|
+
* Risk categories for incidents
|
|
41
|
+
*/
|
|
42
|
+
export var RiskCategory;
|
|
43
|
+
(function (RiskCategory) {
|
|
44
|
+
RiskCategory["BULLYING"] = "bullying";
|
|
45
|
+
RiskCategory["GROOMING"] = "grooming";
|
|
46
|
+
RiskCategory["UNSAFE"] = "unsafe";
|
|
47
|
+
RiskCategory["SELF_HARM"] = "self_harm";
|
|
48
|
+
RiskCategory["OTHER"] = "other";
|
|
49
|
+
})(RiskCategory || (RiskCategory = {}));
|
|
50
|
+
/**
|
|
51
|
+
* Analysis/detection types
|
|
52
|
+
*/
|
|
53
|
+
export var AnalysisType;
|
|
54
|
+
(function (AnalysisType) {
|
|
55
|
+
AnalysisType["BULLYING"] = "bullying";
|
|
56
|
+
AnalysisType["GROOMING"] = "grooming";
|
|
57
|
+
AnalysisType["UNSAFE"] = "unsafe";
|
|
58
|
+
AnalysisType["EMOTIONS"] = "emotions";
|
|
59
|
+
})(AnalysisType || (AnalysisType = {}));
|
|
60
|
+
/**
|
|
61
|
+
* Emotional trend direction
|
|
62
|
+
*/
|
|
63
|
+
export var EmotionTrend;
|
|
64
|
+
(function (EmotionTrend) {
|
|
65
|
+
EmotionTrend["IMPROVING"] = "improving";
|
|
66
|
+
EmotionTrend["STABLE"] = "stable";
|
|
67
|
+
EmotionTrend["WORSENING"] = "worsening";
|
|
68
|
+
})(EmotionTrend || (EmotionTrend = {}));
|
|
69
|
+
/**
|
|
70
|
+
* Incident status
|
|
71
|
+
*/
|
|
72
|
+
export var IncidentStatus;
|
|
73
|
+
(function (IncidentStatus) {
|
|
74
|
+
IncidentStatus["NEW"] = "new";
|
|
75
|
+
IncidentStatus["REVIEWED"] = "reviewed";
|
|
76
|
+
IncidentStatus["RESOLVED"] = "resolved";
|
|
77
|
+
})(IncidentStatus || (IncidentStatus = {}));
|
|
78
|
+
/**
|
|
79
|
+
* Tool names for tracking
|
|
80
|
+
*/
|
|
81
|
+
export var ToolName;
|
|
82
|
+
(function (ToolName) {
|
|
83
|
+
ToolName["DETECT_BULLYING"] = "detectBullying";
|
|
84
|
+
ToolName["DETECT_GROOMING"] = "detectGrooming";
|
|
85
|
+
ToolName["DETECT_UNSAFE_CONTEXT"] = "detectUnsafeContext";
|
|
86
|
+
ToolName["EMOTION_SUMMARY"] = "emotionSummary";
|
|
87
|
+
ToolName["HEALTHY_ACTION_PLAN"] = "healthyActionPlan";
|
|
88
|
+
ToolName["INCIDENT_REPORT"] = "incidentReport";
|
|
89
|
+
ToolName["POLICY_CONFIG"] = "policyConfig";
|
|
90
|
+
})(ToolName || (ToolName = {}));
|
|
91
|
+
// =============================================================================
|
|
92
|
+
// Subscription Tiers
|
|
93
|
+
// =============================================================================
|
|
94
|
+
/**
|
|
95
|
+
* Subscription tier levels
|
|
96
|
+
*/
|
|
97
|
+
export var Tier;
|
|
98
|
+
(function (Tier) {
|
|
99
|
+
Tier["STARTER"] = "starter";
|
|
100
|
+
Tier["PRO"] = "pro";
|
|
101
|
+
Tier["BUSINESS"] = "business";
|
|
102
|
+
Tier["ENTERPRISE"] = "enterprise";
|
|
103
|
+
})(Tier || (Tier = {}));
|
|
104
|
+
/**
|
|
105
|
+
* Monthly API call limits per tier
|
|
106
|
+
*/
|
|
107
|
+
export const TIER_MONTHLY_LIMITS = {
|
|
108
|
+
[Tier.STARTER]: 1000,
|
|
109
|
+
[Tier.PRO]: 100000,
|
|
110
|
+
[Tier.BUSINESS]: 250000,
|
|
111
|
+
[Tier.ENTERPRISE]: -1, // Unlimited
|
|
112
|
+
};
|
|
113
|
+
// =============================================================================
|
|
114
|
+
// Webhook Events
|
|
115
|
+
// =============================================================================
|
|
116
|
+
export var WebhookEventType;
|
|
117
|
+
(function (WebhookEventType) {
|
|
118
|
+
WebhookEventType["INCIDENT_CRITICAL"] = "incident.critical";
|
|
119
|
+
WebhookEventType["INCIDENT_HIGH"] = "incident.high";
|
|
120
|
+
WebhookEventType["GROOMING_DETECTED"] = "grooming.detected";
|
|
121
|
+
WebhookEventType["SELF_HARM_DETECTED"] = "self_harm.detected";
|
|
122
|
+
WebhookEventType["BULLYING_SEVERE"] = "bullying.severe";
|
|
123
|
+
})(WebhookEventType || (WebhookEventType = {}));
|
|
124
|
+
// =============================================================================
|
|
125
|
+
// Error Codes
|
|
126
|
+
// =============================================================================
|
|
127
|
+
export var ErrorCode;
|
|
128
|
+
(function (ErrorCode) {
|
|
129
|
+
// Authentication errors (AUTH_*)
|
|
130
|
+
ErrorCode["API_KEY_REQUIRED"] = "AUTH_1001";
|
|
131
|
+
ErrorCode["API_KEY_NOT_FOUND"] = "AUTH_1002";
|
|
132
|
+
ErrorCode["API_KEY_INVALID"] = "AUTH_1003";
|
|
133
|
+
ErrorCode["API_KEY_REVOKED"] = "AUTH_1004";
|
|
134
|
+
ErrorCode["API_KEY_INACTIVE"] = "AUTH_1005";
|
|
135
|
+
ErrorCode["API_KEY_EXPIRED"] = "AUTH_1006";
|
|
136
|
+
ErrorCode["UNAUTHORIZED"] = "AUTH_1007";
|
|
137
|
+
// Rate limiting errors (RATE_*)
|
|
138
|
+
ErrorCode["RATE_LIMIT_EXCEEDED"] = "RATE_2001";
|
|
139
|
+
ErrorCode["DAILY_LIMIT_EXCEEDED"] = "RATE_2002";
|
|
140
|
+
ErrorCode["QUOTA_EXCEEDED"] = "RATE_2003";
|
|
141
|
+
// Validation errors (VAL_*)
|
|
142
|
+
ErrorCode["VALIDATION_FAILED"] = "VAL_3001";
|
|
143
|
+
ErrorCode["INVALID_INPUT"] = "VAL_3002";
|
|
144
|
+
ErrorCode["MISSING_FIELD"] = "VAL_3003";
|
|
145
|
+
ErrorCode["INVALID_FORMAT"] = "VAL_3004";
|
|
146
|
+
ErrorCode["BATCH_SIZE_EXCEEDED"] = "VAL_3005";
|
|
147
|
+
ErrorCode["MESSAGE_TOO_LONG"] = "VAL_3006";
|
|
148
|
+
ErrorCode["TOO_MANY_MESSAGES"] = "VAL_3007";
|
|
149
|
+
// Service errors (SVC_*)
|
|
150
|
+
ErrorCode["INTERNAL_ERROR"] = "SVC_4001";
|
|
151
|
+
ErrorCode["DATABASE_ERROR"] = "SVC_4002";
|
|
152
|
+
ErrorCode["SERVICE_UNAVAILABLE"] = "SVC_4003";
|
|
153
|
+
ErrorCode["LLM_SERVICE_ERROR"] = "SVC_4004";
|
|
154
|
+
ErrorCode["WEBHOOK_DELIVERY_FAILED"] = "SVC_4005";
|
|
155
|
+
// Analysis errors (ANALYSIS_*)
|
|
156
|
+
ErrorCode["ANALYSIS_FAILED"] = "ANALYSIS_5001";
|
|
157
|
+
ErrorCode["UNSUPPORTED_TYPE"] = "ANALYSIS_5002";
|
|
158
|
+
ErrorCode["NO_CONTENT"] = "ANALYSIS_5003";
|
|
159
|
+
})(ErrorCode || (ErrorCode = {}));
|
|
160
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,gFAAgF;AAChF,wBAAwB;AACxB,gFAAgF;AAEhF;;GAEG;AACH,MAAM,CAAN,IAAY,QAKX;AALD,WAAY,QAAQ;IAChB,uBAAW,CAAA;IACX,6BAAiB,CAAA;IACjB,yBAAa,CAAA;IACb,iCAAqB,CAAA;AACzB,CAAC,EALW,QAAQ,KAAR,QAAQ,QAKnB;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,YAMX;AAND,WAAY,YAAY;IACpB,6BAAa,CAAA;IACb,2BAAW,CAAA;IACX,iCAAiB,CAAA;IACjB,6BAAa,CAAA;IACb,qCAAqB,CAAA;AACzB,CAAC,EANW,YAAY,KAAZ,YAAY,QAMvB;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,SAKX;AALD,WAAY,SAAS;IACjB,wBAAW,CAAA;IACX,kCAAqB,CAAA;IACrB,0BAAa,CAAA;IACb,kCAAqB,CAAA;AACzB,CAAC,EALW,SAAS,KAAT,SAAS,QAKpB;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,YAMX;AAND,WAAY,YAAY;IACpB,qCAAqB,CAAA;IACrB,qCAAqB,CAAA;IACrB,iCAAiB,CAAA;IACjB,uCAAuB,CAAA;IACvB,+BAAe,CAAA;AACnB,CAAC,EANW,YAAY,KAAZ,YAAY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AC,CAAC,EAAE,YAAY;CACtC,CAAC;AAEF,gFAAgF;AAChF,iBAAiB;AACjB,gFAAgF;AAEhF,MAAM,CAAN,IAAY,gBAMX;AAND,WAAY,gBAAgB;IACxB,2DAAuC,CAAA;IACvC,mDAA+B,CAAA;IAC/B,2DAAuC,CAAA;IACvC,6DAAyC,CAAA;IACzC,uDAAmC,CAAA;AACvC,CAAC,EANW,gBAAgB,KAAhB,gBAAgB,QAM3B;AAED,gFAAgF;AAChF,cAAc;AACd,gFAAgF;AAEhF,MAAM,CAAN,IAAY,SAmCX;AAnCD,WAAY,SAAS;IACjB,iCAAiC;IACjC,2CAA8B,CAAA;IAC9B,4CAA+B,CAAA;IAC/B,0CAA6B,CAAA;IAC7B,0CAA6B,CAAA;IAC7B,2CAA8B,CAAA;IAC9B,0CAA6B,CAAA;IAC7B,uCAA0B,CAAA;IAE1B,gCAAgC;IAChC,8CAAiC,CAAA;IACjC,+CAAkC,CAAA;IAClC,yCAA4B,CAAA;IAE5B,4BAA4B;IAC5B,2CAA8B,CAAA;IAC9B,uCAA0B,CAAA;IAC1B,uCAA0B,CAAA;IAC1B,wCAA2B,CAAA;IAC3B,6CAAgC,CAAA;IAChC,0CAA6B,CAAA;IAC7B,2CAA8B,CAAA;IAE9B,yBAAyB;IACzB,wCAA2B,CAAA;IAC3B,wCAA2B,CAAA;IAC3B,6CAAgC,CAAA;IAChC,2CAA8B,CAAA;IAC9B,iDAAoC,CAAA;IAEpC,+BAA+B;IAC/B,8CAAiC,CAAA;IACjC,+CAAkC,CAAA;IAClC,yCAA4B,CAAA;AAChC,CAAC,EAnCW,SAAS,KAAT,SAAS,QAmCpB"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base error class for SafeNest SDK errors
|
|
3
|
+
*/
|
|
4
|
+
export declare class SafeNestError extends Error {
|
|
5
|
+
readonly statusCode?: number | undefined;
|
|
6
|
+
readonly details?: unknown | undefined;
|
|
7
|
+
constructor(message: string, statusCode?: number | undefined, details?: unknown | undefined);
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Error thrown when authentication fails (401)
|
|
11
|
+
*/
|
|
12
|
+
export declare class AuthenticationError extends SafeNestError {
|
|
13
|
+
constructor(message?: string);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Error thrown when rate limit is exceeded (429)
|
|
17
|
+
*/
|
|
18
|
+
export declare class RateLimitError extends SafeNestError {
|
|
19
|
+
readonly retryAfter?: number | undefined;
|
|
20
|
+
constructor(message?: string, retryAfter?: number | undefined);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Error thrown when request validation fails (400)
|
|
24
|
+
*/
|
|
25
|
+
export declare class ValidationError extends SafeNestError {
|
|
26
|
+
constructor(message: string, details?: unknown);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Error thrown when a resource is not found (404)
|
|
30
|
+
*/
|
|
31
|
+
export declare class NotFoundError extends SafeNestError {
|
|
32
|
+
constructor(message?: string);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Error thrown when the server returns an error (5xx)
|
|
36
|
+
*/
|
|
37
|
+
export declare class ServerError extends SafeNestError {
|
|
38
|
+
constructor(message?: string, statusCode?: number);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Error thrown when a request times out
|
|
42
|
+
*/
|
|
43
|
+
export declare class TimeoutError extends SafeNestError {
|
|
44
|
+
constructor(message?: string);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Error thrown when network connectivity fails
|
|
48
|
+
*/
|
|
49
|
+
export declare class NetworkError extends SafeNestError {
|
|
50
|
+
constructor(message?: string);
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,aAAc,SAAQ,KAAK;aAGhB,UAAU,CAAC,EAAE,MAAM;aACnB,OAAO,CAAC,EAAE,OAAO;gBAFjC,OAAO,EAAE,MAAM,EACC,UAAU,CAAC,EAAE,MAAM,YAAA,EACnB,OAAO,CAAC,EAAE,OAAO,YAAA;CAMxC;AAED;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,aAAa;gBACtC,OAAO,SAAsD;CAK5E;AAED;;GAEG;AACH,qBAAa,cAAe,SAAQ,aAAa;aAGzB,UAAU,CAAC,EAAE,MAAM;gBADnC,OAAO,SAAiD,EACxC,UAAU,CAAC,EAAE,MAAM,YAAA;CAM1C;AAED;;GAEG;AACH,qBAAa,eAAgB,SAAQ,aAAa;gBAClC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO;CAKjD;AAED;;GAEG;AACH,qBAAa,aAAc,SAAQ,aAAa;gBAChC,OAAO,SAAuB;CAK7C;AAED;;GAEG;AACH,qBAAa,WAAY,SAAQ,aAAa;gBAC9B,OAAO,SAA0C,EAAE,UAAU,SAAM;CAKlF;AAED;;GAEG;AACH,qBAAa,YAAa,SAAQ,aAAa;gBAC/B,OAAO,SAAsB;CAK5C;AAED;;GAEG;AACH,qBAAa,YAAa,SAAQ,aAAa;gBAC/B,OAAO,SAAiD;CAKvE"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base error class for SafeNest SDK errors
|
|
3
|
+
*/
|
|
4
|
+
export class SafeNestError extends Error {
|
|
5
|
+
statusCode;
|
|
6
|
+
details;
|
|
7
|
+
constructor(message, statusCode, details) {
|
|
8
|
+
super(message);
|
|
9
|
+
this.statusCode = statusCode;
|
|
10
|
+
this.details = details;
|
|
11
|
+
this.name = 'SafeNestError';
|
|
12
|
+
Object.setPrototypeOf(this, SafeNestError.prototype);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Error thrown when authentication fails (401)
|
|
17
|
+
*/
|
|
18
|
+
export class AuthenticationError extends SafeNestError {
|
|
19
|
+
constructor(message = 'Authentication failed. Please check your API key.') {
|
|
20
|
+
super(message, 401);
|
|
21
|
+
this.name = 'AuthenticationError';
|
|
22
|
+
Object.setPrototypeOf(this, AuthenticationError.prototype);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Error thrown when rate limit is exceeded (429)
|
|
27
|
+
*/
|
|
28
|
+
export class RateLimitError extends SafeNestError {
|
|
29
|
+
retryAfter;
|
|
30
|
+
constructor(message = 'Rate limit exceeded. Please try again later.', retryAfter) {
|
|
31
|
+
super(message, 429);
|
|
32
|
+
this.retryAfter = retryAfter;
|
|
33
|
+
this.name = 'RateLimitError';
|
|
34
|
+
Object.setPrototypeOf(this, RateLimitError.prototype);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Error thrown when request validation fails (400)
|
|
39
|
+
*/
|
|
40
|
+
export class ValidationError extends SafeNestError {
|
|
41
|
+
constructor(message, details) {
|
|
42
|
+
super(message, 400, details);
|
|
43
|
+
this.name = 'ValidationError';
|
|
44
|
+
Object.setPrototypeOf(this, ValidationError.prototype);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Error thrown when a resource is not found (404)
|
|
49
|
+
*/
|
|
50
|
+
export class NotFoundError extends SafeNestError {
|
|
51
|
+
constructor(message = 'Resource not found') {
|
|
52
|
+
super(message, 404);
|
|
53
|
+
this.name = 'NotFoundError';
|
|
54
|
+
Object.setPrototypeOf(this, NotFoundError.prototype);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Error thrown when the server returns an error (5xx)
|
|
59
|
+
*/
|
|
60
|
+
export class ServerError extends SafeNestError {
|
|
61
|
+
constructor(message = 'Server error. Please try again later.', statusCode = 500) {
|
|
62
|
+
super(message, statusCode);
|
|
63
|
+
this.name = 'ServerError';
|
|
64
|
+
Object.setPrototypeOf(this, ServerError.prototype);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Error thrown when a request times out
|
|
69
|
+
*/
|
|
70
|
+
export class TimeoutError extends SafeNestError {
|
|
71
|
+
constructor(message = 'Request timed out') {
|
|
72
|
+
super(message);
|
|
73
|
+
this.name = 'TimeoutError';
|
|
74
|
+
Object.setPrototypeOf(this, TimeoutError.prototype);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Error thrown when network connectivity fails
|
|
79
|
+
*/
|
|
80
|
+
export class NetworkError extends SafeNestError {
|
|
81
|
+
constructor(message = 'Network error. Please check your connection.') {
|
|
82
|
+
super(message);
|
|
83
|
+
this.name = 'NetworkError';
|
|
84
|
+
Object.setPrototypeOf(this, NetworkError.prototype);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,OAAO,aAAc,SAAQ,KAAK;IAGhB;IACA;IAHpB,YACI,OAAe,EACC,UAAmB,EACnB,OAAiB;QAEjC,KAAK,CAAC,OAAO,CAAC,CAAC;QAHC,eAAU,GAAV,UAAU,CAAS;QACnB,YAAO,GAAP,OAAO,CAAU;QAGjC,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;QAC5B,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;IACzD,CAAC;CACJ;AAED;;GAEG;AACH,MAAM,OAAO,mBAAoB,SAAQ,aAAa;IAClD,YAAY,OAAO,GAAG,mDAAmD;QACrE,KAAK,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QACpB,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;QAClC,MAAM,CAA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;AAED;;GAEG;AACH,MAAM,OAAO,YAAa,SAAQ,aAAa;IAC3C,YAAY,OAAO,GAAG,mBAAmB;QACrC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;QAC3B,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,YAAY,CAAC,SAAS,CAAC,CAAC;IACxD,CAAC;CACJ;AAED;;GAEG;AACH,MAAM,OAAO,YAAa,SAAQ,aAAa;IAC3C,YAAY,OAAO,GAAG,8CAA8C;QAChE,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;QAC3B,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,YAAY,CAAC,SAAS,CAAC,CAAC;IACxD,CAAC;CACJ"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { SafeNest, SafeNestClient } from './client.js';
|
|
2
|
+
export { Severity, GroomingRisk, RiskLevel, RiskCategory, AnalysisType, EmotionTrend, IncidentStatus, ToolName, WebhookEventType, ErrorCode, Tier, TIER_MONTHLY_LIMITS, } from './constants.js';
|
|
3
|
+
export { SafeNestError, AuthenticationError, RateLimitError, ValidationError, NotFoundError, ServerError, TimeoutError, NetworkError, } from './errors.js';
|
|
4
|
+
export type { SafeNestOptions, SafeNestClientOptions, Usage, RequestMeta, ApiError, ContextInput, DetectBullyingInput, BullyingResult, GroomingMessage, DetectGroomingInput, GroomingResult, DetectUnsafeInput, UnsafeResult, AnalyzeInput, AnalyzeResult, EmotionMessage, AnalyzeEmotionsInput, EmotionsResult, Audience, GetActionPlanInput, ActionPlanResult, ReportMessage, GenerateReportInput, ReportResult, PolicyConfig, PolicyConfigResponse, ThresholdConfig, BullyingPolicyConfig, GroomingPolicyConfig, SelfHarmPolicyConfig, HateSpeechPolicyConfig, ThreatsPolicyConfig, SexualContentPolicyConfig, ViolencePolicyConfig, EmotionMonitoringConfig, IncidentReportingConfig, DetectBullyingRequest, DetectBullyingResponse, DetectGroomingRequest, DetectGroomingResponse, DetectUnsafeRequest, DetectUnsafeResponse, EmotionSummaryRequest, EmotionSummaryResponse, ActionPlanRole, ActionPlanRequest, ActionPlanResponse, IncidentMessage, IncidentReportRequest, IncidentReportResponse, } from './types/index.js';
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAGvD,OAAO,EACH,QAAQ,EACR,YAAY,EACZ,SAAS,EACT,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,QAAQ,EACR,gBAAgB,EAChB,SAAS,EACT,IAAI,EACJ,mBAAmB,GACtB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EACH,aAAa,EACb,mBAAmB,EACnB,cAAc,EACd,eAAe,EACf,aAAa,EACb,WAAW,EACX,YAAY,EACZ,YAAY,GACf,MAAM,aAAa,CAAC;AAGrB,YAAY,EAER,eAAe,EACf,qBAAqB,EACrB,KAAK,EACL,WAAW,EACX,QAAQ,EAGR,YAAY,EACZ,mBAAmB,EACnB,cAAc,EACd,eAAe,EACf,mBAAmB,EACnB,cAAc,EACd,iBAAiB,EACjB,YAAY,EACZ,YAAY,EACZ,aAAa,EAGb,cAAc,EACd,oBAAoB,EACpB,cAAc,EAGd,QAAQ,EACR,kBAAkB,EAClB,gBAAgB,EAGhB,aAAa,EACb,mBAAmB,EACnB,YAAY,EAGZ,YAAY,EACZ,oBAAoB,EACpB,eAAe,EACf,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,sBAAsB,EACtB,mBAAmB,EACnB,yBAAyB,EACzB,oBAAoB,EACpB,uBAAuB,EACvB,uBAAuB,EAGvB,qBAAqB,EACrB,sBAAsB,EACtB,qBAAqB,EACrB,sBAAsB,EACtB,mBAAmB,EACnB,oBAAoB,EACpB,qBAAqB,EACrB,sBAAsB,EACtB,cAAc,EACd,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,EACf,qBAAqB,EACrB,sBAAsB,GACzB,MAAM,kBAAkB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// Main export
|
|
2
|
+
export { SafeNest, SafeNestClient } from './client.js';
|
|
3
|
+
// Constants and enums export
|
|
4
|
+
export { Severity, GroomingRisk, RiskLevel, RiskCategory, AnalysisType, EmotionTrend, IncidentStatus, ToolName, WebhookEventType, ErrorCode, Tier, TIER_MONTHLY_LIMITS, } from './constants.js';
|
|
5
|
+
// Error exports
|
|
6
|
+
export { SafeNestError, AuthenticationError, RateLimitError, ValidationError, NotFoundError, ServerError, TimeoutError, NetworkError, } from './errors.js';
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc;AACd,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAEvD,6BAA6B;AAC7B,OAAO,EACH,QAAQ,EACR,YAAY,EACZ,SAAS,EACT,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,QAAQ,EACR,gBAAgB,EAChB,SAAS,EACT,IAAI,EACJ,mBAAmB,GACtB,MAAM,gBAAgB,CAAC;AAExB,gBAAgB;AAChB,OAAO,EACH,aAAa,EACb,mBAAmB,EACnB,cAAc,EACd,eAAe,EACf,aAAa,EACb,WAAW,EACX,YAAY,EACZ,YAAY,GACf,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { ContextInput } from './safety.js';
|
|
2
|
+
import { EmotionTrend } from '../constants.js';
|
|
3
|
+
import { TrackingFields } from './index.js';
|
|
4
|
+
export { EmotionTrend };
|
|
5
|
+
export interface EmotionMessage {
|
|
6
|
+
/** Sender identifier or role */
|
|
7
|
+
sender: string;
|
|
8
|
+
/** Message content */
|
|
9
|
+
content: string;
|
|
10
|
+
/** Optional timestamp */
|
|
11
|
+
timestamp?: string | Date;
|
|
12
|
+
}
|
|
13
|
+
export interface AnalyzeEmotionsInput extends TrackingFields {
|
|
14
|
+
/** Single content string or message history to analyze */
|
|
15
|
+
content?: string;
|
|
16
|
+
/** Chat history to analyze (alternative to content) */
|
|
17
|
+
messages?: EmotionMessage[];
|
|
18
|
+
/** Context for better analysis */
|
|
19
|
+
context?: ContextInput;
|
|
20
|
+
}
|
|
21
|
+
export interface EmotionsResult {
|
|
22
|
+
/** Primary emotions detected */
|
|
23
|
+
dominant_emotions: string[];
|
|
24
|
+
/** Scores for each detected emotion (0-1) */
|
|
25
|
+
emotion_scores: Record<string, number>;
|
|
26
|
+
/** Overall emotional trend */
|
|
27
|
+
trend: EmotionTrend;
|
|
28
|
+
/** Summary of the emotional analysis */
|
|
29
|
+
summary: string;
|
|
30
|
+
/** Recommended follow-up action */
|
|
31
|
+
recommended_followup: string;
|
|
32
|
+
/** Echo of provided external_id (if any) */
|
|
33
|
+
external_id?: string;
|
|
34
|
+
/** Echo of provided metadata (if any) */
|
|
35
|
+
metadata?: Record<string, unknown>;
|
|
36
|
+
}
|
|
37
|
+
export type EmotionSummaryRequest = AnalyzeEmotionsInput;
|
|
38
|
+
export type EmotionSummaryResponse = EmotionsResult;
|
|
39
|
+
//# sourceMappingURL=analysis.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analysis.d.ts","sourceRoot":"","sources":["../../src/types/analysis.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAG5C,OAAO,EAAE,YAAY,EAAE,CAAC;AAMxB,MAAM,WAAW,cAAc;IAC3B,gCAAgC;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,sBAAsB;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,yBAAyB;IACzB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B;AAED,MAAM,WAAW,oBAAqB,SAAQ,cAAc;IACxD,0DAA0D;IAC1D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,uDAAuD;IACvD,QAAQ,CAAC,EAAE,cAAc,EAAE,CAAC;IAC5B,kCAAkC;IAClC,OAAO,CAAC,EAAE,YAAY,CAAC;CAC1B;AAED,MAAM,WAAW,cAAc;IAC3B,gCAAgC;IAChC,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B,6CAA6C;IAC7C,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACvC,8BAA8B;IAC9B,KAAK,EAAE,YAAY,CAAC;IACpB,wCAAwC;IACxC,OAAO,EAAE,MAAM,CAAC;IAChB,mCAAmC;IACnC,oBAAoB,EAAE,MAAM,CAAC;IAC7B,4CAA4C;IAC5C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,yCAAyC;IACzC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACtC;AAGD,MAAM,MAAM,qBAAqB,GAAG,oBAAoB,CAAC;AACzD,MAAM,MAAM,sBAAsB,GAAG,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analysis.js","sourceRoot":"","sources":["../../src/types/analysis.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAG/C,iCAAiC;AACjC,OAAO,EAAE,YAAY,EAAE,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { TrackingFields } from './index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Target audience for action plans
|
|
4
|
+
*/
|
|
5
|
+
export type Audience = 'child' | 'parent' | 'educator' | 'platform';
|
|
6
|
+
export interface GetActionPlanInput extends TrackingFields {
|
|
7
|
+
/** Description of the situation */
|
|
8
|
+
situation: string;
|
|
9
|
+
/** Age of the child */
|
|
10
|
+
childAge?: number;
|
|
11
|
+
/** Target audience for the guidance (defaults to 'parent') */
|
|
12
|
+
audience?: Audience;
|
|
13
|
+
/** Severity level to tailor the response */
|
|
14
|
+
severity?: 'low' | 'medium' | 'high' | 'critical';
|
|
15
|
+
}
|
|
16
|
+
export interface ActionPlanResult {
|
|
17
|
+
/** Target audience label */
|
|
18
|
+
audience: string;
|
|
19
|
+
/** Step-by-step action items */
|
|
20
|
+
steps: string[];
|
|
21
|
+
/** Tone used in the guidance */
|
|
22
|
+
tone: string;
|
|
23
|
+
/** Approximate reading level */
|
|
24
|
+
reading_level?: string;
|
|
25
|
+
/** Echo of provided external_id (if any) */
|
|
26
|
+
external_id?: string;
|
|
27
|
+
/** Echo of provided metadata (if any) */
|
|
28
|
+
metadata?: Record<string, unknown>;
|
|
29
|
+
}
|
|
30
|
+
export type ActionPlanRole = Audience;
|
|
31
|
+
export type ActionPlanRequest = GetActionPlanInput;
|
|
32
|
+
export type ActionPlanResponse = ActionPlanResult;
|
|
33
|
+
//# sourceMappingURL=guidance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guidance.d.ts","sourceRoot":"","sources":["../../src/types/guidance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,QAAQ,GAAG,UAAU,GAAG,UAAU,CAAC;AAMpE,MAAM,WAAW,kBAAmB,SAAQ,cAAc;IACtD,mCAAmC;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,uBAAuB;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,8DAA8D;IAC9D,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,4CAA4C;IAC5C,QAAQ,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,UAAU,CAAC;CACrD;AAED,MAAM,WAAW,gBAAgB;IAC7B,4BAA4B;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,gCAAgC;IAChC,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,gCAAgC;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,gCAAgC;IAChC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,4CAA4C;IAC5C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,yCAAyC;IACzC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACtC;AAGD,MAAM,MAAM,cAAc,GAAG,QAAQ,CAAC;AACtC,MAAM,MAAM,iBAAiB,GAAG,kBAAkB,CAAC;AACnD,MAAM,MAAM,kBAAkB,GAAG,gBAAgB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guidance.js","sourceRoot":"","sources":["../../src/types/guidance.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
export * from './safety.js';
|
|
2
|
+
export * from './analysis.js';
|
|
3
|
+
export * from './guidance.js';
|
|
4
|
+
export * from './reports.js';
|
|
5
|
+
export * from './policy.js';
|
|
6
|
+
/**
|
|
7
|
+
* Tracking fields for correlating requests with your systems
|
|
8
|
+
*/
|
|
9
|
+
export interface TrackingFields {
|
|
10
|
+
/**
|
|
11
|
+
* Your unique identifier for this request (e.g., message ID, user ID, session ID)
|
|
12
|
+
* Maximum 255 characters. Echoed back in response and included in webhooks.
|
|
13
|
+
*/
|
|
14
|
+
external_id?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Custom key-value pairs for additional context
|
|
17
|
+
* Stored with detection results and included in webhooks.
|
|
18
|
+
*/
|
|
19
|
+
metadata?: Record<string, unknown>;
|
|
20
|
+
}
|
|
21
|
+
export interface ApiError {
|
|
22
|
+
error: {
|
|
23
|
+
code: string;
|
|
24
|
+
message: string;
|
|
25
|
+
details?: unknown;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
export interface SafeNestOptions {
|
|
29
|
+
/** Request timeout in milliseconds (defaults to 30000) */
|
|
30
|
+
timeout?: number;
|
|
31
|
+
/** Number of retry attempts (defaults to 3) */
|
|
32
|
+
retries?: number;
|
|
33
|
+
/** Initial retry delay in milliseconds (defaults to 1000) */
|
|
34
|
+
retryDelay?: number;
|
|
35
|
+
}
|
|
36
|
+
export interface Usage {
|
|
37
|
+
/** Total message limit */
|
|
38
|
+
limit: number;
|
|
39
|
+
/** Messages used */
|
|
40
|
+
used: number;
|
|
41
|
+
/** Messages remaining */
|
|
42
|
+
remaining: number;
|
|
43
|
+
}
|
|
44
|
+
export interface RequestMeta {
|
|
45
|
+
/** Request correlation ID */
|
|
46
|
+
requestId: string;
|
|
47
|
+
/** Request latency in milliseconds */
|
|
48
|
+
latencyMs: number;
|
|
49
|
+
/** Current usage stats */
|
|
50
|
+
usage?: Usage;
|
|
51
|
+
}
|
|
52
|
+
export interface SafeNestClientOptions extends SafeNestOptions {
|
|
53
|
+
apiKey: string;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AACA,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAM5B;;GAEG;AACH,MAAM,WAAW,cAAc;IAC3B;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACtC;AAED,MAAM,WAAW,QAAQ;IACrB,KAAK,EAAE;QACH,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,CAAC,EAAE,OAAO,CAAC;KACrB,CAAC;CACL;AAED,MAAM,WAAW,eAAe;IAC5B,0DAA0D;IAC1D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,+CAA+C;IAC/C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,6DAA6D;IAC7D,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,KAAK;IAClB,0BAA0B;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,oBAAoB;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,yBAAyB;IACzB,SAAS,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,WAAW;IACxB,6BAA6B;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,sCAAsC;IACtC,SAAS,EAAE,MAAM,CAAC;IAClB,0BAA0B;IAC1B,KAAK,CAAC,EAAE,KAAK,CAAC;CACjB;AAGD,MAAM,WAAW,qBAAsB,SAAQ,eAAe;IAC1D,MAAM,EAAE,MAAM,CAAC;CAClB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,sBAAsB;AACtB,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export interface ThresholdConfig {
|
|
2
|
+
enabled: boolean;
|
|
3
|
+
minRiskScoreToFlag: number;
|
|
4
|
+
minRiskScoreToBlock: number;
|
|
5
|
+
}
|
|
6
|
+
export interface BullyingPolicyConfig extends ThresholdConfig {
|
|
7
|
+
autoModeration: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface GroomingPolicyConfig extends ThresholdConfig {
|
|
10
|
+
requireAdultReview: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface SelfHarmPolicyConfig {
|
|
13
|
+
enabled: boolean;
|
|
14
|
+
minRiskScoreToAlert: number;
|
|
15
|
+
provideResources: boolean;
|
|
16
|
+
escalateImmediately: boolean;
|
|
17
|
+
}
|
|
18
|
+
export interface HateSpeechPolicyConfig extends ThresholdConfig {
|
|
19
|
+
}
|
|
20
|
+
export interface ThreatsPolicyConfig extends ThresholdConfig {
|
|
21
|
+
notifyAuthorities: boolean;
|
|
22
|
+
}
|
|
23
|
+
export interface SexualContentPolicyConfig extends ThresholdConfig {
|
|
24
|
+
ageAppropriate: boolean;
|
|
25
|
+
}
|
|
26
|
+
export interface ViolencePolicyConfig extends ThresholdConfig {
|
|
27
|
+
}
|
|
28
|
+
export interface EmotionMonitoringConfig {
|
|
29
|
+
enabled: boolean;
|
|
30
|
+
trackTrends: boolean;
|
|
31
|
+
alertOnDistress: boolean;
|
|
32
|
+
}
|
|
33
|
+
export interface IncidentReportingConfig {
|
|
34
|
+
enabled: boolean;
|
|
35
|
+
anonymize: boolean;
|
|
36
|
+
notifyParents: boolean;
|
|
37
|
+
}
|
|
38
|
+
export interface PolicyConfig {
|
|
39
|
+
bullying: BullyingPolicyConfig;
|
|
40
|
+
grooming: GroomingPolicyConfig;
|
|
41
|
+
selfHarm: SelfHarmPolicyConfig;
|
|
42
|
+
hateSpeech: HateSpeechPolicyConfig;
|
|
43
|
+
threats: ThreatsPolicyConfig;
|
|
44
|
+
sexualContent: SexualContentPolicyConfig;
|
|
45
|
+
violence: ViolencePolicyConfig;
|
|
46
|
+
emotionMonitoring: EmotionMonitoringConfig;
|
|
47
|
+
incidentReporting: IncidentReportingConfig;
|
|
48
|
+
}
|
|
49
|
+
export interface PolicyConfigResponse {
|
|
50
|
+
success: boolean;
|
|
51
|
+
config?: PolicyConfig;
|
|
52
|
+
message?: string;
|
|
53
|
+
}
|
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C;IACnC,OAAO,EAAE,mBAAmB,CAAC;IAC7B,aAAa,EAAE,yBAAyB,CAAC;IACzC,QAAQ,EAAE,oBAAoB,CAAC;IAC/B,iBAAiB,EAAE,uBAAuB,CAAC;IAC3C,iBAAiB,EAAE,uBAAuB,CAAC;CAC9C;AAED,MAAM,WAAW,oBAAoB;IACjC,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"policy.js","sourceRoot":"","sources":["../../src/types/policy.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,uBAAuB;AACvB,gFAAgF"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { TrackingFields } from './index.js';
|
|
2
|
+
export interface ReportMessage {
|
|
3
|
+
/** Sender identifier or role */
|
|
4
|
+
sender: string;
|
|
5
|
+
/** Message content */
|
|
6
|
+
content: string;
|
|
7
|
+
/** Optional timestamp */
|
|
8
|
+
timestamp?: string | Date;
|
|
9
|
+
}
|
|
10
|
+
export interface GenerateReportInput extends TrackingFields {
|
|
11
|
+
/** Messages involved in the incident */
|
|
12
|
+
messages: ReportMessage[];
|
|
13
|
+
/** Age of the child */
|
|
14
|
+
childAge?: number;
|
|
15
|
+
/** Optional incident metadata */
|
|
16
|
+
incident?: {
|
|
17
|
+
/** Incident type/category */
|
|
18
|
+
type?: string;
|
|
19
|
+
/** When the incident occurred */
|
|
20
|
+
occurredAt?: string | Date;
|
|
21
|
+
/** Additional notes */
|
|
22
|
+
notes?: string;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export interface ReportResult {
|
|
26
|
+
/** Summary of the incident */
|
|
27
|
+
summary: string;
|
|
28
|
+
/** Risk level assessment */
|
|
29
|
+
risk_level: 'low' | 'medium' | 'high' | 'critical';
|
|
30
|
+
/** Categories of concerns */
|
|
31
|
+
categories: string[];
|
|
32
|
+
/** Recommended next steps */
|
|
33
|
+
recommended_next_steps: string[];
|
|
34
|
+
/** Echo of provided external_id (if any) */
|
|
35
|
+
external_id?: string;
|
|
36
|
+
/** Echo of provided metadata (if any) */
|
|
37
|
+
metadata?: Record<string, unknown>;
|
|
38
|
+
}
|
|
39
|
+
export type IncidentMessage = ReportMessage;
|
|
40
|
+
export type IncidentReportRequest = GenerateReportInput;
|
|
41
|
+
export type IncidentReportResponse = ReportResult;
|
|
42
|
+
//# sourceMappingURL=reports.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reports.d.ts","sourceRoot":"","sources":["../../src/types/reports.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAM5C,MAAM,WAAW,aAAa;IAC1B,gCAAgC;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,sBAAsB;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,yBAAyB;IACzB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B;AAED,MAAM,WAAW,mBAAoB,SAAQ,cAAc;IACvD,wCAAwC;IACxC,QAAQ,EAAE,aAAa,EAAE,CAAC;IAC1B,uBAAuB;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iCAAiC;IACjC,QAAQ,CAAC,EAAE;QACP,6BAA6B;QAC7B,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,iCAAiC;QACjC,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAC3B,uBAAuB;QACvB,KAAK,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;CACL;AAED,MAAM,WAAW,YAAY;IACzB,8BAA8B;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,4BAA4B;IAC5B,UAAU,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,UAAU,CAAC;IACnD,6BAA6B;IAC7B,UAAU,EAAE,MAAM,EAAE,CAAC;IACr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