@handlebar/governance-schema 0.0.6-dev.1 → 0.0.6-dev.10

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.
@@ -48,6 +48,27 @@ export type ToolTagCondition = {
48
48
  op: "allOf";
49
49
  tags: string[];
50
50
  };
51
+ /**
52
+ * Match on arbitrary tags assigned to the enduser.
53
+ * "enduser" in this context means the users of a Handlebar user.
54
+ * - has: existence AND truthiness of the tag. E.g. "has:tier" would be false if "tier=0", "tier=false", or no "tier" tag exists.
55
+ * - hasValue: tag exists and has an exact given value
56
+ */
57
+ export type EndUserTagCondition = {
58
+ kind: "enduserTag";
59
+ op: "has";
60
+ tag: string;
61
+ } | {
62
+ kind: "enduserTag";
63
+ op: "hasValue";
64
+ tag: string;
65
+ value: string;
66
+ } | {
67
+ kind: "enduserTag";
68
+ op: "hasValueAny";
69
+ tag: string;
70
+ values: string[];
71
+ };
51
72
  /**
52
73
  * Scope for execution time measurement.
53
74
  * - "tool": the single tool call duration
@@ -118,4 +139,4 @@ export type NotCondition = {
118
139
  /**
119
140
  * The full condition algebra supported by the rule engine.
120
141
  */
121
- export type RuleCondition = ToolNameCondition | ToolTagCondition | ExecutionTimeCondition | SequenceCondition | MaxCallsCondition | CustomFunctionCondition | AndCondition | OrCondition | NotCondition;
142
+ export type RuleCondition = ToolNameCondition | ToolTagCondition | EndUserTagCondition | ExecutionTimeCondition | SequenceCondition | MaxCallsCondition | CustomFunctionCondition | AndCondition | OrCondition | NotCondition;
@@ -0,0 +1,12 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * Delegate condition evaluation to a user-defined function.
4
+ * - `name` is resolved by the host SDK/application
5
+ * - `args` is an opaque, JSON-serialisable payload consumed by user code
6
+ */
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>;
@@ -0,0 +1,25 @@
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>;
8
+ /**
9
+ * Direct impact of a rule breach.
10
+ *
11
+ * RuleEffect has an immediate impact on the agent run/tool action.
12
+ * This is in contract to side effects (yet to be defined),
13
+ * which would include "log" or "modify context".
14
+ */
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>;
@@ -0,0 +1,23 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * Match on arbitrary tags assigned to the enduser.
4
+ * "enduser" in this context means the users of a Handlebar user.
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.
6
+ * - hasValue: tag exists and has an exact given value
7
+ */
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>;
@@ -0,0 +1,11 @@
1
+ export type { Glob, JSONValue } from "./common";
2
+ export type { RuleCondition } from "./condition";
3
+ export type { CustomFunctionCondition } from "./custom";
4
+ export type { RuleEffect, RuleEffectKind } from "./effects";
5
+ export type { EndUserTagCondition } from "./enduser";
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";
@@ -0,0 +1,66 @@
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
+ llm_tokens_in: "llm_tokens_in";
11
+ llm_tokens_out: "llm_tokens_out";
12
+ }>;
13
+ }, z.core.$strict>, z.ZodObject<{
14
+ kind: z.ZodLiteral<"custom">;
15
+ key: z.ZodString;
16
+ }, z.core.$strict>], "kind">;
17
+ export type MetricRef = z.infer<typeof MetricRefSchema>;
18
+ export declare const MetricWindowConditionSchema: z.ZodObject<{
19
+ kind: z.ZodLiteral<"metricWindow">;
20
+ scope: z.ZodEnum<{
21
+ agent: "agent";
22
+ agent_user: "agent_user";
23
+ }>;
24
+ metric: z.ZodDiscriminatedUnion<[z.ZodObject<{
25
+ kind: z.ZodLiteral<"inbuilt">;
26
+ key: z.ZodEnum<{
27
+ bytes_in: "bytes_in";
28
+ bytes_out: "bytes_out";
29
+ duration_ms: "duration_ms";
30
+ records_in: "records_in";
31
+ records_out: "records_out";
32
+ llm_tokens_in: "llm_tokens_in";
33
+ llm_tokens_out: "llm_tokens_out";
34
+ }>;
35
+ }, z.core.$strict>, z.ZodObject<{
36
+ kind: z.ZodLiteral<"custom">;
37
+ key: z.ZodString;
38
+ }, z.core.$strict>], "kind">;
39
+ aggregate: z.ZodEnum<{
40
+ sum: "sum";
41
+ avg: "avg";
42
+ max: "max";
43
+ min: "min";
44
+ count: "count";
45
+ }>;
46
+ windowSeconds: z.ZodNumber;
47
+ filter: z.ZodOptional<z.ZodObject<{
48
+ toolName: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
49
+ toolTag: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
50
+ }, z.core.$strict>>;
51
+ op: z.ZodEnum<{
52
+ gt: "gt";
53
+ gte: "gte";
54
+ lt: "lt";
55
+ lte: "lte";
56
+ eq: "eq";
57
+ neq: "neq";
58
+ }>;
59
+ value: z.ZodNumber;
60
+ onMissing: z.ZodOptional<z.ZodEnum<{
61
+ allow: "allow";
62
+ block: "block";
63
+ hitl: "hitl";
64
+ }>>;
65
+ }, z.core.$strict>;
66
+ export type MetricWindowCondition = z.infer<typeof MetricWindowConditionSchema>;