@vibesdotdev/moderation 0.0.0-stage → 1.0.0-rc.5

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.
Files changed (79) hide show
  1. package/LICENSE +18 -0
  2. package/README.md +83 -2
  3. package/dist/decide.d.ts +16 -0
  4. package/dist/decide.d.ts.map +1 -0
  5. package/dist/decide.js +81 -0
  6. package/dist/decide.js.map +1 -0
  7. package/dist/docs/moderation.decisions.docs.descriptor.d.ts +24 -0
  8. package/dist/docs/moderation.decisions.docs.descriptor.d.ts.map +1 -0
  9. package/dist/docs/moderation.decisions.docs.descriptor.js +94 -0
  10. package/dist/docs/moderation.decisions.docs.descriptor.js.map +1 -0
  11. package/dist/docs/moderation.docs.descriptor.d.ts +22 -0
  12. package/dist/docs/moderation.docs.descriptor.d.ts.map +1 -0
  13. package/dist/docs/moderation.docs.descriptor.js +68 -0
  14. package/dist/docs/moderation.docs.descriptor.js.map +1 -0
  15. package/dist/docs/moderation.subjects.docs.descriptor.d.ts +23 -0
  16. package/dist/docs/moderation.subjects.docs.descriptor.d.ts.map +1 -0
  17. package/dist/docs/moderation.subjects.docs.descriptor.js +99 -0
  18. package/dist/docs/moderation.subjects.docs.descriptor.js.map +1 -0
  19. package/dist/errors.d.ts +17 -0
  20. package/dist/errors.d.ts.map +1 -0
  21. package/dist/errors.js +36 -0
  22. package/dist/errors.js.map +1 -0
  23. package/dist/index.d.ts +6 -0
  24. package/dist/index.d.ts.map +1 -0
  25. package/dist/index.js +8 -0
  26. package/dist/index.js.map +1 -0
  27. package/dist/kinds/subject.kind.d.ts +10 -0
  28. package/dist/kinds/subject.kind.d.ts.map +1 -0
  29. package/dist/kinds/subject.kind.js +16 -0
  30. package/dist/kinds/subject.kind.js.map +1 -0
  31. package/dist/moderate.d.ts +17 -0
  32. package/dist/moderate.d.ts.map +1 -0
  33. package/dist/moderate.js +38 -0
  34. package/dist/moderate.js.map +1 -0
  35. package/dist/moderation.plugin.d.ts +12 -0
  36. package/dist/moderation.plugin.d.ts.map +1 -0
  37. package/dist/moderation.plugin.js +23 -0
  38. package/dist/moderation.plugin.js.map +1 -0
  39. package/dist/orchestration/labels.d.ts +5 -0
  40. package/dist/orchestration/labels.d.ts.map +1 -0
  41. package/dist/orchestration/labels.js +34 -0
  42. package/dist/orchestration/labels.js.map +1 -0
  43. package/dist/orchestration/resolve.d.ts +11 -0
  44. package/dist/orchestration/resolve.d.ts.map +1 -0
  45. package/dist/orchestration/resolve.js +90 -0
  46. package/dist/orchestration/resolve.js.map +1 -0
  47. package/dist/orchestration/state.d.ts +10 -0
  48. package/dist/orchestration/state.d.ts.map +1 -0
  49. package/dist/orchestration/state.js +58 -0
  50. package/dist/orchestration/state.js.map +1 -0
  51. package/dist/schemas/decision.d.ts +131 -0
  52. package/dist/schemas/decision.d.ts.map +1 -0
  53. package/dist/schemas/decision.js +97 -0
  54. package/dist/schemas/decision.js.map +1 -0
  55. package/dist/schemas/errors.d.ts +12 -0
  56. package/dist/schemas/errors.d.ts.map +1 -0
  57. package/dist/schemas/errors.js +11 -0
  58. package/dist/schemas/errors.js.map +1 -0
  59. package/dist/schemas/evaluation.d.ts +47 -0
  60. package/dist/schemas/evaluation.d.ts.map +1 -0
  61. package/dist/schemas/evaluation.js +14 -0
  62. package/dist/schemas/evaluation.js.map +1 -0
  63. package/dist/schemas/index.d.ts +6 -0
  64. package/dist/schemas/index.d.ts.map +1 -0
  65. package/dist/schemas/index.js +9 -0
  66. package/dist/schemas/index.js.map +1 -0
  67. package/dist/schemas/input.d.ts +30 -0
  68. package/dist/schemas/input.d.ts.map +1 -0
  69. package/dist/schemas/input.js +20 -0
  70. package/dist/schemas/input.js.map +1 -0
  71. package/dist/schemas/labels.d.ts +19 -0
  72. package/dist/schemas/labels.d.ts.map +1 -0
  73. package/dist/schemas/labels.js +18 -0
  74. package/dist/schemas/labels.js.map +1 -0
  75. package/dist/schemas/subject.d.ts +79 -0
  76. package/dist/schemas/subject.d.ts.map +1 -0
  77. package/dist/schemas/subject.js +66 -0
  78. package/dist/schemas/subject.js.map +1 -0
  79. package/package.json +100 -4
