@lannguyensi/harness 0.25.2 → 0.26.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.
- package/CHANGELOG.md +20 -0
- package/dist/cli/event-input.d.ts +28 -0
- package/dist/cli/event-input.js +72 -0
- package/dist/cli/event-input.js.map +1 -0
- package/dist/cli/explain-action.d.ts +20 -0
- package/dist/cli/explain-action.js +27 -0
- package/dist/cli/explain-action.js.map +1 -0
- package/dist/cli/index.js +56 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/pack/hook-branch-protection.js +1 -1
- package/dist/cli/pack/hook-branch-protection.js.map +1 -1
- package/dist/cli/pack/hook-codex-pre-tool-use.js +1 -1
- package/dist/cli/pack/hook-codex-pre-tool-use.js.map +1 -1
- package/dist/cli/pack/hook-post-tool-use.js +1 -1
- package/dist/cli/pack/hook-post-tool-use.js.map +1 -1
- package/dist/cli/pack/hook-pre-tool-use.js +1 -1
- package/dist/cli/pack/hook-pre-tool-use.js.map +1 -1
- package/dist/cli/pack/hook-track-active-claim.js +1 -1
- package/dist/cli/pack/hook-track-active-claim.js.map +1 -1
- package/dist/cli/{pack/pause-check.d.ts → pause-check.d.ts} +1 -1
- package/dist/cli/{pack/pause-check.js → pause-check.js} +14 -11
- package/dist/cli/pause-check.js.map +1 -0
- package/dist/cli/policy/intercept.d.ts +5 -0
- package/dist/cli/policy/intercept.js +21 -0
- package/dist/cli/policy/intercept.js.map +1 -1
- package/dist/cli/resolve-env.d.ts +32 -0
- package/dist/cli/resolve-env.js +47 -0
- package/dist/cli/resolve-env.js.map +1 -0
- package/dist/cli/test-risk.d.ts +26 -0
- package/dist/cli/test-risk.js +34 -0
- package/dist/cli/test-risk.js.map +1 -0
- package/dist/runtime/action-envelope.d.ts +64 -0
- package/dist/runtime/action-envelope.js +46 -0
- package/dist/runtime/action-envelope.js.map +1 -0
- package/dist/runtime/environment-resolver.d.ts +36 -0
- package/dist/runtime/environment-resolver.js +138 -0
- package/dist/runtime/environment-resolver.js.map +1 -0
- package/dist/runtime/index.d.ts +4 -0
- package/dist/runtime/index.js +4 -0
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/kube-context.d.ts +16 -0
- package/dist/runtime/kube-context.js +63 -0
- package/dist/runtime/kube-context.js.map +1 -0
- package/dist/runtime/risk-classifier.d.ts +38 -0
- package/dist/runtime/risk-classifier.js +121 -0
- package/dist/runtime/risk-classifier.js.map +1 -0
- package/dist/schema/environments.d.ts +215 -0
- package/dist/schema/environments.js +101 -0
- package/dist/schema/environments.js.map +1 -0
- package/dist/schema/index.d.ts +408 -0
- package/dist/schema/index.js +8 -0
- package/dist/schema/index.js.map +1 -1
- package/dist/schema/policies.d.ts +139 -0
- package/dist/schema/policies.js +39 -0
- package/dist/schema/policies.js.map +1 -1
- package/dist/schema/risk.d.ts +131 -0
- package/dist/schema/risk.js +87 -0
- package/dist/schema/risk.js.map +1 -0
- package/package.json +1 -1
- package/dist/cli/pack/pause-check.js.map +0 -1
|
@@ -72,6 +72,32 @@ export declare const PolicyUxSchema: z.ZodObject<{
|
|
|
72
72
|
required: string[];
|
|
73
73
|
run: string[];
|
|
74
74
|
}>;
|
|
75
|
+
export declare const PolicyWhenSchema: z.ZodEffects<z.ZodObject<{
|
|
76
|
+
"risk.severity_at_least": z.ZodOptional<z.ZodEnum<["low", "medium", "high", "critical"]>>;
|
|
77
|
+
"risk.category_in": z.ZodOptional<z.ZodArray<z.ZodEnum<["destructive", "data_loss", "production_mutation", "credential_access", "secret_exfiltration", "network_exfiltration", "deployment_change", "infrastructure_change", "privilege_escalation", "irreversible_action", "mass_update"]>, "many">>;
|
|
78
|
+
"environment.name": z.ZodOptional<z.ZodEnum<["production", "staging", "dev", "local", "unknown"]>>;
|
|
79
|
+
"action.reversible": z.ZodOptional<z.ZodBoolean>;
|
|
80
|
+
}, "strict", z.ZodTypeAny, {
|
|
81
|
+
"risk.severity_at_least"?: "low" | "medium" | "high" | "critical" | undefined;
|
|
82
|
+
"risk.category_in"?: ("destructive" | "data_loss" | "production_mutation" | "credential_access" | "secret_exfiltration" | "network_exfiltration" | "deployment_change" | "infrastructure_change" | "privilege_escalation" | "irreversible_action" | "mass_update")[] | undefined;
|
|
83
|
+
"environment.name"?: "production" | "staging" | "dev" | "local" | "unknown" | undefined;
|
|
84
|
+
"action.reversible"?: boolean | undefined;
|
|
85
|
+
}, {
|
|
86
|
+
"risk.severity_at_least"?: "low" | "medium" | "high" | "critical" | undefined;
|
|
87
|
+
"risk.category_in"?: ("destructive" | "data_loss" | "production_mutation" | "credential_access" | "secret_exfiltration" | "network_exfiltration" | "deployment_change" | "infrastructure_change" | "privilege_escalation" | "irreversible_action" | "mass_update")[] | undefined;
|
|
88
|
+
"environment.name"?: "production" | "staging" | "dev" | "local" | "unknown" | undefined;
|
|
89
|
+
"action.reversible"?: boolean | undefined;
|
|
90
|
+
}>, {
|
|
91
|
+
"risk.severity_at_least"?: "low" | "medium" | "high" | "critical" | undefined;
|
|
92
|
+
"risk.category_in"?: ("destructive" | "data_loss" | "production_mutation" | "credential_access" | "secret_exfiltration" | "network_exfiltration" | "deployment_change" | "infrastructure_change" | "privilege_escalation" | "irreversible_action" | "mass_update")[] | undefined;
|
|
93
|
+
"environment.name"?: "production" | "staging" | "dev" | "local" | "unknown" | undefined;
|
|
94
|
+
"action.reversible"?: boolean | undefined;
|
|
95
|
+
}, {
|
|
96
|
+
"risk.severity_at_least"?: "low" | "medium" | "high" | "critical" | undefined;
|
|
97
|
+
"risk.category_in"?: ("destructive" | "data_loss" | "production_mutation" | "credential_access" | "secret_exfiltration" | "network_exfiltration" | "deployment_change" | "infrastructure_change" | "privilege_escalation" | "irreversible_action" | "mass_update")[] | undefined;
|
|
98
|
+
"environment.name"?: "production" | "staging" | "dev" | "local" | "unknown" | undefined;
|
|
99
|
+
"action.reversible"?: boolean | undefined;
|
|
100
|
+
}>;
|
|
75
101
|
export declare const PolicySchema: z.ZodEffects<z.ZodObject<{
|
|
76
102
|
name: z.ZodString;
|
|
77
103
|
description: z.ZodString;
|
|
@@ -217,6 +243,32 @@ export declare const PolicySchema: z.ZodEffects<z.ZodObject<{
|
|
|
217
243
|
required: string[];
|
|
218
244
|
run: string[];
|
|
219
245
|
}>>;
|
|
246
|
+
when: z.ZodOptional<z.ZodEffects<z.ZodObject<{
|
|
247
|
+
"risk.severity_at_least": z.ZodOptional<z.ZodEnum<["low", "medium", "high", "critical"]>>;
|
|
248
|
+
"risk.category_in": z.ZodOptional<z.ZodArray<z.ZodEnum<["destructive", "data_loss", "production_mutation", "credential_access", "secret_exfiltration", "network_exfiltration", "deployment_change", "infrastructure_change", "privilege_escalation", "irreversible_action", "mass_update"]>, "many">>;
|
|
249
|
+
"environment.name": z.ZodOptional<z.ZodEnum<["production", "staging", "dev", "local", "unknown"]>>;
|
|
250
|
+
"action.reversible": z.ZodOptional<z.ZodBoolean>;
|
|
251
|
+
}, "strict", z.ZodTypeAny, {
|
|
252
|
+
"risk.severity_at_least"?: "low" | "medium" | "high" | "critical" | undefined;
|
|
253
|
+
"risk.category_in"?: ("destructive" | "data_loss" | "production_mutation" | "credential_access" | "secret_exfiltration" | "network_exfiltration" | "deployment_change" | "infrastructure_change" | "privilege_escalation" | "irreversible_action" | "mass_update")[] | undefined;
|
|
254
|
+
"environment.name"?: "production" | "staging" | "dev" | "local" | "unknown" | undefined;
|
|
255
|
+
"action.reversible"?: boolean | undefined;
|
|
256
|
+
}, {
|
|
257
|
+
"risk.severity_at_least"?: "low" | "medium" | "high" | "critical" | undefined;
|
|
258
|
+
"risk.category_in"?: ("destructive" | "data_loss" | "production_mutation" | "credential_access" | "secret_exfiltration" | "network_exfiltration" | "deployment_change" | "infrastructure_change" | "privilege_escalation" | "irreversible_action" | "mass_update")[] | undefined;
|
|
259
|
+
"environment.name"?: "production" | "staging" | "dev" | "local" | "unknown" | undefined;
|
|
260
|
+
"action.reversible"?: boolean | undefined;
|
|
261
|
+
}>, {
|
|
262
|
+
"risk.severity_at_least"?: "low" | "medium" | "high" | "critical" | undefined;
|
|
263
|
+
"risk.category_in"?: ("destructive" | "data_loss" | "production_mutation" | "credential_access" | "secret_exfiltration" | "network_exfiltration" | "deployment_change" | "infrastructure_change" | "privilege_escalation" | "irreversible_action" | "mass_update")[] | undefined;
|
|
264
|
+
"environment.name"?: "production" | "staging" | "dev" | "local" | "unknown" | undefined;
|
|
265
|
+
"action.reversible"?: boolean | undefined;
|
|
266
|
+
}, {
|
|
267
|
+
"risk.severity_at_least"?: "low" | "medium" | "high" | "critical" | undefined;
|
|
268
|
+
"risk.category_in"?: ("destructive" | "data_loss" | "production_mutation" | "credential_access" | "secret_exfiltration" | "network_exfiltration" | "deployment_change" | "infrastructure_change" | "privilege_escalation" | "irreversible_action" | "mass_update")[] | undefined;
|
|
269
|
+
"environment.name"?: "production" | "staging" | "dev" | "local" | "unknown" | undefined;
|
|
270
|
+
"action.reversible"?: boolean | undefined;
|
|
271
|
+
}>>;
|
|
220
272
|
}, "strict", z.ZodTypeAny, {
|
|
221
273
|
name: string;
|
|
222
274
|
description: string;
|
|
@@ -258,6 +310,12 @@ export declare const PolicySchema: z.ZodEffects<z.ZodObject<{
|
|
|
258
310
|
required: string[];
|
|
259
311
|
run: string[];
|
|
260
312
|
} | undefined;
|
|
313
|
+
when?: {
|
|
314
|
+
"risk.severity_at_least"?: "low" | "medium" | "high" | "critical" | undefined;
|
|
315
|
+
"risk.category_in"?: ("destructive" | "data_loss" | "production_mutation" | "credential_access" | "secret_exfiltration" | "network_exfiltration" | "deployment_change" | "infrastructure_change" | "privilege_escalation" | "irreversible_action" | "mass_update")[] | undefined;
|
|
316
|
+
"environment.name"?: "production" | "staging" | "dev" | "local" | "unknown" | undefined;
|
|
317
|
+
"action.reversible"?: boolean | undefined;
|
|
318
|
+
} | undefined;
|
|
261
319
|
}, {
|
|
262
320
|
name: string;
|
|
263
321
|
description: string;
|
|
@@ -299,6 +357,12 @@ export declare const PolicySchema: z.ZodEffects<z.ZodObject<{
|
|
|
299
357
|
required: string[];
|
|
300
358
|
run: string[];
|
|
301
359
|
} | undefined;
|
|
360
|
+
when?: {
|
|
361
|
+
"risk.severity_at_least"?: "low" | "medium" | "high" | "critical" | undefined;
|
|
362
|
+
"risk.category_in"?: ("destructive" | "data_loss" | "production_mutation" | "credential_access" | "secret_exfiltration" | "network_exfiltration" | "deployment_change" | "infrastructure_change" | "privilege_escalation" | "irreversible_action" | "mass_update")[] | undefined;
|
|
363
|
+
"environment.name"?: "production" | "staging" | "dev" | "local" | "unknown" | undefined;
|
|
364
|
+
"action.reversible"?: boolean | undefined;
|
|
365
|
+
} | undefined;
|
|
302
366
|
}>, {
|
|
303
367
|
name: string;
|
|
304
368
|
description: string;
|
|
@@ -340,6 +404,12 @@ export declare const PolicySchema: z.ZodEffects<z.ZodObject<{
|
|
|
340
404
|
required: string[];
|
|
341
405
|
run: string[];
|
|
342
406
|
} | undefined;
|
|
407
|
+
when?: {
|
|
408
|
+
"risk.severity_at_least"?: "low" | "medium" | "high" | "critical" | undefined;
|
|
409
|
+
"risk.category_in"?: ("destructive" | "data_loss" | "production_mutation" | "credential_access" | "secret_exfiltration" | "network_exfiltration" | "deployment_change" | "infrastructure_change" | "privilege_escalation" | "irreversible_action" | "mass_update")[] | undefined;
|
|
410
|
+
"environment.name"?: "production" | "staging" | "dev" | "local" | "unknown" | undefined;
|
|
411
|
+
"action.reversible"?: boolean | undefined;
|
|
412
|
+
} | undefined;
|
|
343
413
|
}, {
|
|
344
414
|
name: string;
|
|
345
415
|
description: string;
|
|
@@ -381,6 +451,12 @@ export declare const PolicySchema: z.ZodEffects<z.ZodObject<{
|
|
|
381
451
|
required: string[];
|
|
382
452
|
run: string[];
|
|
383
453
|
} | undefined;
|
|
454
|
+
when?: {
|
|
455
|
+
"risk.severity_at_least"?: "low" | "medium" | "high" | "critical" | undefined;
|
|
456
|
+
"risk.category_in"?: ("destructive" | "data_loss" | "production_mutation" | "credential_access" | "secret_exfiltration" | "network_exfiltration" | "deployment_change" | "infrastructure_change" | "privilege_escalation" | "irreversible_action" | "mass_update")[] | undefined;
|
|
457
|
+
"environment.name"?: "production" | "staging" | "dev" | "local" | "unknown" | undefined;
|
|
458
|
+
"action.reversible"?: boolean | undefined;
|
|
459
|
+
} | undefined;
|
|
384
460
|
}>;
|
|
385
461
|
export declare const PoliciesSchema: z.ZodEffects<z.ZodArray<z.ZodEffects<z.ZodObject<{
|
|
386
462
|
name: z.ZodString;
|
|
@@ -527,6 +603,32 @@ export declare const PoliciesSchema: z.ZodEffects<z.ZodArray<z.ZodEffects<z.ZodO
|
|
|
527
603
|
required: string[];
|
|
528
604
|
run: string[];
|
|
529
605
|
}>>;
|
|
606
|
+
when: z.ZodOptional<z.ZodEffects<z.ZodObject<{
|
|
607
|
+
"risk.severity_at_least": z.ZodOptional<z.ZodEnum<["low", "medium", "high", "critical"]>>;
|
|
608
|
+
"risk.category_in": z.ZodOptional<z.ZodArray<z.ZodEnum<["destructive", "data_loss", "production_mutation", "credential_access", "secret_exfiltration", "network_exfiltration", "deployment_change", "infrastructure_change", "privilege_escalation", "irreversible_action", "mass_update"]>, "many">>;
|
|
609
|
+
"environment.name": z.ZodOptional<z.ZodEnum<["production", "staging", "dev", "local", "unknown"]>>;
|
|
610
|
+
"action.reversible": z.ZodOptional<z.ZodBoolean>;
|
|
611
|
+
}, "strict", z.ZodTypeAny, {
|
|
612
|
+
"risk.severity_at_least"?: "low" | "medium" | "high" | "critical" | undefined;
|
|
613
|
+
"risk.category_in"?: ("destructive" | "data_loss" | "production_mutation" | "credential_access" | "secret_exfiltration" | "network_exfiltration" | "deployment_change" | "infrastructure_change" | "privilege_escalation" | "irreversible_action" | "mass_update")[] | undefined;
|
|
614
|
+
"environment.name"?: "production" | "staging" | "dev" | "local" | "unknown" | undefined;
|
|
615
|
+
"action.reversible"?: boolean | undefined;
|
|
616
|
+
}, {
|
|
617
|
+
"risk.severity_at_least"?: "low" | "medium" | "high" | "critical" | undefined;
|
|
618
|
+
"risk.category_in"?: ("destructive" | "data_loss" | "production_mutation" | "credential_access" | "secret_exfiltration" | "network_exfiltration" | "deployment_change" | "infrastructure_change" | "privilege_escalation" | "irreversible_action" | "mass_update")[] | undefined;
|
|
619
|
+
"environment.name"?: "production" | "staging" | "dev" | "local" | "unknown" | undefined;
|
|
620
|
+
"action.reversible"?: boolean | undefined;
|
|
621
|
+
}>, {
|
|
622
|
+
"risk.severity_at_least"?: "low" | "medium" | "high" | "critical" | undefined;
|
|
623
|
+
"risk.category_in"?: ("destructive" | "data_loss" | "production_mutation" | "credential_access" | "secret_exfiltration" | "network_exfiltration" | "deployment_change" | "infrastructure_change" | "privilege_escalation" | "irreversible_action" | "mass_update")[] | undefined;
|
|
624
|
+
"environment.name"?: "production" | "staging" | "dev" | "local" | "unknown" | undefined;
|
|
625
|
+
"action.reversible"?: boolean | undefined;
|
|
626
|
+
}, {
|
|
627
|
+
"risk.severity_at_least"?: "low" | "medium" | "high" | "critical" | undefined;
|
|
628
|
+
"risk.category_in"?: ("destructive" | "data_loss" | "production_mutation" | "credential_access" | "secret_exfiltration" | "network_exfiltration" | "deployment_change" | "infrastructure_change" | "privilege_escalation" | "irreversible_action" | "mass_update")[] | undefined;
|
|
629
|
+
"environment.name"?: "production" | "staging" | "dev" | "local" | "unknown" | undefined;
|
|
630
|
+
"action.reversible"?: boolean | undefined;
|
|
631
|
+
}>>;
|
|
530
632
|
}, "strict", z.ZodTypeAny, {
|
|
531
633
|
name: string;
|
|
532
634
|
description: string;
|
|
@@ -568,6 +670,12 @@ export declare const PoliciesSchema: z.ZodEffects<z.ZodArray<z.ZodEffects<z.ZodO
|
|
|
568
670
|
required: string[];
|
|
569
671
|
run: string[];
|
|
570
672
|
} | undefined;
|
|
673
|
+
when?: {
|
|
674
|
+
"risk.severity_at_least"?: "low" | "medium" | "high" | "critical" | undefined;
|
|
675
|
+
"risk.category_in"?: ("destructive" | "data_loss" | "production_mutation" | "credential_access" | "secret_exfiltration" | "network_exfiltration" | "deployment_change" | "infrastructure_change" | "privilege_escalation" | "irreversible_action" | "mass_update")[] | undefined;
|
|
676
|
+
"environment.name"?: "production" | "staging" | "dev" | "local" | "unknown" | undefined;
|
|
677
|
+
"action.reversible"?: boolean | undefined;
|
|
678
|
+
} | undefined;
|
|
571
679
|
}, {
|
|
572
680
|
name: string;
|
|
573
681
|
description: string;
|
|
@@ -609,6 +717,12 @@ export declare const PoliciesSchema: z.ZodEffects<z.ZodArray<z.ZodEffects<z.ZodO
|
|
|
609
717
|
required: string[];
|
|
610
718
|
run: string[];
|
|
611
719
|
} | undefined;
|
|
720
|
+
when?: {
|
|
721
|
+
"risk.severity_at_least"?: "low" | "medium" | "high" | "critical" | undefined;
|
|
722
|
+
"risk.category_in"?: ("destructive" | "data_loss" | "production_mutation" | "credential_access" | "secret_exfiltration" | "network_exfiltration" | "deployment_change" | "infrastructure_change" | "privilege_escalation" | "irreversible_action" | "mass_update")[] | undefined;
|
|
723
|
+
"environment.name"?: "production" | "staging" | "dev" | "local" | "unknown" | undefined;
|
|
724
|
+
"action.reversible"?: boolean | undefined;
|
|
725
|
+
} | undefined;
|
|
612
726
|
}>, {
|
|
613
727
|
name: string;
|
|
614
728
|
description: string;
|
|
@@ -650,6 +764,12 @@ export declare const PoliciesSchema: z.ZodEffects<z.ZodArray<z.ZodEffects<z.ZodO
|
|
|
650
764
|
required: string[];
|
|
651
765
|
run: string[];
|
|
652
766
|
} | undefined;
|
|
767
|
+
when?: {
|
|
768
|
+
"risk.severity_at_least"?: "low" | "medium" | "high" | "critical" | undefined;
|
|
769
|
+
"risk.category_in"?: ("destructive" | "data_loss" | "production_mutation" | "credential_access" | "secret_exfiltration" | "network_exfiltration" | "deployment_change" | "infrastructure_change" | "privilege_escalation" | "irreversible_action" | "mass_update")[] | undefined;
|
|
770
|
+
"environment.name"?: "production" | "staging" | "dev" | "local" | "unknown" | undefined;
|
|
771
|
+
"action.reversible"?: boolean | undefined;
|
|
772
|
+
} | undefined;
|
|
653
773
|
}, {
|
|
654
774
|
name: string;
|
|
655
775
|
description: string;
|
|
@@ -691,6 +811,12 @@ export declare const PoliciesSchema: z.ZodEffects<z.ZodArray<z.ZodEffects<z.ZodO
|
|
|
691
811
|
required: string[];
|
|
692
812
|
run: string[];
|
|
693
813
|
} | undefined;
|
|
814
|
+
when?: {
|
|
815
|
+
"risk.severity_at_least"?: "low" | "medium" | "high" | "critical" | undefined;
|
|
816
|
+
"risk.category_in"?: ("destructive" | "data_loss" | "production_mutation" | "credential_access" | "secret_exfiltration" | "network_exfiltration" | "deployment_change" | "infrastructure_change" | "privilege_escalation" | "irreversible_action" | "mass_update")[] | undefined;
|
|
817
|
+
"environment.name"?: "production" | "staging" | "dev" | "local" | "unknown" | undefined;
|
|
818
|
+
"action.reversible"?: boolean | undefined;
|
|
819
|
+
} | undefined;
|
|
694
820
|
}>, "many">, {
|
|
695
821
|
name: string;
|
|
696
822
|
description: string;
|
|
@@ -732,6 +858,12 @@ export declare const PoliciesSchema: z.ZodEffects<z.ZodArray<z.ZodEffects<z.ZodO
|
|
|
732
858
|
required: string[];
|
|
733
859
|
run: string[];
|
|
734
860
|
} | undefined;
|
|
861
|
+
when?: {
|
|
862
|
+
"risk.severity_at_least"?: "low" | "medium" | "high" | "critical" | undefined;
|
|
863
|
+
"risk.category_in"?: ("destructive" | "data_loss" | "production_mutation" | "credential_access" | "secret_exfiltration" | "network_exfiltration" | "deployment_change" | "infrastructure_change" | "privilege_escalation" | "irreversible_action" | "mass_update")[] | undefined;
|
|
864
|
+
"environment.name"?: "production" | "staging" | "dev" | "local" | "unknown" | undefined;
|
|
865
|
+
"action.reversible"?: boolean | undefined;
|
|
866
|
+
} | undefined;
|
|
735
867
|
}[], {
|
|
736
868
|
name: string;
|
|
737
869
|
description: string;
|
|
@@ -773,7 +905,14 @@ export declare const PoliciesSchema: z.ZodEffects<z.ZodArray<z.ZodEffects<z.ZodO
|
|
|
773
905
|
required: string[];
|
|
774
906
|
run: string[];
|
|
775
907
|
} | undefined;
|
|
908
|
+
when?: {
|
|
909
|
+
"risk.severity_at_least"?: "low" | "medium" | "high" | "critical" | undefined;
|
|
910
|
+
"risk.category_in"?: ("destructive" | "data_loss" | "production_mutation" | "credential_access" | "secret_exfiltration" | "network_exfiltration" | "deployment_change" | "infrastructure_change" | "privilege_escalation" | "irreversible_action" | "mass_update")[] | undefined;
|
|
911
|
+
"environment.name"?: "production" | "staging" | "dev" | "local" | "unknown" | undefined;
|
|
912
|
+
"action.reversible"?: boolean | undefined;
|
|
913
|
+
} | undefined;
|
|
776
914
|
}[]>;
|
|
777
915
|
export type Policy = z.infer<typeof PolicySchema>;
|
|
778
916
|
export type Producer = z.infer<typeof ProducerSchema>;
|
|
779
917
|
export type PolicyUx = z.infer<typeof PolicyUxSchema>;
|
|
918
|
+
export type PolicyWhen = z.infer<typeof PolicyWhenSchema>;
|
package/dist/schema/policies.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import { MatchableEnvironmentSchema } from "./environments.js";
|
|
2
3
|
import { ExtractMapSchema } from "./extract.js";
|
|
3
4
|
import { HookEventSchema } from "./hooks.js";
|
|
4
5
|
import { RequiresSchema, isBuiltinVariable, referencedVariables } from "./requires.js";
|
|
6
|
+
import { RiskCategorySchema, RiskSeveritySchema } from "./risk.js";
|
|
5
7
|
export const PolicyTriggerSchema = z
|
|
6
8
|
.object({
|
|
7
9
|
event: HookEventSchema,
|
|
@@ -79,6 +81,42 @@ export const PolicyUxSchema = z
|
|
|
79
81
|
run: z.array(z.string().min(1)).min(1),
|
|
80
82
|
})
|
|
81
83
|
.strict();
|
|
84
|
+
// `when:` — Phase 7 #1 anchor. The risk/environment-aware match layer.
|
|
85
|
+
//
|
|
86
|
+
// STATUS: schema vocabulary only. `harness policy intercept` does NOT
|
|
87
|
+
// evaluate `when:` yet — a policy's `trigger:` remains the sole match
|
|
88
|
+
// surface at runtime. The Phase 7 #5 evaluator will AND a declared
|
|
89
|
+
// `when:` onto the trigger match, reading the enriched Action Envelope
|
|
90
|
+
// (see docs/ROADMAP.md and docs/risk-gate.md). A `when:` block today is
|
|
91
|
+
// parsed, validated, and otherwise inert.
|
|
92
|
+
//
|
|
93
|
+
// Each clause is optional and keyed by the envelope path it tests:
|
|
94
|
+
// risk.severity_at_least — envelope risk severity at or above this
|
|
95
|
+
// rung of the ordered scale.
|
|
96
|
+
// risk.category_in — envelope risk carries any of these
|
|
97
|
+
// categories.
|
|
98
|
+
// environment.name — resolved environment equals this name
|
|
99
|
+
// (`unknown` is matchable: unknown is not
|
|
100
|
+
// safe).
|
|
101
|
+
// action.reversible — envelope action reversibility flag.
|
|
102
|
+
// An empty `when: {}` is rejected: it would be a silent no-op.
|
|
103
|
+
export const PolicyWhenSchema = z
|
|
104
|
+
.object({
|
|
105
|
+
"risk.severity_at_least": RiskSeveritySchema.optional(),
|
|
106
|
+
"risk.category_in": z.array(RiskCategorySchema).min(1).optional(),
|
|
107
|
+
"environment.name": MatchableEnvironmentSchema.optional(),
|
|
108
|
+
"action.reversible": z.boolean().optional(),
|
|
109
|
+
})
|
|
110
|
+
.strict()
|
|
111
|
+
.superRefine((when, ctx) => {
|
|
112
|
+
if (Object.keys(when).length === 0) {
|
|
113
|
+
ctx.addIssue({
|
|
114
|
+
code: z.ZodIssueCode.custom,
|
|
115
|
+
path: [],
|
|
116
|
+
message: "policy.when must declare at least one clause; an empty when: {} is a silent no-op",
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
});
|
|
82
120
|
export const PolicySchema = z
|
|
83
121
|
.object({
|
|
84
122
|
name: z.string().min(1),
|
|
@@ -89,6 +127,7 @@ export const PolicySchema = z
|
|
|
89
127
|
enforcement: PolicyEnforcementSchema,
|
|
90
128
|
producers: z.array(ProducerSchema).min(1).optional(),
|
|
91
129
|
ux: PolicyUxSchema.optional(),
|
|
130
|
+
when: PolicyWhenSchema.optional(),
|
|
92
131
|
})
|
|
93
132
|
.strict()
|
|
94
133
|
.superRefine((policy, ctx) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"policies.js","sourceRoot":"","sources":["../../src/schema/policies.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"policies.js","sourceRoot":"","sources":["../../src/schema/policies.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACvF,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAEnE,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC;KACjC,MAAM,CAAC;IACN,KAAK,EAAE,eAAe;IACtB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IACnC,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IACxC,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IACxC,OAAO,EAAE,gBAAgB,CAAC,QAAQ,EAAE;CACrC,CAAC;KACD,MAAM,EAAE,CAAC;AAEZ,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAC,IAAI,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3B,IAAI,EAAE,CAAC,CAAC,EAAE,MAAM,CAAC;gBACjB,OAAO,EAAE,0BAA0B,CAAC,CAAC,IAAI,EAAE;aAC5C,CAAC,CAAC;QACL,CAAC;QACD,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IACnB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const RiskSeveritySchema: z.ZodEnum<["low", "medium", "high", "critical"]>;
|
|
3
|
+
export declare const RiskCategorySchema: z.ZodEnum<["destructive", "data_loss", "production_mutation", "credential_access", "secret_exfiltration", "network_exfiltration", "deployment_change", "infrastructure_change", "privilege_escalation", "irreversible_action", "mass_update"]>;
|
|
4
|
+
export declare const RiskClassifierSchema: z.ZodObject<{
|
|
5
|
+
name: z.ZodString;
|
|
6
|
+
tool: z.ZodString;
|
|
7
|
+
patterns: z.ZodArray<z.ZodEffects<z.ZodObject<{
|
|
8
|
+
pattern: z.ZodString;
|
|
9
|
+
categories: z.ZodArray<z.ZodEnum<["destructive", "data_loss", "production_mutation", "credential_access", "secret_exfiltration", "network_exfiltration", "deployment_change", "infrastructure_change", "privilege_escalation", "irreversible_action", "mass_update"]>, "many">;
|
|
10
|
+
severity: z.ZodEnum<["low", "medium", "high", "critical"]>;
|
|
11
|
+
}, "strict", z.ZodTypeAny, {
|
|
12
|
+
pattern: string;
|
|
13
|
+
categories: ("destructive" | "data_loss" | "production_mutation" | "credential_access" | "secret_exfiltration" | "network_exfiltration" | "deployment_change" | "infrastructure_change" | "privilege_escalation" | "irreversible_action" | "mass_update")[];
|
|
14
|
+
severity: "low" | "medium" | "high" | "critical";
|
|
15
|
+
}, {
|
|
16
|
+
pattern: string;
|
|
17
|
+
categories: ("destructive" | "data_loss" | "production_mutation" | "credential_access" | "secret_exfiltration" | "network_exfiltration" | "deployment_change" | "infrastructure_change" | "privilege_escalation" | "irreversible_action" | "mass_update")[];
|
|
18
|
+
severity: "low" | "medium" | "high" | "critical";
|
|
19
|
+
}>, {
|
|
20
|
+
pattern: string;
|
|
21
|
+
categories: ("destructive" | "data_loss" | "production_mutation" | "credential_access" | "secret_exfiltration" | "network_exfiltration" | "deployment_change" | "infrastructure_change" | "privilege_escalation" | "irreversible_action" | "mass_update")[];
|
|
22
|
+
severity: "low" | "medium" | "high" | "critical";
|
|
23
|
+
}, {
|
|
24
|
+
pattern: string;
|
|
25
|
+
categories: ("destructive" | "data_loss" | "production_mutation" | "credential_access" | "secret_exfiltration" | "network_exfiltration" | "deployment_change" | "infrastructure_change" | "privilege_escalation" | "irreversible_action" | "mass_update")[];
|
|
26
|
+
severity: "low" | "medium" | "high" | "critical";
|
|
27
|
+
}>, "many">;
|
|
28
|
+
}, "strict", z.ZodTypeAny, {
|
|
29
|
+
patterns: {
|
|
30
|
+
pattern: string;
|
|
31
|
+
categories: ("destructive" | "data_loss" | "production_mutation" | "credential_access" | "secret_exfiltration" | "network_exfiltration" | "deployment_change" | "infrastructure_change" | "privilege_escalation" | "irreversible_action" | "mass_update")[];
|
|
32
|
+
severity: "low" | "medium" | "high" | "critical";
|
|
33
|
+
}[];
|
|
34
|
+
name: string;
|
|
35
|
+
tool: string;
|
|
36
|
+
}, {
|
|
37
|
+
patterns: {
|
|
38
|
+
pattern: string;
|
|
39
|
+
categories: ("destructive" | "data_loss" | "production_mutation" | "credential_access" | "secret_exfiltration" | "network_exfiltration" | "deployment_change" | "infrastructure_change" | "privilege_escalation" | "irreversible_action" | "mass_update")[];
|
|
40
|
+
severity: "low" | "medium" | "high" | "critical";
|
|
41
|
+
}[];
|
|
42
|
+
name: string;
|
|
43
|
+
tool: string;
|
|
44
|
+
}>;
|
|
45
|
+
export declare const RiskSchema: z.ZodEffects<z.ZodObject<{
|
|
46
|
+
classifiers: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
47
|
+
name: z.ZodString;
|
|
48
|
+
tool: z.ZodString;
|
|
49
|
+
patterns: z.ZodArray<z.ZodEffects<z.ZodObject<{
|
|
50
|
+
pattern: z.ZodString;
|
|
51
|
+
categories: z.ZodArray<z.ZodEnum<["destructive", "data_loss", "production_mutation", "credential_access", "secret_exfiltration", "network_exfiltration", "deployment_change", "infrastructure_change", "privilege_escalation", "irreversible_action", "mass_update"]>, "many">;
|
|
52
|
+
severity: z.ZodEnum<["low", "medium", "high", "critical"]>;
|
|
53
|
+
}, "strict", z.ZodTypeAny, {
|
|
54
|
+
pattern: string;
|
|
55
|
+
categories: ("destructive" | "data_loss" | "production_mutation" | "credential_access" | "secret_exfiltration" | "network_exfiltration" | "deployment_change" | "infrastructure_change" | "privilege_escalation" | "irreversible_action" | "mass_update")[];
|
|
56
|
+
severity: "low" | "medium" | "high" | "critical";
|
|
57
|
+
}, {
|
|
58
|
+
pattern: string;
|
|
59
|
+
categories: ("destructive" | "data_loss" | "production_mutation" | "credential_access" | "secret_exfiltration" | "network_exfiltration" | "deployment_change" | "infrastructure_change" | "privilege_escalation" | "irreversible_action" | "mass_update")[];
|
|
60
|
+
severity: "low" | "medium" | "high" | "critical";
|
|
61
|
+
}>, {
|
|
62
|
+
pattern: string;
|
|
63
|
+
categories: ("destructive" | "data_loss" | "production_mutation" | "credential_access" | "secret_exfiltration" | "network_exfiltration" | "deployment_change" | "infrastructure_change" | "privilege_escalation" | "irreversible_action" | "mass_update")[];
|
|
64
|
+
severity: "low" | "medium" | "high" | "critical";
|
|
65
|
+
}, {
|
|
66
|
+
pattern: string;
|
|
67
|
+
categories: ("destructive" | "data_loss" | "production_mutation" | "credential_access" | "secret_exfiltration" | "network_exfiltration" | "deployment_change" | "infrastructure_change" | "privilege_escalation" | "irreversible_action" | "mass_update")[];
|
|
68
|
+
severity: "low" | "medium" | "high" | "critical";
|
|
69
|
+
}>, "many">;
|
|
70
|
+
}, "strict", z.ZodTypeAny, {
|
|
71
|
+
patterns: {
|
|
72
|
+
pattern: string;
|
|
73
|
+
categories: ("destructive" | "data_loss" | "production_mutation" | "credential_access" | "secret_exfiltration" | "network_exfiltration" | "deployment_change" | "infrastructure_change" | "privilege_escalation" | "irreversible_action" | "mass_update")[];
|
|
74
|
+
severity: "low" | "medium" | "high" | "critical";
|
|
75
|
+
}[];
|
|
76
|
+
name: string;
|
|
77
|
+
tool: string;
|
|
78
|
+
}, {
|
|
79
|
+
patterns: {
|
|
80
|
+
pattern: string;
|
|
81
|
+
categories: ("destructive" | "data_loss" | "production_mutation" | "credential_access" | "secret_exfiltration" | "network_exfiltration" | "deployment_change" | "infrastructure_change" | "privilege_escalation" | "irreversible_action" | "mass_update")[];
|
|
82
|
+
severity: "low" | "medium" | "high" | "critical";
|
|
83
|
+
}[];
|
|
84
|
+
name: string;
|
|
85
|
+
tool: string;
|
|
86
|
+
}>, "many">>;
|
|
87
|
+
}, "strict", z.ZodTypeAny, {
|
|
88
|
+
classifiers: {
|
|
89
|
+
patterns: {
|
|
90
|
+
pattern: string;
|
|
91
|
+
categories: ("destructive" | "data_loss" | "production_mutation" | "credential_access" | "secret_exfiltration" | "network_exfiltration" | "deployment_change" | "infrastructure_change" | "privilege_escalation" | "irreversible_action" | "mass_update")[];
|
|
92
|
+
severity: "low" | "medium" | "high" | "critical";
|
|
93
|
+
}[];
|
|
94
|
+
name: string;
|
|
95
|
+
tool: string;
|
|
96
|
+
}[];
|
|
97
|
+
}, {
|
|
98
|
+
classifiers?: {
|
|
99
|
+
patterns: {
|
|
100
|
+
pattern: string;
|
|
101
|
+
categories: ("destructive" | "data_loss" | "production_mutation" | "credential_access" | "secret_exfiltration" | "network_exfiltration" | "deployment_change" | "infrastructure_change" | "privilege_escalation" | "irreversible_action" | "mass_update")[];
|
|
102
|
+
severity: "low" | "medium" | "high" | "critical";
|
|
103
|
+
}[];
|
|
104
|
+
name: string;
|
|
105
|
+
tool: string;
|
|
106
|
+
}[] | undefined;
|
|
107
|
+
}>, {
|
|
108
|
+
classifiers: {
|
|
109
|
+
patterns: {
|
|
110
|
+
pattern: string;
|
|
111
|
+
categories: ("destructive" | "data_loss" | "production_mutation" | "credential_access" | "secret_exfiltration" | "network_exfiltration" | "deployment_change" | "infrastructure_change" | "privilege_escalation" | "irreversible_action" | "mass_update")[];
|
|
112
|
+
severity: "low" | "medium" | "high" | "critical";
|
|
113
|
+
}[];
|
|
114
|
+
name: string;
|
|
115
|
+
tool: string;
|
|
116
|
+
}[];
|
|
117
|
+
}, {
|
|
118
|
+
classifiers?: {
|
|
119
|
+
patterns: {
|
|
120
|
+
pattern: string;
|
|
121
|
+
categories: ("destructive" | "data_loss" | "production_mutation" | "credential_access" | "secret_exfiltration" | "network_exfiltration" | "deployment_change" | "infrastructure_change" | "privilege_escalation" | "irreversible_action" | "mass_update")[];
|
|
122
|
+
severity: "low" | "medium" | "high" | "critical";
|
|
123
|
+
}[];
|
|
124
|
+
name: string;
|
|
125
|
+
tool: string;
|
|
126
|
+
}[] | undefined;
|
|
127
|
+
}>;
|
|
128
|
+
export type RiskSeverity = z.infer<typeof RiskSeveritySchema>;
|
|
129
|
+
export type RiskCategory = z.infer<typeof RiskCategorySchema>;
|
|
130
|
+
export type RiskClassifier = z.infer<typeof RiskClassifierSchema>;
|
|
131
|
+
export type RiskConfig = z.infer<typeof RiskSchema>;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
// Risk Gate vocabulary — Phase 7 #1 anchor.
|
|
3
|
+
//
|
|
4
|
+
// STATUS: schema vocabulary only. `harness validate` parses and
|
|
5
|
+
// validates a `risk:` block, but no runtime surface reads it yet. The
|
|
6
|
+
// Risk Classifier that consumes `risk.classifiers[]` to assign an
|
|
7
|
+
// Action Envelope a severity + categories lands in Phase 7 #3 (see
|
|
8
|
+
// docs/ROADMAP.md and docs/risk-gate.md). Until then a `risk:` block is
|
|
9
|
+
// inert, validated config.
|
|
10
|
+
//
|
|
11
|
+
// Design source: lava-ice-logs/2026-04-30/harness-risk-gate-extension.md.
|
|
12
|
+
// Severity is an ordered scale: a future `when.risk.severity_at_least:
|
|
13
|
+
// high` clause matches `high` and `critical`. The ordering is the enum
|
|
14
|
+
// declaration order — the Phase 7 #5 evaluator derives the comparison
|
|
15
|
+
// from `RiskSeveritySchema.options`. This anchor only fixes the set.
|
|
16
|
+
export const RiskSeveritySchema = z.enum(["low", "medium", "high", "critical"]);
|
|
17
|
+
// Closed category vocabulary. Phase 7 #1 deliberately ships a fixed set
|
|
18
|
+
// rather than a free-form string: a typo (`data-loss` for `data_loss`)
|
|
19
|
+
// is then a validate-time error instead of a clause that silently never
|
|
20
|
+
// matches, and `when.risk.category_in` stays statically checkable. New
|
|
21
|
+
// categories are a schema addition, not operator config — see
|
|
22
|
+
// docs/risk-gate.md for the rationale and the v2 escape hatch.
|
|
23
|
+
export const RiskCategorySchema = z.enum([
|
|
24
|
+
"destructive",
|
|
25
|
+
"data_loss",
|
|
26
|
+
"production_mutation",
|
|
27
|
+
"credential_access",
|
|
28
|
+
"secret_exfiltration",
|
|
29
|
+
"network_exfiltration",
|
|
30
|
+
"deployment_change",
|
|
31
|
+
"infrastructure_change",
|
|
32
|
+
"privilege_escalation",
|
|
33
|
+
"irreversible_action",
|
|
34
|
+
"mass_update",
|
|
35
|
+
]);
|
|
36
|
+
// One pattern → (categories, severity) assignment. `pattern` is a
|
|
37
|
+
// regular expression matched against the classified tool's raw input
|
|
38
|
+
// (the exact field and match semantics are the Phase 7 #3 classifier's
|
|
39
|
+
// concern; the anchor only stores and regex-validates the string).
|
|
40
|
+
const RiskPatternSchema = z
|
|
41
|
+
.object({
|
|
42
|
+
pattern: z.string().min(1),
|
|
43
|
+
categories: z.array(RiskCategorySchema).min(1),
|
|
44
|
+
severity: RiskSeveritySchema,
|
|
45
|
+
})
|
|
46
|
+
.strict()
|
|
47
|
+
.superRefine((rule, ctx) => {
|
|
48
|
+
try {
|
|
49
|
+
new RegExp(rule.pattern);
|
|
50
|
+
}
|
|
51
|
+
catch (err) {
|
|
52
|
+
ctx.addIssue({
|
|
53
|
+
code: z.ZodIssueCode.custom,
|
|
54
|
+
path: ["pattern"],
|
|
55
|
+
message: `invalid regex: ${err.message}`,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
export const RiskClassifierSchema = z
|
|
60
|
+
.object({
|
|
61
|
+
name: z.string().min(1),
|
|
62
|
+
// The tool name whose input the classifier's patterns run against
|
|
63
|
+
// (e.g. `Bash`). The matcher that binds a classifier to a live tool
|
|
64
|
+
// event is Phase 7 #3; the anchor only records the binding.
|
|
65
|
+
tool: z.string().min(1),
|
|
66
|
+
patterns: z.array(RiskPatternSchema).min(1),
|
|
67
|
+
})
|
|
68
|
+
.strict();
|
|
69
|
+
export const RiskSchema = z
|
|
70
|
+
.object({
|
|
71
|
+
classifiers: z.array(RiskClassifierSchema).default([]),
|
|
72
|
+
})
|
|
73
|
+
.strict()
|
|
74
|
+
.superRefine((risk, ctx) => {
|
|
75
|
+
const seen = new Set();
|
|
76
|
+
risk.classifiers.forEach((c, i) => {
|
|
77
|
+
if (seen.has(c.name)) {
|
|
78
|
+
ctx.addIssue({
|
|
79
|
+
code: z.ZodIssueCode.custom,
|
|
80
|
+
path: ["classifiers", i, "name"],
|
|
81
|
+
message: `duplicate risk classifier name: ${c.name}`,
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
seen.add(c.name);
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
//# sourceMappingURL=risk.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"risk.js","sourceRoot":"","sources":["../../src/schema/risk.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,4CAA4C;AAC5C,EAAE;AACF,gEAAgE;AAChE,sEAAsE;AACtE,kEAAkE;AAClE,mEAAmE;AACnE,wEAAwE;AACxE,2BAA2B;AAC3B,EAAE;AACF,0EAA0E;AAE1E,uEAAuE;AACvE,uEAAuE;AACvE,sEAAsE;AACtE,qEAAqE;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EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACvB,kEAAkE;IAClE,oEAAoE;IACpE,4DAA4D;IAC5D,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACvB,QAAQ,EAAE,CAAC,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;CAC5C,CAAC;KACD,MAAM,EAAE,CAAC;AAEZ,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC;KACxB,MAAM,CAAC;IACN,WAAW,EAAE,CAAC,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;CACvD,CAAC;KACD,MAAM,EAAE;KACR,WAAW,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE;IACzB,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QAChC,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;YACrB,GAAG,CAAC,QAAQ,CAAC;gBACX,IAAI,EAAE,CAAC,CAAC,YAAY,CAAC,MAAM;gBAC3B,IAAI,EAAE,CAAC,aAAa,EAAE,CAAC,EAAE,MAAM,CAAC;gBAChC,OAAO,EAAE,mCAAmC,CAAC,CAAC,IAAI,EAAE;aACrD,CAAC,CAAC;QACL,CAAC;QACD,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IACnB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lannguyensi/harness",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.26.0",
|
|
4
4
|
"description": "Declarative control plane for agent harnesses — one YAML for grounding, tools, memory, and hooks.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://github.com/LanNguyenSi/harness",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pause-check.js","sourceRoot":"","sources":["../../../src/cli/pack/pause-check.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,uEAAuE;AACvE,sEAAsE;AACtE,uEAAuE;AACvE,qEAAqE;AACrE,sCAAsC;AACtC,EAAE;AACF,uEAAuE;AACvE,uEAAuE;AACvE,qEAAqE;AACrE,2BAA2B;AAE3B,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAE,YAAY,EAAsB,MAAM,cAAc,CAAC;AAehE;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,IAAuB;IAC1D,IAAI,YAAoB,CAAC;IACzB,IAAI,IAAI,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;QACpC,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC;IACnC,CAAC;SAAM,CAAC;QACN,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,IAAI,EAAE,CAAC;YACrC,YAAY,GAAG,mBAAmB,CAAC;gBACjC,GAAG,CAAC,MAAM,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBACpE,YAAY,EAAE,YAAY,CAAC,MAAM,CAAC,CAAC,IAAI;aACxC,CAAC,CAAC;QACL,CAAC;QAAC,MAAM,CAAC;YACP,kEAAkE;YAClE,mEAAmE;YACnE,oCAAoC;YACpC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;QAC3B,CAAC;IACH,CAAC;IACD,MAAM,YAAY,GAA6C;QAC7D,YAAY;QACZ,SAAS,EAAE,IA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