conduct-cli 0.4.6__tar.gz → 0.4.8__tar.gz
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.
- {conduct_cli-0.4.6 → conduct_cli-0.4.8}/PKG-INFO +1 -1
- {conduct_cli-0.4.6 → conduct_cli-0.4.8}/pyproject.toml +1 -1
- {conduct_cli-0.4.6 → conduct_cli-0.4.8}/src/conduct_cli/guard.py +13 -11
- {conduct_cli-0.4.6 → conduct_cli-0.4.8}/src/conduct_cli.egg-info/PKG-INFO +1 -1
- {conduct_cli-0.4.6 → conduct_cli-0.4.8}/README.md +0 -0
- {conduct_cli-0.4.6 → conduct_cli-0.4.8}/setup.cfg +0 -0
- {conduct_cli-0.4.6 → conduct_cli-0.4.8}/setup.py +0 -0
- {conduct_cli-0.4.6 → conduct_cli-0.4.8}/src/conduct_cli/__init__.py +0 -0
- {conduct_cli-0.4.6 → conduct_cli-0.4.8}/src/conduct_cli/api.py +0 -0
- {conduct_cli-0.4.6 → conduct_cli-0.4.8}/src/conduct_cli/guardmcp.py +0 -0
- {conduct_cli-0.4.6 → conduct_cli-0.4.8}/src/conduct_cli/main.py +0 -0
- {conduct_cli-0.4.6 → conduct_cli-0.4.8}/src/conduct_cli.egg-info/SOURCES.txt +0 -0
- {conduct_cli-0.4.6 → conduct_cli-0.4.8}/src/conduct_cli.egg-info/dependency_links.txt +0 -0
- {conduct_cli-0.4.6 → conduct_cli-0.4.8}/src/conduct_cli.egg-info/entry_points.txt +0 -0
- {conduct_cli-0.4.6 → conduct_cli-0.4.8}/src/conduct_cli.egg-info/requires.txt +0 -0
- {conduct_cli-0.4.6 → conduct_cli-0.4.8}/src/conduct_cli.egg-info/top_level.txt +0 -0
|
@@ -125,7 +125,7 @@ def _detect_ai_tool():
|
|
|
125
125
|
return "unknown"
|
|
126
126
|
|
|
127
127
|
|
|
128
|
-
def _post_event(tool_name, tool_input, decision, rule_id=None, message=None,
|
|
128
|
+
def _post_event(tool_name, tool_input, decision, rule_id=None, message=None, session_id=None):
|
|
129
129
|
try:
|
|
130
130
|
cfg = json.loads(CONFIG_PATH.read_text()) if CONFIG_PATH.exists() else {}
|
|
131
131
|
except Exception:
|
|
@@ -143,8 +143,8 @@ def _post_event(tool_name, tool_input, decision, rule_id=None, message=None, too
|
|
|
143
143
|
"input_summary": json.dumps(tool_input)[:200],
|
|
144
144
|
"decision": decision,
|
|
145
145
|
"rule_id": rule_id,
|
|
146
|
-
"rule_message":
|
|
147
|
-
"
|
|
146
|
+
"rule_message": message,
|
|
147
|
+
"hook_session_id": session_id,
|
|
148
148
|
})
|
|
149
149
|
api_url = cfg.get("api_url", "https://api.conductai.ai").rstrip("/")
|
|
150
150
|
script = (
|
|
@@ -163,18 +163,19 @@ def _post_event(tool_name, tool_input, decision, rule_id=None, message=None, too
|
|
|
163
163
|
)
|
|
164
164
|
|
|
165
165
|
|
|
166
|
-
def _post_usage(
|
|
166
|
+
def _post_usage(session_id, tool_name, tokens_input, tokens_output, duration_ms):
|
|
167
167
|
"""Fire-and-forget POST to /guard/events/usage"""
|
|
168
168
|
try:
|
|
169
169
|
cfg = json.loads(CONFIG_PATH.read_text()) if CONFIG_PATH.exists() else {}
|
|
170
170
|
except Exception:
|
|
171
171
|
return
|
|
172
172
|
workspace_id = cfg.get("workspace_id")
|
|
173
|
-
if not workspace_id or not
|
|
173
|
+
if not workspace_id or not session_id:
|
|
174
174
|
return
|
|
175
175
|
payload = json.dumps({
|
|
176
|
-
"workspace_id":
|
|
177
|
-
"
|
|
176
|
+
"workspace_id": workspace_id,
|
|
177
|
+
"hook_session_id": session_id,
|
|
178
|
+
"tool_name": tool_name,
|
|
178
179
|
"tokens_input": tokens_input,
|
|
179
180
|
"tokens_output": tokens_output,
|
|
180
181
|
"duration_ms": duration_ms,
|
|
@@ -203,12 +204,13 @@ def post_usage_main():
|
|
|
203
204
|
data = json.load(sys.stdin)
|
|
204
205
|
except Exception:
|
|
205
206
|
sys.exit(0)
|
|
206
|
-
|
|
207
|
+
session_id = data.get("session_id")
|
|
208
|
+
tool_name = (data.get("tool_name") or "").lower()
|
|
207
209
|
usage = data.get("usage") or {}
|
|
208
210
|
tokens_input = usage.get("input_tokens", 0)
|
|
209
211
|
tokens_output = usage.get("output_tokens", 0)
|
|
210
212
|
duration_ms = data.get("duration_ms")
|
|
211
|
-
_post_usage(
|
|
213
|
+
_post_usage(session_id, tool_name, tokens_input, tokens_output, duration_ms)
|
|
212
214
|
sys.exit(0)
|
|
213
215
|
|
|
214
216
|
|
|
@@ -226,15 +228,15 @@ def main():
|
|
|
226
228
|
print(f"[ConductGuard] {reason or 'Budget hard cap reached. Contact your manager.'}")
|
|
227
229
|
sys.exit(2)
|
|
228
230
|
|
|
231
|
+
session_id = data.get("session_id")
|
|
229
232
|
tool_name = (data.get("tool_name") or "").lower()
|
|
230
233
|
tool_input = data.get("tool_input") or {}
|
|
231
|
-
tool_use_id = data.get("tool_use_id")
|
|
232
234
|
|
|
233
235
|
_, action, rule_id, message = _check_policy(tool_name, tool_input)
|
|
234
236
|
|
|
235
237
|
# Always post an event — "allowed" for normal calls, "blocked"/"warned" for violations
|
|
236
238
|
decision = {"block": "blocked", "warn": "warned", "approval": "blocked"}.get(action, "allowed")
|
|
237
|
-
_post_event(tool_name, tool_input, decision, rule_id, message,
|
|
239
|
+
_post_event(tool_name, tool_input, decision, rule_id, message, session_id=session_id)
|
|
238
240
|
|
|
239
241
|
if action == "block":
|
|
240
242
|
print(f"[ConductGuard] {message}")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|