@davidorex/pi-behavior-monitors 0.1.3 → 0.3.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.
@@ -1,156 +1,160 @@
1
1
  {
2
- "type": "object",
3
- "required": ["name", "event", "classify", "patterns", "actions"],
4
- "properties": {
5
- "name": { "type": "string" },
6
- "description": { "type": "string" },
7
- "event": {
8
- "type": "string",
9
- "enum": ["message_end", "turn_end", "agent_end", "command"]
10
- },
11
- "when": {
12
- "type": "string",
13
- "description": "Activation condition: 'always', 'has_tool_results', 'has_file_writes', 'has_bash', 'every(N)', 'tool(name)'",
14
- "default": "always"
15
- },
16
- "scope": {
17
- "type": "object",
18
- "properties": {
19
- "target": {
20
- "type": "string",
21
- "enum": ["main", "subagent", "all", "workflow"],
22
- "default": "main"
23
- },
24
- "filter": {
25
- "type": "object",
26
- "properties": {
27
- "agent_type": {
28
- "type": "array",
29
- "items": { "type": "string" },
30
- "description": "Only monitor agents with these names/types"
31
- },
32
- "step_name": {
33
- "type": "string",
34
- "description": "Glob pattern for workflow step names"
35
- },
36
- "workflow": {
37
- "type": "string",
38
- "description": "Glob pattern for workflow names"
39
- }
40
- }
41
- }
42
- }
43
- },
44
- "classify": {
45
- "type": "object",
46
- "required": ["model", "context", "prompt"],
47
- "properties": {
48
- "model": {
49
- "type": "string",
50
- "description": "Model ID or provider/model for classification calls"
51
- },
52
- "context": {
53
- "type": "array",
54
- "items": {
55
- "type": "string",
56
- "enum": ["tool_results", "assistant_text", "user_text", "tool_calls", "custom_messages"]
57
- }
58
- },
59
- "excludes": {
60
- "type": "array",
61
- "items": { "type": "string" },
62
- "description": "Skip activation if these monitors already steered this turn"
63
- },
64
- "prompt": {
65
- "type": "string",
66
- "description": "Classification prompt template with {tool_results}, {assistant_text}, {patterns}, {instructions} placeholders"
67
- }
68
- }
69
- },
70
- "patterns": {
71
- "type": "object",
72
- "required": ["path"],
73
- "properties": {
74
- "path": {
75
- "type": "string",
76
- "description": "Path to patterns JSON file (relative to monitor dir)"
77
- },
78
- "learn": {
79
- "type": "boolean",
80
- "default": true,
81
- "description": "Auto-learn new patterns from 'new' verdicts"
82
- }
83
- }
84
- },
85
- "instructions": {
86
- "type": "object",
87
- "properties": {
88
- "path": {
89
- "type": "string",
90
- "description": "Path to instructions JSON file (relative to monitor dir)"
91
- }
92
- }
93
- },
94
- "actions": {
95
- "type": "object",
96
- "properties": {
97
- "on_flag": { "$ref": "#/$defs/action" },
98
- "on_new": { "$ref": "#/$defs/action" },
99
- "on_clean": { "$ref": "#/$defs/action" }
100
- }
101
- },
102
- "ceiling": {
103
- "type": "integer",
104
- "default": 5,
105
- "description": "Max consecutive steers before escalation"
106
- },
107
- "escalate": {
108
- "type": "string",
109
- "enum": ["ask", "dismiss"],
110
- "default": "ask"
111
- }
112
- },
113
- "$defs": {
114
- "action": {
115
- "type": "object",
116
- "properties": {
117
- "steer": {
118
- "type": ["string", "null"],
119
- "description": "Message to inject into conversation. Null = no steering."
120
- },
121
- "write": {
122
- "type": "object",
123
- "required": ["path", "merge"],
124
- "properties": {
125
- "path": {
126
- "type": "string",
127
- "description": "JSON file to write findings to"
128
- },
129
- "schema": {
130
- "type": "string",
131
- "description": "Schema the target file conforms to"
132
- },
133
- "merge": {
134
- "type": "string",
135
- "enum": ["append", "upsert"],
136
- "description": "append = add to array, upsert = update by id"
137
- },
138
- "array_field": {
139
- "type": "string",
140
- "description": "Which field in the target JSON holds the array (e.g. 'gaps', 'findings')",
141
- "default": "items"
142
- },
143
- "template": {
144
- "type": "object",
145
- "description": "Template for mapping classification output to target schema. Use {description}, {severity}, {finding_id}, {monitor_name}, {timestamp} placeholders."
146
- }
147
- }
148
- },
149
- "learn_pattern": {
150
- "type": "boolean",
151
- "description": "If true, add new pattern to patterns file on 'new' verdict"
152
- }
153
- }
154
- }
155
- }
2
+ "type": "object",
3
+ "required": ["name", "event", "classify", "patterns", "actions"],
4
+ "properties": {
5
+ "name": { "type": "string" },
6
+ "description": { "type": "string" },
7
+ "event": {
8
+ "type": "string",
9
+ "enum": ["message_end", "turn_end", "agent_end", "command"]
10
+ },
11
+ "when": {
12
+ "type": "string",
13
+ "description": "Activation condition: 'always', 'has_tool_results', 'has_file_writes', 'has_bash', 'every(N)', 'tool(name)'",
14
+ "default": "always"
15
+ },
16
+ "scope": {
17
+ "type": "object",
18
+ "properties": {
19
+ "target": {
20
+ "type": "string",
21
+ "enum": ["main", "subagent", "all", "workflow"],
22
+ "default": "main"
23
+ },
24
+ "filter": {
25
+ "type": "object",
26
+ "properties": {
27
+ "agent_type": {
28
+ "type": "array",
29
+ "items": { "type": "string" },
30
+ "description": "Only monitor agents with these names/types"
31
+ },
32
+ "step_name": {
33
+ "type": "string",
34
+ "description": "Glob pattern for workflow step names"
35
+ },
36
+ "workflow": {
37
+ "type": "string",
38
+ "description": "Glob pattern for workflow names"
39
+ }
40
+ }
41
+ }
42
+ }
43
+ },
44
+ "classify": {
45
+ "type": "object",
46
+ "required": ["model", "context"],
47
+ "properties": {
48
+ "model": {
49
+ "type": "string",
50
+ "description": "Model ID or provider/model for classification calls"
51
+ },
52
+ "context": {
53
+ "type": "array",
54
+ "items": {
55
+ "type": "string"
56
+ },
57
+ "description": "Context collector names. Built-in: tool_results, assistant_text, user_text, tool_calls, custom_messages, project_vision, project_conventions, git_status. Unknown collectors produce empty string."
58
+ },
59
+ "excludes": {
60
+ "type": "array",
61
+ "items": { "type": "string" },
62
+ "description": "Skip activation if these monitors already steered this turn"
63
+ },
64
+ "promptTemplate": {
65
+ "type": "string",
66
+ "description": "Path to .md Nunjucks template file for classification prompt. Searched in .pi/monitors/, ~/.pi/agent/monitors/, then package examples/. Takes precedence over inline prompt."
67
+ },
68
+ "prompt": {
69
+ "type": "string",
70
+ "description": "Inline classification prompt with {placeholder} substitution. Used when promptTemplate is absent."
71
+ }
72
+ }
73
+ },
74
+ "patterns": {
75
+ "type": "object",
76
+ "required": ["path"],
77
+ "properties": {
78
+ "path": {
79
+ "type": "string",
80
+ "description": "Path to patterns JSON file (relative to monitor dir)"
81
+ },
82
+ "learn": {
83
+ "type": "boolean",
84
+ "default": true,
85
+ "description": "Auto-learn new patterns from 'new' verdicts"
86
+ }
87
+ }
88
+ },
89
+ "instructions": {
90
+ "type": "object",
91
+ "properties": {
92
+ "path": {
93
+ "type": "string",
94
+ "description": "Path to instructions JSON file (relative to monitor dir)"
95
+ }
96
+ }
97
+ },
98
+ "actions": {
99
+ "type": "object",
100
+ "properties": {
101
+ "on_flag": { "$ref": "#/$defs/action" },
102
+ "on_new": { "$ref": "#/$defs/action" },
103
+ "on_clean": { "$ref": "#/$defs/action" }
104
+ }
105
+ },
106
+ "ceiling": {
107
+ "type": "integer",
108
+ "default": 5,
109
+ "description": "Max consecutive steers before escalation"
110
+ },
111
+ "escalate": {
112
+ "type": "string",
113
+ "enum": ["ask", "dismiss"],
114
+ "default": "ask"
115
+ }
116
+ },
117
+ "$defs": {
118
+ "action": {
119
+ "type": "object",
120
+ "properties": {
121
+ "steer": {
122
+ "type": ["string", "null"],
123
+ "description": "Message to inject into conversation. Null = no steering."
124
+ },
125
+ "write": {
126
+ "type": "object",
127
+ "required": ["path", "merge"],
128
+ "properties": {
129
+ "path": {
130
+ "type": "string",
131
+ "description": "JSON file to write findings to"
132
+ },
133
+ "schema": {
134
+ "type": "string",
135
+ "description": "Schema the target file conforms to"
136
+ },
137
+ "merge": {
138
+ "type": "string",
139
+ "enum": ["append", "upsert"],
140
+ "description": "append = add to array, upsert = update by id"
141
+ },
142
+ "array_field": {
143
+ "type": "string",
144
+ "description": "Which field in the target JSON holds the array (e.g. 'gaps', 'findings')",
145
+ "default": "items"
146
+ },
147
+ "template": {
148
+ "type": "object",
149
+ "description": "Template for mapping classification output to target schema. Use {description}, {severity}, {finding_id}, {monitor_name}, {timestamp} placeholders."
150
+ }
151
+ }
152
+ },
153
+ "learn_pattern": {
154
+ "type": "boolean",
155
+ "description": "If true, add new pattern to patterns file on 'new' verdict"
156
+ }
157
+ }
158
+ }
159
+ }
156
160
  }