@handlebar/governance-schema 0.0.6-dev.6 → 0.0.6-dev.8

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.
@@ -1,11 +1,12 @@
1
- import type { JSONValue } from "./common";
1
+ import { z } from "zod";
2
2
  /**
3
3
  * Delegate condition evaluation to a user-defined function.
4
4
  * - `name` is resolved by the host SDK/application
5
- * - `args` is an opaque, JSON-serializable payload consumed by user code
5
+ * - `args` is an opaque, JSON-serialisable payload consumed by user code
6
6
  */
7
- export type CustomFunctionCondition = {
8
- kind: "custom";
9
- name: string;
10
- args?: JSONValue;
11
- };
7
+ export declare const CustomFunctionConditionSchema: z.ZodObject<{
8
+ kind: z.ZodLiteral<"custom">;
9
+ name: z.ZodString;
10
+ args: z.ZodOptional<z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>, z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>]>>;
11
+ }, z.core.$strict>;
12
+ export type CustomFunctionCondition = z.infer<typeof CustomFunctionConditionSchema>;
@@ -1,4 +1,10 @@
1
- export type RuleEffectKind = "allow" | "hitl" | "block";
1
+ import z from "zod";
2
+ export declare const RuleEffectKindSchema: z.ZodEnum<{
3
+ allow: "allow";
4
+ block: "block";
5
+ hitl: "hitl";
6
+ }>;
7
+ export type RuleEffectKind = z.infer<typeof RuleEffectKindSchema>;
2
8
  /**
3
9
  * Direct impact of a rule breach.
4
10
  *
@@ -6,13 +12,14 @@ export type RuleEffectKind = "allow" | "hitl" | "block";
6
12
  * This is in contract to side effects (yet to be defined),
7
13
  * which would include "log" or "modify context".
8
14
  */
9
- export type RuleEffect = {
10
- type: "allow";
11
- reason?: string;
12
- } | {
13
- type: "hitl";
14
- reason?: string;
15
- } | {
16
- type: "block";
17
- reason?: string;
18
- };
15
+ export declare const RuleEffectSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
16
+ type: z.ZodLiteral<"allow">;
17
+ reason: z.ZodOptional<z.ZodString>;
18
+ }, z.core.$strict>, z.ZodObject<{
19
+ type: z.ZodLiteral<"hitl">;
20
+ reason: z.ZodOptional<z.ZodString>;
21
+ }, z.core.$strict>, z.ZodObject<{
22
+ type: z.ZodLiteral<"block">;
23
+ reason: z.ZodOptional<z.ZodString>;
24
+ }, z.core.$strict>], "type">;
25
+ export type RuleEffect = z.infer<typeof RuleEffectSchema>;
@@ -1,21 +1,23 @@
1
+ import { z } from "zod";
1
2
  /**
2
3
  * Match on arbitrary tags assigned to the enduser.
3
4
  * "enduser" in this context means the users of a Handlebar user.
4
5
  * - has: existence AND truthiness of the tag. E.g. "has:tier" would be false if "tier=0", "tier=false", or no "tier" tag exists.
5
6
  * - hasValue: tag exists and has an exact given value
6
7
  */
7
- export type EndUserTagCondition = {
8
- kind: "enduserTag";
9
- op: "has";
10
- tag: string;
11
- } | {
12
- kind: "enduserTag";
13
- op: "hasValue";
14
- tag: string;
15
- value: string;
16
- } | {
17
- kind: "enduserTag";
18
- op: "hasValueAny";
19
- tag: string;
20
- values: string[];
21
- };
8
+ export declare const EndUserTagConditionSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
9
+ kind: z.ZodLiteral<"enduserTag">;
10
+ op: z.ZodLiteral<"has">;
11
+ tag: z.ZodString;
12
+ }, z.core.$strict>, z.ZodObject<{
13
+ kind: z.ZodLiteral<"enduserTag">;
14
+ op: z.ZodLiteral<"hasValue">;
15
+ tag: z.ZodString;
16
+ value: z.ZodString;
17
+ }, z.core.$strict>, z.ZodObject<{
18
+ kind: z.ZodLiteral<"enduserTag">;
19
+ op: z.ZodLiteral<"hasValueAny">;
20
+ tag: z.ZodString;
21
+ values: z.ZodArray<z.ZodString>;
22
+ }, z.core.$strict>], "op">;
23
+ export type EndUserTagCondition = z.infer<typeof EndUserTagConditionSchema>;
@@ -1,10 +1,11 @@
1
+ export type { Glob, JSONValue } from "./common";
1
2
  export type { RuleCondition } from "./condition";