@@ -0,0 +1,97 @@
1
+ import * as z from 'zod/v4';
2
+ import { ModerationLabelValueSchema } from "./labels.js";
3
+ import { ModerationSubjectRefSchema } from "./subject.js";
4
+ /**
5
+ * Where the scores came from. `native` answers are calibrated probabilities
6
+ * from a structured-evaluation model; `adapted` answers come from a JSON-mode
7
+ * chat model running the same battery and carry no calibration.
8
+ */
9
+ export const ModerationAnswerSourceSchema = z.enum(['native', 'adapted']);
10
+ /** One label score for one subject, with the battery and answer source that produced it. */
11
+ export const ModerationLabelSchema = z.object({
12
+ subject: ModerationSubjectRefSchema,
13
+ value: ModerationLabelValueSchema,
14
+ score: z.number().min(0).max(1),
15
+ source: z.object({
16
+ batteryId: z.string().min(1),
17
+ answerSource: ModerationAnswerSourceSchema
18
+ })
19
+ });
20
+ export const ModerationActionSchema = z.enum(['allow', 'review', 'hide']);
21
+ /** A label whose score crossed a threshold, and which threshold it crossed. */
22
+ export const ModerationTriggerSchema = z.object({
23
+ label: ModerationLabelValueSchema,
24
+ score: z.number().min(0).max(1),
25
+ threshold: z.number().min(0).max(1),
26
+ level: z.enum(['review', 'hide'])
27
+ });
28
+ function sameSubject(a, b) {
29
+ return a.type === b.type && a.id === b.id && a.containerId === b.containerId;
30
+ }
31
+ /**
32
+ * The outcome of moderating one subject. The refinement keeps the action,
33
+ * the triggers and the labels mutually consistent, so a decision that says
34
+ * `allow` while carrying a hide trigger cannot be constructed.
35
+ */
36
+ export const ModerationDecisionSchema = z
37
+ .object({
38
+ subject: ModerationSubjectRefSchema,
39
+ action: ModerationActionSchema,
40
+ answerSource: ModerationAnswerSourceSchema,
41
+ labels: z.array(ModerationLabelSchema).min(1),
42
+ triggers: z.array(ModerationTriggerSchema),
43
+ decidedAt: z.iso.datetime()
44
+ })
45
+ .superRefine((decision, ctx) => {
46
+ const issue = (message, path = []) => {
47
+ ctx.addIssue({ code: 'custom', message, path });
48
+ };
49
+ const hides = decision.triggers.some((trigger) => trigger.level === 'hide');
50
+ if ((decision.action === 'allow') !== (decision.triggers.length === 0)) {
51
+ issue("action 'allow' requires, and is required by, an empty trigger list", ['action']);
52
+ }
53
+ if ((decision.action === 'hide') !== hides) {
54
+ issue("action 'hide' requires, and is required by, a hide-level trigger", ['action']);
55
+ }
56
+ if (decision.answerSource === 'adapted' && hides) {
57
+ issue('adapted answers are uncalibrated and cannot produce a hide trigger', ['triggers']);
58
+ }
59
+ const values = new Set();
60
+ for (const [index, label] of decision.labels.entries()) {
61
+ if (values.has(label.value))
62
+ issue(`duplicate label '${label.value}'`, ['labels', index]);
63
+ values.add(label.value);
64
+ if (!sameSubject(label.subject, decision.subject)) {
65
+ issue('label subject differs from the decision subject', ['labels', index, 'subject']);
66
+ }
67
+ if (label.source.answerSource !== decision.answerSource) {
68
+ issue('label answerSource differs from the decision answerSource', [
69
+ 'labels',
70
+ index,
71
+ 'source',
72
+ 'answerSource'
73
+ ]);
74
+ }
75
+ }
76
+ const triggered = new Set();
77
+ for (const [index, trigger] of decision.triggers.entries()) {
78
+ if (triggered.has(trigger.label))
79
+ issue(`duplicate trigger '${trigger.label}'`, ['triggers', index]);
80
+ triggered.add(trigger.label);
81
+ const label = decision.labels.find((label) => label.value === trigger.label);
82
+ if (!values.has(trigger.label)) {
83
+ issue(`trigger names label '${trigger.label}' that the decision does not carry`, [
84
+ 'triggers',
85
+ index,
86
+ 'label'
87
+ ]);
88
+ }
89
+ if (label && trigger.score !== label.score) {
90
+ issue('trigger score differs from its label score', ['triggers', index, 'score']);
91
+ }
92
+ if (trigger.score < trigger.threshold) {
93
+ issue('trigger score is below its claimed crossed threshold', ['triggers', index, 'threshold']);
94
+ }
95
+ }
96
+ });
97
+ //# sourceMappingURL=decision.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decision.js","sourceRoot":"","sources":["../../src/schemas/decision.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAA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AK,CAAC,CAAC,CAAC;QACrG,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAC7B,MAAM,KAAK,GAAG,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,KAAK,OAAO,CAAC,KAAK,CAAC,CAAC;QAC7E,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YAChC,KAAK,CAAC,wBAAwB,OAAO,CAAC,KAAK,oCAAoC,EAAE;gBAChF,UAAU;gBACV,KAAK;gBACL,OAAO;aACP,CAAC,CAAC;QACJ,CAAC;QACD,IAAI,KAAK,IAAI,OAAO,CAAC,KAAK,KAAK,KAAK,CAAC,KAAK,EAAE,CAAC;YAC5C,KAAK,CAAC,4CAA4C,EAAE,CAAC,UAAU,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC;QACnF,CAAC;QACD,IAAI,OAAO,CAAC,KAAK,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;YACvC,KAAK,CAAC,sDAAsD,EAAE,CAAC,UAAU,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC;QACjG,CAAC;IACF,CAAC;AACF,CAAC,CAAC,CAAC"}
@@ -0,0 +1,12 @@
1
+ import * as z from 'zod/v4';
2
+ export declare const MODERATION_ERROR_CODES: readonly ["MODERATION_SUBJECT_UNKNOWN", "MODERATION_BATTERY_UNKNOWN", "MODERATION_BATTERY_MISMATCH", "MODERATION_STATE_INVALID", "MODERATION_EVALUATOR_UNAVAILABLE", "MODERATION_EVALUATION_INVALID"];
3
+ export declare const ModerationErrorCodeSchema: z.ZodEnum<{
4
+ MODERATION_SUBJECT_UNKNOWN: "MODERATION_SUBJECT_UNKNOWN";
5
+ MODERATION_BATTERY_UNKNOWN: "MODERATION_BATTERY_UNKNOWN";
6
+ MODERATION_BATTERY_MISMATCH: "MODERATION_BATTERY_MISMATCH";
7
+ MODERATION_STATE_INVALID: "MODERATION_STATE_INVALID";
8
+ MODERATION_EVALUATOR_UNAVAILABLE: "MODERATION_EVALUATOR_UNAVAILABLE";
9
+ MODERATION_EVALUATION_INVALID: "MODERATION_EVALUATION_INVALID";
10
+ }>;
11
+ export type ModerationErrorCode = z.infer<typeof ModerationErrorCodeSchema>;
12
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/schemas/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAE5B,eAAO,MAAM,sBAAsB,uMAOzB,CAAC;AAEX,eAAO,MAAM,yBAAyB;;;;;;;EAAiC,CAAC;AACxE,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC"}
@@ -0,0 +1,11 @@
1
+ import * as z from 'zod/v4';
2
+ export const MODERATION_ERROR_CODES = [
3
+ 'MODERATION_SUBJECT_UNKNOWN',
4
+ 'MODERATION_BATTERY_UNKNOWN',
5
+ 'MODERATION_BATTERY_MISMATCH',
6
+ 'MODERATION_STATE_INVALID',
7
+ 'MODERATION_EVALUATOR_UNAVAILABLE',
8
+ 'MODERATION_EVALUATION_INVALID'
9
+ ];
10
+ export const ModerationErrorCodeSchema = z.enum(MODERATION_ERROR_CODES);
11
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/schemas/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAE5B,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACrC,4BAA4B;IAC5B,4BAA4B;IAC5B,6BAA6B;IAC7B,0BAA0B;IAC1B,kCAAkC;IAClC,+BAA+B;CACtB,CAAC;AAEX,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC"}
@@ -0,0 +1,47 @@
1
+ import type { AIClient } from '@vibesdotdev/ai/client';
2
+ import * as z from 'zod/v4';
3
+ export declare const EvaluationBatterySchema: z.ZodObject<{
4
+ id: z.ZodString;
5
+ enabled: z.ZodDefault<z.ZodBoolean>;
6
+ questions: z.ZodRecord<z.ZodString, z.ZodObject<{
7
+ type: z.ZodEnum<{
8
+ score: "score";
9
+ noul: "noul";
10
+ choice: "choice";
11
+ }>;
12
+ instructions: z.ZodString;
13
+ criteria: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodRecord<z.ZodString, z.ZodUnknown>, z.ZodArray<z.ZodString>]>>>;
14
+ }, z.core.$strip>>;
15
+ requiredState: z.ZodOptional<z.ZodArray<z.ZodString>>;
16
+ }, z.core.$strip>;
17
+ export declare const EvaluationResponseSchema: z.ZodObject<{
18
+ source: z.ZodOptional<z.ZodEnum<{
19
+ native: "native";
20
+ adapted: "adapted";
21
+ }>>;
22
+ answers: z.ZodRecord<z.ZodString, z.ZodDiscriminatedUnion<[z.ZodObject<{
23
+ type: z.ZodLiteral<"noul">;
24
+ noul: z.ZodNumber;
25
+ }, z.core.$strip>, z.ZodObject<{
26
+ type: z.ZodLiteral<"choice">;
27
+ choice: z.ZodString;
28
+ confidence: z.ZodNumber;
29
+ probabilities: z.ZodRecord<z.ZodString, z.ZodNumber>;
30
+ }, z.core.$strip>, z.ZodObject<{
31
+ type: z.ZodLiteral<"score">;
32
+ score: z.ZodNumber;
33
+ confidence: z.ZodNumber;
34
+ legend: z.ZodRecord<z.ZodString, z.ZodString>;
35
+ probabilities: z.ZodRecord<z.ZodString, z.ZodNumber>;
36
+ }, z.core.$strip>], "type">>;
37
+ }, z.core.$strip>;
38
+ export declare const NoulAnswerSchema: z.ZodObject<{
39
+ type: z.ZodLiteral<"noul">;
40
+ noul: z.ZodNumber;
41
+ }, z.core.$strip>;
42
+ export declare const EvaluatorAdmissionSchema: z.ZodObject<{
43
+ evaluate: z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>;
44
+ }, z.core.$strip>;
45
+ export type ModerationEvaluator = Pick<AIClient, 'evaluate'>;
46
+ export type EvaluationResponse = Awaited<ReturnType<AIClient['evaluate']>>;
47
+ //# sourceMappingURL=evaluation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evaluation.d.ts","sourceRoot":"","sources":["../../src/schemas/evaluation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAMvD,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAE5B,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;iBAElC,CAAC;AACH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;iBAEnC,CAAC;AACH,eAAO,MAAM,gBAAgB;;;iBAE3B,CAAC;AACH,eAAO,MAAM,wBAAwB;;iBAAuC,CAAC;AAC7E,MAAM,MAAM,mBAAmB,GAAG,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;AAC7D,MAAM,MAAM,kBAAkB,GAAG,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { AIEvaluationSchemaDescriptorSchema } from '@vibesdotdev/ai/evaluation-schemas/schemas/index';
2
+ import { EvaluationGenerationResponseSchema, EvaluationNoulAnswerSchema } from '@vibesdotdev/ai-schemas/generation/responses';
3
+ import * as z from 'zod/v4';
4
+ export const EvaluationBatterySchema = AIEvaluationSchemaDescriptorSchema.pick({
5
+ id: true, enabled: true, requiredState: true, questions: true
6
+ });
7
+ export const EvaluationResponseSchema = EvaluationGenerationResponseSchema.pick({
8
+ answers: true, source: true
9
+ });
10
+ export const NoulAnswerSchema = EvaluationNoulAnswerSchema.extend({
11
+ noul: z.number().min(0).max(1)
12
+ });
13
+ export const EvaluatorAdmissionSchema = z.object({ evaluate: z.function() });
14
+ //# sourceMappingURL=evaluation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evaluation.js","sourceRoot":"","sources":["../../src/schemas/evaluation.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kCAAkC,EAAE,MAAM,kDAAkD,CAAC;AACtG,OAAO,EACN,kCAAkC,EAClC,0BAA0B,EAC1B,MAAM,8CAA8C,CAAC;AACtD,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAE5B,MAAM,CAAC,MAAM,uBAAuB,GAAG,kCAAkC,CAAC,IAAI,CAAC;IAC9E,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI;CAC7D,CAAC,CAAC;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,kCAAkC,CAAC,IAAI,CAAC;IAC/E,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI;CAC3B,CAAC,CAAC;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,0BAA0B,CAAC,MAAM,CAAC;IACjE,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;CAC9B,CAAC,CAAC;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC"}
@@ -0,0 +1,6 @@
1
+ export { MODERATION_LABELS, ModerationLabelValueSchema, type ModerationLabelValue } from './labels.ts';
2
+ export { ModerationThresholdsSchema, ModerationSubjectRefSchema, ModerationSubjectDescriptorSchema, createModerationSubjectDescriptor, type ModerationThresholds, type ModerationSubjectRef, type ModerationSubjectDescriptor } from './subject.ts';
3
+ export { ModerationAnswerSourceSchema, ModerationLabelSchema, ModerationActionSchema, ModerationTriggerSchema, ModerationDecisionSchema, type ModerationAnswerSource, type ModerationLabel, type ModerationAction, type ModerationTrigger, type ModerationDecision } from './decision.ts';
4
+ export { ModerateSubjectInputSchema, ModerateSubjectOptionsSchema, ModerationStateSchema, ModerationStateInputSchema, type ModerateSubjectInput, type ModerateSubjectOptions, type ModerationState, type ModerationStateValue, type ModerationStateInput } from './input.ts';
5
+ export * from './errors.ts';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/schemas/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,iBAAiB,EAAE,0BAA0B,EAAE,KAAK,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACvG,OAAO,EACN,0BAA0B,EAC1B,0BAA0B,EAC1B,iCAAiC,EACjC,iCAAiC,EACjC,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,KAAK,2BAA2B,EAChC,MAAM,cAAc,CAAC;AACtB,OAAO,EACN,4BAA4B,EAC5B,qBAAqB,EACrB,sBAAsB,EACtB,uBAAuB,EACvB,wBAAwB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACN,0BAA0B,EAAE,4BAA4B,EACxD,qBAAqB,EAAE,0BAA0B,EACjD,KAAK,oBAAoB,EAAE,KAAK,sBAAsB,EACtD,KAAK,eAAe,EAAE,KAAK,oBAAoB,EAAE,KAAK,oBAAoB,EAC1E,MAAM,YAAY,CAAC;AACpB,cAAc,aAAa,CAAC"}
@@ -0,0 +1,9 @@
1
+ // @vibesdotdev/moderation/schemas: pure schemas and descriptor factories.
2
+ // Feature descriptor files import this entrypoint, so it never imports
3
+ // moderateSubject or anything that resolves through a runtime.
4
+ export { MODERATION_LABELS, ModerationLabelValueSchema } from "./labels.js";
5
+ export { ModerationThresholdsSchema, ModerationSubjectRefSchema, ModerationSubjectDescriptorSchema, createModerationSubjectDescriptor } from "./subject.js";
6
+ export { ModerationAnswerSourceSchema, ModerationLabelSchema, ModerationActionSchema, ModerationTriggerSchema, ModerationDecisionSchema } from "./decision.js";
7
+ export { ModerateSubjectInputSchema, ModerateSubjectOptionsSchema, ModerationStateSchema, ModerationStateInputSchema } from "./input.js";
8
+ export * from "./errors.js";
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/schemas/index.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,uEAAuE;AACvE,+DAA+D;AAE/D,OAAO,EAAE,iBAAiB,EAAE,0BAA0B,EAA6B,MAAM,aAAa,CAAC;AACvG,OAAO,EACN,0BAA0B,EAC1B,0BAA0B,EAC1B,iCAAiC,EACjC,iCAAiC,EAIjC,MAAM,cAAc,CAAC;AACtB,OAAO,EACN,4BAA4B,EAC5B,qBAAqB,EACrB,sBAAsB,EACtB,uBAAuB,EACvB,wBAAwB,EAMxB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACN,0BAA0B,EAAE,4BAA4B,EACxD,qBAAqB,EAAE,0BAA0B,EAGjD,MAAM,YAAY,CAAC;AACpB,cAAc,aAAa,CAAC"}
@@ -0,0 +1,30 @@
1
+ import * as z from 'zod/v4';
2
+ export declare const ModerationStateSchema: z.ZodRecord<z.ZodString, z.ZodType<import("@vibesdotdev/kernel/bootstrap").JsonValue, import("@vibesdotdev/kernel/bootstrap").JsonValue, z.core.$ZodTypeInternals<import("@vibesdotdev/kernel/bootstrap").JsonValue, import("@vibesdotdev/kernel/bootstrap").JsonValue>>>;
3
+ export declare const ModerationStateInputSchema: z.ZodOptional<z.ZodType<import("@vibesdotdev/kernel/bootstrap").JsonValue, import("@vibesdotdev/kernel/bootstrap").JsonValue, z.core.$ZodTypeInternals<import("@vibesdotdev/kernel/bootstrap").JsonValue, import("@vibesdotdev/kernel/bootstrap").JsonValue>>>;
4
+ export type ModerationState = z.infer<typeof ModerationStateSchema>;
5
+ export type ModerationStateValue = ModerationState[string];
6
+ export type ModerationStateInput = z.infer<typeof ModerationStateInputSchema>;
7
+ export declare const ModerateSubjectInputSchema: z.ZodObject<{
8
+ subject: z.ZodObject<{
9
+ type: z.ZodString;
10
+ id: z.ZodString;
11
+ containerId: z.ZodOptional<z.ZodString>;
12
+ }, z.core.$strip>;
13
+ state: z.ZodOptional<z.ZodType<import("@vibesdotdev/kernel/bootstrap").JsonValue, import("@vibesdotdev/kernel/bootstrap").JsonValue, z.core.$ZodTypeInternals<import("@vibesdotdev/kernel/bootstrap").JsonValue, import("@vibesdotdev/kernel/bootstrap").JsonValue>>>;
14
+ }, z.core.$strip>;
15
+ export declare const ModerationEnvelopeSchema: z.ZodObject<{
16
+ subject: z.ZodObject<{
17
+ type: z.ZodString;
18
+ id: z.ZodString;
19
+ containerId: z.ZodOptional<z.ZodString>;
20
+ }, z.core.$strip>;
21
+ state: z.ZodOptional<z.ZodUnknown>;
22
+ }, z.core.$strip>;
23
+ export type ModerationCallerState = z.infer<typeof ModerationEnvelopeSchema>['state'];
24
+ export type ModerateSubjectInput = z.infer<typeof ModerateSubjectInputSchema>;
25
+ export declare const ModerateSubjectOptionsSchema: z.ZodObject<{
26
+ now: z.ZodOptional<z.ZodFunction<z.ZodTuple<readonly [], null>, z.ZodDate>>;
27
+ }, z.core.$strip>;
28
+ export type ModerateSubjectOptions = z.infer<typeof ModerateSubjectOptionsSchema>;
29
+ export declare const EmptyStateValueSchema: z.ZodUnion<readonly [z.ZodUndefined, z.ZodNull, z.ZodString, z.ZodArray<z.ZodType<import("@vibesdotdev/kernel/bootstrap").JsonValue, import("@vibesdotdev/kernel/bootstrap").JsonValue, z.core.$ZodTypeInternals<import("@vibesdotdev/kernel/bootstrap").JsonValue, import("@vibesdotdev/kernel/bootstrap").JsonValue>>>]>;
30
+ //# sourceMappingURL=input.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../src/schemas/input.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAI5B,eAAO,MAAM,qBAAqB,2QAAwC,CAAC;AAC3E,eAAO,MAAM,0BAA0B,gQAA6B,CAAC;AACrE,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AACpE,MAAM,MAAM,oBAAoB,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;AAC3D,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAG9E,eAAO,MAAM,0BAA0B;;;;;;;iBAGrC,CAAC;AACH,eAAO,MAAM,wBAAwB;;;;;;;iBAEnC,CAAC;AACH,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC,OAAO,CAAC,CAAC;AAEtF,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAC9E,eAAO,MAAM,4BAA4B;;iBAEvC,CAAC;AACH,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAC;AAClF,eAAO,MAAM,qBAAqB,4TAEhC,CAAC"}
@@ -0,0 +1,20 @@
1
+ import * as z from 'zod/v4';
2
+ import { JsonValueSchema } from '@vibesdotdev/kernel/schemas/json';
3
+ import { ModerationSubjectRefSchema } from "./subject.js";
4
+ export const ModerationStateSchema = z.record(z.string(), JsonValueSchema);
5
+ export const ModerationStateInputSchema = JsonValueSchema.optional();
6
+ // Public input types describe JSON; orchestration inspects caller data before JSON traversal.
7
+ export const ModerateSubjectInputSchema = z.object({
8
+ subject: ModerationSubjectRefSchema,
9
+ state: ModerationStateInputSchema
10
+ });
11
+ export const ModerationEnvelopeSchema = ModerateSubjectInputSchema.extend({
12
+ state: z.unknown().optional()
13
+ });
14
+ export const ModerateSubjectOptionsSchema = z.object({
15
+ now: z.function({ input: [], output: z.date() }).optional()
16
+ });
17
+ export const EmptyStateValueSchema = z.union([
18
+ z.undefined(), z.null(), z.string().trim().max(0), z.array(JsonValueSchema).max(0)
19
+ ]);
20
+ //# sourceMappingURL=input.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"input.js","sourceRoot":"","sources":["../../src/schemas/input.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAC;AAE1D,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,eAAe,CAAC,CAAC;AAC3E,MAAM,CAAC,MAAM,0BAA0B,GAAG,eAAe,CAAC,QAAQ,EAAE,CAAC;AAKrE,8FAA8F;AAC9F,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,CAAC,MAAM,CAAC;IAClD,OAAO,EAAE,0BAA0B;IACnC,KAAK,EAAE,0BAA0B;CACjC,CAAC,CAAC;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,0BAA0B,CAAC,MAAM,CAAC;IACzE,KAAK,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;CAC7B,CAAC,CAAC;AAIH,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,CAAC,MAAM,CAAC;IACpD,GAAG,EAAE,CAAC,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,QAAQ,EAAE;CAC3D,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC;IAC5C,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;CAClF,CAAC,CAAC"}
@@ -0,0 +1,19 @@
1
+ import * as z from 'zod/v4';
2
+ /**
3
+ * The closed moderation label vocabulary. A feature's battery names its
4
+ * `noul` heads exactly as these labels, so a label IS the head name and no
5
+ * mapping table exists. Adding a label is an amendment to this package.
6
+ */
7
+ export declare const MODERATION_LABELS: readonly ["harassment", "hate", "sexual", "sexual_minors", "violence", "self_harm", "spam", "scam"];
8
+ export declare const ModerationLabelValueSchema: z.ZodEnum<{
9
+ harassment: "harassment";
10
+ hate: "hate";
11
+ sexual: "sexual";
12
+ sexual_minors: "sexual_minors";
13
+ violence: "violence";
14
+ self_harm: "self_harm";
15
+ spam: "spam";
16
+ scam: "scam";
17
+ }>;
18
+ export type ModerationLabelValue = z.infer<typeof ModerationLabelValueSchema>;
19
+ //# sourceMappingURL=labels.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"labels.d.ts","sourceRoot":"","sources":["../../src/schemas/labels.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAE5B;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,qGASpB,CAAC;AAEX,eAAO,MAAM,0BAA0B;;;;;;;;;EAA4B,CAAC;AAEpE,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC"}
@@ -0,0 +1,18 @@
1
+ import * as z from 'zod/v4';
2
+ /**
3
+ * The closed moderation label vocabulary. A feature's battery names its
4
+ * `noul` heads exactly as these labels, so a label IS the head name and no
5
+ * mapping table exists. Adding a label is an amendment to this package.
6
+ */
7
+ export const MODERATION_LABELS = [
8
+ 'harassment',
9
+ 'hate',
10
+ 'sexual',
11
+ 'sexual_minors',
12
+ 'violence',
13
+ 'self_harm',
14
+ 'spam',
15
+ 'scam'
16
+ ];
17
+ export const ModerationLabelValueSchema = z.enum(MODERATION_LABELS);
18
+ //# sourceMappingURL=labels.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"labels.js","sourceRoot":"","sources":["../../src/schemas/labels.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAE5B;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAChC,YAAY;IACZ,MAAM;IACN,QAAQ;IACR,eAAe;IACf,UAAU;IACV,WAAW;IACX,MAAM;IACN,MAAM;CACG,CAAC;AAEX,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC"}
@@ -0,0 +1,79 @@
1
+ import * as z from 'zod/v4';
2
+ /**
3
+ * Score thresholds on the 0..1 scale. A score at or above `reviewAt` asks for
4
+ * review; at or above `hideAt` it hides (native answers only).
5
+ */
6
+ export declare const ModerationThresholdsSchema: z.ZodObject<{
7
+ reviewAt: z.ZodNumber;
8
+ hideAt: z.ZodNumber;
9
+ }, z.core.$strip>;
10
+ export type ModerationThresholds = z.infer<typeof ModerationThresholdsSchema>;
11
+ /** Which piece of content a label or decision is about. `type` is the subject descriptor id. */
12
+ export declare const ModerationSubjectRefSchema: z.ZodObject<{
13
+ type: z.ZodString;
14
+ id: z.ZodString;
15
+ containerId: z.ZodOptional<z.ZodString>;
16
+ }, z.core.$strip>;
17
+ export type ModerationSubjectRef = z.infer<typeof ModerationSubjectRefSchema>;
18
+ /**
19
+ * `moderation/subject` descriptor: a moderatable content type, the
20
+ * `ai/evaluation-schema` battery that judges it, the labels it scores and the
21
+ * thresholds that turn scores into actions.
22
+ */
23
+ export declare const ModerationSubjectDescriptorSchema: z.ZodObject<{
24
+ tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
25
+ hardware: z.ZodOptional<z.ZodArray<z.ZodString>>;
26
+ enabled: z.ZodOptional<z.ZodBoolean>;
27
+ priority: z.ZodOptional<z.ZodNumber>;
28
+ capabilityId: z.ZodOptional<z.ZodString>;
29
+ requiredContext: z.ZodOptional<z.ZodArray<z.ZodString>>;
30
+ optionalContext: z.ZodOptional<z.ZodArray<z.ZodString>>;
31
+ config: z.ZodOptional<z.ZodUnknown>;
32
+ retention: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
33
+ maxAgeDays: z.ZodOptional<z.ZodNumber>;
34
+ maxEntries: z.ZodOptional<z.ZodNumber>;
35
+ maxBytes: z.ZodOptional<z.ZodNumber>;
36
+ cascadeFrom: z.ZodOptional<z.ZodString>;
37
+ ageField: z.ZodOptional<z.ZodString>;
38
+ reason: z.ZodString;
39
+ enforcedBy: z.ZodOptional<z.ZodString>;
40
+ }, z.core.$strip>]>>;
41
+ kind: z.ZodLiteral<"moderation/subject">;
42
+ id: z.ZodString;
43
+ name: z.ZodString;
44
+ description: z.ZodString;
45
+ batteryId: z.ZodString;
46
+ labels: z.ZodArray<z.ZodEnum<{
47
+ harassment: "harassment";
48
+ hate: "hate";
49
+ sexual: "sexual";
50
+ sexual_minors: "sexual_minors";
51
+ violence: "violence";
52
+ self_harm: "self_harm";
53
+ spam: "spam";
54
+ scam: "scam";
55
+ }>>;
56
+ thresholds: z.ZodObject<{
57
+ default: z.ZodObject<{
58
+ reviewAt: z.ZodNumber;
59
+ hideAt: z.ZodNumber;
60
+ }, z.core.$strip>;
61
+ labels: z.ZodOptional<z.ZodRecord<z.ZodEnum<{
62
+ harassment: "harassment";
63
+ hate: "hate";
64
+ sexual: "sexual";
65
+ sexual_minors: "sexual_minors";
66
+ violence: "violence";
67
+ self_harm: "self_harm";
68
+ spam: "spam";
69
+ scam: "scam";
70
+ }> & z.core.$partial, z.ZodObject<{
71
+ reviewAt: z.ZodNumber;
72
+ hideAt: z.ZodNumber;
73
+ }, z.core.$strip>>>;
74
+ }, z.core.$strip>;
75
+ }, z.core.$strip>;
76
+ export type ModerationSubjectDescriptor = z.infer<typeof ModerationSubjectDescriptorSchema>;
77
+ /** Parse a subject descriptor and stamp its kind. Throws on an invalid subject. */
78
+ export declare function createModerationSubjectDescriptor(input: Omit<z.input<typeof ModerationSubjectDescriptorSchema>, 'kind'>): ModerationSubjectDescriptor;
79
+ //# sourceMappingURL=subject.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subject.d.ts","sourceRoot":"","sources":["../../src/schemas/subject.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAM5B;;;GAGG;AACH,eAAO,MAAM,0BAA0B;;;iBAOpC,CAAC;AAEJ,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAE9E,gGAAgG;AAChG,eAAO,MAAM,0BAA0B;;;;iBAIrC,CAAC;AAEH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAE9E;;;;GAIG;AACH,eAAO,MAAM,iCAAiC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAgC5C,CAAC;AAEH,MAAM,MAAM,2BAA2B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iCAAiC,CAAC,CAAC;AAE5F,mFAAmF;AACnF,wBAAgB,iCAAiC,CAChD,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,iCAAiC,CAAC,EAAE,MAAM,CAAC,GACpE,2BAA2B,CAE7B"}
@@ -0,0 +1,66 @@
1
+ import { RuntimeDescriptorSchema } from '@vibesdotdev/kernel/schemas';
2
+ import * as z from 'zod/v4';
3
+ import { ModerationLabelValueSchema } from "./labels.js";
4
+ /** `<feature>.<subject>`, e.g. `chat.message` or a host-owned `cinderlink.chat-message`. */
5
+ const SUBJECT_ID = /^[a-z][a-z0-9-]*\.[a-z][a-z0-9-]*$/;
6
+ /**
7
+ * Score thresholds on the 0..1 scale. A score at or above `reviewAt` asks for
8
+ * review; at or above `hideAt` it hides (native answers only).
9
+ */
10
+ export const ModerationThresholdsSchema = z
11
+ .object({
12
+ reviewAt: z.number().min(0).max(1),
13
+ hideAt: z.number().min(0).max(1)
14
+ })
15
+ .refine((thresholds) => thresholds.reviewAt <= thresholds.hideAt, {
16
+ message: 'reviewAt must not exceed hideAt'
17
+ });
18
+ /** Which piece of content a label or decision is about. `type` is the subject descriptor id. */
19
+ export const ModerationSubjectRefSchema = z.object({
20
+ type: z.string().regex(SUBJECT_ID, 'subject type must be a moderation/subject id like chat.message'),
21
+ id: z.string().min(1),
22
+ containerId: z.string().min(1).optional()
23
+ });
24
+ /**
25
+ * `moderation/subject` descriptor: a moderatable content type, the
26
+ * `ai/evaluation-schema` battery that judges it, the labels it scores and the
27
+ * thresholds that turn scores into actions.
28
+ */
29
+ export const ModerationSubjectDescriptorSchema = RuntimeDescriptorSchema.extend({
30
+ kind: z.literal('moderation/subject'),
31
+ id: z.string().regex(SUBJECT_ID, 'subject id must look like <feature>.<subject>'),
32
+ name: z.string().min(1),
33
+ description: z.string().min(1),
34
+ batteryId: z.string().min(1),
35
+ labels: z.array(ModerationLabelValueSchema).min(1),
36
+ thresholds: z.object({
37
+ default: ModerationThresholdsSchema,
38
+ labels: z.partialRecord(ModerationLabelValueSchema, ModerationThresholdsSchema).optional()
39
+ })
40
+ }).superRefine((subject, ctx) => {
41
+ const seen = new Set();
42
+ for (const [index, label] of subject.labels.entries()) {
43
+ if (seen.has(label)) {
44
+ ctx.addIssue({
45
+ code: 'custom',
46
+ path: ['labels', index],
47
+ message: `duplicate label '${label}'`
48
+ });
49
+ }
50
+ seen.add(label);
51
+ }
52
+ for (const label of Object.keys(subject.thresholds.labels ?? {})) {
53
+ if (!seen.has(label)) {
54
+ ctx.addIssue({
55
+ code: 'custom',
56
+ path: ['thresholds', 'labels', label],
57
+ message: `threshold override for undeclared label '${label}'`
58
+ });
59
+ }
60
+ }
61
+ });
62
+ /** Parse a subject descriptor and stamp its kind. Throws on an invalid subject. */
63
+ export function createModerationSubjectDescriptor(input) {
64
+ return ModerationSubjectDescriptorSchema.parse({ ...input, kind: 'moderation/subject' });
65
+ }
66
+ //# sourceMappingURL=subject.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subject.js","sourceRoot":"","sources":["../../src/schemas/subject.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AAEzD,4FAA4F;AAC5F,MAAM,UAAU,GAAG,oCAAoC,CAAC;AAExD;;;GAGG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC;KACzC,MAAM,CAAC;IACP,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IAClC,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;CAChC,CAAC;KACD,MAAM,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,QAAQ,IAAI,UAAU,CAAC,MAAM,EAAE;IACjE,OAAO,EAAE,iCAAiC;CAC1C,CAAC,CAAC;AAIJ,gGAAgG;AAChG,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,CAAC,MAAM,CAAC;IAClD,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,UAAU,EAAE,gEAAgE,CAAC;IACpG,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACrB,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ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B,CAAC;IACD,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,MAAM,IAAI,EAAE,CAAC,EAAE,CAAC;QAClE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;YACtB,GAAG,CAAC,QAAQ,CAAC;gBACZ,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,CAAC,YAAY,EAAE,QAAQ,EAAE,KAAK,CAAC;gBACrC,OAAO,EAAE,4CAA4C,KAAK,GAAG;aAC7D,CAAC,CAAC;QACJ,CAAC;IACF,CAAC;AACF,CAAC,CAAC,CAAC;AAIH,mFAAmF;AACnF,MAAM,UAAU,iCAAiC,CAChD,KAAsE;IAEtE,OAAO,iCAAiC,CAAC,KAAK,CAAC,EAAE,GAAG,KAAK,EAAE,IAAI,EAAE,oBAAoB,EAAE,CAAC,CAAC;AAC1F,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,102 @@
1
1
  {
2
2
  "name": "@vibesdotdev/moderation",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.0.0-rc.5",
4
+ "dependencies": {
5
+ "@vibesdotdev/kernel": "^1.0.0-rc.13",
6
+ "zod": "^4.6.7",
7
+ "@vibesdotdev/ai": "^1.0.0-rc.10",
8
+ "@vibesdotdev/ai-schemas": "^1.0.0-rc.6"
9
+ },
10
+ "gitHead": "769aa8a370cf2a9d1ee086cf71c986c7591356cf",
11
+ "_vibes_source": {
12
+ "repo": "ssh://git@git.vibes.dev/vibesdotdev/framework.git",
13
+ "sha": "769aa8a370cf2a9d1ee086cf71c986c7591356cf",
14
+ "workspaceDigest": "sha256:2a2c017574a051cd196d2158a6507e06c3f25f8ba78823461682b6a1d6983af5"
15
+ },
16
+ "main": "./dist/index.js",
17
+ "exports": {
18
+ ".": {
19
+ "bun": "./dist/index.js",
20
+ "types": "./dist/index.d.ts",
21
+ "import": "./dist/index.js",
22
+ "default": "./dist/index.js"
23
+ },
24
+ "./plugin": {
25
+ "bun": "./dist/moderation.plugin.js",
26
+ "types": "./dist/moderation.plugin.d.ts",
27
+ "import": "./dist/moderation.plugin.js",
28
+ "default": "./dist/moderation.plugin.js"
29
+ },
30
+ "./schemas": {
31
+ "bun": "./dist/schemas/index.js",
32
+ "types": "./dist/schemas/index.d.ts",
33
+ "import": "./dist/schemas/index.js",
34
+ "default": "./dist/schemas/index.js"
35
+ }
36
+ },
37
+ "files": [
38
+ "dist",
39
+ "README.md",
40
+ "LICENSE",
41
+ "!dist/**/__tests__/**",
42
+ "!dist/**/*.test.js",
43
+ "!dist/**/*.test.d.ts",
44
+ "!dist/**/*.spec.js",
45
+ "!dist/**/*.spec.d.ts",
46
+ "!dist/**/*.tsbuildinfo",
47
+ "!**/.turbo/**",
48
+ "!**/.svelte-kit/**",
49
+ "!**/.vibes/**",
50
+ "!**/__tests__/**",
51
+ "!**/__stubs__/**",
52
+ "!**/*.test.js",
53
+ "!**/*.test.mjs",
54
+ "!**/*.test.cjs",
55
+ "!**/*.test.jsx",
56
+ "!**/*.test.ts",
57
+ "!**/*.test.mts",
58
+ "!**/*.test.cts",
59
+ "!**/*.test.tsx",
60
+ "!**/*.spec.js",
61
+ "!**/*.spec.mjs",
62
+ "!**/*.spec.cjs",
63
+ "!**/*.spec.jsx",
64
+ "!**/*.spec.ts",
65
+ "!**/*.spec.mts",
66
+ "!**/*.spec.cts",
67
+ "!**/*.spec.tsx",
68
+ "!**/SPEC.md",
69
+ "!**/tsconfig.json",
70
+ "!**/tsconfig.*.json",
71
+ "!**/*.tsbuildinfo",
72
+ "!**/.build-ok.json",
73
+ "!**/*.tgz"
74
+ ],
75
+ "scripts": {
76
+ "lint": "node ../node_modules/@vibesdotdev/internal-oxlint-toolchain/ratchet.mjs .",
77
+ "test": "${BUN:-bun} test src",
78
+ "check": "${BUN:-bun} --bun tsc -p tsconfig.json",
79
+ "build": "rm -rf dist && ${BUN:-bun} --bun tsc -p tsconfig.build.json"
80
+ },
81
+ "repository": {
82
+ "type": "git",
83
+ "url": "ssh://git@git.vibes.dev/vibesdotdev/framework.git",
84
+ "directory": "moderation"
85
+ },
86
+ "publishConfig": {
87
+ "registry": "https://packages.vibes.dev",
88
+ "access": "public"
89
+ },
90
+ "vibes": {
91
+ "visibility": "public",
92
+ "registry": {
93
+ "repositoryId": "4b1374d4-6830-4bfd-98e3-de66416368a8",
94
+ "directory": "moderation"
95
+ },
96
+ "handedRuntimeLogging": true
97
+ },
98
+ "description": "Content moderation contract: the moderation/subject kind, the label vocabulary, label and decision records, and moderateSubject over the runtime's AI evaluator.",
99
+ "type": "module",
100
+ "types": "./dist/index.d.ts",
101
+ "license": "MIT"
102
+ }