@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,44 +1,79 @@
1
- import type { JSONValue } from "./common";
2
- import type { RuleEffectKind } from "./effects";
3
- /**
4
- * Requires the existence of subject data at runtime.
5
- *
6
- * Handlebar is agnostic to the source of the data,
7
- * so long as it is present in the engine runtime.
8
- */
9
- export type RequireSubjectCondition = {
10
- kind: "requireSubject";
11
- subjectType: string;
12
- idSystem?: string;
13
- };
14
- type SignalBinding = {
15
- from: "endUserId";
16
- } | {
17
- from: "endUserTag";
18
- tag: string;
19
- } | {
20
- from: "toolName";
21
- } | {
22
- from: "toolTag";
23
- tag: string;
24
- } | {
25
- from: "toolArg";
26
- path: string;
27
- } | {
28
- from: "subject";
29
- subjectType: string;
30
- role?: string;
31
- field?: "id" | "idSystem";
32
- } | {
33
- from: "const";
34
- value: JSONValue;
35
- };
36
- export type SignalCondition = {
37
- kind: "signal";
38
- key: string;
39
- args: Record<string, SignalBinding>;
40
- op: "eq" | "neq" | "gt" | "gte" | "lt" | "lte" | "in" | "nin";
41
- value: JSONValue;
42
- onMissing?: RuleEffectKind;
43
- };
44
- export {};
1
+ import { z } from "zod";
2
+ export declare const RequireSubjectConditionSchema: z.ZodObject<{
3
+ kind: z.ZodLiteral<"requireSubject">;
4
+ subjectType: z.ZodString;
5
+ idSystem: z.ZodOptional<z.ZodString>;
6
+ }, z.core.$strict>;
7
+ export type RequireSubjectCondition = z.infer<typeof RequireSubjectConditionSchema>;
8
+ export declare const SignalBindingSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
9
+ from: z.ZodLiteral<"enduserId">;
10
+ }, z.core.$strict>, z.ZodObject<{
11
+ from: z.ZodLiteral<"enduserTag">;
12
+ tag: z.ZodString;
13
+ }, z.core.$strict>, z.ZodObject<{
14
+ from: z.ZodLiteral<"toolName">;
15
+ }, z.core.$strict>, z.ZodObject<{
16
+ from: z.ZodLiteral<"toolTag">;
17
+ tag: z.ZodString;
18
+ }, z.core.$strict>, z.ZodObject<{
19
+ from: z.ZodLiteral<"toolArg">;
20
+ path: z.ZodString;
21
+ }, z.core.$strict>, z.ZodObject<{
22
+ from: z.ZodLiteral<"subject">;
23
+ subjectType: z.ZodString;
24
+ role: z.ZodOptional<z.ZodString>;
25
+ field: z.ZodOptional<z.ZodEnum<{
26
+ idSystem: "idSystem";
27
+ id: "id";
28
+ }>>;
29
+ }, z.core.$strict>, z.ZodObject<{
30
+ from: z.ZodLiteral<"const">;
31
+ value: 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]>>]>;
32
+ }, z.core.$strict>], "from">;
33
+ export type SignalBinding = z.infer<typeof SignalBindingSchema>;
34
+ export declare const SignalConditionSchema: z.ZodObject<{
35
+ kind: z.ZodLiteral<"signal">;
36
+ key: z.ZodString;
37
+ args: z.ZodRecord<z.ZodString, z.ZodDiscriminatedUnion<[z.ZodObject<{
38
+ from: z.ZodLiteral<"enduserId">;
39
+ }, z.core.$strict>, z.ZodObject<{
40
+ from: z.ZodLiteral<"enduserTag">;
41
+ tag: z.ZodString;
42
+ }, z.core.$strict>, z.ZodObject<{
43
+ from: z.ZodLiteral<"toolName">;
44
+ }, z.core.$strict>, z.ZodObject<{
45
+ from: z.ZodLiteral<"toolTag">;
46
+ tag: z.ZodString;
47
+ }, z.core.$strict>, z.ZodObject<{
48
+ from: z.ZodLiteral<"toolArg">;
49
+ path: z.ZodString;
50
+ }, z.core.$strict>, z.ZodObject<{
51
+ from: z.ZodLiteral<"subject">;
52
+ subjectType: z.ZodString;
53
+ role: z.ZodOptional<z.ZodString>;
54
+ field: z.ZodOptional<z.ZodEnum<{
55
+ idSystem: "idSystem";
56
+ id: "id";
57
+ }>>;
58
+ }, z.core.$strict>, z.ZodObject<{
59
+ from: z.ZodLiteral<"const">;
60
+ value: 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]>>]>;
61
+ }, z.core.$strict>], "from">>;
62
+ op: z.ZodEnum<{
63
+ in: "in";
64
+ gt: "gt";
65
+ gte: "gte";
66
+ lt: "lt";
67
+ lte: "lte";
68
+ eq: "eq";
69
+ neq: "neq";
70
+ nin: "nin";
71
+ }>;
72
+ value: 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]>>]>;
73
+ onMissing: z.ZodOptional<z.ZodEnum<{
74
+ allow: "allow";
75
+ block: "block";
76
+ hitl: "hitl";
77
+ }>>;
78
+ }, z.core.$strict>;
79
+ export type SignalCondition = z.infer<typeof SignalConditionSchema>;
@@ -1,28 +1,56 @@
1
- export type TimeGateCondition = {
2
- kind: "timeGate";
3
- timezone: {
4
- source: "endUserTag";
5
- tag: string;
6
- fallback?: "org";
7
- };
8
- windows: Array<{
9
- days: ("mon" | "tue" | "wed" | "thu" | "fri" | "sat" | "sun")[];
10
- start: string;
11
- end: string;
1
+ import { z } from "zod";
2
+ declare const DaySchema: z.ZodEnum<{
3
+ mon: "mon";
4
+ tue: "tue";
5
+ wed: "wed";
6
+ thu: "thu";
7
+ fri: "fri";
8
+ sat: "sat";
9
+ sun: "sun";
10
+ }>;
11
+ export type Day = z.infer<typeof DaySchema>;
12
+ export declare const TimeGateConditionSchema: z.ZodObject<{
13
+ kind: z.ZodLiteral<"timeGate">;
14
+ timezone: z.ZodObject<{
15
+ source: z.ZodLiteral<"enduserTag">;
16
+ tag: z.ZodString;
17
+ fallback: z.ZodOptional<z.ZodLiteral<"org">>;
18
+ }, z.core.$strict>;
19
+ windows: z.ZodArray<z.ZodObject<{
20
+ days: z.ZodArray<z.ZodEnum<{
21
+ mon: "mon";
22
+ tue: "tue";
23
+ wed: "wed";
24
+ thu: "thu";
25
+ fri: "fri";
26
+ sat: "sat";
27
+ sun: "sun";
28
+ }>>;
29
+ start: z.ZodString;
30
+ end: z.ZodString;
31
+ }, z.core.$strict>>;
32
+ }, z.core.$strict>;
33
+ export type TimeGateCondition = z.infer<typeof TimeGateConditionSchema>;
34
+ declare const ExecutionTimeScopeSchema: z.ZodEnum<{
35
+ tool: "tool";
36
+ total: "total";
37
+ }>;
38
+ export type ExecutionTimeScope = z.infer<typeof ExecutionTimeScopeSchema>;
39
+ export declare const ExecutionTimeConditionSchema: z.ZodObject<{
40
+ kind: z.ZodLiteral<"executionTime">;
41
+ scope: z.ZodEnum<{
42
+ tool: "tool";
43
+ total: "total";
12
44
  }>;
13
- };
14
- /**
15
- * Scope for execution time measurement.
16
- * - "tool": the single tool call duration
17
- * - "total": end-to-end agent run (from start to now)
18
- */
19
- export type ExecutionTimeScope = "tool" | "total";
20
- /**
21
- * Match against execution time thresholds (milliseconds).
22
- */
23
- export type ExecutionTimeCondition = {
24
- kind: "executionTime";
25
- scope: ExecutionTimeScope;
26
- op: "gt" | "gte" | "lt" | "lte" | "eq" | "neq";
27
- ms: number;
28
- };
45
+ op: z.ZodEnum<{
46
+ gt: "gt";
47
+ gte: "gte";
48
+ lt: "lt";
49
+ lte: "lte";
50
+ eq: "eq";
51
+ neq: "neq";
52
+ }>;
53
+ ms: z.ZodNumber;
54
+ }, z.core.$strict>;
55
+ export type ExecutionTimeCondition = z.infer<typeof ExecutionTimeConditionSchema>;
56
+ export {};
@@ -1,64 +1,58 @@
1
- import type { Glob } from "./common";
2
- /**
3
- * Match on a tool's name.
4
- * - glob comparator supports wildcard matching
5
- * - in comparator permits list membership check
6
- */
7
- export type ToolNameCondition = {
8
- kind: "toolName";
9
- op: "eq" | "neq" | "contains" | "startsWith" | "endsWith" | "glob";
10
- value: string | Glob;
11
- } | {
12
- kind: "toolName";
13
- op: "in";
14
- value: (string | Glob)[];
15
- };
16
- /**
17
- * Match on tool tags present on the tool.
18
- * - has: single tag must be present
19
- * - anyOf: at least one tag present
20
- * - allOf: every provided tag must be present
21
- */
22
- export type ToolTagCondition = {
23
- kind: "toolTag";
24
- op: "has";
25
- tag: string;
26
- } | {
27
- kind: "toolTag";
28
- op: "anyOf";
29
- tags: string[];
30
- } | {
31
- kind: "toolTag";
32
- op: "allOf";
33
- tags: string[];
34
- };
35
- /**
36
- * Enforce sequencing constraints within the current run history.
37
- * - mustHaveCalled: all listed tool name patterns must have been called earlier
38
- * - mustNotHaveCalled: none of the listed patterns may have been called earlier
39
- */
40
- export type SequenceCondition = {
41
- kind: "sequence";
42
- mustHaveCalled?: Glob[];
43
- mustNotHaveCalled?: Glob[];
44
- };
45
- /**
46
- * Select tools for counting within a run.
47
- * - by toolName: count calls whose name matches any provided glob patterns
48
- * - by toolTag: count calls whose tool includes any of the provided tags
49
- */
50
- export type MaxCallsSelector = {
51
- by: "toolName";
52
- patterns: Glob[];
53
- } | {
54
- by: "toolTag";
55
- tags: string[];
56
- };
57
- /**
58
- * Assert a maximum number of calls within a run for the selected tools (inclusive).
59
- */
60
- export type MaxCallsCondition = {
61
- kind: "maxCalls";
62
- selector: MaxCallsSelector;
63
- max: number;
64
- };
1
+ import { z } from "zod";
2
+ export declare const ToolNameConditionSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
3
+ kind: z.ZodLiteral<"toolName">;
4
+ op: z.ZodEnum<{
5
+ eq: "eq";
6
+ neq: "neq";
7
+ contains: "contains";
8
+ startsWith: "startsWith";
9
+ endsWith: "endsWith";
10
+ glob: "glob";
11
+ }>;
12
+ value: z.ZodString;
13
+ }, z.core.$strict>, z.ZodObject<{
14
+ kind: z.ZodLiteral<"toolName">;
15
+ op: z.ZodLiteral<"in">;
16
+ value: z.ZodArray<z.ZodString>;
17
+ }, z.core.$strict>], "op">;
18
+ export type ToolNameCondition = z.infer<typeof ToolNameConditionSchema>;
19
+ export declare const ToolTagConditionSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
20
+ kind: z.ZodLiteral<"toolTag">;
21
+ op: z.ZodLiteral<"has">;
22
+ tag: z.ZodString;
23
+ }, z.core.$strict>, z.ZodObject<{
24
+ kind: z.ZodLiteral<"toolTag">;
25
+ op: z.ZodLiteral<"anyOf">;
26
+ tags: z.ZodArray<z.ZodString>;
27
+ }, z.core.$strict>, z.ZodObject<{
28
+ kind: z.ZodLiteral<"toolTag">;
29
+ op: z.ZodLiteral<"allOf">;
30
+ tags: z.ZodArray<z.ZodString>;
31
+ }, z.core.$strict>], "op">;
32
+ export type ToolTagCondition = z.infer<typeof ToolTagConditionSchema>;
33
+ export declare const SequenceConditionSchema: z.ZodObject<{
34
+ kind: z.ZodLiteral<"sequence">;
35
+ mustHaveCalled: z.ZodOptional<z.ZodArray<z.ZodString>>;
36
+ mustNotHaveCalled: z.ZodOptional<z.ZodArray<z.ZodString>>;
37
+ }, z.core.$strict>;
38
+ export type SequenceCondition = z.infer<typeof SequenceConditionSchema>;
39
+ export declare const MaxCallsSelectorSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
40
+ by: z.ZodLiteral<"toolName">;
41
+ patterns: z.ZodArray<z.ZodString>;
42
+ }, z.core.$strict>, z.ZodObject<{
43
+ by: z.ZodLiteral<"toolTag">;
44
+ tags: z.ZodArray<z.ZodString>;
45
+ }, z.core.$strict>], "by">;
46
+ export type MaxCallsSelector = z.infer<typeof MaxCallsSelectorSchema>;
47
+ export declare const MaxCallsConditionSchema: z.ZodObject<{
48
+ kind: z.ZodLiteral<"maxCalls">;
49
+ selector: z.ZodDiscriminatedUnion<[z.ZodObject<{
50
+ by: z.ZodLiteral<"toolName">;
51
+ patterns: z.ZodArray<z.ZodString>;
52
+ }, z.core.$strict>, z.ZodObject<{
53
+ by: z.ZodLiteral<"toolTag">;
54
+ tags: z.ZodArray<z.ZodString>;
55
+ }, z.core.$strict>], "by">;
56
+ max: z.ZodNumber;
57
+ }, z.core.$strict>;
58
+ export type MaxCallsCondition = z.infer<typeof MaxCallsConditionSchema>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@handlebar/governance-schema",
3
- "version": "0.0.6-dev.6",
3
+ "version": "0.0.6-dev.8",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",