harnery 0.10.0 → 0.12.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.
Files changed (44) hide show
  1. package/README.md +1 -1
  2. package/dist/commander.d.ts.map +1 -1
  3. package/dist/commander.js +2 -0
  4. package/dist/commands/policy.d.ts +6 -0
  5. package/dist/commands/policy.d.ts.map +1 -0
  6. package/dist/commands/policy.js +42 -0
  7. package/dist/commands/workflow.d.ts.map +1 -1
  8. package/dist/commands/workflow.js +62 -2
  9. package/dist/core/policy/evaluate.d.ts +14 -0
  10. package/dist/core/policy/evaluate.d.ts.map +1 -0
  11. package/dist/core/policy/evaluate.js +238 -0
  12. package/dist/core/policy/file.d.ts +3 -0
  13. package/dist/core/policy/file.d.ts.map +1 -0
  14. package/dist/core/policy/file.js +20 -0
  15. package/dist/core/policy/index.d.ts +5 -0
  16. package/dist/core/policy/index.d.ts.map +1 -0
  17. package/dist/core/policy/index.js +3 -0
  18. package/dist/core/policy/types.d.ts +91 -0
  19. package/dist/core/policy/types.d.ts.map +1 -0
  20. package/dist/core/policy/types.js +1 -0
  21. package/dist/core/workflow/engine.d.ts +5 -0
  22. package/dist/core/workflow/engine.d.ts.map +1 -1
  23. package/dist/core/workflow/engine.js +412 -47
  24. package/dist/core/workflow/index.d.ts +5 -0
  25. package/dist/core/workflow/index.d.ts.map +1 -0
  26. package/dist/core/workflow/index.js +3 -0
  27. package/dist/core/workflow/proof.d.ts +49 -0
  28. package/dist/core/workflow/proof.d.ts.map +1 -0
  29. package/dist/core/workflow/proof.js +375 -0
  30. package/dist/core/workflow/types.d.ts +180 -0
  31. package/dist/core/workflow/types.d.ts.map +1 -1
  32. package/dist/core/workflow/types.js +1 -1
  33. package/package.json +16 -6
  34. package/src/commander.ts +2 -0
  35. package/src/commands/policy.ts +50 -0
  36. package/src/commands/workflow.ts +82 -2
  37. package/src/core/policy/evaluate.ts +311 -0
  38. package/src/core/policy/file.ts +20 -0
  39. package/src/core/policy/index.ts +26 -0
  40. package/src/core/policy/types.ts +107 -0
  41. package/src/core/workflow/engine.ts +452 -53
  42. package/src/core/workflow/index.ts +44 -0
  43. package/src/core/workflow/proof.ts +485 -0
  44. package/src/core/workflow/types.ts +210 -0
@@ -0,0 +1,107 @@
1
+ export const POLICY_SCHEMA_VERSION = 1 as const;
2
+
3
+ export type PolicyVerdict = "allow" | "ask" | "deny";
4
+ export type PolicyPhase = "dispatch" | "external_mutation";
5
+ export type PolicyIsolation = "shared" | "worktree" | "sandbox" | "remote";
6
+ export type PolicyNetworkAccess = "enabled" | "disabled" | "unknown";
7
+
8
+ /** Host-owned policy document. Workflow metadata cannot supply this value. */
9
+ export interface PolicySpec {
10
+ schema_version?: typeof POLICY_SCHEMA_VERSION;
11
+ name?: string;
12
+ max_cost_usd?: number;
13
+ /** Applied when a cost ceiling exists but the host cannot price a dispatch. */
14
+ unknown_cost?: Exclude<PolicyVerdict, "allow">;
15
+ allowed_harnesses?: readonly string[];
16
+ allowed_models?: readonly string[];
17
+ /** Absolute paths, or paths relative to the policy file. */
18
+ allowed_paths?: readonly string[];
19
+ network?: PolicyVerdict;
20
+ external_actions?: PolicyVerdict;
21
+ /** Allowed host-declared execution boundaries. No strength ordering is inferred. */
22
+ allowed_isolation?: readonly PolicyIsolation[];
23
+ }
24
+
25
+ export interface NormalizedPolicy {
26
+ schema_version: typeof POLICY_SCHEMA_VERSION;
27
+ name: string;
28
+ max_cost_usd?: number;
29
+ unknown_cost: Exclude<PolicyVerdict, "allow">;
30
+ allowed_harnesses?: readonly string[];
31
+ allowed_models?: readonly string[];
32
+ allowed_paths?: readonly string[];
33
+ network: PolicyVerdict;
34
+ external_actions: PolicyVerdict;
35
+ allowed_isolation?: readonly PolicyIsolation[];
36
+ }
37
+
38
+ export interface PolicyRequest {
39
+ phase: PolicyPhase;
40
+ action: string;
41
+ path?: string;
42
+ harness?: string;
43
+ model?: string;
44
+ effort?: string;
45
+ max_attempts?: number;
46
+ max_turns?: number;
47
+ timeout_ms?: number;
48
+ /** Prompt size for host estimation. Prompt content is never included. */
49
+ prompt_bytes?: number;
50
+ isolation: PolicyIsolation;
51
+ network_access: PolicyNetworkAccess;
52
+ service?: string;
53
+ target?: string;
54
+ current_cost_usd?: number;
55
+ projected_cost_usd?: number | null;
56
+ }
57
+
58
+ export type PolicyRequestSummary = PolicyRequest;
59
+
60
+ export interface PolicyRuleResult {
61
+ code: string;
62
+ verdict: PolicyVerdict;
63
+ reason: string;
64
+ }
65
+
66
+ export interface PolicyEvaluation {
67
+ verdict: PolicyVerdict;
68
+ reason: string;
69
+ rules: PolicyRuleResult[];
70
+ }
71
+
72
+ export interface PolicyAskResolution {
73
+ verdict: "allow" | "deny";
74
+ reason?: string;
75
+ }
76
+
77
+ export type PolicyAskResolver = (
78
+ request: Readonly<PolicyRequestSummary>,
79
+ evaluation: Readonly<PolicyEvaluation>,
80
+ ) => Promise<PolicyAskResolution> | PolicyAskResolution;
81
+
82
+ export interface PolicyDecision {
83
+ id: string;
84
+ checked_at: string;
85
+ policy: string;
86
+ phase: PolicyPhase;
87
+ initial_verdict: PolicyVerdict;
88
+ verdict: "allow" | "deny";
89
+ resolved_by: "policy" | "host" | "fail_closed";
90
+ reason: string;
91
+ rule_codes: string[];
92
+ request: PolicyRequestSummary;
93
+ }
94
+
95
+ export interface ExternalMutationRequest {
96
+ /** Short verb phrase, for example "publish release" or "write report". */
97
+ action: string;
98
+ path?: string;
99
+ network?: boolean;
100
+ service?: string;
101
+ /** Bounded destination descriptor. Do not include credentials or payloads. */
102
+ target?: string;
103
+ }
104
+
105
+ export type DispatchCostEstimator = (
106
+ request: Readonly<PolicyRequestSummary>,
107
+ ) => Promise<number | null> | number | null;