mirror of
https://github.com/usestrix/strix.git
synced 2026-08-24 20:02:39 +02:00
Engine + integration: - Reviewer inspection now surfaces the real frozen source of an already-frozen workspace script/dependency instead of an empty string, so workspace-resident scripts resolve without a needless human defer. - Guard effectful static tools via an explicit, documented set plus the SDK's per-tool needs_approval signal; give the exec/stdin wrappers the same idempotency guard as their sibling wrappers. - Centralize DEFAULT_SAFETY_MODE and share one resume safety-mode rule between the CLI and runner so the two cannot drift; type InspectionContext.runner, reuse RUNTIME_STATE_DIR_NAME, and drop a dead workdir parameter and a write-only field. TUI approval experience: - Approve All drops the run into dangerous mode: it approves the pending call and turns review off for the rest of the run, with a standing "review off" status flag. - The status row shows the owning agent as paused while it waits on a decision. - Redesigned prompt: a risk + tool header, a collapsible command/reason preview that expands (e) and scrolls, and no internal digest, agent, or request ids. Full Python (1138) and Go suites, ruff, and mypy strix/ pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
56 lines
1.3 KiB
Go
56 lines
1.3 KiB
Go
package protocol
|
|
|
|
import (
|
|
"encoding/json"
|
|
"reflect"
|
|
"testing"
|
|
)
|
|
|
|
func TestProtocolVersionAndCapabilities(t *testing.T) {
|
|
if Version != 5 {
|
|
t.Fatalf("protocol version = %d, want 5", Version)
|
|
}
|
|
wantCapabilities := []string{
|
|
"state-revisions",
|
|
"collection-deltas",
|
|
"structured-command-errors",
|
|
"agents-collection",
|
|
"safety-approvals",
|
|
}
|
|
if !reflect.DeepEqual(Capabilities, wantCapabilities) {
|
|
t.Fatalf("capabilities = %#v, want %#v", Capabilities, wantCapabilities)
|
|
}
|
|
|
|
}
|
|
|
|
func TestSnapshotDecodesPendingSafetyApprovals(t *testing.T) {
|
|
var snapshot Snapshot
|
|
if err := json.Unmarshal([]byte(`{
|
|
"pending_approvals": [{
|
|
"request_id": "approval-1",
|
|
"agent_id": "agent-1",
|
|
"action": "Run exploit",
|
|
"reason": "Changes target state",
|
|
"tool_name": "exec_command",
|
|
"digest": "abc123",
|
|
"risk": "medium"
|
|
}]
|
|
}`), &snapshot); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if len(snapshot.PendingApprovals) != 1 {
|
|
t.Fatalf("pending approvals = %d, want 1", len(snapshot.PendingApprovals))
|
|
}
|
|
if got := snapshot.PendingApprovals[0]; got != (SafetyApproval{
|
|
RequestID: "approval-1",
|
|
AgentID: "agent-1",
|
|
Action: "Run exploit",
|
|
Reason: "Changes target state",
|
|
ToolName: "exec_command",
|
|
Digest: "abc123",
|
|
Risk: "medium",
|
|
}) {
|
|
t.Fatalf("pending approval = %#v", got)
|
|
}
|
|
}
|