@handlebar/governance-schema 0.0.4 → 0.0.6-dev.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/dist/audit/events.base.d.ts +28 -0
- package/dist/audit/events.d.ts +52 -0
- package/dist/audit/events.llm.d.ts +106 -0
- package/dist/audit/index.d.ts +4 -0
- package/dist/enduser.types.d.ts +13 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +65 -33
- package/dist/rules/rule.types.d.ts +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const AuditEnvelopeSchema: z.ZodObject<{
|
|
3
|
+
schema: z.ZodLiteral<"handlebar.audit.v1">;
|
|
4
|
+
ts: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodDate>;
|
|
5
|
+
runId: z.ZodString;
|
|
6
|
+
stepIndex: z.ZodOptional<z.ZodNumber>;
|
|
7
|
+
decisionId: z.ZodOptional<z.ZodString>;
|
|
8
|
+
user: z.ZodOptional<z.ZodObject<{
|
|
9
|
+
userId: z.ZodOptional<z.ZodString>;
|
|
10
|
+
userCategory: z.ZodOptional<z.ZodString>;
|
|
11
|
+
sessionId: z.ZodOptional<z.ZodString>;
|
|
12
|
+
}, z.core.$strip>>;
|
|
13
|
+
otel: z.ZodOptional<z.ZodObject<{
|
|
14
|
+
traceId: z.ZodOptional<z.ZodString>;
|
|
15
|
+
spanId: z.ZodOptional<z.ZodString>;
|
|
16
|
+
}, z.core.$strip>>;
|
|
17
|
+
sample: z.ZodOptional<z.ZodObject<{
|
|
18
|
+
rate: z.ZodOptional<z.ZodNumber>;
|
|
19
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
20
|
+
}, z.core.$strip>>;
|
|
21
|
+
redaction: z.ZodOptional<z.ZodObject<{
|
|
22
|
+
level: z.ZodOptional<z.ZodEnum<{
|
|
23
|
+
none: "none";
|
|
24
|
+
partial: "partial";
|
|
25
|
+
strict: "strict";
|
|
26
|
+
}>>;
|
|
27
|
+
}, z.core.$strip>>;
|
|
28
|
+
}, z.core.$strip>;
|
package/dist/audit/events.d.ts
CHANGED
|
@@ -514,6 +514,58 @@ export declare const AuditEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
514
514
|
details: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
515
515
|
fatal: z.ZodOptional<z.ZodBoolean>;
|
|
516
516
|
}, z.core.$strip>;
|
|
517
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
518
|
+
schema: z.ZodLiteral<"handlebar.audit.v1">;
|
|
519
|
+
ts: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodDate>;
|
|
520
|
+
runId: z.ZodString;
|
|
521
|
+
stepIndex: z.ZodOptional<z.ZodNumber>;
|
|
522
|
+
decisionId: z.ZodOptional<z.ZodString>;
|
|
523
|
+
user: z.ZodOptional<z.ZodObject<{
|
|
524
|
+
userId: z.ZodOptional<z.ZodString>;
|
|
525
|
+
userCategory: z.ZodOptional<z.ZodString>;
|
|
526
|
+
sessionId: z.ZodOptional<z.ZodString>;
|
|
527
|
+
}, z.core.$strip>>;
|
|
528
|
+
otel: z.ZodOptional<z.ZodObject<{
|
|
529
|
+
traceId: z.ZodOptional<z.ZodString>;
|
|
530
|
+
spanId: z.ZodOptional<z.ZodString>;
|
|
531
|
+
}, z.core.$strip>>;
|
|
532
|
+
sample: z.ZodOptional<z.ZodObject<{
|
|
533
|
+
rate: z.ZodOptional<z.ZodNumber>;
|
|
534
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
535
|
+
}, z.core.$strip>>;
|
|
536
|
+
redaction: z.ZodOptional<z.ZodObject<{
|
|
537
|
+
level: z.ZodOptional<z.ZodEnum<{
|
|
538
|
+
none: "none";
|
|
539
|
+
partial: "partial";
|
|
540
|
+
strict: "strict";
|
|
541
|
+
}>>;
|
|
542
|
+
}, z.core.$strip>>;
|
|
543
|
+
kind: z.ZodLiteral<"message.raw.created">;
|
|
544
|
+
data: z.ZodObject<{
|
|
545
|
+
messageId: z.ZodUUID;
|
|
546
|
+
role: z.ZodEnum<{
|
|
547
|
+
user: "user";
|
|
548
|
+
system: "system";
|
|
549
|
+
developer: "developer";
|
|
550
|
+
assistant: "assistant";
|
|
551
|
+
tool: "tool";
|
|
552
|
+
}>;
|
|
553
|
+
kind: z.ZodEnum<{
|
|
554
|
+
input: "input";
|
|
555
|
+
output: "output";
|
|
556
|
+
tool_call: "tool_call";
|
|
557
|
+
tool_result: "tool_result";
|
|
558
|
+
observation: "observation";
|
|
559
|
+
internal_summary: "internal_summary";
|
|
560
|
+
thinking: "thinking";
|
|
561
|
+
}>;
|
|
562
|
+
content: z.ZodString;
|
|
563
|
+
contentTruncated: z.ZodBoolean;
|
|
564
|
+
parentMessageId: z.ZodOptional<z.ZodUUID>;
|
|
565
|
+
turnIndex: z.ZodOptional<z.ZodNumber>;
|
|
566
|
+
name: z.ZodOptional<z.ZodString>;
|
|
567
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
568
|
+
}, z.core.$strip>;
|
|
517
569
|
}, z.core.$strip>], "kind">;
|
|
518
570
|
export type AuditEvent = z.infer<typeof AuditEventSchema>;
|
|
519
571
|
export type AuditEventByKind = {
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const MessageRoleSchema: z.ZodEnum<{
|
|
3
|
+
user: "user";
|
|
4
|
+
system: "system";
|
|
5
|
+
developer: "developer";
|
|
6
|
+
assistant: "assistant";
|
|
7
|
+
tool: "tool";
|
|
8
|
+
}>;
|
|
9
|
+
/**
|
|
10
|
+
* Message "kind" is about how it appears in an agent flow.
|
|
11
|
+
* - input: user message
|
|
12
|
+
* - output: assistant natural language output
|
|
13
|
+
* - tool_call: assistant initiated tool call (as text/JSON tool call)
|
|
14
|
+
* - tool_result: tool return value summarised or raw ref
|
|
15
|
+
* - observation: agent framework observation (non-tool, e.g. environment signal)
|
|
16
|
+
* - internal_summary: optional short summary generated for UI
|
|
17
|
+
* - thinking: model CoT
|
|
18
|
+
*
|
|
19
|
+
*/
|
|
20
|
+
export declare const MessageKindSchema: z.ZodEnum<{
|
|
21
|
+
input: "input";
|
|
22
|
+
output: "output";
|
|
23
|
+
tool_call: "tool_call";
|
|
24
|
+
tool_result: "tool_result";
|
|
25
|
+
observation: "observation";
|
|
26
|
+
internal_summary: "internal_summary";
|
|
27
|
+
thinking: "thinking";
|
|
28
|
+
}>;
|
|
29
|
+
export declare const MessageSchema: z.ZodObject<{
|
|
30
|
+
messageId: z.ZodUUID;
|
|
31
|
+
role: z.ZodEnum<{
|
|
32
|
+
user: "user";
|
|
33
|
+
system: "system";
|
|
34
|
+
developer: "developer";
|
|
35
|
+
assistant: "assistant";
|
|
36
|
+
tool: "tool";
|
|
37
|
+
}>;
|
|
38
|
+
kind: z.ZodEnum<{
|
|
39
|
+
input: "input";
|
|
40
|
+
output: "output";
|
|
41
|
+
tool_call: "tool_call";
|
|
42
|
+
tool_result: "tool_result";
|
|
43
|
+
observation: "observation";
|
|
44
|
+
internal_summary: "internal_summary";
|
|
45
|
+
thinking: "thinking";
|
|
46
|
+
}>;
|
|
47
|
+
content: z.ZodString;
|
|
48
|
+
contentTruncated: z.ZodBoolean;
|
|
49
|
+
parentMessageId: z.ZodOptional<z.ZodUUID>;
|
|
50
|
+
turnIndex: z.ZodOptional<z.ZodNumber>;
|
|
51
|
+
name: z.ZodOptional<z.ZodString>;
|
|
52
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
53
|
+
}, z.core.$strip>;
|
|
54
|
+
export declare const MessageEventSchema: z.ZodObject<{
|
|
55
|
+
schema: z.ZodLiteral<"handlebar.audit.v1">;
|
|
56
|
+
ts: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodDate>;
|
|
57
|
+
runId: z.ZodString;
|
|
58
|
+
stepIndex: z.ZodOptional<z.ZodNumber>;
|
|
59
|
+
decisionId: z.ZodOptional<z.ZodString>;
|
|
60
|
+
user: z.ZodOptional<z.ZodObject<{
|
|
61
|
+
userId: z.ZodOptional<z.ZodString>;
|
|
62
|
+
userCategory: z.ZodOptional<z.ZodString>;
|
|
63
|
+
sessionId: z.ZodOptional<z.ZodString>;
|
|
64
|
+
}, z.core.$strip>>;
|
|
65
|
+
otel: z.ZodOptional<z.ZodObject<{
|
|
66
|
+
traceId: z.ZodOptional<z.ZodString>;
|
|
67
|
+
spanId: z.ZodOptional<z.ZodString>;
|
|
68
|
+
}, z.core.$strip>>;
|
|
69
|
+
sample: z.ZodOptional<z.ZodObject<{
|
|
70
|
+
rate: z.ZodOptional<z.ZodNumber>;
|
|
71
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
72
|
+
}, z.core.$strip>>;
|
|
73
|
+
redaction: z.ZodOptional<z.ZodObject<{
|
|
74
|
+
level: z.ZodOptional<z.ZodEnum<{
|
|
75
|
+
none: "none";
|
|
76
|
+
partial: "partial";
|
|
77
|
+
strict: "strict";
|
|
78
|
+
}>>;
|
|
79
|
+
}, z.core.$strip>>;
|
|
80
|
+
kind: z.ZodLiteral<"message.raw.created">;
|
|
81
|
+
data: z.ZodObject<{
|
|
82
|
+
messageId: z.ZodUUID;
|
|
83
|
+
role: z.ZodEnum<{
|
|
84
|
+
user: "user";
|
|
85
|
+
system: "system";
|
|
86
|
+
developer: "developer";
|
|
87
|
+
assistant: "assistant";
|
|
88
|
+
tool: "tool";
|
|
89
|
+
}>;
|
|
90
|
+
kind: z.ZodEnum<{
|
|
91
|
+
input: "input";
|
|
92
|
+
output: "output";
|
|
93
|
+
tool_call: "tool_call";
|
|
94
|
+
tool_result: "tool_result";
|
|
95
|
+
observation: "observation";
|
|
96
|
+
internal_summary: "internal_summary";
|
|
97
|
+
thinking: "thinking";
|
|
98
|
+
}>;
|
|
99
|
+
content: z.ZodString;
|
|
100
|
+
contentTruncated: z.ZodBoolean;
|
|
101
|
+
parentMessageId: z.ZodOptional<z.ZodUUID>;
|
|
102
|
+
turnIndex: z.ZodOptional<z.ZodNumber>;
|
|
103
|
+
name: z.ZodOptional<z.ZodString>;
|
|
104
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
105
|
+
}, z.core.$strip>;
|
|
106
|
+
}, z.core.$strip>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const EndUserConfigSchema: z.ZodObject<{
|
|
3
|
+
externalId: z.ZodString;
|
|
4
|
+
metadata: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
5
|
+
name: z.ZodOptional<z.ZodString>;
|
|
6
|
+
}, z.core.$strip>;
|
|
7
|
+
export declare const EndUserGroupConfigSchema: z.ZodObject<{
|
|
8
|
+
externalId: z.ZodString;
|
|
9
|
+
metadata: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
10
|
+
name: z.ZodOptional<z.ZodString>;
|
|
11
|
+
}, z.core.$strip>;
|
|
12
|
+
export type EndUserConfig = z.infer<typeof EndUserConfigSchema>;
|
|
13
|
+
export type EndUserGroupConfig = z.infer<typeof EndUserGroupConfigSchema>;
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -12574,29 +12574,7 @@ function date4(params) {
|
|
|
12574
12574
|
|
|
12575
12575
|
// node_modules/zod/v4/classic/external.js
|
|
12576
12576
|
config(en_default());
|
|
12577
|
-
//
|
|
12578
|
-
var zod_default = exports_external;
|
|
12579
|
-
|
|
12580
|
-
// src/audit/governance-actions.ts
|
|
12581
|
-
var AppliedActionSchema = exports_external.object({
|
|
12582
|
-
type: exports_external.custom(),
|
|
12583
|
-
ruleId: exports_external.string()
|
|
12584
|
-
});
|
|
12585
|
-
var GovernanceDecisionSchema = exports_external.object({
|
|
12586
|
-
effect: exports_external.custom(),
|
|
12587
|
-
code: exports_external.custom(),
|
|
12588
|
-
matchedRuleIds: exports_external.array(exports_external.string()),
|
|
12589
|
-
appliedActions: exports_external.array(AppliedActionSchema),
|
|
12590
|
-
reason: exports_external.optional(exports_external.string())
|
|
12591
|
-
});
|
|
12592
|
-
|
|
12593
|
-
// src/audit/events.ts
|
|
12594
|
-
var CountersSchema = exports_external.record(exports_external.string(), exports_external.union([exports_external.string(), exports_external.number()]));
|
|
12595
|
-
var ToolMetaSchema = exports_external.object({
|
|
12596
|
-
redacted: exports_external.boolean(),
|
|
12597
|
-
redactedFields: exports_external.array(exports_external.string()).optional(),
|
|
12598
|
-
sizeBytesApprox: exports_external.number().min(0).optional()
|
|
12599
|
-
});
|
|
12577
|
+
// src/audit/events.base.ts
|
|
12600
12578
|
var AuditEnvelopeSchema = exports_external.object({
|
|
12601
12579
|
schema: exports_external.literal("handlebar.audit.v1"),
|
|
12602
12580
|
ts: exports_external.preprocess((v) => {
|
|
@@ -12628,6 +12606,54 @@ var AuditEnvelopeSchema = exports_external.object({
|
|
|
12628
12606
|
level: exports_external.enum(["none", "partial", "strict"]).optional()
|
|
12629
12607
|
}).optional()
|
|
12630
12608
|
});
|
|
12609
|
+
|
|
12610
|
+
// src/audit/events.llm.ts
|
|
12611
|
+
var MessageRoleSchema = exports_external.enum(["system", "developer", "user", "assistant", "tool"]);
|
|
12612
|
+
var MessageKindSchema = exports_external.enum([
|
|
12613
|
+
"input",
|
|
12614
|
+
"output",
|
|
12615
|
+
"tool_call",
|
|
12616
|
+
"tool_result",
|
|
12617
|
+
"observation",
|
|
12618
|
+
"internal_summary",
|
|
12619
|
+
"thinking"
|
|
12620
|
+
]);
|
|
12621
|
+
var MessageSchema = exports_external.object({
|
|
12622
|
+
messageId: exports_external.uuidv7(),
|
|
12623
|
+
role: MessageRoleSchema,
|
|
12624
|
+
kind: MessageKindSchema,
|
|
12625
|
+
content: exports_external.string(),
|
|
12626
|
+
contentTruncated: exports_external.boolean(),
|
|
12627
|
+
parentMessageId: exports_external.uuidv7().optional(),
|
|
12628
|
+
turnIndex: exports_external.number().int().min(0).optional(),
|
|
12629
|
+
name: exports_external.string().optional(),
|
|
12630
|
+
tags: exports_external.array(exports_external.string()).optional()
|
|
12631
|
+
});
|
|
12632
|
+
var MessageEventSchema = AuditEnvelopeSchema.extend({
|
|
12633
|
+
kind: exports_external.literal("message.raw.created"),
|
|
12634
|
+
data: MessageSchema
|
|
12635
|
+
});
|
|
12636
|
+
|
|
12637
|
+
// src/audit/governance-actions.ts
|
|
12638
|
+
var AppliedActionSchema = exports_external.object({
|
|
12639
|
+
type: exports_external.custom(),
|
|
12640
|
+
ruleId: exports_external.string()
|
|
12641
|
+
});
|
|
12642
|
+
var GovernanceDecisionSchema = exports_external.object({
|
|
12643
|
+
effect: exports_external.custom(),
|
|
12644
|
+
code: exports_external.custom(),
|
|
12645
|
+
matchedRuleIds: exports_external.array(exports_external.string()),
|
|
12646
|
+
appliedActions: exports_external.array(AppliedActionSchema),
|
|
12647
|
+
reason: exports_external.optional(exports_external.string())
|
|
12648
|
+
});
|
|
12649
|
+
|
|
12650
|
+
// src/audit/events.ts
|
|
12651
|
+
var CountersSchema = exports_external.record(exports_external.string(), exports_external.union([exports_external.string(), exports_external.number()]));
|
|
12652
|
+
var ToolMetaSchema = exports_external.object({
|
|
12653
|
+
redacted: exports_external.boolean(),
|
|
12654
|
+
redactedFields: exports_external.array(exports_external.string()).optional(),
|
|
12655
|
+
sizeBytesApprox: exports_external.number().min(0).optional()
|
|
12656
|
+
});
|
|
12631
12657
|
var RunStartedEventSchema = AuditEnvelopeSchema.extend({
|
|
12632
12658
|
kind: exports_external.literal("run.started"),
|
|
12633
12659
|
data: exports_external.object({
|
|
@@ -12717,18 +12743,19 @@ var AuditEventSchema = exports_external.discriminatedUnion("kind", [
|
|
|
12717
12743
|
ToolDecisionEventSchema,
|
|
12718
12744
|
ToolResultEventSchema,
|
|
12719
12745
|
RunEndedEventSchema,
|
|
12720
|
-
ErrorEventSchema
|
|
12746
|
+
ErrorEventSchema,
|
|
12747
|
+
MessageEventSchema
|
|
12721
12748
|
]);
|
|
12722
12749
|
// src/rules/rule.types.ts
|
|
12723
|
-
var RuleConfigSchema =
|
|
12724
|
-
priority:
|
|
12725
|
-
when:
|
|
12726
|
-
condition:
|
|
12727
|
-
actions:
|
|
12728
|
-
});
|
|
12729
|
-
var RuleSchema =
|
|
12730
|
-
id:
|
|
12731
|
-
policy_id:
|
|
12750
|
+
var RuleConfigSchema = exports_external.object({
|
|
12751
|
+
priority: exports_external.number().min(0),
|
|
12752
|
+
when: exports_external.custom(),
|
|
12753
|
+
condition: exports_external.custom(),
|
|
12754
|
+
actions: exports_external.array(exports_external.custom())
|
|
12755
|
+
});
|
|
12756
|
+
var RuleSchema = exports_external.object({
|
|
12757
|
+
id: exports_external.uuid({ version: "v7" }),
|
|
12758
|
+
policy_id: exports_external.uuid({ version: "v7" })
|
|
12732
12759
|
}).and(RuleConfigSchema);
|
|
12733
12760
|
export {
|
|
12734
12761
|
ToolResultEventSchema,
|
|
@@ -12737,10 +12764,15 @@ export {
|
|
|
12737
12764
|
RunEndedEventSchema,
|
|
12738
12765
|
RuleSchema,
|
|
12739
12766
|
RuleConfigSchema,
|
|
12767
|
+
MessageSchema,
|
|
12768
|
+
MessageRoleSchema,
|
|
12769
|
+
MessageKindSchema,
|
|
12770
|
+
MessageEventSchema,
|
|
12740
12771
|
HitlMetaSchema,
|
|
12741
12772
|
GovernanceDecisionSchema,
|
|
12742
12773
|
ErrorEventSchema,
|
|
12743
12774
|
AuditEventSchema,
|
|
12775
|
+
AuditEnvelopeSchema,
|
|
12744
12776
|
AppliedActionSchema
|
|
12745
12777
|
};
|
|
12746
12778
|
// 🚲
|