2
- export type { RulePhase, RuleSelector, Rule } from "./rule";
3
- export type { RuleEffect, RuleEffectKind } from "./effects";
4
- export type { RequireSubjectCondition, SignalCondition } from "./signals";
5
- export type { TimeGateCondition, ExecutionTimeCondition, ExecutionTimeScope } from "./time";
6
- export type { MetricWindowCondition } from "./metrics";
7
3
  export type { CustomFunctionCondition } from "./custom";
4
+ export type { RuleEffect, RuleEffectKind } from "./effects";
8
5
  export type { EndUserTagCondition } from "./enduser";
9
- export type { MaxCallsCondition, MaxCallsSelector, SequenceCondition, ToolNameCondition, ToolTagCondition } from "./tools";
10
- export type { Glob, JSONValue } from "./common";
6
+ export type { MetricWindowCondition } from "./metrics";
7
+ export type { Rule, RulePhase, RuleSelector } from "./rule";
8
+ export { RuleSchema, RuleSpecSchema } from "./rule";
9
+ export type { RequireSubjectCondition, SignalBinding, SignalCondition, } from "./signals";
10
+ export type { ExecutionTimeCondition, ExecutionTimeScope, TimeGateCondition, } from "./time";
11
+ export type { MaxCallsCondition, MaxCallsSelector, SequenceCondition, ToolNameCondition, ToolTagCondition, } from "./tools";
@@ -1,24 +1,62 @@
1
- import type { Glob } from "./common";
2
- import type { RuleEffectKind } from "./effects";
3
- type MetricRef = {
4
- kind: "inbuilt";
5
- key: "bytes_in" | "bytes_out" | "records_in" | "records_out" | "duration_ms";
6
- } | {
7
- kind: "custom";
8
- key: string;
9
- };
10
- export type MetricWindowCondition = {
11
- kind: "metricWindow";
12
- scope: "agent" | "agent_user";
13
- metric: MetricRef;
14
- aggregate: "sum" | "avg" | "max" | "min" | "count";
15
- windowSeconds: number;
16
- filter?: {
17
- toolName?: Glob | Glob[];
18
- toolTag?: string | string[];
19
- };
20
- op: "gt" | "gte" | "lt" | "lte" | "eq" | "neq";
21
- value: number;
22
- onMissing?: RuleEffectKind;
23
- };
24
- export {};
1
+ import { z } from "zod";
2
+ export declare const MetricRefSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
3
+ kind: z.ZodLiteral<"inbuilt">;
4
+ key: z.ZodEnum<{
5
+ bytes_in: "bytes_in";
6
+ bytes_out: "bytes_out";
7
+ duration_ms: "duration_ms";
8
+ records_in: "records_in";
9
+ records_out: "records_out";
10
+ }>;
11
+ }, z.core.$strict>, z.ZodObject<{
12
+ kind: z.ZodLiteral<"custom">;
13
+ key: z.ZodString;
14
+ }, z.core.$strict>], "kind">;
15
+ export type MetricRef = z.infer<typeof MetricRefSchema>;
16
+ export declare const MetricWindowConditionSchema: z.ZodObject<{
17
+ kind: z.ZodLiteral<"metricWindow">;
18
+ scope: z.ZodEnum<{
19
+ agent: "agent";
20
+ agent_user: "agent_user";
21
+ }>;
22
+ metric: z.ZodDiscriminatedUnion<[z.ZodObject<{
23
+ kind: z.ZodLiteral<"inbuilt">;
24
+ key: z.ZodEnum<{
25
+ bytes_in: "bytes_in";
26
+ bytes_out: "bytes_out";
27
+ duration_ms: "duration_ms";
28
+ records_in: "records_in";
29
+ records_out: "records_out";
30
+ }>;
31
+ }, z.core.$strict>, z.ZodObject<{
32
+ kind: z.ZodLiteral<"custom">;
33
+ key: z.ZodString;
34
+ }, z.core.$strict>], "kind">;
35
+ aggregate: z.ZodEnum<{
36
+ sum: "sum";
37
+ avg: "avg";
38
+ max: "max";
39
+ min: "min";
40
+ count: "count";
41
+ }>;
42
+ windowSeconds: z.ZodNumber;
43
+ filter: z.ZodOptional<z.ZodObject<{
44
+ toolName: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
45
+ toolTag: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
46
+ }, z.core.$strict>>;
47
+ op: z.ZodEnum<{
48
+ gt: "gt";
49
+ gte: "gte";
50
+ lt: "lt";
51
+ lte: "lte";
52
+ eq: "eq";
53
+ neq: "neq";
54
+ }>;
55
+ value: z.ZodNumber;
56
+ onMissing: z.ZodOptional<z.ZodEnum<{
57
+ allow: "allow";
58
+ block: "block";
59
+ hitl: "hitl";
60
+ }>>;
61
+ }, z.core.$strict>;
62
+ export type MetricWindowCondition = z.infer<typeof MetricWindowConditionSchema>;